(svn r3612) - RoadStop->slot[] stores a vehicle index. Adjust its type and use INVALID_VEHICLE instead of nonsense INVALID_SLOT.
authorpeter1138
Sat, 18 Feb 2006 14:11:23 +0000
changeset 3032 3d607ca2d8fc
parent 3031 bd5cae1efa8c
child 3033 e4f7c60a1742
(svn r3612) - RoadStop->slot[] stores a vehicle index. Adjust its type and use INVALID_VEHICLE instead of nonsense INVALID_SLOT.
oldloader.c
roadveh_cmd.c
station.h
station_cmd.c
--- a/oldloader.c	Fri Feb 17 20:24:17 2006 +0000
+++ b/oldloader.c	Sat Feb 18 14:11:23 2006 +0000
@@ -372,7 +372,7 @@
 			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 @@
 			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;
 		}
 	}
 }
--- a/roadveh_cmd.c	Fri Feb 17 20:24:17 2006 +0000
+++ b/roadveh_cmd.c	Sat Feb 18 14:11:23 2006 +0000
@@ -231,7 +231,7 @@
 	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 @@
 			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 @@
 			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;
--- a/station.h	Fri Feb 17 20:24:17 2006 +0000
+++ b/station.h	Sat Feb 18 14:11:23 2006 +0000
@@ -28,7 +28,6 @@
 
 enum {
 	INVALID_STATION = 0xFFFF,
-	INVALID_SLOT = 0xFFFF,
 	NUM_SLOTS = 2,
 	ROAD_STOP_LIMIT = 8,
 };
@@ -40,7 +39,7 @@
 	bool used;
 	byte status;
 	uint32 index;
-	uint16 slot[NUM_SLOTS];
+	VehicleID slot[NUM_SLOTS];
 	StationID station;
 	uint8 type;
 	struct RoadStop *next;
--- a/station_cmd.c	Fri Feb 17 20:24:17 2006 +0000
+++ b/station_cmd.c	Sat Feb 18 14:11:23 2006 +0000
@@ -88,7 +88,7 @@
 	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 @@
 
 		/* 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 @@
 
 	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;
 				}
 			}
 		}