summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-02-18 14:11:23 +0000
committerpeter1138 <peter1138@openttd.org>2006-02-18 14:11:23 +0000
commit95ce125633734ced1cfc1de45034b51a26fc94cc (patch)
tree472160528d13b96f762e1c4fbef14b3176941371
parent3161c5973e49504dd078298a0da6097ae3cc9584 (diff)
downloadopenttd-95ce125633734ced1cfc1de45034b51a26fc94cc.tar.xz
(svn r3612) - RoadStop->slot[] stores a vehicle index. Adjust its type and use INVALID_VEHICLE instead of nonsense INVALID_SLOT.
-rw-r--r--oldloader.c4
-rw-r--r--roadveh_cmd.c8
-rw-r--r--station.h3
-rw-r--r--station_cmd.c8
4 files changed, 11 insertions, 12 deletions
diff --git a/oldloader.c b/oldloader.c
index b3cfa27e2..653963a41 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 7bf29103f..7ef55f052 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 ca5d6c20e..53f6de5e2 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 19bbe0769..9799878ba 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;
}
}
}