mirror of https://github.com/OpenTTD/OpenTTD
(svn r13678) -Fix (r13677): electric trains from pre elrail savegames would get stopped on load.
parent
22249a7317
commit
3a793ceea9
|
@ -1265,6 +1265,8 @@ static bool InitializeWindowsAndCaches()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InitializeVehicleCaches();
|
||||||
|
|
||||||
SetCachedEngineCounts();
|
SetCachedEngineCounts();
|
||||||
|
|
||||||
/* Towns have a noise controlled number of airports system
|
/* Towns have a noise controlled number of airports system
|
||||||
|
@ -1382,16 +1384,6 @@ bool AfterLoadGame()
|
||||||
/* reinit the landscape variables (landscape might have changed) */
|
/* reinit the landscape variables (landscape might have changed) */
|
||||||
InitializeLandscapeVariables(true);
|
InitializeLandscapeVariables(true);
|
||||||
|
|
||||||
/* from version 38 we have optional elrails, since we cannot know the
|
|
||||||
* preference of a user, let elrails enabled; it can be disabled manually */
|
|
||||||
if (CheckSavegameVersion(38)) _settings_game.vehicle.disable_elrails = false;
|
|
||||||
|
|
||||||
/* Do the same as when elrails were enabled/disabled manually just now.
|
|
||||||
* This needs to be done before AfterLoadVehicles because that relies on
|
|
||||||
* the compatible railtypes and such to be correct. */
|
|
||||||
SettingsDisableElrail(_settings_game.vehicle.disable_elrails);
|
|
||||||
InitializeRailGUI();
|
|
||||||
|
|
||||||
/* Update all vehicles */
|
/* Update all vehicles */
|
||||||
AfterLoadVehicles(true);
|
AfterLoadVehicles(true);
|
||||||
|
|
||||||
|
@ -1963,6 +1955,13 @@ bool AfterLoadGame()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* from version 38 we have optional elrails, since we cannot know the
|
||||||
|
* preference of a user, let elrails enabled; it can be disabled manually */
|
||||||
|
if (CheckSavegameVersion(38)) _settings_game.vehicle.disable_elrails = false;
|
||||||
|
/* do the same as when elrails were enabled/disabled manually just now */
|
||||||
|
SettingsDisableElrail(_settings_game.vehicle.disable_elrails);
|
||||||
|
InitializeRailGUI();
|
||||||
|
|
||||||
/* From version 53, the map array was changed for house tiles to allow
|
/* From version 53, the map array was changed for house tiles to allow
|
||||||
* space for newhouses grf features. A new byte, m7, was also added. */
|
* space for newhouses grf features. A new byte, m7, was also added. */
|
||||||
if (CheckSavegameVersion(53)) {
|
if (CheckSavegameVersion(53)) {
|
||||||
|
|
|
@ -275,17 +275,8 @@ void AfterLoadVehicles(bool clear_te_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
assert(v->first != NULL);
|
assert(v->First() != NULL);
|
||||||
|
|
||||||
if (v->type == VEH_TRAIN && (IsFrontEngine(v) || IsFreeWagon(v))) {
|
|
||||||
if (IsFrontEngine(v)) v->u.rail.last_speed = v->cur_speed; // update displayed train speed
|
|
||||||
TrainConsistChanged(v);
|
|
||||||
} else if (v->type == VEH_ROAD && IsRoadVehFront(v)) {
|
|
||||||
RoadVehUpdateCache(v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FOR_ALL_VEHICLES(v) {
|
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
case VEH_ROAD:
|
case VEH_ROAD:
|
||||||
v->u.road.roadtype = HasBit(EngInfo(v->engine_type)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD;
|
v->u.road.roadtype = HasBit(EngInfo(v->engine_type)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD;
|
||||||
|
@ -321,6 +312,19 @@ void AfterLoadVehicles(bool clear_te_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitializeVehicleCaches()
|
||||||
|
{
|
||||||
|
Vehicle *v;
|
||||||
|
FOR_ALL_VEHICLES(v) {
|
||||||
|
if (v->type == VEH_TRAIN && (IsFrontEngine(v) || IsFreeWagon(v))) {
|
||||||
|
if (IsFrontEngine(v)) v->u.rail.last_speed = v->cur_speed; // update displayed train speed
|
||||||
|
TrainConsistChanged(v);
|
||||||
|
} else if (v->type == VEH_ROAD && IsRoadVehFront(v)) {
|
||||||
|
RoadVehUpdateCache(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Vehicle::Vehicle()
|
Vehicle::Vehicle()
|
||||||
{
|
{
|
||||||
this->type = VEH_INVALID;
|
this->type = VEH_INVALID;
|
||||||
|
|
|
@ -191,6 +191,7 @@ DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125)
|
||||||
struct SaveLoad;
|
struct SaveLoad;
|
||||||
extern const SaveLoad *GetVehicleDescription(VehicleType vt);
|
extern const SaveLoad *GetVehicleDescription(VehicleType vt);
|
||||||
extern void AfterLoadVehicles(bool clear_te_id);
|
extern void AfterLoadVehicles(bool clear_te_id);
|
||||||
|
extern void InitializeVehicleCaches();
|
||||||
struct LoadgameState;
|
struct LoadgameState;
|
||||||
extern bool LoadOldVehicle(LoadgameState *ls, int num);
|
extern bool LoadOldVehicle(LoadgameState *ls, int num);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue