mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use Map::Iterate() on waypoint conversion
Still maintains the same logic as before when determining valid and invalid waypoints.pull/13151/head
parent
7d0b1cd002
commit
913d6eceb0
|
@ -101,14 +101,16 @@ void MoveWaypointsToBaseStations()
|
||||||
* the map array. If this is the case, try to locate the actual location in the map array */
|
* the map array. If this is the case, try to locate the actual location in the map array */
|
||||||
if (!IsTileType(t, MP_RAILWAY) || GetRailTileType(t) != 2 /* RAIL_TILE_WAYPOINT */ || Tile(t).m2() != wp.index) {
|
if (!IsTileType(t, MP_RAILWAY) || GetRailTileType(t) != 2 /* RAIL_TILE_WAYPOINT */ || Tile(t).m2() != wp.index) {
|
||||||
Debug(sl, 0, "Found waypoint tile {} with invalid position", t);
|
Debug(sl, 0, "Found waypoint tile {} with invalid position", t);
|
||||||
for (t = 0; t < Map::Size(); t++) {
|
t = INVALID_TILE;
|
||||||
if (IsTileType(t, MP_RAILWAY) && GetRailTileType(t) == 2 /* RAIL_TILE_WAYPOINT */ && Tile(t).m2() == wp.index) {
|
for (auto tile : Map::Iterate()) {
|
||||||
Debug(sl, 0, "Found actual waypoint position at {}", t);
|
if (IsTileType(tile, MP_RAILWAY) && GetRailTileType(tile) == 2 /* RAIL_TILE_WAYPOINT */ && tile.m2() == wp.index) {
|
||||||
|
t = TileIndex(tile);
|
||||||
|
Debug(sl, 0, "Found actual waypoint position at {}", TileIndex(tile));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (t == Map::Size()) {
|
if (t == INVALID_TILE) {
|
||||||
SlErrorCorrupt("Waypoint with invalid tile");
|
SlErrorCorrupt("Waypoint with invalid tile");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue