Changeset - r26070:de9aec7a21fe
[Not reviewed]
master
0 1 0
Charles Pigott - 3 years ago 2021-11-15 13:39:41
charlespigott@googlemail.com
Fix #9680: Recalculating aircraft positions before map array updates caused crashes (#9699)
1 file changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/saveload/afterload.cpp
Show inline comments
 
@@ -948,28 +948,24 @@ bool AfterLoadGame()
 
						break;
 
					}
 

	
 
					default: break;
 
				}
 
				break;
 
			}
 

	
 
			default: break;
 
		}
 
	}
 

	
 
	/* In version 2.2 of the savegame, we have new airports, so status of all aircraft is reset.
 
	 * This has to be called after the oilrig airport_type update above ^^^ ! */
 
	if (IsSavegameVersionBefore(SLV_2, 2)) UpdateOldAircraft();
 

	
 
	/* In version 6.1 we put the town index in the map-array. To do this, we need
 
	 *  to use m2 (16bit big), so we need to clean m2, and that is where this is
 
	 *  all about ;) */
 
	if (IsSavegameVersionBefore(SLV_6, 1)) {
 
		for (TileIndex t = 0; t < map_size; t++) {
 
			switch (GetTileType(t)) {
 
				case MP_HOUSE:
 
					_m[t].m4 = _m[t].m2;
 
					SetTownIndex(t, CalcClosestTownFromTile(t)->index);
 
					break;
 

	
 
				case MP_ROAD:
 
@@ -2890,24 +2886,28 @@ bool AfterLoadGame()
 

	
 
	if (IsSavegameVersionBefore(SLV_186)) {
 
		/* Move ObjectType from map to pool */
 
		for (TileIndex t = 0; t < map_size; t++) {
 
			if (IsTileType(t, MP_OBJECT)) {
 
				Object *o = Object::Get(_m[t].m2);
 
				o->type = _m[t].m5;
 
				_m[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;
0 comments (0 inline, 0 general)