From 4719c452e87a157c590a4352a88a33e4911aad6f Mon Sep 17 00:00:00 2001 From: Darkvater Date: Mon, 11 Apr 2005 20:54:25 +0000 Subject: [PATCH] (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 --- order_cmd.c | 10 ++-------- roadveh_cmd.c | 7 +++++-- station.h | 1 + 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/order_cmd.c b/order_cmd.c index 5553b8ac91..9ddf3920d0 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 5accdf632c..7106ce3d10 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 bb1fe66ce5..f76eda2275 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);