Changeset - r24167:2ba5eeed4f1f
[Not reviewed]
master
0 1 0
SamuXarick - 4 years ago 2020-05-04 17:41:16
43006711+SamuXarick@users.noreply.github.com
Fix #8108: possible crash on loading TTD savegames with phantom oil rigs
1 file changed with 8 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/saveload/afterload.cpp
Show inline comments
 
@@ -929,19 +929,19 @@ bool AfterLoadGame()
 
						break;
 

	
 
					case STATION_OILRIG: {
 
						/* The internal encoding of oil rigs was changed twice.
 
						 * It was 3 (till 2.2) and later 5 (till 5.1).
 
						 * DeleteOilRig asserts on the correct type, and
 
						 * setting it unconditionally does not hurt.
 
						 */
 
						Station::GetByTile(t)->airport.type = AT_OILRIG;
 

	
 
						/* Very old savegames sometimes have phantom oil rigs, i.e.
 
						 * an oil rig which got shut down, but not completely removed from
 
						 * the map
 
						 */
 
						TileIndex t1 = TILE_ADDXY(t, 0, 1);
 
						if (IsTileType(t1, MP_INDUSTRY) &&
 
								GetIndustryGfx(t1) == GFX_OILRIG_1) {
 
							/* The internal encoding of oil rigs was changed twice.
 
							 * It was 3 (till 2.2) and later 5 (till 5.1).
 
							 * Setting it unconditionally does not hurt.
 
							 */
 
							Station::GetByTile(t)->airport.type = AT_OILRIG;
 
						} else {
 
						if (!IsTileType(t1, MP_INDUSTRY) || GetIndustryGfx(t1) != GFX_OILRIG_1) {
 
							DeleteOilRig(t);
 
						}
 
						break;
0 comments (0 inline, 0 general)