mirror of https://github.com/OpenTTD/OpenTTD
Refresh company finance windows via a WindowTimer instead of in game loop. As the invalidation affects multiple windows this is a global timer instead of window-specific.pull/14235/head
parent
bc778545b3
commit
156f98ba06
|
@ -39,6 +39,7 @@
|
|||
#include "timer/timer.h"
|
||||
#include "timer/timer_game_economy.h"
|
||||
#include "timer/timer_game_tick.h"
|
||||
#include "timer/timer_window.h"
|
||||
|
||||
#include "widgets/statusbar_widget.h"
|
||||
|
||||
|
@ -219,8 +220,7 @@ void InvalidateCompanyWindows(const Company *company)
|
|||
/**
|
||||
* Refresh all company finance windows previously marked dirty.
|
||||
*/
|
||||
void InvalidateCompanyWindows()
|
||||
{
|
||||
static const IntervalTimer<TimerWindow> invalidate_company_windows_interval(std::chrono::milliseconds(1), [](auto) {
|
||||
for (CompanyID cid : _dirty_company_finances) {
|
||||
if (cid == _local_company) SetWindowWidgetDirty(WC_STATUS_BAR, 0, WID_S_RIGHT);
|
||||
Window *w = FindWindowById(WC_FINANCES, cid);
|
||||
|
@ -233,8 +233,8 @@ void InvalidateCompanyWindows()
|
|||
}
|
||||
SetWindowWidgetDirty(WC_COMPANY, cid, WID_C_DESC_COMPANY_VALUE);
|
||||
}
|
||||
_dirty_company_finances = {};
|
||||
}
|
||||
_dirty_company_finances.Reset();
|
||||
});
|
||||
|
||||
/**
|
||||
* Get the amount of money that a company has available, or INT64_MAX
|
||||
|
|
|
@ -23,7 +23,6 @@ void ShowCompanyFinances(CompanyID company);
|
|||
void ShowCompany(CompanyID company);
|
||||
|
||||
void InvalidateCompanyWindows(const Company *c);
|
||||
void InvalidateCompanyWindows();
|
||||
void CloseCompanyWindows(CompanyID company);
|
||||
void DirtyCompanyInfrastructureWindows(CompanyID company);
|
||||
|
||||
|
|
|
@ -1244,7 +1244,6 @@ void StateGameLoop()
|
|||
|
||||
CallWindowGameTickEvent();
|
||||
NewsLoop();
|
||||
InvalidateCompanyWindows();
|
||||
} else {
|
||||
if (_debug_desync_level > 2 && TimerGameEconomy::date_fract == 0 && (TimerGameEconomy::date.base() & 0x1F) == 0) {
|
||||
/* Save the desync savegame if needed. */
|
||||
|
@ -1281,7 +1280,6 @@ void StateGameLoop()
|
|||
|
||||
CallWindowGameTickEvent();
|
||||
NewsLoop();
|
||||
InvalidateCompanyWindows();
|
||||
cur_company.Restore();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue