(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.
pull/155/head
maedhros 18 years ago
parent 19250f91b0
commit 6777662286

@ -1347,6 +1347,15 @@ int32 CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (rear != NULL) { if (rear != NULL) {
cost -= rear->value; 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) { if (flags & DC_EXEC) {
first = UnlinkWagon(rear, first); first = UnlinkWagon(rear, first);
DeleteDepotHighlightOfVehicle(rear); DeleteDepotHighlightOfVehicle(rear);

Loading…
Cancel
Save