Fix road/tram type load check for savegame versions before 62
This commit is contained in:
@@ -46,6 +46,24 @@ inline bool MayHaveRoad(TileIndex t)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether a tile type can have road/tram types.
|
||||
* @param type Tile type.
|
||||
* @return true if tile type can have road/tram types.
|
||||
*/
|
||||
inline bool MayTileTypeHaveRoad(TileType type)
|
||||
{
|
||||
switch (type) {
|
||||
case MP_ROAD:
|
||||
case MP_STATION:
|
||||
case MP_TUNNELBRIDGE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of the road tile.
|
||||
* @param t Tile to query.
|
||||
|
@@ -441,7 +441,12 @@ void AfterLoadVehicles(bool part_of_load)
|
||||
for (RoadVehicle *u = rv; u != nullptr; u = u->Next()) {
|
||||
u->roadtype = rv->roadtype;
|
||||
u->compatible_roadtypes = rv->compatible_roadtypes;
|
||||
if (GetRoadType(u->tile, GetRoadTramType(u->roadtype)) == INVALID_ROADTYPE) is_invalid = true;
|
||||
if (IsSavegameVersionBefore(SLV_62)) {
|
||||
/* Use simplified check before trams were introduced */
|
||||
if (!MayTileTypeHaveRoad(GetTileType(u->tile))) is_invalid = true;
|
||||
} else {
|
||||
if (!MayHaveRoad(u->tile) || GetRoadType(u->tile, GetRoadTramType(u->roadtype)) == INVALID_ROADTYPE) is_invalid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_invalid && part_of_load) {
|
||||
|
Reference in New Issue
Block a user