diff options
author | maedhros <maedhros@openttd.org> | 2007-06-12 17:10:52 +0000 |
---|---|---|
committer | maedhros <maedhros@openttd.org> | 2007-06-12 17:10:52 +0000 |
commit | 49ba521e77f6e336bbdd4ad6a7aa95d91f689e08 (patch) | |
tree | 89135b7e0750e5051594c9553bd9e21199340021 | |
parent | 73790d9cd6de5b704f006b20b7fd5e150368fd55 (diff) | |
download | openttd-49ba521e77f6e336bbdd4ad6a7aa95d91f689e08.tar.xz |
(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.
-rw-r--r-- | src/economy.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/economy.cpp b/src/economy.cpp index ff8f496d2..64bcbe832 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -355,7 +355,30 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player) 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; |