1
0
Fork 0

Codechange: use the appropriate type for OldWaypoint indices

pull/13463/head
Rubidium 2025-02-04 16:20:53 +01:00 committed by rubidium42
parent fd85ab1e2c
commit 2f1d0acec9
1 changed files with 7 additions and 5 deletions

View File

@ -22,9 +22,11 @@
#include "../safeguards.h" #include "../safeguards.h"
using OldWaypointID = uint16_t;
/** Helper structure to convert from the old waypoint system. */ /** Helper structure to convert from the old waypoint system. */
struct OldWaypoint { struct OldWaypoint {
size_t index; OldWaypointID index;
TileIndex xy; TileIndex xy;
TownID town_index; TownID town_index;
Town *town; Town *town;
@ -38,7 +40,7 @@ struct OldWaypoint {
const StationSpec *spec; const StationSpec *spec;
Owner owner; Owner owner;
size_t new_index; StationID new_index;
}; };
/** Temporary array with old waypoints. */ /** Temporary array with old waypoints. */
@ -55,7 +57,7 @@ static void UpdateWaypointOrder(Order *o)
for (OldWaypoint &wp : _old_waypoints) { for (OldWaypoint &wp : _old_waypoints) {
if (wp.index != o->GetDestination()) continue; if (wp.index != o->GetDestination()) continue;
o->SetDestination((DestinationID)wp.new_index); o->SetDestination(wp.new_index);
return; return;
} }
} }
@ -76,7 +78,7 @@ void MoveWaypointsToBaseStations()
/* Waypoint indices were not added to the map prior to this. */ /* Waypoint indices were not added to the map prior to this. */
Tile tile = wp.xy; Tile tile = wp.xy;
tile.m2() = (StationID)wp.index; tile.m2() = wp.index;
if (HasBit(tile.m3(), 4)) { if (HasBit(tile.m3(), 4)) {
wp.spec = StationClass::Get(STAT_CLASS_WAYP)->GetSpec(tile.m4() + 1); wp.spec = StationClass::Get(STAT_CLASS_WAYP)->GetSpec(tile.m4() + 1);
@ -195,7 +197,7 @@ struct CHKPChunkHandler : ChunkHandler {
while ((index = SlIterateArray()) != -1) { while ((index = SlIterateArray()) != -1) {
OldWaypoint *wp = &_old_waypoints.emplace_back(); OldWaypoint *wp = &_old_waypoints.emplace_back();
wp->index = index; wp->index = static_cast<OldWaypointID>(index);
SlObject(wp, _old_waypoint_desc); SlObject(wp, _old_waypoint_desc);
} }
} }