From 6cfefdb2750d9beccb350ea47db9e2edaa61655c Mon Sep 17 00:00:00 2001 From: peter1138 Date: Sat, 18 Feb 2006 14:11:23 +0000 Subject: [PATCH] (svn r3612) - RoadStop->slot[] stores a vehicle index. Adjust its type and use INVALID_VEHICLE instead of nonsense INVALID_SLOT. --- oldloader.c | 4 ++-- roadveh_cmd.c | 8 ++++---- station.h | 3 +-- station_cmd.c | 8 ++++---- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/oldloader.c b/oldloader.c index b3cfa27e23..653963a416 100644 --- a/oldloader.c +++ b/oldloader.c @@ -372,7 +372,7 @@ static void FixOldStations(void) st->bus_stops->station = st->index; st->bus_stops->next = NULL; st->bus_stops->prev = NULL; - st->bus_stops->slot[0] = st->bus_stops->slot[1] = INVALID_SLOT; + st->bus_stops->slot[0] = st->bus_stops->slot[1] = INVALID_VEHICLE; } if (st->lorry_tile_obsolete != 0) { @@ -383,7 +383,7 @@ static void FixOldStations(void) st->truck_stops->station = st->index; st->truck_stops->next = NULL; st->truck_stops->prev = NULL; - st->truck_stops->slot[0] = st->truck_stops->slot[1] = INVALID_SLOT; + st->truck_stops->slot[0] = st->truck_stops->slot[1] = INVALID_VEHICLE; } } } diff --git a/roadveh_cmd.c b/roadveh_cmd.c index 7bf29103f3..7ef55f052e 100644 --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -231,7 +231,7 @@ void ClearSlot(Vehicle *v, RoadStop *rs) if (rs != NULL) { // check that the slot is indeed assigned to the same vehicle assert(rs->slot[v->u.road.slotindex] == v->index); - rs->slot[v->u.road.slotindex] = INVALID_SLOT; + rs->slot[v->u.road.slotindex] = INVALID_VEHICLE; } } @@ -1578,7 +1578,7 @@ void OnNewDay_RoadVeh(Vehicle *v) DEBUG(ms, 2) ("Multistop: Attempting to obtain a slot for vehicle %d at station %d (0x%x)", v->unitnumber, st->index, st->xy); for (; rs != NULL; rs = rs->next) { // Only consider those with at least a free slot. - if (!(rs->slot[0] == INVALID_SLOT || rs->slot[1] == INVALID_SLOT)) + if (!(rs->slot[0] == INVALID_VEHICLE || rs->slot[1] == INVALID_VEHICLE)) continue; // Previously the NPF pathfinder was used here even if NPF is OFF.. WTF? @@ -1614,8 +1614,8 @@ void OnNewDay_RoadVeh(Vehicle *v) if (best_stop != NULL) { int slot; // Find a free slot in this stop. We know that at least one is free. - assert(best_stop->slot[0] == INVALID_SLOT || best_stop->slot[1] == INVALID_SLOT); - slot = (best_stop->slot[0] == INVALID_SLOT) ? 0 : 1; + assert(best_stop->slot[0] == INVALID_VEHICLE || best_stop->slot[1] == INVALID_VEHICLE); + slot = (best_stop->slot[0] == INVALID_VEHICLE) ? 0 : 1; best_stop->slot[slot] = v->index; v->u.road.slot = best_stop; v->dest_tile = best_stop->xy; diff --git a/station.h b/station.h index ca5d6c20e1..53f6de5e25 100644 --- a/station.h +++ b/station.h @@ -28,7 +28,6 @@ typedef enum RoadStopType { enum { INVALID_STATION = 0xFFFF, - INVALID_SLOT = 0xFFFF, NUM_SLOTS = 2, ROAD_STOP_LIMIT = 8, }; @@ -40,7 +39,7 @@ typedef struct RoadStop { bool used; byte status; uint32 index; - uint16 slot[NUM_SLOTS]; + VehicleID slot[NUM_SLOTS]; StationID station; uint8 type; struct RoadStop *next; diff --git a/station_cmd.c b/station_cmd.c index 19bbe07697..9799878bac 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -88,7 +88,7 @@ static void InitializeRoadStop(RoadStop *road_stop, RoadStop *previous, TileInde road_stop->xy = tile; road_stop->used = true; road_stop->status = 3; //stop is free - road_stop->slot[0] = road_stop->slot[1] = INVALID_SLOT; + road_stop->slot[0] = road_stop->slot[1] = INVALID_VEHICLE; road_stop->next = NULL; road_stop->prev = previous; road_stop->station = index; @@ -1428,7 +1428,7 @@ static int32 RemoveRoadStop(Station *st, uint32 flags, TileIndex tile) /* Clear all vehicles destined for this station */ for (i = 0; i != NUM_SLOTS; i++) { - if (cur_stop->slot[i] != INVALID_SLOT) { + if (cur_stop->slot[i] != INVALID_VEHICLE) { Vehicle *v = GetVehicle(cur_stop->slot[i]); ClearSlot(v, v->u.road.slot); } @@ -2301,14 +2301,14 @@ static void CheckOrphanedSlots(const Station *st, RoadStopType rst) for (rs = GetPrimaryRoadStop(st, rst); rs != NULL; rs = rs->next) { for (k = 0; k < NUM_SLOTS; k++) { - if (rs->slot[k] != INVALID_SLOT) { + if (rs->slot[k] != INVALID_VEHICLE) { const Vehicle *v = GetVehicle(rs->slot[k]); if (v->type != VEH_Road || v->u.road.slot != rs) { DEBUG(ms, 0) ( "Multistop: Orphaned %s slot at 0x%X of station %d (don't panic)", (rst == RS_BUS) ? "bus" : "truck", rs->xy, st->index); - rs->slot[k] = INVALID_SLOT; + rs->slot[k] = INVALID_VEHICLE; } } }