Remove disaster vehicles from tick cache immediately on deletion
This commit is contained in:
@@ -1022,6 +1022,8 @@ Vehicle::~Vehicle()
|
||||
|
||||
if (this->type != VEH_EFFECT) InvalidateVehicleTickCaches();
|
||||
|
||||
if (this->type == VEH_DISASTER) RemoveFromOtherVehicleTickCache(this);
|
||||
|
||||
if (this->breakdowns_since_last_service) _vehicles_to_pay_repair.erase(this);
|
||||
|
||||
if (this->type < VEH_BEGIN || this->type >= VEH_COMPANY_END) {
|
||||
@@ -1145,6 +1147,13 @@ void ClearVehicleTickCaches()
|
||||
_tick_other_veh_cache.clear();
|
||||
}
|
||||
|
||||
void RemoveFromOtherVehicleTickCache(const Vehicle *v)
|
||||
{
|
||||
for (auto &u : _tick_other_veh_cache) {
|
||||
if (u == v) u = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void RebuildVehicleTickCaches()
|
||||
{
|
||||
Vehicle *v = NULL;
|
||||
@@ -1300,6 +1309,7 @@ void CallVehicleTicks()
|
||||
}
|
||||
{
|
||||
for (Vehicle *u : _tick_other_veh_cache) {
|
||||
if (!u) continue;
|
||||
v = u;
|
||||
u->Tick();
|
||||
}
|
||||
|
Reference in New Issue
Block a user