Mercurial > hg > openttd
changeset 6876:d73e7573898d draft
(svn r10117) -Fix [FS#863]: When deleting the vehicles of bankrupt players, delete trains as
a whole rather than each part individually, as that leads to invalid tests on
parts that have already been deleted.
author | maedhros <maedhros@openttd.org> |
---|---|
date | Tue, 12 Jun 2007 17:10:52 +0000 |
parents | 5e797b77132a |
children | 0b5424c73bd4 |
files | src/economy.cpp |
diffstat | 1 files changed, 24 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/economy.cpp +++ b/src/economy.cpp @@ -355,7 +355,30 @@ DeleteWindowById(WC_VEHICLE_VIEW, v->index); DeleteWindowById(WC_VEHICLE_DETAILS, v->index); DeleteWindowById(WC_VEHICLE_ORDERS, v->index); - DeleteVehicle(v); + + if (v->IsPrimaryVehicle() || (v->type == VEH_TRAIN && IsFreeWagon(v))) { + switch (v->type) { + default: NOT_REACHED(); + + case VEH_TRAIN: { + Vehicle *u = v; + do { + Vehicle *next = GetNextVehicle(u); + DeleteVehicle(u); + u = next; + } while (u != NULL); + } break; + + case VEH_ROAD: + case VEH_SHIP: + DeleteVehicle(v); + break; + + case VEH_AIRCRAFT: + DeleteVehicleChain(v); + break; + } + } } else { v->owner = new_player; v->group_id = DEFAULT_GROUP;