TBTR: Fix CmdDeleteVirtualTrain deleting non-head vehicles

Deleting a non-head virtual vehicle left a dangling next pointer on
the previous vehicle. Delete the head instead.
Check for non-virtual vehicles
pull/199/head
Jonathan G Rennison 4 years ago
parent 0d4a023c1d
commit 65cdb35898

@ -1109,7 +1109,12 @@ CommandCost CmdDeleteVirtualTrain(TileIndex tile, DoCommandFlag flags, uint32 p1
return CMD_ERROR;
}
vehicle = vehicle->First();
Train* train = Train::From(vehicle);
if (!train->IsVirtual()) {
return CMD_ERROR;
}
bool should_execute = (flags & DC_EXEC) != 0;

Loading…
Cancel
Save