diff options
author | rubidium <rubidium@openttd.org> | 2008-12-26 20:45:02 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-12-26 20:45:02 +0000 |
commit | f18043ee21218dc9ea26ce41b1294c5212ac363c (patch) | |
tree | 8f057180fb9ab731f9c1950f45a7d957bf7d4ae0 /src/vehicle.cpp | |
parent | 73ca72922c64db43f16b4283548ccf30aca3e59a (diff) | |
download | openttd-f18043ee21218dc9ea26ce41b1294c5212ac363c.tar.xz |
(svn r14747) -Codechange: remove DeleteVehicleChain in favour of the vehicle destructor as that was already doing the same for a few vehicle types.
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r-- | src/vehicle.cpp | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index faa042b33..f6dc3514d 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -671,13 +671,6 @@ void Vehicle::PreDestructor() this->cargo.Truncate(0); DeleteVehicleOrders(this); - /* Now remove any artic part. This will trigger an other - * destroy vehicle, which on his turn can remove any - * other artic parts. */ - if ((this->type == VEH_TRAIN && EngineHasArticPart(this)) || (this->type == VEH_ROAD && RoadVehHasArticPart(this))) { - delete this->Next(); - } - extern void StopGlobalFollowVehicle(const Vehicle *v); StopGlobalFollowVehicle(this); } @@ -688,7 +681,15 @@ Vehicle::~Vehicle() if (CleaningPool()) return; + /* sometimes, eg. for disaster vehicles, when company bankrupts, when removing crashed/flooded vehicles, + * it may happen that vehicle chain is deleted when visible */ + if (!(this->vehstatus & VS_HIDDEN)) MarkSingleVehicleDirty(this); + + Vehicle *v = this->Next(); this->SetNext(NULL); + + delete v; + UpdateVehiclePosHash(this, INVALID_COORD, 0); this->next_hash = NULL; this->next_new_hash = NULL; @@ -699,24 +700,6 @@ Vehicle::~Vehicle() } /** - * Deletes all vehicles in a chain. - * @param v The first vehicle in the chain. - */ -void DeleteVehicleChain(Vehicle *v) -{ - assert(v->First() == v); - - do { - Vehicle *u = v; - /* sometimes, eg. for disaster vehicles, when company bankrupts, when removing crashed/flooded vehicles, - * it may happen that vehicle chain is deleted when visible */ - if (!(v->vehstatus & VS_HIDDEN)) MarkSingleVehicleDirty(v); - v = v->Next(); - delete u; - } while (v != NULL); -} - -/** * List of vehicles that should check for autoreplace this tick. * Mapping of vehicle -> leave depot immediatelly after autoreplace. */ |