mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-17 01:12:39 +01:00
Fix #12831: Delay vehicle cache init to after map upgrades in load
Split AfterLoadVehicles into two functions. Vehicle cache init and other functionality requiring an upgraded and valid map is now performed later in the load process.
This commit is contained in:
committed by
rubidium42
parent
dfb74e25f7
commit
f19829d029
@@ -598,7 +598,11 @@ void DrawRailCatenary(const TileInfo *ti)
|
||||
void SettingsDisableElrail(int32_t new_value)
|
||||
{
|
||||
bool disable = (new_value != 0);
|
||||
UpdateDisableElrailSettingState(disable, true);
|
||||
}
|
||||
|
||||
void UpdateDisableElrailSettingState(bool disable, bool update_vehicles)
|
||||
{
|
||||
/* pick appropriate railtype for elrail engines depending on setting */
|
||||
const RailType new_railtype = disable ? RAILTYPE_RAIL : RAILTYPE_ELECTRIC;
|
||||
|
||||
@@ -626,10 +630,12 @@ void SettingsDisableElrail(int32_t new_value)
|
||||
}
|
||||
|
||||
/* Fix the total power and acceleration for trains */
|
||||
for (Train *t : Train::Iterate()) {
|
||||
/* power and acceleration is cached only for front engines */
|
||||
if (t->IsFrontEngine()) {
|
||||
t->ConsistChanged(CCF_TRACK);
|
||||
if (update_vehicles) {
|
||||
for (Train *t : Train::Iterate()) {
|
||||
/* power and acceleration is cached only for front engines */
|
||||
if (t->IsFrontEngine()) {
|
||||
t->ConsistChanged(CCF_TRACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user