summaryrefslogtreecommitdiff
path: root/roadveh_cmd.c
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2005-04-08 22:44:06 +0000
committerDarkvater <Darkvater@openttd.org>2005-04-08 22:44:06 +0000
commit8f4583b1610dcf848cc45b2714964d9217c60611 (patch)
tree03255e464a7b6b59f6adf9af778478eb33638e18 /roadveh_cmd.c
parent4a1d9a4775a217f343efcc53f179c23af93960fb (diff)
downloadopenttd-8f4583b1610dcf848cc45b2714964d9217c60611.tar.xz
(svn r2168) - Fix: Various stages of invisible trains, and wrong v->u.rail.track combinations. When a vehicle was sold its (possibly) assigned road slot for multislot was not cleared, thus resulting in a bug confusion. This should fix [ 1178520 ] Assertion failure in ai.c (invalid v->u.rail.track). With big thanks to TrueLight for the demo-recording patch, BJH for the wonderful savegame, Hackykid for his brilliant suggestions of the problem and Celestar for... ehm, making it all possible ;p
Diffstat (limited to 'roadveh_cmd.c')
-rw-r--r--roadveh_cmd.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index d868624c7..591bd8879 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -229,6 +229,15 @@ int32 CmdStartStopRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return 0;
}
+static inline 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)
+ rs->slot[v->u.road.slotindex] = INVALID_SLOT;
+}
+
// p1 = vehicle index in GetVehicle()
// p2 not used
int32 CmdSellRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
@@ -253,6 +262,7 @@ int32 CmdSellRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
RebuildVehicleLists();
InvalidateWindow(WC_COMPANY, v->owner);
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
+ ClearSlot(v, v->u.road.slot);
DeleteVehicle(v);
}
InvalidateWindow(WC_REPLACE_VEHICLE, VEH_Road); // updates the replace Road window
@@ -1177,14 +1187,6 @@ static const byte _road_veh_data_1[] = {
static const byte _roadveh_data_2[4] = { 0,1,8,9 };
-static inline 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;
- rs->slot[v->u.road.slotindex] = INVALID_SLOT;
-}
-
static void RoadVehController(Vehicle *v)
{
GetNewVehiclePosResult gp;