summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2005-04-11 20:54:25 +0000
committerDarkvater <Darkvater@openttd.org>2005-04-11 20:54:25 +0000
commit4719c452e87a157c590a4352a88a33e4911aad6f (patch)
treeed024e987f57f23fee9bfa53bbd1a640d8ebd288
parent78eeb84d6bd29736a35467651d4a8631e9cf4171 (diff)
downloadopenttd-4719c452e87a157c590a4352a88a33e4911aad6f.tar.xz
(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
-rw-r--r--order_cmd.c10
-rw-r--r--roadveh_cmd.c7
-rw-r--r--station.h1
3 files changed, 8 insertions, 10 deletions
diff --git a/order_cmd.c b/order_cmd.c
index 5553b8ac9..9ddf3920d 100644
--- a/order_cmd.c
+++ b/order_cmd.c
@@ -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 @@ int32 CmdSkipOrder(int x, int y, uint32 flags, uint32 vehicle_id, uint32 not_use
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
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 5accdf632..7106ce3d1 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -229,13 +229,16 @@ int32 CmdStartStopRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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()
diff --git a/station.h b/station.h
index bb1fe66ce..f76eda227 100644
--- a/station.h
+++ b/station.h
@@ -270,6 +270,7 @@ static inline int GetRoadStopType(TileIndex tile)
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);