(svn r3612) - RoadStop->slot[] stores a vehicle index. Adjust its type and use INVALID_VEHICLE instead of nonsense INVALID_SLOT.

This commit is contained in:
peter1138 2006-02-18 14:11:23 +00:00
parent 9ed8143264
commit 6cfefdb275
4 changed files with 11 additions and 12 deletions

View File

@ -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;
}
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;
}
}
}