Changeset - r24824:25e416ad7835
[Not reviewed]
master
0 2 0
Jonathan G Rennison - 4 years ago 2021-02-18 11:29:30
j.g.rennison@gmail.com
Fix: Whole status bar instead of money widget refreshed on money change (#8692)

This could result in the rest of the status bar being
redrawn unnecessarily frequently
2 files changed with 4 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/company_cmd.cpp
Show inline comments
 
@@ -26,24 +26,25 @@
 
#include "strings_func.h"
 
#include "date_func.h"
 
#include "sound_func.h"
 
#include "rail.h"
 
#include "core/pool_func.hpp"
 
#include "settings_func.h"
 
#include "vehicle_base.h"
 
#include "vehicle_func.h"
 
#include "smallmap_gui.h"
 
#include "game/game.hpp"
 
#include "goal_base.h"
 
#include "story_base.h"
 
#include "widgets/statusbar_widget.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
void ClearEnginesHiddenFlagOfCompany(CompanyID cid);
 

	
 
CompanyID _local_company;   ///< Company controlled by the human player at this client. Can also be #COMPANY_SPECTATOR.
 
CompanyID _current_company; ///< Company currently doing an action.
 
Colours _company_colours[MAX_COMPANIES];  ///< NOSAVE: can be determined from company structs.
 
CompanyManagerFace _company_manager_face; ///< for company manager face storage in openttd.cfg
 
uint _next_competitor_start;              ///< the number of ticks before the next AI is started
 
@@ -173,25 +174,25 @@ static bool IsValidCompanyManagerFace(Co
 

	
 
	return true;
 
}
 

	
 
/**
 
 * Refresh all windows owned by a company.
 
 * @param company Company that changed, and needs its windows refreshed.
 
 */
 
void InvalidateCompanyWindows(const Company *company)
 
{
 
	CompanyID cid = company->index;
 

	
 
	if (cid == _local_company) SetWindowDirty(WC_STATUS_BAR, 0);
 
	if (cid == _local_company) SetWindowWidgetDirty(WC_STATUS_BAR, 0, WID_S_RIGHT);
 
	SetWindowDirty(WC_FINANCES, cid);
 
}
 

	
 
/**
 
 * Verify whether the company can pay the bill.
 
 * @param[in,out] cost Money to pay, is changed to an error if the company does not have enough money.
 
 * @return Function returns \c true if the company has enough money, else it returns \c false.
 
 */
 
bool CheckCompanyHasMoney(CommandCost &cost)
 
{
 
	if (cost.GetCost() > 0) {
 
		const Company *c = Company::GetIfValid(_current_company);
src/date.cpp
Show inline comments
 
@@ -10,24 +10,25 @@
 
#include "stdafx.h"
 
#include "network/network.h"
 
#include "network/network_func.h"
 
#include "currency.h"
 
#include "window_func.h"
 
#include "settings_type.h"
 
#include "date_func.h"
 
#include "vehicle_base.h"
 
#include "rail_gui.h"
 
#include "linkgraph/linkgraph.h"
 
#include "saveload/saveload.h"
 
#include "newgrf_profiling.h"
 
#include "widgets/statusbar_widget.h"
 

	
 
#include "safeguards.h"
 

	
 
Year      _cur_year;   ///< Current year, starting at 0
 
Month     _cur_month;  ///< Current month (0..11)
 
Date      _date;       ///< Current date in days (day counter)
 
DateFract _date_fract; ///< Fractional part of the day.
 
uint16 _tick_counter;  ///< Ever incrementing (and sometimes wrapping) tick counter for setting off various events
 

	
 
/**
 
 * Set the date.
 
 * @param date  New date
 
@@ -246,25 +247,25 @@ static void OnNewMonth()
 
 */
 
static void OnNewDay()
 
{
 
	if (!_newgrf_profilers.empty() && _newgrf_profile_end_date <= _date) {
 
		NewGRFProfiler::FinishAll();
 
	}
 

	
 
	if (_network_server) NetworkServerDailyLoop();
 

	
 
	DisasterDailyLoop();
 
	IndustryDailyLoop();
 

	
 
	SetWindowWidgetDirty(WC_STATUS_BAR, 0, 0);
 
	SetWindowWidgetDirty(WC_STATUS_BAR, 0, WID_S_LEFT);
 
	EnginesDailyLoop();
 

	
 
	/* Refresh after possible snowline change */
 
	SetWindowClassesDirty(WC_TOWN_VIEW);
 
}
 

	
 
/**
 
 * Increases the tick counter, increases date  and possibly calls
 
 * procedures that have to be called daily, monthly or yearly.
 
 */
 
void IncreaseDate()
 
{
0 comments (0 inline, 0 general)