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:
Peter Nelson 2024-10-22 17:32:15 +01:00 committed by Peter Nelson
parent 8bb6572943
commit 3b6d3080f2
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()