1
0
Fork 0

Fix #14256, dfd9fbf873: Company finance windows not updated when paused. (#14258)

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
Peter Nelson 2025-05-13 01:23:27 +01:00 committed by GitHub
parent bc778545b3
commit 156f98ba06
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 7 deletions

View File

@ -39,6 +39,7 @@
#include "timer/timer.h" #include "timer/timer.h"
#include "timer/timer_game_economy.h" #include "timer/timer_game_economy.h"
#include "timer/timer_game_tick.h" #include "timer/timer_game_tick.h"
#include "timer/timer_window.h"
#include "widgets/statusbar_widget.h" #include "widgets/statusbar_widget.h"
@ -219,8 +220,7 @@ void InvalidateCompanyWindows(const Company *company)
/** /**
* Refresh all company finance windows previously marked dirty. * 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) { for (CompanyID cid : _dirty_company_finances) {
if (cid == _local_company) SetWindowWidgetDirty(WC_STATUS_BAR, 0, WID_S_RIGHT); if (cid == _local_company) SetWindowWidgetDirty(WC_STATUS_BAR, 0, WID_S_RIGHT);
Window *w = FindWindowById(WC_FINANCES, cid); Window *w = FindWindowById(WC_FINANCES, cid);
@ -233,8 +233,8 @@ void InvalidateCompanyWindows()
} }
SetWindowWidgetDirty(WC_COMPANY, cid, WID_C_DESC_COMPANY_VALUE); 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 * Get the amount of money that a company has available, or INT64_MAX

View File

@ -23,7 +23,6 @@ void ShowCompanyFinances(CompanyID company);
void ShowCompany(CompanyID company); void ShowCompany(CompanyID company);
void InvalidateCompanyWindows(const Company *c); void InvalidateCompanyWindows(const Company *c);
void InvalidateCompanyWindows();
void CloseCompanyWindows(CompanyID company); void CloseCompanyWindows(CompanyID company);
void DirtyCompanyInfrastructureWindows(CompanyID company); void DirtyCompanyInfrastructureWindows(CompanyID company);

View File

@ -1244,7 +1244,6 @@ void StateGameLoop()
CallWindowGameTickEvent(); CallWindowGameTickEvent();
NewsLoop(); NewsLoop();
InvalidateCompanyWindows();
} else { } else {
if (_debug_desync_level > 2 && TimerGameEconomy::date_fract == 0 && (TimerGameEconomy::date.base() & 0x1F) == 0) { if (_debug_desync_level > 2 && TimerGameEconomy::date_fract == 0 && (TimerGameEconomy::date.base() & 0x1F) == 0) {
/* Save the desync savegame if needed. */ /* Save the desync savegame if needed. */
@ -1281,7 +1280,6 @@ void StateGameLoop()
CallWindowGameTickEvent(); CallWindowGameTickEvent();
NewsLoop(); NewsLoop();
InvalidateCompanyWindows();
cur_company.Restore(); cur_company.Restore();
} }