diff options
author | maedhros <maedhros@openttd.org> | 2007-06-02 14:42:25 +0000 |
---|---|---|
committer | maedhros <maedhros@openttd.org> | 2007-06-02 14:42:25 +0000 |
commit | 229e311cb904b43fed1a7cce821c4137ccd87630 (patch) | |
tree | 203f008545f005e24fd36ddd2035618327891b01 /src | |
parent | 1e7b8190f2ad02d1572b28308473dc7696ea9b0e (diff) | |
download | openttd-229e311cb904b43fed1a7cce821c4137ccd87630.tar.xz |
(svn r10023) -Fix (r3218): When selling trains, if there were no wagons between multiheaded
engines the rear part could be checked despite having already been deleted,
triggering an assert.
Diffstat (limited to 'src')
-rw-r--r-- | src/train_cmd.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 9f8318a55..4c7bf90cf 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1347,6 +1347,15 @@ int32 CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (rear != NULL) { cost -= rear->value; + + /* If this is a multiheaded vehicle with nothing + * between the parts, tmp will be pointing to the + * rear part, which is unlinked from the train and + * deleted here. However, because tmp has already + * been set it needs to be updated now so that the + * loop never sees the rear part. */ + if (tmp == rear) tmp = GetNextVehicle(tmp); + if (flags & DC_EXEC) { first = UnlinkWagon(rear, first); DeleteDepotHighlightOfVehicle(rear); |