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_EFFECT) InvalidateVehicleTickCaches();
|
||||||
|
|
||||||
|
if (this->type == VEH_DISASTER) RemoveFromOtherVehicleTickCache(this);
|
||||||
|
|
||||||
if (this->breakdowns_since_last_service) _vehicles_to_pay_repair.erase(this);
|
if (this->breakdowns_since_last_service) _vehicles_to_pay_repair.erase(this);
|
||||||
|
|
||||||
if (this->type < VEH_BEGIN || this->type >= VEH_COMPANY_END) {
|
if (this->type < VEH_BEGIN || this->type >= VEH_COMPANY_END) {
|
||||||
@@ -1145,6 +1147,13 @@ void ClearVehicleTickCaches()
|
|||||||
_tick_other_veh_cache.clear();
|
_tick_other_veh_cache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RemoveFromOtherVehicleTickCache(const Vehicle *v)
|
||||||
|
{
|
||||||
|
for (auto &u : _tick_other_veh_cache) {
|
||||||
|
if (u == v) u = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RebuildVehicleTickCaches()
|
void RebuildVehicleTickCaches()
|
||||||
{
|
{
|
||||||
Vehicle *v = NULL;
|
Vehicle *v = NULL;
|
||||||
@@ -1300,6 +1309,7 @@ void CallVehicleTicks()
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
for (Vehicle *u : _tick_other_veh_cache) {
|
for (Vehicle *u : _tick_other_veh_cache) {
|
||||||
|
if (!u) continue;
|
||||||
v = u;
|
v = u;
|
||||||
u->Tick();
|
u->Tick();
|
||||||
}
|
}
|
||||||
|
@@ -1299,5 +1299,6 @@ inline void InvalidateVehicleTickCaches()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ClearVehicleTickCaches();
|
void ClearVehicleTickCaches();
|
||||||
|
void RemoveFromOtherVehicleTickCache(const Vehicle *v);
|
||||||
|
|
||||||
#endif /* VEHICLE_BASE_H */
|
#endif /* VEHICLE_BASE_H */
|
||||||
|
Reference in New Issue
Block a user