summaryrefslogtreecommitdiff
path: root/vehicle.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-11-19 22:39:16 +0000
committerbjarni <bjarni@openttd.org>2005-11-19 22:39:16 +0000
commitc7f3192f6ba2f8a9de7175c1eaa6f86971051c01 (patch)
tree0a7751252c0a0f461e92b70583478c1109d798b8 /vehicle.c
parentf2b344084accd953a8e26db9a4196688f07a30a5 (diff)
downloadopenttd-c7f3192f6ba2f8a9de7175c1eaa6f86971051c01.tar.xz
(svn r3223) -Fix: [autoreplace] fixed crash when replacing a train engine without any cars (introduced in r3220)
Diffstat (limited to 'vehicle.c')
-rw-r--r--vehicle.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/vehicle.c b/vehicle.c
index 0ed3e8e0d..f1aaacc8f 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -1655,7 +1655,9 @@ static int32 ReplaceVehicle(Vehicle **w, byte flags)
new_v->current_order = old_v->current_order;
if (old_v->type == VEH_Train){
// move the entire train to the new engine, including the old engine. It will be sold in a moment anyway
- DoCommand(0, 0, (new_v->index << 16) | GetNextVehicle(old_v)->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
+ if (GetNextVehicle(old_v) != NULL) {
+ DoCommand(0, 0, (new_v->index << 16) | GetNextVehicle(old_v)->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
+ }
new_v->u.rail.shortest_platform[0] = old_v->u.rail.shortest_platform[0];
new_v->u.rail.shortest_platform[1] = old_v->u.rail.shortest_platform[1];
}