1
0
Fork 0

Fix: Autoreplace rail/road list only listed buildable types. (#13887)

Instead list all possible types which includes hidden types compatible with buildable types.
pull/13888/head
Peter Nelson 2025-03-25 08:22:30 +00:00 committed by GitHub
parent 1fb4c44bc7
commit adb20f99ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 10 additions and 8 deletions

View File

@ -1792,6 +1792,7 @@ struct CompanyInfrastructureWindow : Window
/* Get the date introduced railtypes as well. */
this->railtypes = AddDateIntroducedRailTypes(this->railtypes, CalendarTime::MAX_DATE);
this->railtypes &= ~_railtypes_hidden_mask;
/* Find the used roadtypes. */
for (const Engine *e : Engine::IterateType(VEH_ROAD)) {

View File

@ -44,7 +44,7 @@
typedef std::vector<Train *> TrainList;
RailTypeInfo _railtypes[RAILTYPE_END];
std::vector<RailType> _sorted_railtypes;
std::vector<RailType> _sorted_railtypes; ///< Sorted list of rail types.
RailTypes _railtypes_hidden_mask;
/** Enum holding the signal offset in the sprite sheet according to the side it is representing. */
@ -137,9 +137,8 @@ void InitRailTypes()
_sorted_railtypes.clear();
for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
if (_railtypes[rt].label != 0 && !HasBit(_railtypes_hidden_mask, rt)) {
_sorted_railtypes.push_back(rt);
}
if (_railtypes[rt].label == 0) continue;
_sorted_railtypes.push_back(rt);
}
std::sort(_sorted_railtypes.begin(), _sorted_railtypes.end(), CompareRailTypes);
}

View File

@ -2052,6 +2052,7 @@ DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
Dimension d = { 0, 0 };
/* Get largest icon size, to ensure text is aligned on each menu item. */
if (!for_replacement) {
used_railtypes &= ~_railtypes_hidden_mask;
for (const auto &rt : _sorted_railtypes) {
if (!HasBit(used_railtypes, rt)) continue;
const RailTypeInfo *rti = GetRailTypeInfo(rt);

View File

@ -52,7 +52,7 @@
typedef std::vector<RoadVehicle *> RoadVehicleList;
RoadTypeInfo _roadtypes[ROADTYPE_END];
std::vector<RoadType> _sorted_roadtypes;
std::vector<RoadType> _sorted_roadtypes; ///< Sorted list of road types.
RoadTypes _roadtypes_hidden_mask;
/**
@ -121,9 +121,8 @@ void InitRoadTypes()
_sorted_roadtypes.clear();
for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
if (_roadtypes[rt].label != 0 && !HasBit(_roadtypes_hidden_mask, rt)) {
_sorted_roadtypes.push_back(rt);
}
if (_roadtypes[rt].label == 0) continue;
_sorted_roadtypes.push_back(rt);
}
std::sort(_sorted_roadtypes.begin(), _sorted_roadtypes.end(), CompareRoadTypes);
}

View File

@ -1779,6 +1779,7 @@ DropDownList GetRoadTypeDropDownList(RoadTramTypes rtts, bool for_replacement, b
Dimension d = { 0, 0 };
/* Get largest icon size, to ensure text is aligned on each menu item. */
if (!for_replacement) {
used_roadtypes &= ~_roadtypes_hidden_mask;
for (const auto &rt : _sorted_roadtypes) {
if (!HasBit(used_roadtypes, rt)) continue;
const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
@ -1820,6 +1821,7 @@ DropDownList GetScenRoadTypeDropDownList(RoadTramTypes rtts)
RoadTypes used_roadtypes = GetRoadTypes(true);
/* Filter listed road types */
used_roadtypes &= ~_roadtypes_hidden_mask;
if (!HasBit(rtts, RTT_ROAD)) used_roadtypes &= _roadtypes_type;
if (!HasBit(rtts, RTT_TRAM)) used_roadtypes &= ~_roadtypes_type;