1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-28 00:49:11 +00:00

Add: Apply rail/road type conversion when NewGRFs are updated mid-game.

This will update the rail/road type of tiles on the map, taking account of tram state, if types are moved around.
This commit is contained in:
2024-10-22 17:32:15 +01:00
parent 25312894da
commit a31d218805
2 changed files with 17 additions and 0 deletions

View File

@@ -3362,6 +3362,7 @@ void ReloadNewGRFData()
RecomputePrices();
/* reload vehicles */
ResetVehicleHash();
AfterLoadLabelMaps();
AfterLoadVehiclesPhase1(false);
AfterLoadVehiclesPhase2(false);
StartupEngines();

View File

@@ -130,11 +130,27 @@ static void ConvertRoadTypes()
}
}
/** Populate label lists with current values. */
static void SetCurrentLabelLists()
{
_railtype_list.clear();
for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
_railtype_list.push_back({GetRailTypeInfo(rt)->label, 0});
}
_roadtype_list.clear();
for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
_roadtype_list.push_back({GetRoadTypeInfo(rt)->label, GetRoadTramType(rt)});
}
}
/** Perform rail type and road type conversion if necessary. */
void AfterLoadLabelMaps()
{
ConvertRailTypes();
ConvertRoadTypes();
SetCurrentLabelLists();
}
void ResetLabelMaps()