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 | 12b359fa32fd3caf9626e8fc4131ab0d2fd0ba9d (patch) | |
tree | 89135b7e0750e5051594c9553bd9e21199340021 | |
parent | 60d738f23ae2ad657e84b9d5d995822072012e03 (diff) | |
download | openttd-12b359fa32fd3caf9626e8fc4131ab0d2fd0ba9d.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; |