From f18043ee21218dc9ea26ce41b1294c5212ac363c Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 26 Dec 2008 20:45:02 +0000 Subject: (svn r14747) -Codechange: remove DeleteVehicleChain in favour of the vehicle destructor as that was already doing the same for a few vehicle types. --- src/vehicle.cpp | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'src/vehicle.cpp') 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; @@ -698,24 +699,6 @@ Vehicle::~Vehicle() new (this) InvalidVehicle(); } -/** - * 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. -- cgit v1.2.3-54-g00ecf