(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.
This commit is contained in:
maedhros 2007-06-02 14:42:25 +00:00
parent 19250f91b0
commit 6777662286

View File

@ -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);