Changeset - r9622:87db2c291409
[Not reviewed]
master
0 3 0
rubidium - 16 years ago 2008-07-06 11:08:40
rubidium@openttd.org
(svn r13678) -Fix (r13677): electric trains from pre elrail savegames would get stopped on load.
3 files changed with 25 insertions and 21 deletions:
0 comments (0 inline, 0 general)
src/openttd.cpp
Show inline comments
 
@@ -1262,12 +1262,14 @@ static bool InitializeWindowsAndCaches()
 
		 * thus the MIN_YEAR (which is really nothing more than Zero, initialized value) test */
 
		if (_file_to_saveload.filetype == FT_SCENARIO && p->inaugurated_year != MIN_YEAR) {
 
			p->inaugurated_year = _cur_year;
 
		}
 
	}
 

	
 
	InitializeVehicleCaches();
 

	
 
	SetCachedEngineCounts();
 

	
 
	/* Towns have a noise controlled number of airports system
 
	 * So each airport's noise value must be added to the town->noise_reached value
 
	 * Reset each town's noise_reached value to '0' before. */
 
	UpdateAirportsNoise();
 
@@ -1379,22 +1381,12 @@ bool AfterLoadGame()
 
	/* Connect front and rear engines of multiheaded trains */
 
	ConnectMultiheadedTrains();
 

	
 
	/* reinit the landscape variables (landscape might have changed) */
 
	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 */
 
	AfterLoadVehicles(true);
 

	
 
	/* Update all waypoints */
 
	if (CheckSavegameVersion(12)) FixOldWaypoints();
 

	
 
@@ -1960,12 +1952,19 @@ bool AfterLoadGame()
 

	
 
		FOR_ALL_VEHICLES(v) {
 
			v->current_order.SetRefit(CT_NO_REFIT);
 
		}
 
	}
 

	
 
	/* 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
 
	 * space for newhouses grf features. A new byte, m7, was also added. */
 
	if (CheckSavegameVersion(53)) {
 
		for (TileIndex t = 0; t < map_size; t++) {
 
			if (IsTileType(t, MP_HOUSE)) {
 
				if (GB(_m[t].m3, 6, 2) != TOWN_HOUSE_COMPLETED) {
src/vehicle.cpp
Show inline comments
 
@@ -272,23 +272,14 @@ void AfterLoadVehicles(bool clear_te_id)
 
				u->first = v;
 
			}
 
		}
 
	}
 

	
 
	FOR_ALL_VEHICLES(v) {
 
		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) {
 
		assert(v->First() != NULL);
 

	
 
		switch (v->type) {
 
			case VEH_ROAD:
 
				v->u.road.roadtype = HasBit(EngInfo(v->engine_type)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD;
 
				v->u.road.compatible_roadtypes = RoadTypeToRoadTypes(v->u.road.roadtype);
 
				/* FALL THROUGH */
 
			case VEH_TRAIN:
 
@@ -318,12 +309,25 @@ void AfterLoadVehicles(bool clear_te_id)
 

	
 
		v->left_coord = INVALID_COORD;
 
		VehiclePositionChanged(v);
 
	}
 
}
 

	
 
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()
 
{
 
	this->type               = VEH_INVALID;
 
	this->left_coord         = INVALID_COORD;
 
	this->group_id           = DEFAULT_GROUP;
 
	this->fill_percent_te_id = INVALID_TE_ID;
src/vehicle_base.h
Show inline comments
 
@@ -188,12 +188,13 @@ struct VehicleShip {
 
DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125)
 

	
 
/* Some declarations of functions, so we can make them friendly */
 
struct SaveLoad;
 
extern const SaveLoad *GetVehicleDescription(VehicleType vt);
 
extern void AfterLoadVehicles(bool clear_te_id);
 
extern void InitializeVehicleCaches();
 
struct LoadgameState;
 
extern bool LoadOldVehicle(LoadgameState *ls, int num);
 

	
 
struct Vehicle : PoolItem<Vehicle, VehicleID, &_Vehicle_pool>, BaseVehicle {
 
private:
 
	Vehicle *next;           ///< pointer to the next vehicle in the chain
0 comments (0 inline, 0 general)