File diff r27049:913f3ce60451 → r27050:d85c65824c1e
src/saveload/afterload.cpp
Show inline comments
 
@@ -2832,96 +2832,101 @@ bool AfterLoadGame()
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_177)) {
 
		/* Fix too high inflation rates */
 
		if (_economy.inflation_prices > MAX_INFLATION) _economy.inflation_prices = MAX_INFLATION;
 
		if (_economy.inflation_payment > MAX_INFLATION) _economy.inflation_payment = MAX_INFLATION;
 

	
 
		/* We have to convert the quarters of bankruptcy into months of bankruptcy */
 
		for (Company *c : Company::Iterate()) {
 
			c->months_of_bankruptcy = 3 * c->months_of_bankruptcy;
 
		}
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_178)) {
 
		extern uint8 _old_diff_level;
 
		/* Initialise script settings profile */
 
		_settings_game.script.settings_profile = IsInsideMM(_old_diff_level, SP_BEGIN, SP_END) ? _old_diff_level : (uint)SP_MEDIUM;
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_182)) {
 
		/* Aircraft acceleration variable was bonkers */
 
		for (Aircraft *v : Aircraft::Iterate()) {
 
			if (v->subtype <= AIR_AIRCRAFT) {
 
				const AircraftVehicleInfo *avi = AircraftVehInfo(v->engine_type);
 
				v->acceleration = avi->acceleration;
 
			}
 
		}
 

	
 
		/* Blocked tiles could be reserved due to a bug, which causes
 
		 * other places to assert upon e.g. station reconstruction. */
 
		for (auto t : Map::Iterate()) {
 
			if (HasStationTileRail(t) && IsStationTileBlocked(t)) {
 
				SetRailStationReservation(t, false);
 
			}
 
		}
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_184)) {
 
		/* The global units configuration is split up in multiple configurations. */
 
		extern uint8 _old_units;
 
		_settings_game.locale.units_velocity = Clamp(_old_units, 0, 2);
 
		_settings_game.locale.units_power    = Clamp(_old_units, 0, 2);
 
		_settings_game.locale.units_weight   = Clamp(_old_units, 1, 2);
 
		_settings_game.locale.units_volume   = Clamp(_old_units, 1, 2);
 
		_settings_game.locale.units_force    = 2;
 
		_settings_game.locale.units_height   = Clamp(_old_units, 0, 2);
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_VELOCITY_NAUTICAL)) {
 
		/* Match nautical velocity with land velocity units. */
 
		_settings_game.locale.units_velocity_nautical = _settings_game.locale.units_velocity;
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_186)) {
 
		/* Move ObjectType from map to pool */
 
		for (auto t : Map::Iterate()) {
 
			if (IsTileType(t, MP_OBJECT)) {
 
				Object *o = Object::Get(t.m2());
 
				o->type = t.m5();
 
				t.m5() = 0; // zero upper bits of (now bigger) ObjectID
 
			}
 
		}
 
	}
 

	
 
	/* In version 2.2 of the savegame, we have new airports, so status of all aircraft is reset.
 
	 * This has to be called after all map array updates */
 
	if (IsSavegameVersionBefore(SLV_2, 2)) UpdateOldAircraft();
 

	
 
	if (IsSavegameVersionBefore(SLV_188)) {
 
		/* Fix articulated road vehicles.
 
		 * Some curves were shorter than other curves.
 
		 * Now they have the same length, but that means that trailing articulated parts will
 
		 * take longer to go through the curve than the parts in front which already left the courve.
 
		 * So, make articulated parts catch up. */
 
		bool roadside = _settings_game.vehicle.road_side == 1;
 
		std::vector<uint> skip_frames;
 
		for (RoadVehicle *v : RoadVehicle::Iterate()) {
 
			if (!v->IsFrontEngine()) continue;
 
			skip_frames.clear();
 
			TileIndex prev_tile = v->tile;
 
			uint prev_tile_skip = 0;
 
			uint cur_skip = 0;
 
			for (RoadVehicle *u = v; u != nullptr; u = u->Next()) {
 
				if (u->tile != prev_tile) {
 
					prev_tile_skip = cur_skip;
 
					prev_tile = u->tile;
 
				} else {
 
					cur_skip = prev_tile_skip;
 
				}
 

	
 
				uint &this_skip = skip_frames.emplace_back(prev_tile_skip);
 

	
 
				/* The following 3 curves now take longer than before */
 
				switch (u->state) {
 
					case 2:
 
						cur_skip++;
 
						if (u->frame <= (roadside ? 9 : 5)) this_skip = cur_skip;
 
						break;
 

	
 
					case 4:
 
						cur_skip++;