mirror of https://github.com/OpenTTD/OpenTTD
Change: Mark build/autoreplace windows dirty less often in monthy loop.
These window classes were marked dirty for every engine that had reliability calculated every month.pull/10284/head
parent
85814b29d4
commit
898dadadb2
|
@ -613,8 +613,7 @@ static void CalcEngineReliability(Engine *e)
|
||||||
ClearLastVariant(e->index, e->type);
|
ClearLastVariant(e->index, e->type);
|
||||||
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
|
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
|
||||||
}
|
}
|
||||||
SetWindowClassesDirty(WC_BUILD_VEHICLE); // Update to show the new reliability
|
|
||||||
SetWindowClassesDirty(WC_REPLACE_VEHICLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Compute the value for #_year_engine_aging_stops. */
|
/** Compute the value for #_year_engine_aging_stops. */
|
||||||
|
@ -716,6 +715,9 @@ void StartupEngines()
|
||||||
|
|
||||||
/* Invalidate any open purchase lists */
|
/* Invalidate any open purchase lists */
|
||||||
InvalidateWindowClassesData(WC_BUILD_VEHICLE);
|
InvalidateWindowClassesData(WC_BUILD_VEHICLE);
|
||||||
|
|
||||||
|
SetWindowClassesDirty(WC_BUILD_VEHICLE);
|
||||||
|
SetWindowClassesDirty(WC_REPLACE_VEHICLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1031,11 +1033,13 @@ static void NewVehicleAvailable(Engine *e)
|
||||||
void EnginesMonthlyLoop()
|
void EnginesMonthlyLoop()
|
||||||
{
|
{
|
||||||
if (_cur_year < _year_engine_aging_stops) {
|
if (_cur_year < _year_engine_aging_stops) {
|
||||||
|
bool refresh = false;
|
||||||
for (Engine *e : Engine::Iterate()) {
|
for (Engine *e : Engine::Iterate()) {
|
||||||
/* Age the vehicle */
|
/* Age the vehicle */
|
||||||
if ((e->flags & ENGINE_AVAILABLE) && e->age != MAX_DAY) {
|
if ((e->flags & ENGINE_AVAILABLE) && e->age != MAX_DAY) {
|
||||||
e->age++;
|
e->age++;
|
||||||
CalcEngineReliability(e);
|
CalcEngineReliability(e);
|
||||||
|
refresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do not introduce invalid engines */
|
/* Do not introduce invalid engines */
|
||||||
|
@ -1062,6 +1066,11 @@ void EnginesMonthlyLoop()
|
||||||
}
|
}
|
||||||
|
|
||||||
InvalidateWindowClassesData(WC_BUILD_VEHICLE); // rebuild the purchase list (esp. when sorted by reliability)
|
InvalidateWindowClassesData(WC_BUILD_VEHICLE); // rebuild the purchase list (esp. when sorted by reliability)
|
||||||
|
|
||||||
|
if (refresh) {
|
||||||
|
SetWindowClassesDirty(WC_BUILD_VEHICLE);
|
||||||
|
SetWindowClassesDirty(WC_REPLACE_VEHICLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue