1
0
Fork 0

Codechange: Use Map::Iterate() on waypoint conversion

Still maintains the same logic as before when determining valid and invalid waypoints.
pull/13151/head
SamuXarick 2024-10-27 22:30:05 +00:00 committed by rubidium42
parent 7d0b1cd002
commit 913d6eceb0
1 changed files with 6 additions and 4 deletions

View File

@ -101,14 +101,16 @@ void MoveWaypointsToBaseStations()
* 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) {
Debug(sl, 0, "Found waypoint tile {} with invalid position", t);
for (t = 0; t < Map::Size(); t++) {
if (IsTileType(t, MP_RAILWAY) && GetRailTileType(t) == 2 /* RAIL_TILE_WAYPOINT */ && Tile(t).m2() == wp.index) {
Debug(sl, 0, "Found actual waypoint position at {}", t);
t = INVALID_TILE;
for (auto tile : Map::Iterate()) {
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;
}
}
}
if (t == Map::Size()) {
if (t == INVALID_TILE) {
SlErrorCorrupt("Waypoint with invalid tile");
}