(svn r2184) - CodeChange: remove the copy of ClearSlot(), which is now also called for CmdSkipOrder(). This also fixes the involuntary crash introduced 2 revisions ago
--- a/order_cmd.c Mon Apr 11 20:19:41 2005 +0000
+++ b/order_cmd.c Mon Apr 11 20:54:25 2005 +0000
@@ -7,7 +7,6 @@
#include "player.h"
#include "news.h"
#include "saveload.h"
-#include "debug.h"
enum {
/* Max orders: 64000 (64 * 1000) */
@@ -362,13 +361,8 @@
if (v->type == VEH_Train)
v->u.rail.days_since_order_progr = 0;
- if (v->type == VEH_Road && v->u.road.slot != NULL) {
- //Clear the slot ClearSlot() of roadveh_cmd.c
- DEBUG(ms, 3) ("Multistop: Clearing slot %d at 0x%x", v->u.road.slotindex, v->dest_tile);
- v->u.road.slot = NULL;
- v->u.road.slot_age = 0;
- v->u.road.slot->slot[v->u.road.slotindex] = INVALID_SLOT;
- }
+ if (v->type == VEH_Road)
+ ClearSlot(v, v->u.road.slot);
}
/* NON-stop flag is misused to see if a train is in a station that is
--- a/roadveh_cmd.c Mon Apr 11 20:19:41 2005 +0000
+++ b/roadveh_cmd.c Mon Apr 11 20:54:25 2005 +0000
@@ -229,13 +229,16 @@
return 0;
}
-static inline void ClearSlot(Vehicle *v, RoadStop *rs)
+void ClearSlot(Vehicle *v, RoadStop *rs)
{
DEBUG(ms, 3) ("Multistop: Clearing slot %d at 0x%x", v->u.road.slotindex, rs->xy);
v->u.road.slot = NULL;
v->u.road.slot_age = 0;
- if (rs != NULL)
+ 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;
+ }
}
// p1 = vehicle index in GetVehicle()
--- a/station.h Mon Apr 11 20:19:41 2005 +0000
+++ b/station.h Mon Apr 11 20:54:25 2005 +0000
@@ -270,6 +270,7 @@
uint GetNumRoadStops(const Station *st, RoadStopType type);
RoadStop * GetPrimaryRoadStop(const Station *st, RoadStopType type);
RoadStop * AllocateRoadStop( void );
+void ClearSlot(Vehicle *v, RoadStop *rs);
static inline bool IsTrainStationTile(uint tile) {
return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_map5[tile], 0, 8);