mirror of https://github.com/OpenTTD/OpenTTD.git
(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:
parent
9ed8143264
commit
6cfefdb275
|
@ -372,7 +372,7 @@ static void FixOldStations(void)
|
||||||
st->bus_stops->station = st->index;
|
st->bus_stops->station = st->index;
|
||||||
st->bus_stops->next = NULL;
|
st->bus_stops->next = NULL;
|
||||||
st->bus_stops->prev = 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) {
|
if (st->lorry_tile_obsolete != 0) {
|
||||||
|
@ -383,7 +383,7 @@ static void FixOldStations(void)
|
||||||
st->truck_stops->station = st->index;
|
st->truck_stops->station = st->index;
|
||||||
st->truck_stops->next = NULL;
|
st->truck_stops->next = NULL;
|
||||||
st->truck_stops->prev = 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,7 +231,7 @@ void ClearSlot(Vehicle *v, RoadStop *rs)
|
||||||
if (rs != NULL) {
|
if (rs != NULL) {
|
||||||
// check that the slot is indeed assigned to the same vehicle
|
// check that the slot is indeed assigned to the same vehicle
|
||||||
assert(rs->slot[v->u.road.slotindex] == v->index);
|
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);
|
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) {
|
for (; rs != NULL; rs = rs->next) {
|
||||||
// Only consider those with at least a free slot.
|
// 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;
|
continue;
|
||||||
|
|
||||||
// Previously the NPF pathfinder was used here even if NPF is OFF.. WTF?
|
// 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) {
|
if (best_stop != NULL) {
|
||||||
int slot;
|
int slot;
|
||||||
// Find a free slot in this stop. We know that at least one is free.
|
// 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);
|
assert(best_stop->slot[0] == INVALID_VEHICLE || best_stop->slot[1] == INVALID_VEHICLE);
|
||||||
slot = (best_stop->slot[0] == INVALID_SLOT) ? 0 : 1;
|
slot = (best_stop->slot[0] == INVALID_VEHICLE) ? 0 : 1;
|
||||||
best_stop->slot[slot] = v->index;
|
best_stop->slot[slot] = v->index;
|
||||||
v->u.road.slot = best_stop;
|
v->u.road.slot = best_stop;
|
||||||
v->dest_tile = best_stop->xy;
|
v->dest_tile = best_stop->xy;
|
||||||
|
|
|
@ -28,7 +28,6 @@ typedef enum RoadStopType {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
INVALID_STATION = 0xFFFF,
|
INVALID_STATION = 0xFFFF,
|
||||||
INVALID_SLOT = 0xFFFF,
|
|
||||||
NUM_SLOTS = 2,
|
NUM_SLOTS = 2,
|
||||||
ROAD_STOP_LIMIT = 8,
|
ROAD_STOP_LIMIT = 8,
|
||||||
};
|
};
|
||||||
|
@ -40,7 +39,7 @@ typedef struct RoadStop {
|
||||||
bool used;
|
bool used;
|
||||||
byte status;
|
byte status;
|
||||||
uint32 index;
|
uint32 index;
|
||||||
uint16 slot[NUM_SLOTS];
|
VehicleID slot[NUM_SLOTS];
|
||||||
StationID station;
|
StationID station;
|
||||||
uint8 type;
|
uint8 type;
|
||||||
struct RoadStop *next;
|
struct RoadStop *next;
|
||||||
|
|
|
@ -88,7 +88,7 @@ static void InitializeRoadStop(RoadStop *road_stop, RoadStop *previous, TileInde
|
||||||
road_stop->xy = tile;
|
road_stop->xy = tile;
|
||||||
road_stop->used = true;
|
road_stop->used = true;
|
||||||
road_stop->status = 3; //stop is free
|
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->next = NULL;
|
||||||
road_stop->prev = previous;
|
road_stop->prev = previous;
|
||||||
road_stop->station = index;
|
road_stop->station = index;
|
||||||
|
@ -1428,7 +1428,7 @@ static int32 RemoveRoadStop(Station *st, uint32 flags, TileIndex tile)
|
||||||
|
|
||||||
/* Clear all vehicles destined for this station */
|
/* Clear all vehicles destined for this station */
|
||||||
for (i = 0; i != NUM_SLOTS; i++) {
|
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]);
|
Vehicle *v = GetVehicle(cur_stop->slot[i]);
|
||||||
ClearSlot(v, v->u.road.slot);
|
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 (rs = GetPrimaryRoadStop(st, rst); rs != NULL; rs = rs->next) {
|
||||||
for (k = 0; k < NUM_SLOTS; k++) {
|
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]);
|
const Vehicle *v = GetVehicle(rs->slot[k]);
|
||||||
|
|
||||||
if (v->type != VEH_Road || v->u.road.slot != rs) {
|
if (v->type != VEH_Road || v->u.road.slot != rs) {
|
||||||
DEBUG(ms, 0) (
|
DEBUG(ms, 0) (
|
||||||
"Multistop: Orphaned %s slot at 0x%X of station %d (don't panic)",
|
"Multistop: Orphaned %s slot at 0x%X of station %d (don't panic)",
|
||||||
(rst == RS_BUS) ? "bus" : "truck", rs->xy, st->index);
|
(rst == RS_BUS) ? "bus" : "truck", rs->xy, st->index);
|
||||||
rs->slot[k] = INVALID_SLOT;
|
rs->slot[k] = INVALID_VEHICLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue