diff options
author | rubidium <rubidium@openttd.org> | 2007-08-05 17:43:04 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-08-05 17:43:04 +0000 |
commit | ab5fa3add2f5f2feeb8f48127f6ee5ab69d42f65 (patch) | |
tree | 0eafac3ddee78188054a0844f0525a87e5435999 /src/vehicle.cpp | |
parent | f6933e18701de289a439b658282549079d511b19 (diff) | |
download | openttd-ab5fa3add2f5f2feeb8f48127f6ee5ab69d42f65.tar.xz |
(svn r10798) -Fix [FS#1105]: virtual functions do not work in destructors :(.
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r-- | src/vehicle.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index c2fbe0548..c845a00b0 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -562,7 +562,7 @@ bool IsEngineCountable(const Vehicle *v) } } -Vehicle::~Vehicle() +void Vehicle::PreDestructor() { if (IsValidStationID(this->last_station_visited)) { GetStation(this->last_station_visited)->loading_vehicles.remove(this); @@ -579,8 +579,6 @@ Vehicle::~Vehicle() if (this->IsPrimaryVehicle()) DecreaseGroupNumVehicle(this->group_id); } - DeleteVehicleNews(this->index, INVALID_STRING_ID); - this->QuickFree(); if (this->type == VEH_ROAD) ClearSlot(this); @@ -589,10 +587,7 @@ Vehicle::~Vehicle() } this->cargo.Truncate(0); - UpdateVehiclePosHash(this, INVALID_COORD, 0); - this->next_hash = NULL; - this->next_new_hash = NULL; - if (IsPlayerBuildableVehicleType(this)) DeleteVehicleOrders(this); + DeleteVehicleOrders(this); /* Now remove any artic part. This will trigger an other * destroy vehicle, which on his turn can remove any @@ -600,6 +595,15 @@ Vehicle::~Vehicle() if ((this->type == VEH_TRAIN && EngineHasArticPart(this)) || (this->type == VEH_ROAD && RoadVehHasArticPart(this))) { delete this->next; } +} + +Vehicle::~Vehicle() +{ + UpdateVehiclePosHash(this, INVALID_COORD, 0); + this->next_hash = NULL; + this->next_new_hash = NULL; + + DeleteVehicleNews(this->index, INVALID_STRING_ID); new (this) InvalidVehicle(); } |