(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 1e7b8190f2
commit 229e311cb9
1 changed files with 9 additions and 0 deletions

View File

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