Changeset - r13024:48c81d0b078a
[Not reviewed]
master
! ! !
frosch - 15 years ago 2009-09-13 19:15:59
frosch@openttd.org
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
61 files changed with 323 insertions and 323 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_gui.cpp
Show inline comments
 
@@ -150,13 +150,13 @@ struct AIListWindow : public Window {
 
			AIConfig::GetConfig(slot)->ChangeAI(NULL);
 
		} else {
 
			AIInfoList::const_iterator it = this->ai_info_list->begin();
 
			for (int i = 0; i < this->selected; i++) it++;
 
			AIConfig::GetConfig(slot)->ChangeAI((*it).second->GetName(), (*it).second->GetVersion());
 
		}
 
		InvalidateWindow(WC_GAME_OPTIONS, 0);
 
		SetWindowDirty(WC_GAME_OPTIONS, 0);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		switch (widget) {
 
			case AIL_WIDGET_LIST: { // Select one of the AIs
 
@@ -764,13 +764,13 @@ struct AIDebugWindow : public Window {
 

	
 
		int scroll_count = (log == NULL) ? 0 : log->used;
 
		if (this->vscroll.GetCount() != scroll_count) {
 
			this->vscroll.SetCount(scroll_count);
 

	
 
			/* We need a repaint */
 
			this->InvalidateWidget(AID_WIDGET_SCROLLBAR);
 
			this->SetWidgetDirty(AID_WIDGET_SCROLLBAR);
 
		}
 

	
 
		if (log == NULL) return;
 

	
 
		/* Detect when the user scrolls the window. Enable autoscroll when the
 
		 * bottom-most line becomes visible. */
 
@@ -780,14 +780,14 @@ struct AIDebugWindow : public Window {
 
		if (this->autoscroll) {
 
			int scroll_pos = max(0, log->used - this->vscroll.GetCapacity());
 
			if (scroll_pos != this->vscroll.GetPosition()) {
 
				this->vscroll.SetPosition(scroll_pos);
 

	
 
				/* We need a repaint */
 
				this->InvalidateWidget(AID_WIDGET_SCROLLBAR);
 
				this->InvalidateWidget(AID_WIDGET_LOG_PANEL);
 
				this->SetWidgetDirty(AID_WIDGET_SCROLLBAR);
 
				this->SetWidgetDirty(AID_WIDGET_LOG_PANEL);
 
			}
 
		}
 
		this->last_vscroll_pos = this->vscroll.GetPosition();
 

	
 
	}
 

	
src/aircraft_cmd.cpp
Show inline comments
 
@@ -430,13 +430,13 @@ CommandCost CmdBuildAircraft(TileIndex t
 
			u->SetNext(w);
 
			VehicleMove(w, false);
 
		}
 

	
 
		InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 
		InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
 
		InvalidateWindow(WC_COMPANY, v->owner);
 
		SetWindowDirty(WC_COMPANY, v->owner);
 
		if (IsLocalCompany())
 
			InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Aircraft window
 

	
 
		Company::Get(_current_company)->num_engines[p1]++;
 
	}
 

	
 
@@ -577,14 +577,14 @@ CommandCost CmdRefitAircraft(TileIndex t
 
		v->cargo.Truncate(v->cargo_type == new_cid ? pass : 0);
 
		u->cargo.Truncate(v->cargo_type == new_cid ? mail : 0);
 
		v->cargo_type = new_cid;
 
		v->cargo_subtype = new_subtype;
 
		v->colourmap = PAL_NONE; // invalidate vehicle colour map
 
		v->InvalidateNewGRFCacheOfChain();
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
		SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 
		SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
 
		InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
 
	}
 

	
 
	return cost;
 
}
 

	
 
@@ -603,16 +603,16 @@ static void CheckIfAircraftNeedsService(
 

	
 
	/* only goto depot if the target airport has terminals (eg. it is airport) */
 
	if (st->airport_tile != INVALID_TILE && st->Airport()->terminals != NULL) {
 
//		printf("targetairport = %d, st->index = %d\n", v->targetairport, st->index);
 
//		v->targetairport = st->index;
 
		v->current_order.MakeGoToDepot(st->index, ODTFB_SERVICE);
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	} else if (v->current_order.IsType(OT_GOTO_DEPOT)) {
 
		v->current_order.MakeDummy();
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	}
 
}
 

	
 
Money Aircraft::GetRunningCost() const
 
{
 
	return GetVehicleProperty(this, 0x0E, AircraftVehInfo(this->engine_type)->running_cost) * _price.aircraft_running;
 
@@ -636,14 +636,14 @@ void Aircraft::OnNewDay()
 

	
 
	this->profit_this_year -= cost.GetCost();
 
	this->running_ticks = 0;
 

	
 
	SubtractMoneyFromCompanyFract(this->owner, cost);
 

	
 
	InvalidateWindow(WC_VEHICLE_DETAILS, this->index);
 
	InvalidateWindowClasses(WC_AIRCRAFT_LIST);
 
	SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
 
	SetWindowClassesDirty(WC_AIRCRAFT_LIST);
 
}
 

	
 
static void HelicopterTickHandler(Aircraft *v)
 
{
 
	Aircraft *u = v->Next()->Next();
 

	
 
@@ -813,13 +813,13 @@ static int UpdateAircraftSpeed(Aircraft 
 
	if (v->vehstatus & VS_AIRCRAFT_BROKEN) spd = min(spd, SPEED_LIMIT_BROKEN);
 

	
 
	/* updates statusbar only if speed have changed to save CPU time */
 
	if (spd != v->cur_speed) {
 
		v->cur_speed = spd;
 
		if (_settings_client.gui.vehicle_speed)
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
			SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	}
 

	
 
	/* Adjust distance moved by plane speed setting */
 
	if (_settings_game.vehicle.plane_speed > 1) spd /= _settings_game.vehicle.plane_speed;
 

	
 
	if (!(v->direction & 1)) spd = spd * 3 / 4;
 
@@ -1216,14 +1216,14 @@ static void HandleBrokenAircraft(Aircraf
 
	if (v->breakdown_ctr != 1) {
 
		v->breakdown_ctr = 1;
 
		v->vehstatus |= VS_AIRCRAFT_BROKEN;
 

	
 
		if (v->breakdowns_since_last_service != 255)
 
			v->breakdowns_since_last_service++;
 
		InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		SetWindowDirty(WC_VEHICLE_VIEW, v->index);
 
		SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 
	}
 
}
 

	
 

	
 
static void HandleAircraftSmoke(Aircraft *v)
 
{
 
@@ -1313,13 +1313,13 @@ static void CrashAirplane(Aircraft *v)
 
{
 
	v->vehstatus |= VS_CRASHED;
 
	v->crashed_counter = 0;
 

	
 
	CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
 

	
 
	InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
	SetWindowDirty(WC_VEHICLE_VIEW, v->index);
 

	
 
	uint amt = 2;
 
	if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) amt += v->cargo.Count();
 
	SetDParam(0, amt);
 

	
 
	v->cargo.Truncate(0);
 
@@ -1436,13 +1436,13 @@ void AircraftLeaveHangar(Aircraft *v)
 
		}
 
	}
 

	
 
	VehicleServiceInDepot(v);
 
	SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos);
 
	InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 
	InvalidateWindowClasses(WC_AIRCRAFT_LIST);
 
	SetWindowClassesDirty(WC_AIRCRAFT_LIST);
 
}
 

	
 
/** Checks if an aircraft should head towards a hangar because it needs replacement
 
 * @param *v the vehicle to test
 
 * @return true if the aircraft should head towards a hangar
 
 */
 
@@ -1547,13 +1547,13 @@ static void AircraftEventHandler_AtTermi
 
		if (_settings_game.order.serviceathelipad) {
 
			if (v->subtype == AIR_HELICOPTER && apc->helipads != NULL) {
 
				/* an exerpt of ServiceAircraft, without the invisibility stuff */
 
				v->date_of_last_service = _date;
 
				v->breakdowns_since_last_service = 0;
 
				v->reliability = Engine::Get(v->engine_type)->reliability;
 
				InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
				SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 
			}
 
		}
 
		return;
 
	}
 

	
 
	if (v->current_order.IsType(OT_NOTHING)) return;
src/bridge_gui.cpp
Show inline comments
 
@@ -118,14 +118,14 @@ private:
 
		this->bridges->Sort();
 

	
 
		/* Display the current sort variant */
 
		this->nested_array[BBSW_DROPDOWN_CRITERIA]->widget_data = this->sorter_names[this->bridges->SortType()];
 

	
 
		/* Set the modified widgets dirty */
 
		this->InvalidateWidget(BBSW_DROPDOWN_CRITERIA);
 
		this->InvalidateWidget(BBSW_BRIDGE_LIST);
 
		this->SetWidgetDirty(BBSW_DROPDOWN_CRITERIA);
 
		this->SetWidgetDirty(BBSW_BRIDGE_LIST);
 
	}
 

	
 
public:
 
	BuildBridgeWindow(const WindowDesc *desc, TileIndex start, TileIndex end, uint32 br_type, GUIBridgeList *bl) : Window(),
 
		start_tile(start),
 
		end_tile(end),
src/cheat_gui.cpp
Show inline comments
 
@@ -64,13 +64,13 @@ static int32 ClickChangeCompanyCheat(int
 
/**
 
 * @param p1 new value
 
 * @param p2 unused
 
 */
 
static int32 ClickSetProdCheat(int32 p1, int32 p2)
 
{
 
	InvalidateWindowClasses(WC_INDUSTRY_VIEW);
 
	SetWindowClassesDirty(WC_INDUSTRY_VIEW);
 
	return p1;
 
}
 

	
 
/**
 
 * @param p1 new climate
 
 * @param p2 unused
 
@@ -101,13 +101,13 @@ static int32 ClickChangeDateCheat(int32 
 
	ConvertDateToYMD(_date, &ymd);
 

	
 
	if ((ymd.year == MIN_YEAR && p2 == -1) || (ymd.year == MAX_YEAR && p2 == 1)) return _cur_year;
 

	
 
	SetDate(ConvertYMDToDate(_cur_year + p2, ymd.month, ymd.day));
 
	EnginesMonthlyLoop();
 
	InvalidateWindow(WC_STATUS_BAR, 0);
 
	SetWindowDirty(WC_STATUS_BAR, 0);
 
	InvalidateWindowClassesData(WC_BUILD_STATION, 0);
 
	ResetSignalVariant();
 
	return _cur_year;
 
}
 

	
 
typedef int32 CheckButtonClick(int32, int32);
src/company_cmd.cpp
Show inline comments
 
@@ -146,14 +146,14 @@ bool IsValidCompanyManagerFace(CompanyMa
 
}
 

	
 
void InvalidateCompanyWindows(const Company *company)
 
{
 
	CompanyID cid = company->index;
 

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

	
 
bool CheckCompanyHasMoney(CommandCost cost)
 
{
 
	if (cost.GetCost() > 0) {
 
		const Company *c = Company::GetIfValid(_current_company);
 
@@ -456,15 +456,15 @@ Company *DoStartupNewCompany(bool is_ai,
 
	RandomCompanyManagerFaceBits(c->face, (GenderEthnicity)Random(), false); // create a random company manager face
 

	
 
	SetDefaultCompanySettings(c->index);
 

	
 
	GeneratePresidentName(c);
 

	
 
	InvalidateWindow(WC_GRAPH_LEGEND, 0);
 
	InvalidateWindow(WC_TOOLBAR_MENU, 0);
 
	InvalidateWindow(WC_CLIENT_LIST, 0);
 
	SetWindowDirty(WC_GRAPH_LEGEND, 0);
 
	SetWindowDirty(WC_TOOLBAR_MENU, 0);
 
	SetWindowDirty(WC_CLIENT_LIST, 0);
 

	
 
	if (is_ai && (!_networking || _network_server)) AI::StartNew(c->index);
 

	
 
	c->num_engines = CallocT<uint16>(Engine::GetPoolSize());
 

	
 
	return c;
 
@@ -592,13 +592,13 @@ void CompaniesYearlyLoop()
 
	Company *c;
 

	
 
	/* Copy statistics */
 
	FOR_ALL_COMPANIES(c) {
 
		memmove(&c->yearly_expenses[1], &c->yearly_expenses[0], sizeof(c->yearly_expenses) - sizeof(c->yearly_expenses[0]));
 
		memset(&c->yearly_expenses[0], 0, sizeof(c->yearly_expenses[0]));
 
		InvalidateWindow(WC_FINANCES, c->index);
 
		SetWindowDirty(WC_FINANCES, c->index);
 
	}
 

	
 
	if (_settings_client.gui.show_finances && _local_company != COMPANY_SPECTATOR) {
 
		ShowCompanyFinances(_local_company);
 
		c = Company::Get(_local_company);
 
		if (c->num_valid_stat_ent > 5 && c->old_economy[0].performance_history < c->old_economy[4].performance_history) {
src/company_gui.cpp
Show inline comments
 
@@ -1662,13 +1662,13 @@ struct CompanyWindow : Window
 
				TileIndex tile = Company::Get((CompanyID)this->window_number)->location_of_HQ;
 
				if (tile == INVALID_TILE) {
 
					if ((byte)this->window_number != _local_company) return;
 
					SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, HT_RECT, this);
 
					SetTileSelectSize(2, 2);
 
					this->LowerWidget(CW_WIDGET_BUILD_VIEW_HQ);
 
					this->InvalidateWidget(CW_WIDGET_BUILD_VIEW_HQ);
 
					this->SetWidgetDirty(CW_WIDGET_BUILD_VIEW_HQ);
 
				} else {
 
					if (_ctrl_pressed) {
 
						ShowExtraViewPortWindow(tile);
 
					} else {
 
						ScrollMainWindowToTile(tile);
 
					}
 
@@ -1677,13 +1677,13 @@ struct CompanyWindow : Window
 
			}
 

	
 
			case CW_WIDGET_RELOCATE_HQ:
 
				SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, HT_RECT, this);
 
				SetTileSelectSize(2, 2);
 
				this->LowerWidget(CW_WIDGET_RELOCATE_HQ);
 
				this->InvalidateWidget(CW_WIDGET_RELOCATE_HQ);
 
				this->SetWidgetDirty(CW_WIDGET_RELOCATE_HQ);
 
				break;
 

	
 
			case CW_WIDGET_BUY_SHARE:
 
				DoCommandP(0, this->window_number, 0, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_ERROR_CAN_T_BUY_25_SHARE_IN_THIS));
 
				break;
 

	
src/console_cmds.cpp
Show inline comments
 
@@ -380,13 +380,13 @@ DEF_CONSOLE_CMD(ConClearBuffer)
 
	if (argc == 0) {
 
		IConsoleHelp("Clear the console buffer. Usage: 'clear'");
 
		return true;
 
	}
 

	
 
	IConsoleClearBuffer();
 
	InvalidateWindow(WC_CONSOLE, 0);
 
	SetWindowDirty(WC_CONSOLE, 0);
 
	return true;
 
}
 

	
 

	
 
/**********************************
 
 * Network Core Console Commands
src/console_gui.cpp
Show inline comments
 
@@ -138,13 +138,13 @@ static void IConsoleClearCommand()
 
{
 
	memset(_iconsole_cmdline.buf, 0, ICON_CMDLN_SIZE);
 
	_iconsole_cmdline.size = 1; // only terminating zero
 
	_iconsole_cmdline.width = 0;
 
	_iconsole_cmdline.caretpos = 0;
 
	_iconsole_cmdline.caretxoffs = 0;
 
	InvalidateWindow(WC_CONSOLE, 0);
 
	SetWindowDirty(WC_CONSOLE, 0);
 
}
 

	
 
static inline void IConsoleResetHistoryPos() {_iconsole_historypos = ICON_HISTORY_SIZE - 1;}
 

	
 

	
 
static void IConsoleHistoryAdd(const char *cmd);
 
@@ -467,8 +467,8 @@ static void IConsoleHistoryNavigate(int 
 
 * @param colour_code the colour of the command. Red in case of errors, etc.
 
 * @param string the message entered or output on the console (notice, error, etc.)
 
 */
 
void IConsoleGUIPrint(ConsoleColour colour_code, char *str)
 
{
 
	new IConsoleLine(str, (TextColour)colour_code);
 
	InvalidateWindow(WC_CONSOLE, 0);
 
	SetWindowDirty(WC_CONSOLE, 0);
 
}
src/date.cpp
Show inline comments
 
@@ -237,13 +237,13 @@ static void OnNewMonth()
 

	
 
	if (_settings_client.gui.autosave != 0 && (_cur_month % _autosave_months[_settings_client.gui.autosave]) == 0) {
 
		_do_autosave = true;
 
		RedrawAutosave();
 
	}
 

	
 
	InvalidateWindowClasses(WC_CHEATS);
 
	SetWindowClassesDirty(WC_CHEATS);
 
	CompaniesMonthlyLoop();
 
	SubsidyMonthlyLoop();
 
	EnginesMonthlyLoop();
 
	TownsMonthlyLoop();
 
	IndustryMonthlyLoop();
 
	StationMonthlyLoop();
 
@@ -261,13 +261,13 @@ static void OnNewDay()
 
	NetworkChatMessageDailyLoop();
 
#endif /* ENABLE_NETWORK */
 

	
 
	DisasterDailyLoop();
 
	IndustryDailyLoop();
 

	
 
	InvalidateWindowWidget(WC_STATUS_BAR, 0, 0);
 
	SetWindowWidgetDirty(WC_STATUS_BAR, 0, 0);
 
	EnginesDailyLoop();
 
}
 

	
 
/**
 
 * Increases the tick counter, increases date  and possibly calls
 
 * procedures that have to be called daily, monthly or yearly.
src/depot_gui.cpp
Show inline comments
 
@@ -723,13 +723,13 @@ struct DepotWindow : Window {
 
			case DEPOT_WIDGET_BUILD: // Build vehicle
 
				ResetObjectToPlace();
 
				ShowBuildVehicleWindow(this->window_number, this->type);
 
				break;
 

	
 
			case DEPOT_WIDGET_CLONE: // Clone button
 
				this->InvalidateWidget(DEPOT_WIDGET_CLONE);
 
				this->SetWidgetDirty(DEPOT_WIDGET_CLONE);
 
				this->ToggleWidgetLoweredState(DEPOT_WIDGET_CLONE);
 

	
 
				if (this->IsWidgetLowered(DEPOT_WIDGET_CLONE)) {
 
					static const CursorID clone_icons[] = {
 
						SPR_CURSOR_CLONE_TRAIN, SPR_CURSOR_CLONE_ROADVEH,
 
						SPR_CURSOR_CLONE_SHIP, SPR_CURSOR_CLONE_AIRPLANE
 
@@ -847,17 +847,17 @@ struct DepotWindow : Window {
 
	}
 

	
 
	virtual void OnPlaceObjectAbort()
 
	{
 
		/* abort clone */
 
		this->RaiseWidget(DEPOT_WIDGET_CLONE);
 
		this->InvalidateWidget(DEPOT_WIDGET_CLONE);
 
		this->SetWidgetDirty(DEPOT_WIDGET_CLONE);
 

	
 
		/* abort drag & drop */
 
		this->sel = INVALID_VEHICLE;
 
		this->InvalidateWidget(DEPOT_WIDGET_MATRIX);
 
		this->SetWidgetDirty(DEPOT_WIDGET_MATRIX);
 
	};
 

	
 
	/* check if a vehicle in a depot was clicked.. */
 
	virtual void OnMouseLoop()
 
	{
 
		const Vehicle *v = _place_clicked_vehicle;
 
@@ -932,17 +932,17 @@ struct DepotWindow : Window {
 
	}
 

	
 
	virtual void OnTimeout()
 
	{
 
		if (!this->IsWidgetDisabled(DEPOT_WIDGET_SELL)) {
 
			this->RaiseWidget(DEPOT_WIDGET_SELL);
 
			this->InvalidateWidget(DEPOT_WIDGET_SELL);
 
			this->SetWidgetDirty(DEPOT_WIDGET_SELL);
 
		}
 
		if (!this->IsWidgetDisabled(DEPOT_WIDGET_SELL_CHAIN)) {
 
			this->RaiseWidget(DEPOT_WIDGET_SELL_CHAIN);
 
			this->InvalidateWidget(DEPOT_WIDGET_SELL_CHAIN);
 
			this->SetWidgetDirty(DEPOT_WIDGET_SELL_CHAIN);
 
		}
 
	}
 

	
 
	virtual void OnResize(Point delta)
 
	{
 
		this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height);
 
@@ -952,13 +952,13 @@ struct DepotWindow : Window {
 
	}
 

	
 
	virtual EventState OnCTRLStateChange()
 
	{
 
		if (this->sel != INVALID_VEHICLE) {
 
			_cursor.vehchain = _ctrl_pressed;
 
			this->InvalidateWidget(DEPOT_WIDGET_MATRIX);
 
			this->SetWidgetDirty(DEPOT_WIDGET_MATRIX);
 
			return ES_HANDLED;
 
		}
 

	
 
		return ES_NOT_HANDLED;
 
	}
 
};
src/economy.cpp
Show inline comments
 
@@ -278,13 +278,13 @@ int UpdateCompanyRatingAndValue(Company 
 
	if (update) {
 
		c->old_economy[0].performance_history = score;
 
		UpdateCompanyHQ(c, score);
 
		c->old_economy[0].company_value = CalculateCompanyValue(c);
 
	}
 

	
 
	InvalidateWindow(WC_PERFORMANCE_DETAIL, 0);
 
	SetWindowDirty(WC_PERFORMANCE_DETAIL, 0);
 
	return score;
 
}
 

	
 
/*  use INVALID_OWNER as new_owner to delete the company. */
 
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
 
{
 
@@ -573,18 +573,18 @@ static void CompaniesGenStatistics()
 

	
 
		UpdateCompanyRatingAndValue(c, true);
 
		if (c->block_preview != 0) c->block_preview--;
 
		CompanyCheckBankrupt(c);
 
	}
 

	
 
	InvalidateWindow(WC_INCOME_GRAPH, 0);
 
	InvalidateWindow(WC_OPERATING_PROFIT, 0);
 
	InvalidateWindow(WC_DELIVERED_CARGO, 0);
 
	InvalidateWindow(WC_PERFORMANCE_HISTORY, 0);
 
	InvalidateWindow(WC_COMPANY_VALUE, 0);
 
	InvalidateWindow(WC_COMPANY_LEAGUE, 0);
 
	SetWindowDirty(WC_INCOME_GRAPH, 0);
 
	SetWindowDirty(WC_OPERATING_PROFIT, 0);
 
	SetWindowDirty(WC_DELIVERED_CARGO, 0);
 
	SetWindowDirty(WC_PERFORMANCE_HISTORY, 0);
 
	SetWindowDirty(WC_COMPANY_VALUE, 0);
 
	SetWindowDirty(WC_COMPANY_LEAGUE, 0);
 
}
 

	
 
/**
 
 * Add monthly inflation
 
 * @param check_year Shall the inflation get stopped after 170 years?
 
 */
 
@@ -667,16 +667,16 @@ void RecomputePrices()
 
	/* Setup cargo payment */
 
	CargoSpec *cs;
 
	FOR_ALL_CARGOSPECS(cs) {
 
		cs->current_payment = ((int64)cs->initial_payment * _economy.inflation_payment) >> 16;
 
	}
 

	
 
	InvalidateWindowClasses(WC_BUILD_VEHICLE);
 
	InvalidateWindowClasses(WC_REPLACE_VEHICLE);
 
	InvalidateWindowClasses(WC_VEHICLE_DETAILS);
 
	InvalidateWindow(WC_PAYMENT_RATES, 0);
 
	SetWindowClassesDirty(WC_BUILD_VEHICLE);
 
	SetWindowClassesDirty(WC_REPLACE_VEHICLE);
 
	SetWindowClassesDirty(WC_VEHICLE_DETAILS);
 
	SetWindowDirty(WC_PAYMENT_RATES, 0);
 
}
 

	
 
static void CompaniesPayInterest()
 
{
 
	const Company *c;
 

	
 
@@ -963,13 +963,13 @@ static void TriggerIndustryProduction(In
 
	i->last_cargo_accepted_at = _date;
 

	
 
	if (HasBit(callback, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(callback, CBM_IND_PRODUCTION_256_TICKS)) {
 
		if (HasBit(callback, CBM_IND_PRODUCTION_CARGO_ARRIVAL)) {
 
			IndustryProductionCallback(i, 0);
 
		} else {
 
			InvalidateWindow(WC_INDUSTRY_VIEW, i->index);
 
			SetWindowDirty(WC_INDUSTRY_VIEW, i->index);
 
		}
 
	} else {
 
		for (uint cargo_index = 0; cargo_index < lengthof(i->incoming_cargo_waiting); cargo_index++) {
 
			uint cargo_waiting = i->incoming_cargo_waiting[cargo_index];
 
			if (cargo_waiting == 0) continue;
 

	
 
@@ -1351,19 +1351,19 @@ static void LoadUnloadVehicle(Vehicle *v
 

	
 
	if (completely_emptied) {
 
		TriggerVehicle(v, VEHICLE_TRIGGER_EMPTY);
 
	}
 

	
 
	if (result != 0) {
 
		InvalidateWindow(GetWindowClassForVehicleType(v->type), v->owner);
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		SetWindowDirty(GetWindowClassForVehicleType(v->type), v->owner);
 
		SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 

	
 
		st->MarkTilesDirty(true);
 
		v->MarkDirty();
 

	
 
		if (result & 2) InvalidateWindow(WC_STATION_VIEW, last_visited);
 
		if (result & 2) SetWindowDirty(WC_STATION_VIEW, last_visited);
 
	}
 
}
 

	
 
/**
 
 * Load/unload the vehicles in this station according to the order
 
 * they entered.
 
@@ -1492,13 +1492,13 @@ CommandCost CmdBuyShareInCompany(TileInd
 
			if (++i == 4) {
 
				c->bankrupt_value = 0;
 
				DoAcquireCompany(c);
 
				break;
 
			}
 
		}
 
		InvalidateWindow(WC_COMPANY, p1);
 
		SetWindowDirty(WC_COMPANY, p1);
 
	}
 
	return cost;
 
}
 

	
 
/** Sell shares in an opposing company.
 
 * @param tile unused
 
@@ -1522,13 +1522,13 @@ CommandCost CmdSellShareInCompany(TileIn
 
	cost = -(cost - (cost >> 7));
 

	
 
	if (flags & DC_EXEC) {
 
		OwnerByte *b = c->share_owners;
 
		while (*b != _current_company) b++; // share owners is guaranteed to contain company
 
		*b = COMPANY_SPECTATOR;
 
		InvalidateWindow(WC_COMPANY, p1);
 
		SetWindowDirty(WC_COMPANY, p1);
 
	}
 
	return CommandCost(EXPENSES_OTHER, cost);
 
}
 

	
 
/** Buy up another company.
 
 * When a competing company is gone bankrupt you get the chance to purchase
src/engine.cpp
Show inline comments
 
@@ -433,14 +433,14 @@ static void CalcEngineReliability(Engine
 
		 * We will now completely retire this design */
 
		e->company_avail = 0;
 
		e->reliability = e->reliability_final;
 
		/* Kick this engine out of the lists */
 
		AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
 
	}
 
	InvalidateWindowClasses(WC_BUILD_VEHICLE); // Update to show the new reliability
 
	InvalidateWindowClasses(WC_REPLACE_VEHICLE);
 
	SetWindowClassesDirty(WC_BUILD_VEHICLE); // Update to show the new reliability
 
	SetWindowClassesDirty(WC_REPLACE_VEHICLE);
 
}
 

	
 
void SetYearEngineAgingStops()
 
{
 
	/* Determine last engine aging year, default to 2050 as previously. */
 
	_year_engine_aging_stops = 2050;
src/genworld_gui.cpp
Show inline comments
 
@@ -51,14 +51,14 @@ enum glwp_modes {
 
extern void SwitchToMode(SwitchMode new_mode);
 
extern void MakeNewgameSettingsLive();
 

	
 
static inline void SetNewLandscapeType(byte landscape)
 
{
 
	_settings_newgame.game_creation.landscape = landscape;
 
	InvalidateWindowClasses(WC_SELECT_GAME);
 
	InvalidateWindowClasses(WC_GENERATE_LANDSCAPE);
 
	SetWindowClassesDirty(WC_SELECT_GAME);
 
	SetWindowClassesDirty(WC_GENERATE_LANDSCAPE);
 
}
 

	
 
enum GenerateLandscapeWindowWidgets {
 
	GLAND_CLOSEBOX,
 
	GLAND_TITLEBAR,
 
	GLAND_BACKGROUND,
 
@@ -799,13 +799,13 @@ struct GenerateLandscapeWindow : public 
 
	virtual void OnTimeout()
 
	{
 
		static const int raise_widgets[] = {GLAND_START_DATE_DOWN, GLAND_START_DATE_UP, GLAND_SNOW_LEVEL_UP, GLAND_SNOW_LEVEL_DOWN, WIDGET_LIST_END};
 
		for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) {
 
			if (this->IsWidgetLowered(*widget)) {
 
				this->RaiseWidget(*widget);
 
				this->InvalidateWidget(*widget);
 
				this->SetWidgetDirty(*widget);
 
			}
 
		}
 
	}
 

	
 
	virtual void OnMouseLoop()
 
	{
 
@@ -877,18 +877,18 @@ struct GenerateLandscapeWindow : public 
 
	{
 
		if (!StrEmpty(str)) {
 
			int32 value = atoi(str);
 

	
 
			switch (this->widget_id) {
 
				case GLAND_START_DATE_TEXT:
 
					this->InvalidateWidget(GLAND_START_DATE_TEXT);
 
					this->SetWidgetDirty(GLAND_START_DATE_TEXT);
 
					_settings_newgame.game_creation.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
 
					break;
 

	
 
				case GLAND_SNOW_LEVEL_TEXT:
 
					this->InvalidateWidget(GLAND_SNOW_LEVEL_TEXT);
 
					this->SetWidgetDirty(GLAND_SNOW_LEVEL_TEXT);
 
					_settings_newgame.game_creation.snow_line_height = Clamp(value, 2, MAX_SNOWLINE_HEIGHT);
 
					break;
 

	
 
				case GLAND_TOWN_PULLDOWN:
 
					_settings_newgame.game_creation.custom_town_number = Clamp(value, 1, CUSTOM_TOWN_MAX_NUMBER);
 
					break;
 
@@ -933,13 +933,13 @@ static void _ShowGenerateLandscape(glwp_
 
	if (mode == GLWP_HEIGHTMAP) {
 
		w->x = x;
 
		w->y = y;
 
		strecpy(w->name, _file_to_saveload.title, lastof(w->name));
 
	}
 

	
 
	InvalidateWindow(WC_GENERATE_LANDSCAPE, mode);
 
	SetWindowDirty(WC_GENERATE_LANDSCAPE, mode);
 
}
 

	
 
void ShowGenerateLandscape()
 
{
 
	_ShowGenerateLandscape(GLWP_GENERATE);
 
}
 
@@ -1097,18 +1097,18 @@ struct CreateScenarioWindow : public Win
 
	{
 
		if (!StrEmpty(str)) {
 
			int32 value = atoi(str);
 

	
 
			switch (this->widget_id) {
 
				case CSCEN_START_DATE_TEXT:
 
					this->InvalidateWidget(CSCEN_START_DATE_TEXT);
 
					this->SetWidgetDirty(CSCEN_START_DATE_TEXT);
 
					_settings_newgame.game_creation.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
 
					break;
 

	
 
				case CSCEN_FLAT_LAND_HEIGHT_TEXT:
 
					this->InvalidateWidget(CSCEN_FLAT_LAND_HEIGHT_TEXT);
 
					this->SetWidgetDirty(CSCEN_FLAT_LAND_HEIGHT_TEXT);
 
					_settings_newgame.game_creation.se_flat_world_height = Clamp(value, 0, MAX_TILE_HEIGHT);
 
					break;
 
			}
 

	
 
			this->SetDirty();
 
		}
 
@@ -1393,13 +1393,13 @@ static void _SetGeneratingWorldProgress(
 
		last_percent = _tp.percent;
 

	
 
		/* Don't continue as dedicated never has a thread running */
 
		return;
 
	}
 

	
 
	InvalidateWindow(WC_GENERATE_PROGRESS_WINDOW, 0);
 
	SetWindowDirty(WC_GENERATE_PROGRESS_WINDOW, 0);
 
	MarkWholeScreenDirty();
 

	
 
	/* Release the rights to the map generator, and acquire the rights to the
 
	 * paint thread. The 'other' thread already has the paint thread rights so
 
	 * this ensures us that we are waiting until the paint thread is done
 
	 * before we reacquire the mapgen rights */
src/graph_gui.cpp
Show inline comments
 
@@ -84,17 +84,17 @@ struct GraphLegendWindow : Window {
 
	{
 
		if (!IsInsideMM(widget, GLW_FIRST_COMPANY, MAX_COMPANIES + GLW_FIRST_COMPANY)) return;
 

	
 
		ToggleBit(_legend_excluded_companies, widget - GLW_FIRST_COMPANY);
 
		this->ToggleWidgetLoweredState(widget);
 
		this->SetDirty();
 
		InvalidateWindow(WC_INCOME_GRAPH, 0);
 
		InvalidateWindow(WC_OPERATING_PROFIT, 0);
 
		InvalidateWindow(WC_DELIVERED_CARGO, 0);
 
		InvalidateWindow(WC_PERFORMANCE_HISTORY, 0);
 
		InvalidateWindow(WC_COMPANY_VALUE, 0);
 
		SetWindowDirty(WC_INCOME_GRAPH, 0);
 
		SetWindowDirty(WC_OPERATING_PROFIT, 0);
 
		SetWindowDirty(WC_DELIVERED_CARGO, 0);
 
		SetWindowDirty(WC_PERFORMANCE_HISTORY, 0);
 
		SetWindowDirty(WC_COMPANY_VALUE, 0);
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
 
	{
 
		if (Company::IsValidID(data)) return;
 

	
 
@@ -400,13 +400,13 @@ protected:
 

	
 
	BaseGraphWindow(const WindowDesc *desc, WindowNumber window_number, int left,
 
									int top, int height, bool has_negative_values, StringID format_str_y_axis) :
 
			Window(desc, window_number), has_negative_values(has_negative_values),
 
			format_str_y_axis(format_str_y_axis)
 
	{
 
		InvalidateWindow(WC_GRAPH_LEGEND, 0);
 
		SetWindowDirty(WC_GRAPH_LEGEND, 0);
 
		this->num_vert_lines = 24;
 

	
 
		this->graph_location.left   = left;
 
		this->graph_location.right  = left + GRAPH_X_POSITION_BEGINNING + this->num_vert_lines * GRAPH_X_POSITION_SEPARATION - 1;
 

	
 
		this->graph_location.top    = top;
src/group_cmd.cpp
Show inline comments
 
@@ -225,13 +225,13 @@ CommandCost CmdAddVehicleGroup(TileIndex
 
				if (v->IsEngineCountable()) UpdateNumEngineGroup(v->engine_type, v->group_id, new_g);
 
				v->group_id = new_g;
 
				break;
 
		}
 

	
 
		/* Update the Replace Vehicle Windows */
 
		InvalidateWindow(WC_REPLACE_VEHICLE, v->type);
 
		SetWindowDirty(WC_REPLACE_VEHICLE, v->type);
 
		InvalidateWindowData(GetWindowClassForVehicleType(v->type), (v->type << 11) | VLW_GROUP_LIST | _current_company);
 
	}
 

	
 
	return CommandCost();
 
}
 

	
 
@@ -359,13 +359,13 @@ void SetTrainGroupID(Train *v, GroupID n
 
		if (u->IsEngineCountable()) UpdateNumEngineGroup(u->engine_type, u->group_id, new_g);
 

	
 
		u->group_id = new_g;
 
	}
 

	
 
	/* Update the Replace Vehicle Windows */
 
	InvalidateWindow(WC_REPLACE_VEHICLE, VEH_TRAIN);
 
	SetWindowDirty(WC_REPLACE_VEHICLE, VEH_TRAIN);
 
}
 

	
 

	
 
/**
 
 * Recalculates the groupID of a train. Should be called each time a vehicle is added
 
 * to/removed from the chain,.
 
@@ -382,13 +382,13 @@ void UpdateTrainGroupID(Train *v)
 
		if (u->IsEngineCountable()) UpdateNumEngineGroup(u->engine_type, u->group_id, new_g);
 

	
 
		u->group_id = new_g;
 
	}
 

	
 
	/* Update the Replace Vehicle Windows */
 
	InvalidateWindow(WC_REPLACE_VEHICLE, VEH_TRAIN);
 
	SetWindowDirty(WC_REPLACE_VEHICLE, VEH_TRAIN);
 
}
 

	
 
uint GetGroupNumEngines(CompanyID company, GroupID id_g, EngineID id_e)
 
{
 
	if (Group::IsValidID(id_g)) return Group::Get(id_g)->num_engines[id_e];
 

	
src/group_gui.cpp
Show inline comments
 
@@ -673,13 +673,13 @@ public:
 
	}
 

	
 
	virtual void OnPlaceObjectAbort()
 
	{
 
		/* abort drag & drop */
 
		this->vehicle_sel = INVALID_VEHICLE;
 
		this->InvalidateWidget(GRP_WIDGET_LIST_VEHICLE);
 
		this->SetWidgetDirty(GRP_WIDGET_LIST_VEHICLE);
 
	}
 

	
 
	void ShowRenameGroupWindow(GroupID group)
 
	{
 
		assert(Group::IsValidID(group));
 
		this->group_rename = group;
src/industry_cmd.cpp
Show inline comments
 
@@ -1891,13 +1891,13 @@ static void UpdateIndustryStatistics(Ind
 
			i->last_month_transported[j] = i->this_month_transported[j];
 
			i->this_month_transported[j] = 0;
 
			refresh = true;
 
		}
 
	}
 

	
 
	if (refresh) InvalidateWindow(WC_INDUSTRY_VIEW, i->index);
 
	if (refresh) SetWindowDirty(WC_INDUSTRY_VIEW, i->index);
 
}
 

	
 
/** Simple helper that will collect data for the generation of industries */
 
struct ProbabilityHelper {
 
	uint16 prob;      ///< probability
 
	IndustryType ind; ///< industry id correcponding
src/industry_gui.cpp
Show inline comments
 
@@ -803,13 +803,13 @@ protected:
 
			this->industries.RebuildDone();
 
			this->vscroll.SetCount(this->industries.Length()); // Update scrollbar as well.
 
		}
 

	
 
		if (!this->industries.Sort()) return;
 
		IndustryDirectoryWindow::last_industry = NULL; // Reset name sorter sort cache
 
		this->InvalidateWidget(IDW_INDUSTRY_LIST); // Set the modified widget dirty
 
		this->SetWidgetDirty(IDW_INDUSTRY_LIST); // Set the modified widget dirty
 
	}
 

	
 
	/**
 
	 * Returns percents of cargo transported if industry produces this cargo, else -1
 
	 *
 
	 * @param i industry to check
src/intro_gui.cpp
Show inline comments
 
@@ -32,13 +32,13 @@
 
#include "table/strings.h"
 
#include "table/sprites.h"
 

	
 
static inline void SetNewLandscapeType(byte landscape)
 
{
 
	_settings_newgame.game_creation.landscape = landscape;
 
	InvalidateWindowClasses(WC_SELECT_GAME);
 
	SetWindowClassesDirty(WC_SELECT_GAME);
 
}
 

	
 
enum SelectGameIntroWidgets {
 
	SGI_CLOSE,
 
	SGI_CAPTION,
 
	SGI_GENERATE_GAME,
src/misc_cmd.cpp
Show inline comments
 
@@ -351,14 +351,14 @@ CommandCost CmdPause(TileIndex tile, DoC
 
				_pause_mode = _pause_mode & ~p1;
 
			} else {
 
				_pause_mode = _pause_mode | p1;
 
			}
 
		}
 

	
 
		InvalidateWindow(WC_STATUS_BAR, 0);
 
		InvalidateWindow(WC_MAIN_TOOLBAR, 0);
 
		SetWindowDirty(WC_STATUS_BAR, 0);
 
		SetWindowDirty(WC_MAIN_TOOLBAR, 0);
 
	}
 
	return CommandCost();
 
}
 

	
 
/** Change the financial flow of your company.
 
 * This is normally only enabled in offline mode, but if there is a debug
src/misc_gui.cpp
Show inline comments
 
@@ -1138,43 +1138,43 @@ HandleEditBoxResult QueryString::HandleE
 
	switch (keycode) {
 
		case WKC_ESC: return HEBR_CANCEL;
 

	
 
		case WKC_RETURN: case WKC_NUM_ENTER: return HEBR_CONFIRM;
 

	
 
		case (WKC_CTRL | 'V'):
 
			if (InsertTextBufferClipboard(&this->text)) w->InvalidateWidget(wid);
 
			if (InsertTextBufferClipboard(&this->text)) w->SetWidgetDirty(wid);
 
			break;
 

	
 
		case (WKC_CTRL | 'U'):
 
			DeleteTextBufferAll(&this->text);
 
			w->InvalidateWidget(wid);
 
			w->SetWidgetDirty(wid);
 
			break;
 

	
 
		case WKC_BACKSPACE: case WKC_DELETE:
 
			if (DeleteTextBufferChar(&this->text, keycode)) w->InvalidateWidget(wid);
 
			if (DeleteTextBufferChar(&this->text, keycode)) w->SetWidgetDirty(wid);
 
			break;
 

	
 
		case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
 
			if (MoveTextBufferPos(&this->text, keycode)) w->InvalidateWidget(wid);
 
			if (MoveTextBufferPos(&this->text, keycode)) w->SetWidgetDirty(wid);
 
			break;
 

	
 
		default:
 
			if (IsValidChar(key, this->afilter)) {
 
				if (InsertTextBufferChar(&this->text, key)) w->InvalidateWidget(wid);
 
				if (InsertTextBufferChar(&this->text, key)) w->SetWidgetDirty(wid);
 
			} else {
 
				state = Window::ES_NOT_HANDLED;
 
			}
 
	}
 

	
 
	return HEBR_EDITING;
 
}
 

	
 
void QueryString::HandleEditBox(Window *w, int wid)
 
{
 
	if (HasEditBoxFocus(w, wid) && HandleCaret(&this->text)) {
 
		w->InvalidateWidget(wid);
 
		w->SetWidgetDirty(wid);
 
		/* When we're not the OSK, notify 'our' OSK to redraw the widget,
 
		 * so the caret changes appropriately. */
 
		if (w->window_class != WC_OSK) {
 
			Window *w_osk = FindWindowById(WC_OSK, 0);
 
			if (w_osk != NULL && w_osk->parent == w) w_osk->OnInvalidateData();
 
		}
 
@@ -1929,13 +1929,13 @@ public:
 
						delete this;
 
						ShowHeightmapLoad();
 
					} else {
 
						/* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */
 
						ttd_strlcpy(this->text.buf, file->title, this->text.maxsize);
 
						UpdateTextBufferSize(&this->text);
 
						this->InvalidateWidget(SLWW_SAVE_OSK_TITLE);
 
						this->SetWidgetDirty(SLWW_SAVE_OSK_TITLE);
 
					}
 
				} else {
 
					/* Changed directory, need repaint. */
 
					this->SetDirty();
 
					BuildFileList();
 
				}
 
@@ -2075,13 +2075,13 @@ void ShowSaveLoadDialog(SaveLoadDialogMo
 

	
 
	new SaveLoadWindow(sld, mode);
 
}
 

	
 
void RedrawAutosave()
 
{
 
	InvalidateWindow(WC_STATUS_BAR, 0);
 
	SetWindowDirty(WC_STATUS_BAR, 0);
 
}
 

	
 
void SetFiosType(const byte fiostype)
 
{
 
	switch (fiostype) {
 
		case FIOS_TYPE_FILE:
src/music_gui.cpp
Show inline comments
 
@@ -145,13 +145,13 @@ static void SelectSongToPlay()
 

	
 
static void StopMusic()
 
{
 
	_music_wnd_cursong = 0;
 
	DoStopMusic();
 
	_song_is_active = false;
 
	InvalidateWindowWidget(WC_MUSIC_WINDOW, 0, 9);
 
	SetWindowWidgetDirty(WC_MUSIC_WINDOW, 0, 9);
 
}
 

	
 
static void PlayPlaylistSong()
 
{
 
	if (_cur_playlist[0] == 0) {
 
		SelectSongToPlay();
 
@@ -166,13 +166,13 @@ static void PlayPlaylistSong()
 
		}
 
	}
 
	_music_wnd_cursong = _cur_playlist[0];
 
	DoPlaySong();
 
	_song_is_active = true;
 

	
 
	InvalidateWindowWidget(WC_MUSIC_WINDOW, 0, 9);
 
	SetWindowWidgetDirty(WC_MUSIC_WINDOW, 0, 9);
 
}
 

	
 
void ResetMusic()
 
{
 
	_music_wnd_cursong = 1;
 
	DoPlaySong();
 
@@ -597,13 +597,13 @@ struct MusicWindow : public Window {
 
				_left_button_clicked = false;
 
			} break;
 

	
 
			case MW_SHUFFLE: // toggle shuffle
 
				msf.shuffle ^= 1;
 
				this->SetWidgetLoweredState(MW_SHUFFLE, msf.shuffle);
 
				this->InvalidateWidget(MW_SHUFFLE);
 
				this->SetWidgetDirty(MW_SHUFFLE);
 
				StopMusic();
 
				SelectSongToPlay();
 
				this->SetDirty();
 
				break;
 

	
 
			case MW_PROGRAMME: // show track selection
 
@@ -620,13 +620,13 @@ struct MusicWindow : public Window {
 
		}
 
	}
 

	
 
#if 0
 
	virtual void OnTick()
 
	{
 
		this->InvalidateWidget(MW_GAUGE);
 
		this->SetWidgetDirty(MW_GAUGE);
 
	}
 
#endif
 
};
 

	
 
static const NWidgetPart _nested_music_window_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
src/network/network.cpp
Show inline comments
 
@@ -438,13 +438,13 @@ static NetworkClientSocket *NetworkAlloc
 
		cs->client_id = _network_client_id++;
 
		NetworkClientInfo *ci = new NetworkClientInfo(cs->client_id);
 
		cs->SetInfo(ci);
 
		ci->client_playas = COMPANY_INACTIVE_CLIENT;
 
		ci->join_date = _date;
 

	
 
		InvalidateWindow(WC_CLIENT_LIST, 0);
 
		SetWindowDirty(WC_CLIENT_LIST, 0);
 
	}
 

	
 
	return cs;
 
}
 

	
 
/* Close a connection */
 
@@ -486,13 +486,13 @@ void NetworkCloseClient(NetworkClientSoc
 

	
 
	if (_network_server) {
 
		/* We just lost one client :( */
 
		if (cs->status >= STATUS_AUTH) _network_game_info.clients_on--;
 
		_network_clients_connected--;
 

	
 
		InvalidateWindow(WC_CLIENT_LIST, 0);
 
		SetWindowDirty(WC_CLIENT_LIST, 0);
 
	}
 

	
 
	delete cs->GetInfo();
 
	delete cs;
 
}
 

	
src/network/network_client.cpp
Show inline comments
 
@@ -121,13 +121,13 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_CO
 
	 * Function: Request company-info (in detail)
 
	 * Data:
 
	 *    <none>
 
	 */
 
	Packet *p;
 
	_network_join_status = NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO;
 
	InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
 
	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
 

	
 
	p = NetworkSend_Init(PACKET_CLIENT_COMPANY_INFO);
 
	MY_CLIENT->Send_Packet(p);
 
}
 

	
 
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN)
 
@@ -142,13 +142,13 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JO
 
	 *    uint8:  Language ID
 
	 *    String: Unique id to find the client back in server-listing
 
	 */
 

	
 
	Packet *p;
 
	_network_join_status = NETWORK_JOIN_STATUS_AUTHORIZING;
 
	InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
 
	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
 

	
 
	p = NetworkSend_Init(PACKET_CLIENT_JOIN);
 
	p->Send_string(_openttd_revision);
 
	p->Send_string(_settings_client.network.client_name); // Client name
 
	p->Send_uint8 (_network_join_as);     // PlayAs
 
	p->Send_uint8 (NETLANG_ANY);          // Language
 
@@ -396,13 +396,13 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
		for (int i = 0; i < NETWORK_STATION_TYPES; i++)
 
			company_info->num_station[i] = p->Recv_uint16();
 
		company_info->ai               = p->Recv_bool();
 

	
 
		p->Recv_string(company_info->clients, sizeof(company_info->clients));
 

	
 
		InvalidateWindow(WC_NETWORK_WINDOW, 0);
 
		SetWindowDirty(WC_NETWORK_WINDOW, 0);
 

	
 
		return NETWORK_RECV_STATUS_OKAY;
 
	}
 

	
 
	return NETWORK_RECV_STATUS_CLOSE_QUERY;
 
}
 
@@ -431,25 +431,25 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
			 * Do not display that for now */
 
		}
 

	
 
		ci->client_playas = playas;
 
		strecpy(ci->client_name, name, lastof(ci->client_name));
 

	
 
		InvalidateWindow(WC_CLIENT_LIST, 0);
 
		SetWindowDirty(WC_CLIENT_LIST, 0);
 

	
 
		return NETWORK_RECV_STATUS_OKAY;
 
	}
 

	
 
	/* We don't have this client_id yet, find an empty client_id, and put the data there */
 
	ci = new NetworkClientInfo(client_id);
 
	ci->client_playas = playas;
 
	if (client_id == _network_own_client_id) MY_CLIENT->SetInfo(ci);
 

	
 
	strecpy(ci->client_name, name, lastof(ci->client_name));
 

	
 
	InvalidateWindow(WC_CLIENT_LIST, 0);
 
	SetWindowDirty(WC_CLIENT_LIST, 0);
 

	
 
	return NETWORK_RECV_STATUS_OKAY;
 
}
 

	
 
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_ERROR)
 
{
 
@@ -557,13 +557,13 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
}
 

	
 
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_WAIT)
 
{
 
	_network_join_status = NETWORK_JOIN_STATUS_WAITING;
 
	_network_join_waiting = p->Recv_uint8();
 
	InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
 
	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
 

	
 
	/* We are put on hold for receiving the map.. we need GUI for this ;) */
 
	DEBUG(net, 1, "The server is currently busy sending the map to someone else, please wait..." );
 
	DEBUG(net, 1, "There are %d clients in front of you", _network_join_waiting);
 

	
 
	return NETWORK_RECV_STATUS_OKAY;
 
@@ -598,13 +598,13 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
		 * that. If kbytes_total is 0, the packet must be malformed as a
 
		 * savegame less than 1 kilobyte is practically impossible. */
 
		if (MY_CLIENT->HasClientQuit()) return NETWORK_RECV_STATUS_CONN_LOST;
 
		if (_network_join_bytes_total == 0) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
 

	
 
		_network_join_status = NETWORK_JOIN_STATUS_DOWNLOADING;
 
		InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
 
		SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
 

	
 
		/* The first packet does not contain any more data */
 
		return NETWORK_RECV_STATUS_OKAY;
 
	}
 

	
 
	if (maptype == MAP_PACKET_NORMAL) {
 
@@ -612,21 +612,21 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
		if (fwrite(p->buffer + p->pos, 1, p->size - p->pos, file_pointer) != (size_t)(p->size - p->pos)) {
 
			_switch_mode_errorstr = STR_NETWORK_ERROR_SAVEGAMEERROR;
 
			return NETWORK_RECV_STATUS_SAVEGAME;
 
		}
 

	
 
		_network_join_bytes = ftell(file_pointer);
 
		InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
 
		SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
 
	}
 

	
 
	/* Check if this was the last packet */
 
	if (maptype == MAP_PACKET_END) {
 
		fclose(file_pointer);
 

	
 
		_network_join_status = NETWORK_JOIN_STATUS_PROCESSING;
 
		InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
 
		SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
 

	
 
		/* The map is done downloading, load it */
 
		if (!SafeSaveOrLoad("network_client.tmp", SL_LOAD, GM_NORMAL, AUTOSAVE_DIR)) {
 
			DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
 
			_switch_mode_errorstr = STR_NETWORK_ERROR_SAVEGAMEERROR;
 
			return NETWORK_RECV_STATUS_SAVEGAME;
 
@@ -772,13 +772,13 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
	NetworkClientInfo *ci = NetworkFindClientInfoFromClientID(client_id);
 
	if (ci != NULL) {
 
		NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, ci->client_name, NULL, GetNetworkErrorMsg((NetworkErrorCode)p->Recv_uint8()));
 
		delete ci;
 
	}
 

	
 
	InvalidateWindow(WC_CLIENT_LIST, 0);
 
	SetWindowDirty(WC_CLIENT_LIST, 0);
 

	
 
	return NETWORK_RECV_STATUS_OKAY;
 
}
 

	
 
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_QUIT)
 
{
 
@@ -791,13 +791,13 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
		NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, ci->client_name, NULL, STR_NETWORK_MESSAGE_CLIENT_LEAVING);
 
		delete ci;
 
	} else {
 
		DEBUG(net, 0, "Unknown client (%d) is leaving the game", client_id);
 
	}
 

	
 
	InvalidateWindow(WC_CLIENT_LIST, 0);
 
	SetWindowDirty(WC_CLIENT_LIST, 0);
 

	
 
	/* If we come here it means we could not locate the client.. strange :s */
 
	return NETWORK_RECV_STATUS_OKAY;
 
}
 

	
 
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_JOIN)
 
@@ -805,13 +805,13 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
	ClientID client_id = (ClientID)p->Recv_uint32();
 

	
 
	NetworkClientInfo *ci = NetworkFindClientInfoFromClientID(client_id);
 
	if (ci != NULL)
 
		NetworkTextMessage(NETWORK_ACTION_JOIN, CC_DEFAULT, false, ci->client_name);
 

	
 
	InvalidateWindow(WC_CLIENT_LIST, 0);
 
	SetWindowDirty(WC_CLIENT_LIST, 0);
 

	
 
	return NETWORK_RECV_STATUS_OKAY;
 
}
 

	
 
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_SHUTDOWN)
 
{
 
@@ -878,13 +878,13 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER
 
	return NETWORK_RECV_STATUS_OKAY;
 
}
 

	
 
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMPANY_UPDATE)
 
{
 
	_network_company_passworded = p->Recv_uint16();
 
	InvalidateWindowClasses(WC_COMPANY);
 
	SetWindowClassesDirty(WC_COMPANY);
 

	
 
	return NETWORK_RECV_STATUS_OKAY;
 
}
 

	
 

	
 
/* The layout for the receive-functions by the client */
src/network/network_content_gui.cpp
Show inline comments
 
@@ -92,23 +92,23 @@ public:
 
		/* Tell all the backends about what we've downloaded */
 
		for (ContentType *iter = this->receivedTypes.Begin(); iter != this->receivedTypes.End(); iter++) {
 
			switch (*iter) {
 
				case CONTENT_TYPE_AI:
 
				case CONTENT_TYPE_AI_LIBRARY:
 
					AI::Rescan();
 
					InvalidateWindowClasses(WC_AI_DEBUG);
 
					SetWindowClassesDirty(WC_AI_DEBUG);
 
					break;
 

	
 
				case CONTENT_TYPE_BASE_GRAPHICS:
 
					BaseGraphics::FindSets();
 
					InvalidateWindow(WC_GAME_OPTIONS, 0);
 
					SetWindowDirty(WC_GAME_OPTIONS, 0);
 
					break;
 

	
 
				case CONTENT_TYPE_BASE_SOUNDS:
 
					BaseSounds::FindSets();
 
					InvalidateWindow(WC_GAME_OPTIONS, 0);
 
					SetWindowDirty(WC_GAME_OPTIONS, 0);
 
					break;
 

	
 
				case CONTENT_TYPE_NEWGRF:
 
					ScanNewGRFFiles();
 
					/* Yes... these are the NewGRF windows */
 
					InvalidateWindowClassesData(WC_SAVELOAD);
src/network/network_gui.cpp
Show inline comments
 
@@ -1200,13 +1200,13 @@ struct NetworkStartServerWindow : public
 
		if (str == NULL) return;
 

	
 
		if (this->widget_id == NSSW_SETPWD) {
 
			strecpy(_settings_client.network.server_password, str, lastof(_settings_client.network.server_password));
 
		} else {
 
			int32 value = atoi(str);
 
			this->InvalidateWidget(this->widget_id);
 
			this->SetWidgetDirty(this->widget_id);
 
			switch (this->widget_id) {
 
				default: NOT_REACHED();
 
				case NSSW_CLIENTS_TXT:    _settings_client.network.max_clients    = Clamp(value, 2, MAX_CLIENTS); break;
 
				case NSSW_COMPANIES_TXT:  _settings_client.network.max_companies  = Clamp(value, 1, MAX_COMPANIES); break;
 
				case NSSW_SPECTATORS_TXT: _settings_client.network.max_spectators = Clamp(value, 0, MAX_CLIENTS); break;
 
			}
src/network/network_server.cpp
Show inline comments
 
@@ -1730,13 +1730,13 @@ void NetworkServerSendConfigUpdate()
 

	
 
void NetworkServerUpdateCompanyPassworded(CompanyID company_id, bool passworded)
 
{
 
	if (NetworkCompanyIsPassworded(company_id) == passworded) return;
 

	
 
	SB(_network_company_passworded, company_id, 1, !!passworded);
 
	InvalidateWindowClasses(WC_COMPANY);
 
	SetWindowClassesDirty(WC_COMPANY);
 

	
 
	NetworkClientSocket *cs;
 
	FOR_ALL_CLIENT_SOCKETS(cs) {
 
		SEND_COMMAND(PACKET_SERVER_COMPANY_UPDATE)(cs);
 
	}
 
}
src/newgrf_industries.cpp
Show inline comments
 
@@ -554,8 +554,8 @@ void IndustryProductionCallback(Industry
 
		int32 again = DerefIndProd(group->again, deref);
 
		if (again == 0) break;
 

	
 
		SB(object.callback_param2, 24, 8, again);
 
	}
 

	
 
	InvalidateWindow(WC_INDUSTRY_VIEW, ind->index);
 
	SetWindowDirty(WC_INDUSTRY_VIEW, ind->index);
 
}
src/news_gui.cpp
Show inline comments
 
@@ -687,13 +687,13 @@ void AddNewsItem(StringID string, NewsSu
 
		ni->prev = _latest_news;
 
	}
 

	
 
	ni->next = NULL;
 
	_latest_news = ni;
 

	
 
	InvalidateWindow(WC_MESSAGE_HISTORY, 0);
 
	SetWindowDirty(WC_MESSAGE_HISTORY, 0);
 
}
 

	
 
/** Delete a news item from the queue */
 
static void DeleteNewsItem(NewsItem *ni)
 
{
 
	if (_forced_news == ni || _current_news == ni) {
 
@@ -721,13 +721,13 @@ static void DeleteNewsItem(NewsItem *ni)
 
	free(ni->free_data);
 

	
 
	if (_current_news == ni) _current_news = ni->prev;
 
	_total_news--;
 
	delete ni;
 

	
 
	InvalidateWindow(WC_MESSAGE_HISTORY, 0);
 
	SetWindowDirty(WC_MESSAGE_HISTORY, 0);
 
}
 

	
 
void DeleteVehicleNews(VehicleID vid, StringID news)
 
{
 
	NewsItem *ni = _oldest_news;
 

	
 
@@ -1157,13 +1157,13 @@ struct MessageOptionsWindow : Window {
 
				ShowDropDownMenu(this, this->message_opt, this->state, WIDGET_NEWSOPT_DROP_SUMMARY, 0, 0);
 
				break;
 

	
 
			case WIDGET_NEWSOPT_SOUNDTICKER: // Change ticker sound on/off
 
				_news_ticker_sound ^= 1;
 
				this->OnInvalidateData(0);
 
				this->InvalidateWidget(widget);
 
				this->SetWidgetDirty(widget);
 
				break;
 

	
 
			default: { // Clicked on the [<] .. [>] widgets
 
				if (widget >= WIDGET_NEWSOPT_START_OPTION && widget < WIDGET_NEWSOPT_END_OPTION) {
 
					int wid = widget - WIDGET_NEWSOPT_START_OPTION;
 
					int element = wid / MOS_WIDG_PER_SETTING;
src/openttd.cpp
Show inline comments
 
@@ -599,13 +599,13 @@ int ttd_main(int argc, char *argv[])
 
	/* initialize all variables that are allocated dynamically */
 
	InitializeDynamicVariables();
 

	
 
	/* Initialize FreeType */
 
	InitFreeType();
 

	
 
	/* This must be done early, since functions use the InvalidateWindow* calls */
 
	/* This must be done early, since functions use the SetWindowDirty* calls */
 
	InitWindowSystem();
 

	
 
	/* Look for the sounds before the graphics. Otherwise none would be set and
 
	 * the first initialisation of the video happens on the wrong data. Now it
 
	 * can do the first initialisation right. */
 
	if (sounds_set == NULL && BaseSounds::ini_set != NULL) sounds_set = strdup(BaseSounds::ini_set);
src/order_cmd.cpp
Show inline comments
 
@@ -176,23 +176,23 @@ Order::Order(uint32 packed)
 
 *
 
 * Updates the widgets of a vehicle which contains the order-data
 
 *
 
 */
 
void InvalidateVehicleOrder(const Vehicle *v, int data)
 
{
 
	InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
	SetWindowDirty(WC_VEHICLE_VIEW, v->index);
 

	
 
	if (data != 0) {
 
		/* Calls SetDirty() too */
 
		InvalidateWindowData(WC_VEHICLE_ORDERS,    v->index, data);
 
		InvalidateWindowData(WC_VEHICLE_TIMETABLE, v->index, data);
 
		return;
 
	}
 

	
 
	InvalidateWindow(WC_VEHICLE_ORDERS,    v->index);
 
	InvalidateWindow(WC_VEHICLE_TIMETABLE, v->index);
 
	SetWindowDirty(WC_VEHICLE_ORDERS,    v->index);
 
	SetWindowDirty(WC_VEHICLE_TIMETABLE, v->index);
 
}
 

	
 
/**
 
 *
 
 * Assign data to an order (from an other order)
 
 *   This function makes sure that the index is maintained correctly
 
@@ -792,14 +792,14 @@ CommandCost CmdSkipToOrder(TileIndex til
 
		if (v->current_order.IsType(OT_LOADING)) v->LeaveStation();
 

	
 
		InvalidateVehicleOrder(v, -2);
 
	}
 

	
 
	/* We have an aircraft/ship, they have a mini-schedule, so update them all */
 
	if (v->type == VEH_AIRCRAFT) InvalidateWindowClasses(WC_AIRCRAFT_LIST);
 
	if (v->type == VEH_SHIP) InvalidateWindowClasses(WC_SHIPS_LIST);
 
	if (v->type == VEH_AIRCRAFT) SetWindowClassesDirty(WC_AIRCRAFT_LIST);
 
	if (v->type == VEH_SHIP) SetWindowClassesDirty(WC_SHIPS_LIST);
 

	
 
	return CommandCost();
 
}
 

	
 
/**
 
 * Move an order inside the orderlist
 
@@ -1512,13 +1512,13 @@ void RemoveOrderFromAllVehicles(OrderTyp
 
		Order *order;
 

	
 
		order = &v->current_order;
 
		if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) ? OT_GOTO_STATION : order->GetType()) == type &&
 
				v->current_order.GetDestination() == destination) {
 
			order->MakeDummy();
 
			InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
			SetWindowDirty(WC_VEHICLE_VIEW, v->index);
 
		}
 

	
 
		/* Clear the order from the order-list */
 
		int id = -1;
 
		FOR_VEHICLE_ORDERS(v, order) {
 
			id++;
 
@@ -1803,13 +1803,13 @@ bool ProcessOrders(Vehicle *v)
 
		case VEH_ROAD:
 
		case VEH_TRAIN:
 
			break;
 

	
 
		case VEH_AIRCRAFT:
 
		case VEH_SHIP:
 
			InvalidateWindowClasses(GetWindowClassForVehicleType(v->type));
 
			SetWindowClassesDirty(GetWindowClassForVehicleType(v->type));
 
			break;
 
	}
 

	
 
	return UpdateOrderDest(v, order) && may_reverse;
 
}
 

	
src/order_gui.cpp
Show inline comments
 
@@ -453,13 +453,13 @@ private:
 
	/**
 
	 * Handle the click on the goto button.
 
	 * @param i Dummy parameter.
 
	 */
 
	void OrderClick_Goto(int i)
 
	{
 
		this->InvalidateWidget(ORDER_WIDGET_GOTO);
 
		this->SetWidgetDirty(ORDER_WIDGET_GOTO);
 
		this->ToggleWidgetLoweredState(ORDER_WIDGET_GOTO);
 
		if (this->IsWidgetLowered(ORDER_WIDGET_GOTO)) {
 
			_place_clicked_vehicle = NULL;
 
			SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, HT_RECT, this);
 
			this->goto_type = OPOS_GOTO;
 
		} else {
 
@@ -518,13 +518,13 @@ private:
 
	/**
 
	 * Handle the click on the conditional order button.
 
	 * @param i Dummy parameter.
 
	 */
 
	void OrderClick_Conditional(int i)
 
	{
 
		this->InvalidateWidget(ORDER_WIDGET_GOTO);
 
		this->SetWidgetDirty(ORDER_WIDGET_GOTO);
 
		this->LowerWidget(ORDER_WIDGET_GOTO);
 
		SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, HT_RECT, this);
 
		this->goto_type = OPOS_CONDITIONAL;
 
	}
 

	
 
	/**
 
@@ -557,13 +557,13 @@ private:
 

	
 
		/* Keypress if negative, so 'toggle' to the next */
 
		if (non_stop < 0) {
 
			non_stop = order->GetNonStopType() ^ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS;
 
		}
 

	
 
		this->InvalidateWidget(ORDER_WIDGET_NON_STOP);
 
		this->SetWidgetDirty(ORDER_WIDGET_NON_STOP);
 
		DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 16), MOF_NON_STOP | non_stop << 4,  CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
 
	}
 

	
 
	/**
 
	 * Handle the click on the skip button.
 
	 * If ctrl is pressed, skip to selected order, else skip to current order + 1
 
@@ -1135,13 +1135,13 @@ public:
 

	
 
					DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 16), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER));
 
				}
 
			}
 
		}
 
		this->RaiseWidget(ORDER_WIDGET_GOTO);
 
		this->InvalidateWidget(ORDER_WIDGET_GOTO);
 
		this->SetWidgetDirty(ORDER_WIDGET_GOTO);
 
	}
 

	
 
	virtual void OnMouseLoop()
 
	{
 
		const Vehicle *v = _place_clicked_vehicle;
 
		/*
 
@@ -1230,13 +1230,13 @@ public:
 
	virtual void OnTimeout()
 
	{
 
		/* unclick all buttons except for the 'goto' button (ORDER_WIDGET_GOTO), which is 'persistent' */
 
		for (uint i = 0; i < this->widget_count; i++) {
 
			if (this->IsWidgetLowered(i) && i != ORDER_WIDGET_GOTO) {
 
				this->RaiseWidget(i);
 
				this->InvalidateWidget(i);
 
				this->SetWidgetDirty(i);
 
			}
 
		}
 
	}
 
};
 

	
 
/**
src/osk_gui.cpp
Show inline comments
 
@@ -242,26 +242,26 @@ struct OskWindow : public Window {
 

	
 
	void InvalidateParent()
 
	{
 
		QueryStringBaseWindow *w = dynamic_cast<QueryStringBaseWindow*>(this->parent);
 
		if (w != NULL) w->OnOSKInput(this->text_btn);
 

	
 
		this->InvalidateWidget(OSK_WIDGET_TEXT);
 
		if (this->parent != NULL) this->parent->InvalidateWidget(this->text_btn);
 
		this->SetWidgetDirty(OSK_WIDGET_TEXT);
 
		if (this->parent != NULL) this->parent->SetWidgetDirty(this->text_btn);
 
	}
 

	
 
	virtual void OnMouseLoop()
 
	{
 
		this->qs->HandleEditBox(this, OSK_WIDGET_TEXT);
 
		/* make the caret of the parent window also blink */
 
		this->parent->InvalidateWidget(this->text_btn);
 
		this->parent->SetWidgetDirty(this->text_btn);
 
	}
 

	
 
	virtual void OnInvalidateData(int)
 
	{
 
		this->InvalidateWidget(OSK_WIDGET_TEXT);
 
		this->SetWidgetDirty(OSK_WIDGET_TEXT);
 
	}
 
};
 

	
 
static const Widget _osk_widgets[] = {
 
{    WWT_CAPTION, RESIZE_NONE,  COLOUR_GREY,     0,   255,     0,    13, STR_WHITE_STRING,  STR_NULL}, // OSK_WIDGET_CAPTION
 
{      WWT_PANEL, RESIZE_NONE,  COLOUR_GREY,     0,   255,    14,    29, 0x0,               STR_NULL}, // OSK_WIDGET_TEXT_BACKGROUND
src/rail_gui.cpp
Show inline comments
 
@@ -311,13 +311,13 @@ enum RailToolbarWidgets {
 
 * @param w window the button belongs to
 
 */
 
static void ToggleRailButton_Remove(Window *w)
 
{
 
	DeleteWindowById(WC_SELECT_STATION, 0);
 
	w->ToggleWidgetLoweredState(RTW_REMOVE);
 
	w->InvalidateWidget(RTW_REMOVE);
 
	w->SetWidgetDirty(RTW_REMOVE);
 
	_remove_button_clicked = w->IsWidgetLowered(RTW_REMOVE);
 
	SetSelectionRed(_remove_button_clicked);
 
}
 

	
 
/** Updates the Remove button because of Ctrl state change
 
 * @param w window the button belongs to
 
@@ -792,13 +792,13 @@ struct BuildRailToolbarWindow : Window {
 
	}
 

	
 
	virtual void OnPlaceObjectAbort()
 
	{
 
		this->RaiseButtons();
 
		this->DisableWidget(RTW_REMOVE);
 
		this->InvalidateWidget(RTW_REMOVE);
 
		this->SetWidgetDirty(RTW_REMOVE);
 

	
 
		DeleteWindowById(WC_BUILD_SIGNAL, TRANSPORT_RAIL);
 
		DeleteWindowById(WC_BUILD_STATION, TRANSPORT_RAIL);
 
		DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_RAIL);
 
		DeleteWindowById(WC_SELECT_STATION, 0);
 
		DeleteWindowByClass(WC_BUILD_BRIDGE);
 
@@ -1598,20 +1598,20 @@ public:
 
				_convert_signal_button = !_convert_signal_button;
 
				break;
 

	
 
			case BSW_DRAG_SIGNALS_DENSITY_DECREASE:
 
				if (_settings_client.gui.drag_signals_density > 1) {
 
					_settings_client.gui.drag_signals_density--;
 
					InvalidateWindow(WC_GAME_OPTIONS, 0);
 
					SetWindowDirty(WC_GAME_OPTIONS, 0);
 
				}
 
				break;
 

	
 
			case BSW_DRAG_SIGNALS_DENSITY_INCREASE:
 
				if (_settings_client.gui.drag_signals_density < 20) {
 
					_settings_client.gui.drag_signals_density++;
 
					InvalidateWindow(WC_GAME_OPTIONS, 0);
 
					SetWindowDirty(WC_GAME_OPTIONS, 0);
 
				}
 
				break;
 

	
 
			default: break;
 
		}
 

	
src/road_gui.cpp
Show inline comments
 
@@ -264,13 +264,13 @@ typedef void OnButtonClick(Window *w);
 
/** Toogles state of the Remove button of Build road toolbar
 
 * @param w window the button belongs to
 
 */
 
static void ToggleRoadButton_Remove(Window *w)
 
{
 
	w->ToggleWidgetLoweredState(RTW_REMOVE);
 
	w->InvalidateWidget(RTW_REMOVE);
 
	w->SetWidgetDirty(RTW_REMOVE);
 
	_remove_button_clicked = w->IsWidgetLowered(RTW_REMOVE);
 
	SetSelectionRed(_remove_button_clicked);
 
}
 

	
 
/** Updates the Remove button because of Ctrl state change
 
 * @param w window the button belongs to
 
@@ -444,18 +444,18 @@ struct BuildRoadToolbarWindow : Window {
 
		/* The remove and the one way button state is driven
 
		 * by the other buttons so they don't act on themselfs.
 
		 * Both are only valid if they are able to apply as options. */
 
		switch (clicked_widget) {
 
			case RTW_REMOVE:
 
				this->RaiseWidget(RTW_ONE_WAY);
 
				this->InvalidateWidget(RTW_ONE_WAY);
 
				this->SetWidgetDirty(RTW_ONE_WAY);
 
				break;
 

	
 
			case RTW_ONE_WAY:
 
				this->RaiseWidget(RTW_REMOVE);
 
				this->InvalidateWidget(RTW_REMOVE);
 
				this->SetWidgetDirty(RTW_REMOVE);
 
				break;
 

	
 
			case RTW_BUS_STATION:
 
			case RTW_TRUCK_STATION:
 
				this->DisableWidget(RTW_ONE_WAY);
 
				this->SetWidgetDisabledState(RTW_REMOVE, !this->IsWidgetLowered(clicked_widget));
 
@@ -530,14 +530,14 @@ struct BuildRoadToolbarWindow : Window {
 
	{
 
		this->RaiseButtons();
 
		this->SetWidgetsDisabledState(true,
 
			RTW_REMOVE,
 
			RTW_ONE_WAY,
 
			WIDGET_LIST_END);
 
		this->InvalidateWidget(RTW_REMOVE);
 
		this->InvalidateWidget(RTW_ONE_WAY);
 
		this->SetWidgetDirty(RTW_REMOVE);
 
		this->SetWidgetDirty(RTW_ONE_WAY);
 

	
 
		DeleteWindowById(WC_BUS_STATION, TRANSPORT_ROAD);
 
		DeleteWindowById(WC_TRUCK_STATION, TRANSPORT_ROAD);
 
		DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_ROAD);
 
		DeleteWindowById(WC_SELECT_STATION, 0);
 
		DeleteWindowByClass(WC_BUILD_BRIDGE);
src/roadveh_cmd.cpp
Show inline comments
 
@@ -292,13 +292,13 @@ CommandCost CmdBuildRoadVeh(TileIndex ti
 
		}
 

	
 
		VehicleMove(v, false);
 

	
 
		InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 
		InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
 
		InvalidateWindow(WC_COMPANY, v->owner);
 
		SetWindowDirty(WC_COMPANY, v->owner);
 
		if (IsLocalCompany()) {
 
			InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Road window
 
		}
 

	
 
		Company::Get(_current_company)->num_engines[p1]++;
 

	
 
@@ -617,13 +617,13 @@ static void RoadVehCrash(RoadVehicle *v)
 

	
 
		MarkSingleVehicleDirty(u);
 
	}
 

	
 
	ClearSlot(v);
 

	
 
	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 

	
 
	AI::NewEvent(v->owner, new AIEventVehicleCrashed(v->index, v->tile, AIEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING));
 

	
 
	SetDParam(0, pass);
 
	AddVehicleNewsItem(
 
		(pass == 1) ?
 
@@ -660,14 +660,14 @@ static void HandleBrokenRoadVeh(RoadVehi
 
		v->breakdown_ctr = 1;
 
		v->cur_speed = 0;
 

	
 
		if (v->breakdowns_since_last_service != 255)
 
			v->breakdowns_since_last_service++;
 

	
 
		InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		SetWindowDirty(WC_VEHICLE_VIEW, v->index);
 
		SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 

	
 
		if (!PlayVehicleSound(v, VSE_BREAKDOWN)) {
 
			SndPlayVehicleFx((_settings_game.game_creation.landscape != LT_TOYLAND) ?
 
				SND_0F_VEHICLE_BREAKDOWN : SND_35_COMEDY_BREAKDOWN, v);
 
		}
 

	
 
@@ -677,13 +677,13 @@ static void HandleBrokenRoadVeh(RoadVehi
 
		}
 
	}
 

	
 
	if ((v->tick_counter & 1) == 0) {
 
		if (--v->breakdown_delay == 0) {
 
			v->breakdown_ctr = 0;
 
			InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
			SetWindowDirty(WC_VEHICLE_VIEW, v->index);
 
		}
 
	}
 
}
 

	
 
TileIndex RoadVehicle::GetOrderStationLocation(StationID station)
 
{
 
@@ -833,13 +833,13 @@ static int RoadVehAccelerate(RoadVehicle
 
		v->cur_speed = min(v->cur_speed, GetBridgeSpec(GetBridgeType(v->tile))->speed * 2);
 
	}
 

	
 
	/* Update statusbar only if speed has changed to save CPU time */
 
	if (oldspeed != v->cur_speed) {
 
		if (_settings_client.gui.vehicle_speed) {
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
			SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		}
 
	}
 

	
 
	/* Speed is scaled in the same manner as for trains. @see train_cmd.cpp */
 
	int scaled_spd = spd * 3 >> 2;
 

	
 
@@ -1727,13 +1727,13 @@ again:
 

	
 
			DEBUG(ms, 2, " force a slot clearing");
 
			ClearSlot(v);
 
		}
 

	
 
		StartRoadVehSound(v);
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	}
 

	
 
	/* Check tile position conditions - i.e. stop position in depot,
 
	 * entry onto bridge or into tunnel */
 
	uint32 r = VehicleEnterTile(v, v->tile, x, y);
 
	if (HasBit(r, VETS_CANNOT_ENTER)) {
 
@@ -1842,13 +1842,13 @@ static void CheckIfRoadVehNeedsService(R
 
	if (rfdd.best_length == UINT_MAX || rfdd.best_length > MAX_ACCEPTABLE_DEPOT_DIST) {
 
		if (v->current_order.IsType(OT_GOTO_DEPOT)) {
 
			/* If we were already heading for a depot but it has
 
			 * suddenly moved farther away, we continue our normal
 
			 * schedule? */
 
			v->current_order.MakeDummy();
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
			SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		}
 
		return;
 
	}
 

	
 
	DepotID depot = GetDepotIndex(rfdd.tile);
 

	
 
@@ -1860,13 +1860,13 @@ static void CheckIfRoadVehNeedsService(R
 

	
 
	if (v->current_order.IsType(OT_LOADING)) v->LeaveStation();
 
	ClearSlot(v);
 

	
 
	v->current_order.MakeGoToDepot(depot, ODTFB_SERVICE);
 
	v->dest_tile = rfdd.tile;
 
	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
}
 

	
 
void RoadVehicle::OnNewDay()
 
{
 
	if (!this->IsRoadVehFront()) return;
 

	
 
@@ -1954,14 +1954,14 @@ void RoadVehicle::OnNewDay()
 

	
 
	this->profit_this_year -= cost.GetCost();
 
	this->running_ticks = 0;
 

	
 
	SubtractMoneyFromCompanyFract(this->owner, cost);
 

	
 
	InvalidateWindow(WC_VEHICLE_DETAILS, this->index);
 
	InvalidateWindowClasses(WC_ROADVEH_LIST);
 
	SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
 
	SetWindowClassesDirty(WC_ROADVEH_LIST);
 
}
 

	
 
Trackdir RoadVehicle::GetVehicleTrackdir() const
 
{
 
	if (this->vehstatus & VS_CRASHED) return INVALID_TRACKDIR;
 

	
 
@@ -2066,14 +2066,14 @@ CommandCost CmdRefitRoadVeh(TileIndex ti
 

	
 
		if (flags & DC_EXEC) {
 
			v->cargo_cap = capacity;
 
			v->cargo.Truncate((v->cargo_type == new_cid) ? capacity : 0);
 
			v->cargo_type = new_cid;
 
			v->cargo_subtype = new_subtype;
 
			InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
			InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
			SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 
			SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
 
			InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
 
		}
 
	}
 

	
 
	if (flags & DC_EXEC) RoadVehUpdateCache(RoadVehicle::Get(p1)->First());
 

	
src/settings.cpp
Show inline comments
 
@@ -661,19 +661,19 @@ static bool RedrawScreen(int32 p1)
 
	MarkWholeScreenDirty();
 
	return true;
 
}
 

	
 
static bool InvalidateDetailsWindow(int32 p1)
 
{
 
	InvalidateWindowClasses(WC_VEHICLE_DETAILS);
 
	SetWindowClassesDirty(WC_VEHICLE_DETAILS);
 
	return true;
 
}
 

	
 
static bool InvalidateStationBuildWindow(int32 p1)
 
{
 
	InvalidateWindow(WC_BUILD_STATION, 0);
 
	SetWindowDirty(WC_BUILD_STATION, 0);
 
	return true;
 
}
 

	
 
static bool InvalidateBuildIndustryWindow(int32 p1)
 
{
 
	InvalidateWindowData(WC_BUILD_INDUSTRY, 0);
 
@@ -749,13 +749,13 @@ static bool TrainAccelerationModelChange
 

	
 
	return true;
 
}
 

	
 
static bool DragSignalsDensityChanged(int32)
 
{
 
	InvalidateWindow(WC_BUILD_SIGNAL, 0);
 
	SetWindowDirty(WC_BUILD_SIGNAL, 0);
 

	
 
	return true;
 
}
 

	
 
/*
 
 * A: competitors
 
@@ -817,13 +817,13 @@ static bool DifficultyChange(int32)
 
{
 
	if (_game_mode == GM_MENU) {
 
		if (_settings_newgame.difficulty.diff_level != 3) {
 
			ShowErrorMessage(INVALID_STRING_ID, STR_WARNING_DIFFICULTY_TO_CUSTOM, 0, 0);
 
			_settings_newgame.difficulty.diff_level = 3;
 
		}
 
		InvalidateWindowClasses(WC_SELECT_GAME);
 
		SetWindowClassesDirty(WC_SELECT_GAME);
 
	} else {
 
		_settings_game.difficulty.diff_level = 3;
 
	}
 

	
 
	/* If we are a network-client, update the difficult setting (if it is open).
 
	 * Use this instead of just dirtying the window because we need to load in
 
@@ -1443,13 +1443,13 @@ CommandCost CmdChangeSetting(TileIndex t
 
		if (sd->desc.flags & SGF_NO_NETWORK) {
 
			GamelogStartAction(GLAT_SETTING);
 
			GamelogSetting(sd->desc.name, oldval, newval);
 
			GamelogStopAction();
 
		}
 

	
 
		InvalidateWindow(WC_GAME_OPTIONS, 0);
 
		SetWindowDirty(WC_GAME_OPTIONS, 0);
 
	}
 

	
 
	return CommandCost();
 
}
 

	
 
/** Change one of the per-company settings.
 
@@ -1477,13 +1477,13 @@ CommandCost CmdChangeCompanySetting(Tile
 

	
 
		if (sd->desc.proc != NULL && !sd->desc.proc(newval)) {
 
			WriteValue(var, sd->save.conv, (int64)oldval);
 
			return CommandCost();
 
		}
 

	
 
		InvalidateWindow(WC_GAME_OPTIONS, 0);
 
		SetWindowDirty(WC_GAME_OPTIONS, 0);
 
	}
 

	
 
	return CommandCost();
 
}
 

	
 
/** Top function to save the new value of an element of the Settings struct
 
@@ -1506,13 +1506,13 @@ bool SetSettingValue(uint index, int32 v
 

	
 
		if (_game_mode != GM_MENU) {
 
			void *var2 = GetVariableAddress(&_settings_newgame, &sd->save);
 
			Write_ValidateSetting(var2, sd, value);
 
		}
 
		if (sd->desc.proc != NULL) sd->desc.proc((int32)ReadValue(var, sd->save.conv));
 
		InvalidateWindow(WC_GAME_OPTIONS, 0);
 
		SetWindowDirty(WC_GAME_OPTIONS, 0);
 
		return true;
 
	}
 

	
 
	/* send non-company-based settings over the network */
 
	if (!_networking || (_networking && _network_server)) {
 
		return DoCommandP(0, index, value, CMD_CHANGE_SETTING);
src/settings_gui.cpp
Show inline comments
 
@@ -381,13 +381,13 @@ struct GameOptionsWindow : Window {
 
				}
 
				break;
 

	
 
			case GOW_TOWNNAME_DROPDOWN: // Town names
 
				if (_game_mode == GM_MENU || Town::GetNumItems() == 0) {
 
					this->opt->game_creation.town_name = index;
 
					InvalidateWindow(WC_GAME_OPTIONS, 0);
 
					SetWindowDirty(WC_GAME_OPTIONS, 0);
 
				}
 
				break;
 

	
 
			case GOW_AUTOSAVE_DROPDOWN: // Autosave options
 
				_settings_client.gui.autosave = index;
 
				this->SetDirty();
src/ship_cmd.cpp
Show inline comments
 
@@ -143,20 +143,20 @@ static void CheckIfShipNeedsService(Vehi
 

	
 
	const Depot *depot = FindClosestShipDepot(v);
 

	
 
	if (depot == NULL || DistanceManhattan(v->tile, depot->xy) > 12) {
 
		if (v->current_order.IsType(OT_GOTO_DEPOT)) {
 
			v->current_order.MakeDummy();
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
			SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		}
 
		return;
 
	}
 

	
 
	v->current_order.MakeGoToDepot(depot->index, ODTFB_SERVICE);
 
	v->dest_tile = depot->xy;
 
	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
}
 

	
 
Money Ship::GetRunningCost() const
 
{
 
	return GetVehicleProperty(this, 0x0F, ShipVehInfo(this->engine_type)->running_cost) * _price.ship_running;
 
}
 
@@ -178,15 +178,15 @@ void Ship::OnNewDay()
 

	
 
	this->profit_this_year -= cost.GetCost();
 
	this->running_ticks = 0;
 

	
 
	SubtractMoneyFromCompanyFract(this->owner, cost);
 

	
 
	InvalidateWindow(WC_VEHICLE_DETAILS, this->index);
 
	SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
 
	/* we need this for the profit */
 
	InvalidateWindowClasses(WC_SHIPS_LIST);
 
	SetWindowClassesDirty(WC_SHIPS_LIST);
 
}
 

	
 
Trackdir Ship::GetVehicleTrackdir() const
 
{
 
	if (this->vehstatus & VS_CRASHED) return INVALID_TRACKDIR;
 

	
 
@@ -209,14 +209,14 @@ static void HandleBrokenShip(Vehicle *v)
 
		v->breakdown_ctr = 1;
 
		v->cur_speed = 0;
 

	
 
		if (v->breakdowns_since_last_service != 255)
 
			v->breakdowns_since_last_service++;
 

	
 
		InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		SetWindowDirty(WC_VEHICLE_VIEW, v->index);
 
		SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 

	
 
		if (!PlayVehicleSound(v, VSE_BREAKDOWN)) {
 
			SndPlayVehicleFx((_settings_game.game_creation.landscape != LT_TOYLAND) ?
 
				SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v);
 
		}
 

	
 
@@ -226,13 +226,13 @@ static void HandleBrokenShip(Vehicle *v)
 
		}
 
	}
 

	
 
	if (!(v->tick_counter & 1)) {
 
		if (!--v->breakdown_delay) {
 
			v->breakdown_ctr = 0;
 
			InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
			SetWindowDirty(WC_VEHICLE_VIEW, v->index);
 
		}
 
	}
 
}
 

	
 
void Ship::MarkDirty()
 
{
 
@@ -287,13 +287,13 @@ void Ship::UpdateDeltaXY(Direction direc
 
	this->z_extent      = 6;
 
}
 

	
 
void RecalcShipStuff(Vehicle *v)
 
{
 
	v->UpdateViewport(false, true);
 
	InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
	SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
 
}
 

	
 
static const TileIndexDiffC _ship_leave_depot_offs[] = {
 
	{-1,  0},
 
	{ 0, -1}
 
};
 
@@ -321,13 +321,13 @@ static void CheckShipLeaveDepot(Ship *v)
 
	v->cur_speed = 0;
 
	RecalcShipStuff(v);
 

	
 
	PlayShipSound(v);
 
	VehicleServiceInDepot(v);
 
	InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 
	InvalidateWindowClasses(WC_SHIPS_LIST);
 
	SetWindowClassesDirty(WC_SHIPS_LIST);
 
}
 

	
 
static bool ShipAccelerate(Vehicle *v)
 
{
 
	uint spd;
 
	byte t;
 
@@ -335,13 +335,13 @@ static bool ShipAccelerate(Vehicle *v)
 
	spd = min(v->cur_speed + 1, GetVehicleProperty(v, 0x0B, v->max_speed));
 

	
 
	/* updates statusbar only if speed have changed to save CPU time */
 
	if (spd != v->cur_speed) {
 
		v->cur_speed = spd;
 
		if (_settings_client.gui.vehicle_speed)
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
			SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	}
 

	
 
	/* Decrease somewhat when turning */
 
	if (!(v->direction & 1)) spd = spd * 3 / 4;
 

	
 
	if (spd == 0) return false;
 
@@ -624,13 +624,13 @@ static void ShipController(Ship *v)
 
				if (HasBit(r, VETS_CANNOT_ENTER)) goto reverse_direction;
 

	
 
				/* A leave station order only needs one tick to get processed, so we can
 
				 * always skip ahead. */
 
				if (v->current_order.IsType(OT_LEAVESTATION)) {
 
					v->current_order.Free();
 
					InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
					SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
				} else if (v->dest_tile != 0) {
 
					/* We have a target, let's see if we reached it... */
 
					if (v->current_order.IsType(OT_GOTO_WAYPOINT) &&
 
							DistanceManhattan(v->dest_tile, gp.new_tile) <= 3) {
 
						/* We got within 3 tiles of our target buoy, so let's skip to our
 
						 * next order */
 
@@ -816,13 +816,13 @@ CommandCost CmdBuildShip(TileIndex tile,
 
		v->InvalidateNewGRFCacheOfChain();
 

	
 
		VehicleMove(v, false);
 

	
 
		InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 
		InvalidateWindowClassesData(WC_SHIPS_LIST, 0);
 
		InvalidateWindow(WC_COMPANY, v->owner);
 
		SetWindowDirty(WC_COMPANY, v->owner);
 
		if (IsLocalCompany())
 
			InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Ship window
 

	
 
		Company::Get(_current_company)->num_engines[p1]++;
 
	}
 

	
 
@@ -945,14 +945,14 @@ CommandCost CmdRefitShip(TileIndex tile,
 
		v->cargo_cap = capacity;
 
		v->cargo.Truncate((v->cargo_type == new_cid) ? capacity : 0);
 
		v->cargo_type = new_cid;
 
		v->cargo_subtype = new_subtype;
 
		v->colourmap = PAL_NONE; // invalidate vehicle colour map
 
		v->InvalidateNewGRFCacheOfChain();
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
		SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 
		SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
 
		InvalidateWindowClassesData(WC_SHIPS_LIST, 0);
 
	}
 

	
 
	return cost;
 

	
 
}
src/signs_gui.cpp
Show inline comments
 
@@ -173,13 +173,13 @@ struct SignListWindow : Window, SignList
 

	
 
	virtual void OnInvalidateData(int data)
 
	{
 
		if (data == 0) { // New or deleted sign.
 
			this->signs.ForceRebuild();
 
			this->BuildSignsList();
 
			this->InvalidateWidget(SLW_CAPTION);
 
			this->SetWidgetDirty(SLW_CAPTION);
 
			this->vscroll.SetCount(this->signs.Length());
 
		} else { // Change of sign contents.
 
			this->signs.ForceResort();
 
		}
 

	
 
		this->SortSignsList();
 
@@ -269,13 +269,13 @@ struct SignWindow : QueryStringBaseWindo
 
		}
 
		*last_of = '\0';
 

	
 
		this->cur_sign = si->index;
 
		InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, MAX_LENGTH_SIGN_NAME_PIXELS);
 

	
 
		this->InvalidateWidget(QUERY_EDIT_SIGN_WIDGET_TEXT);
 
		this->SetWidgetDirty(QUERY_EDIT_SIGN_WIDGET_TEXT);
 
		this->SetFocusedWidget(QUERY_EDIT_SIGN_WIDGET_TEXT);
 
	}
 

	
 
	/**
 
	 * Returns a pointer to the (alphabetically) previous or next sign of the current sign.
 
	 * @param next false if the previous sign is wanted, true if the next sign is wanted
src/station_cmd.cpp
Show inline comments
 
@@ -424,13 +424,13 @@ void Station::UpdateVirtCoord()
 
	if ((this->facilities & FACIL_AIRPORT) && this->airport_type == AT_OILRIG) pt.y -= 16;
 

	
 
	SetDParam(0, this->index);
 
	SetDParam(1, this->facilities);
 
	this->sign.UpdatePosition(pt.x, pt.y, STR_VIEWPORT_STATION);
 

	
 
	InvalidateWindow(WC_STATION_VIEW, this->index);
 
	SetWindowDirty(WC_STATION_VIEW, this->index);
 
}
 

	
 
/** Update the virtual coords needed to draw the station sign for all stations. */
 
void UpdateAllStationVirtCoords()
 
{
 
	BaseStation *st;
 
@@ -618,13 +618,13 @@ void UpdateStationAcceptance(Station *st
 
		/* Show news message if there are any changes */
 
		if (num_acc > 0) ShowRejectOrAcceptNews(st, num_acc, accepts, accept_msg[num_acc - 1]);
 
		if (num_rej > 0) ShowRejectOrAcceptNews(st, num_rej, rejects, reject_msg[num_rej - 1]);
 
	}
 

	
 
	/* redraw the station view since acceptance changed */
 
	InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_ACCEPTLIST);
 
	SetWindowWidgetDirty(WC_STATION_VIEW, st->index, SVW_ACCEPTLIST);
 
}
 

	
 
static void UpdateStationSignCoord(BaseStation *st)
 
{
 
	const StationRect *r = &st->rect;
 

	
 
@@ -1150,13 +1150,13 @@ CommandCost CmdBuildRailStation(TileInde
 
		st->MarkTilesDirty(false);
 
		st->UpdateVirtCoord();
 
		UpdateStationAcceptance(st, false);
 
		st->RecomputeIndustriesNear();
 
		InvalidateWindowData(WC_SELECT_STATION, 0, 0);
 
		InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
 
		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS);
 
		SetWindowWidgetDirty(WC_STATION_VIEW, st->index, SVW_TRAINS);
 
	}
 

	
 
	return cost;
 
}
 

	
 
static void MakeRailStationAreaSmaller(BaseStation *st)
 
@@ -1307,13 +1307,13 @@ CommandCost RemoveFromRailBaseStation(Ti
 
		MakeRailStationAreaSmaller(st);
 
		UpdateStationSignCoord(st);
 

	
 
		/* if we deleted the whole station, delete the train facility. */
 
		if (st->train_station.tile == INVALID_TILE) {
 
			st->facilities &= ~FACIL_TRAIN;
 
			InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS);
 
			SetWindowWidgetDirty(WC_STATION_VIEW, st->index, SVW_TRAINS);
 
			st->UpdateVirtCoord();
 
			DeleteStationIfEmpty(st);
 
		}
 
	}
 

	
 
	total_cost.AddCost(quantity * removal_cost);
 
@@ -1342,13 +1342,13 @@ CommandCost CmdRemoveFromRailStation(Til
 
	if (ret.Failed()) return ret;
 

	
 
	/* Do all station specific functions here. */
 
	for (Station **stp = affected_stations.Begin(); stp != affected_stations.End(); stp++) {
 
		Station *st = *stp;
 

	
 
		if (st->train_station.tile == INVALID_TILE) InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS);
 
		if (st->train_station.tile == INVALID_TILE) SetWindowWidgetDirty(WC_STATION_VIEW, st->index, SVW_TRAINS);
 
		st->MarkTilesDirty(false);
 
		st->RecomputeIndustriesNear();
 
	}
 

	
 
	/* Now apply the rail cost to the number that we deleted */
 
	return ret;
 
@@ -1430,13 +1430,13 @@ CommandCost RemoveRailStation(T *st, DoC
 

	
 
		free(st->speclist);
 
		st->num_specs = 0;
 
		st->speclist  = NULL;
 
		st->cached_anim_triggers = 0;
 

	
 
		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS);
 
		SetWindowWidgetDirty(WC_STATION_VIEW, st->index, SVW_TRAINS);
 
		st->UpdateVirtCoord();
 
		DeleteStationIfEmpty(st);
 
	}
 

	
 
	return cost;
 
}
 
@@ -1633,13 +1633,13 @@ CommandCost CmdBuildRoadStop(TileIndex t
 

	
 
		st->UpdateVirtCoord();
 
		UpdateStationAcceptance(st, false);
 
		st->RecomputeIndustriesNear();
 
		InvalidateWindowData(WC_SELECT_STATION, 0, 0);
 
		InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
 
		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_ROADVEHS);
 
		SetWindowWidgetDirty(WC_STATION_VIEW, st->index, SVW_ROADVEHS);
 
	}
 
	return cost;
 
}
 

	
 

	
 
static Vehicle *ClearRoadStopStatusEnum(Vehicle *v, void *)
 
@@ -1698,13 +1698,13 @@ static CommandCost RemoveRoadStop(TileIn
 
			/* tell the predecessor in the list to skip this stop */
 
			RoadStop *pred = *primary_stop;
 
			while (pred->next != cur_stop) pred = pred->next;
 
			pred->next = cur_stop->next;
 
		}
 

	
 
		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_ROADVEHS);
 
		SetWindowWidgetDirty(WC_STATION_VIEW, st->index, SVW_ROADVEHS);
 
		delete cur_stop;
 

	
 
		/* Make sure no vehicle is going to the old roadstop */
 
		RoadVehicle *v;
 
		FOR_ALL_ROADVEHICLES(v) {
 
			if (v->First() == v && v->current_order.IsType(OT_GOTO_STATION) &&
 
@@ -1998,16 +1998,16 @@ CommandCost CmdBuildAirport(TileIndex ti
 

	
 
		st->UpdateVirtCoord();
 
		UpdateStationAcceptance(st, false);
 
		st->RecomputeIndustriesNear();
 
		InvalidateWindowData(WC_SELECT_STATION, 0, 0);
 
		InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
 
		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES);
 
		SetWindowWidgetDirty(WC_STATION_VIEW, st->index, SVW_PLANES);
 

	
 
		if (_settings_game.economy.station_noise_level) {
 
			InvalidateWindow(WC_TOWN_VIEW, st->town->index);
 
			SetWindowDirty(WC_TOWN_VIEW, st->town->index);
 
		}
 
	}
 

	
 
	return cost;
 
}
 

	
 
@@ -2063,16 +2063,16 @@ static CommandCost RemoveAirport(TileInd
 

	
 
		st->rect.AfterRemoveRect(st, tile, w, h);
 

	
 
		st->airport_tile = INVALID_TILE;
 
		st->facilities &= ~FACIL_AIRPORT;
 

	
 
		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES);
 
		SetWindowWidgetDirty(WC_STATION_VIEW, st->index, SVW_PLANES);
 

	
 
		if (_settings_game.economy.station_noise_level) {
 
			InvalidateWindow(WC_TOWN_VIEW, st->town->index);
 
			SetWindowDirty(WC_TOWN_VIEW, st->town->index);
 
		}
 

	
 
		st->UpdateVirtCoord();
 
		st->RecomputeIndustriesNear();
 
		DeleteStationIfEmpty(st);
 
	}
 
@@ -2208,13 +2208,13 @@ CommandCost CmdBuildDock(TileIndex tile,
 

	
 
		st->UpdateVirtCoord();
 
		UpdateStationAcceptance(st, false);
 
		st->RecomputeIndustriesNear();
 
		InvalidateWindowData(WC_SELECT_STATION, 0, 0);
 
		InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
 
		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
 
		SetWindowWidgetDirty(WC_STATION_VIEW, st->index, SVW_SHIPS);
 
	}
 

	
 
	return CommandCost(EXPENSES_CONSTRUCTION, _price.build_dock);
 
}
 

	
 
/**
 
@@ -2243,13 +2243,13 @@ static CommandCost RemoveDock(TileIndex 
 

	
 
		MarkTileDirtyByTile(tile2);
 

	
 
		st->dock_tile = INVALID_TILE;
 
		st->facilities &= ~FACIL_DOCK;
 

	
 
		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
 
		SetWindowWidgetDirty(WC_STATION_VIEW, st->index, SVW_SHIPS);
 
		st->UpdateVirtCoord();
 
		st->RecomputeIndustriesNear();
 
		DeleteStationIfEmpty(st);
 
	}
 

	
 
	return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_dock);
 
@@ -2820,15 +2820,15 @@ static void UpdateStationRating(Station 
 
			}
 
		}
 
	} while (++ge != endof(st->goods));
 

	
 
	StationID index = st->index;
 
	if (waiting_changed) {
 
		InvalidateWindow(WC_STATION_VIEW, index); // update whole window
 
		SetWindowDirty(WC_STATION_VIEW, index); // update whole window
 
	} else {
 
		InvalidateWindowWidget(WC_STATION_VIEW, index, SVW_RATINGLIST); // update only ratings list
 
		SetWindowWidgetDirty(WC_STATION_VIEW, index, SVW_RATINGLIST); // update only ratings list
 
	}
 
}
 

	
 
/* called for every station each tick */
 
static void StationHandleSmallTick(BaseStation *st)
 
{
 
@@ -2888,13 +2888,13 @@ static void UpdateStationWaiting(Station
 
{
 
	st->goods[type].cargo.Append(new CargoPacket(st->index, amount, source_type, source_id));
 
	SetBit(st->goods[type].acceptance_pickup, GoodsEntry::PICKUP);
 

	
 
	StationAnimationTrigger(st, st->xy, STAT_ANIM_NEW_CARGO, type);
 

	
 
	InvalidateWindow(WC_STATION_VIEW, st->index);
 
	SetWindowDirty(WC_STATION_VIEW, st->index);
 
	st->MarkTilesDirty(true);
 
}
 

	
 
static bool IsUniqueStationName(const char *name)
 
{
 
	const Station *st;
src/station_gui.cpp
Show inline comments
 
@@ -251,13 +251,13 @@ protected:
 
		if (!this->stations.Sort()) return;
 

	
 
		/* Reset name sorter sort cache */
 
		this->last_station = NULL;
 

	
 
		/* Set the modified widget dirty */
 
		this->InvalidateWidget(SLW_LIST);
 
		this->SetWidgetDirty(SLW_LIST);
 
	}
 

	
 
public:
 
	CompanyStationsWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		this->owner = (Owner)this->window_number;
 
@@ -966,13 +966,13 @@ struct StationViewWindow : public Window
 
	{
 
		if (row == 0) return;
 

	
 
		for (CargoID c = 0; c < NUM_CARGO; c++) {
 
			if (this->cargo_rows[c] == row) {
 
				ToggleBit(this->cargo, c);
 
				this->InvalidateWidget(SVW_WAITING);
 
				this->SetWidgetDirty(SVW_WAITING);
 
				break;
 
			}
 
		}
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget)
src/statusbar_gui.cpp
Show inline comments
 
@@ -168,20 +168,20 @@ struct StatusBarWindow : Window {
 
	virtual void OnTick()
 
	{
 
		if (_pause_mode != PM_UNPAUSED) return;
 

	
 
		if (this->ticker_scroll < TICKER_STOP) { // Scrolling text
 
			this->ticker_scroll += COUNTER_STEP;
 
			this->InvalidateWidget(SBW_MIDDLE);
 
			this->SetWidgetDirty(SBW_MIDDLE);
 
		}
 

	
 
		if (this->reminder_timeout > REMINDER_STOP) { // Red blot to show there are new unread newsmessages
 
			this->reminder_timeout -= COUNTER_STEP;
 
		} else if (this->reminder_timeout < REMINDER_STOP) {
 
			this->reminder_timeout = REMINDER_STOP;
 
			this->InvalidateWidget(SBW_MIDDLE);
 
			this->SetWidgetDirty(SBW_MIDDLE);
 
		}
 
	}
 
};
 

	
 
static const Widget _main_status_widgets[] = {
 
{      WWT_PANEL,   RESIZE_NONE,   COLOUR_GREY,     0,   139,     0,    11, 0x0, STR_NULL},
src/terraform_gui.cpp
Show inline comments
 
@@ -731,13 +731,13 @@ struct ScenarioEditorLandscapeGeneration
 
	virtual void OnTimeout()
 
	{
 
		for (uint i = ETTW_START; i < this->nested_array_size; i++) {
 
			if (i == ETTW_BUTTONS_START) i = ETTW_BUTTONS_END; // skip the buttons
 
			if (this->IsWidgetLowered(i)) {
 
				this->RaiseWidget(i);
 
				this->InvalidateWidget(i);
 
				this->SetWidgetDirty(i);
 
			}
 
		}
 
	}
 

	
 
	virtual void OnPlaceObject(Point pt, TileIndex tile)
 
	{
src/timetable_cmd.cpp
Show inline comments
 
@@ -37,13 +37,13 @@ static void ChangeTimetable(Vehicle *v, 
 
			if (is_journey) {
 
				v->current_order.travel_time = time;
 
			} else {
 
				v->current_order.wait_time = time;
 
			}
 
		}
 
		InvalidateWindow(WC_VEHICLE_TIMETABLE, v->index);
 
		SetWindowDirty(WC_VEHICLE_TIMETABLE, v->index);
 
	}
 
}
 

	
 
/**
 
 * Add or remove waiting times from an order.
 
 * @param tile Not used.
 
@@ -173,13 +173,13 @@ CommandCost CmdAutofillTimetable(TileInd
 
	for (Vehicle *v2 = v->FirstShared(); v2 != NULL; v2 = v2->NextShared()) {
 
		if (v2 != v) {
 
			/* Stop autofilling; only one vehicle at a time can perform autofill */
 
			ClrBit(v2->vehicle_flags, VF_AUTOFILL_TIMETABLE);
 
			ClrBit(v2->vehicle_flags, VF_AUTOFILL_PRES_WAIT_TIME);
 
		}
 
		InvalidateWindow(WC_VEHICLE_TIMETABLE, v2->index);
 
		SetWindowDirty(WC_VEHICLE_TIMETABLE, v2->index);
 
	}
 

	
 
	return CommandCost();
 
}
 

	
 
void UpdateVehicleTimetable(Vehicle *v, bool travelling)
 
@@ -238,9 +238,9 @@ void UpdateVehicleTimetable(Vehicle *v, 
 
	 * when this happens. */
 
	if (timetabled == 0 && (travelling || v->lateness_counter >= 0)) return;
 

	
 
	v->lateness_counter -= (timetabled - time_taken);
 

	
 
	for (v = v->FirstShared(); v != NULL; v = v->NextShared()) {
 
		InvalidateWindow(WC_VEHICLE_TIMETABLE, v->index);
 
		SetWindowDirty(WC_VEHICLE_TIMETABLE, v->index);
 
	}
 
}
src/toolbar_gui.cpp
Show inline comments
 
@@ -1117,18 +1117,18 @@ struct MainToolbarWindow : Window {
 
	}
 

	
 
	virtual void OnTick()
 
	{
 
		if (this->IsWidgetLowered(TBN_PAUSE) != !!_pause_mode) {
 
			this->ToggleWidgetLoweredState(TBN_PAUSE);
 
			this->InvalidateWidget(TBN_PAUSE);
 
			this->SetWidgetDirty(TBN_PAUSE);
 
		}
 

	
 
		if (this->IsWidgetLowered(TBN_FASTFORWARD) != !!_fast_forward) {
 
			this->ToggleWidgetLoweredState(TBN_FASTFORWARD);
 
			this->InvalidateWidget(TBN_FASTFORWARD);
 
			this->SetWidgetDirty(TBN_FASTFORWARD);
 
		}
 
	}
 

	
 
	virtual void OnResize(Point delta)
 
	{
 
		if (this->width <= TBP_NORMAL_MAXBUTTON * TBP_BUTTONWIDTH) {
 
@@ -1140,13 +1140,13 @@ struct MainToolbarWindow : Window {
 

	
 
	virtual void OnTimeout()
 
	{
 
		for (uint i = TBN_SETTINGS; i < this->widget_count - 1; i++) {
 
			if (this->IsWidgetLowered(i)) {
 
				this->RaiseWidget(i);
 
				this->InvalidateWidget(i);
 
				this->SetWidgetDirty(i);
 
			}
 
		}
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
 
	{
 
@@ -1390,14 +1390,14 @@ public:
 
		}
 
	}
 

	
 
	virtual void OnTimeout()
 
	{
 
		this->SetWidgetsLoweredState(false, TBSE_DATEBACKWARD, TBSE_DATEFORWARD, WIDGET_LIST_END);
 
		this->InvalidateWidget(TBSE_DATEBACKWARD);
 
		this->InvalidateWidget(TBSE_DATEFORWARD);
 
		this->SetWidgetDirty(TBSE_DATEBACKWARD);
 
		this->SetWidgetDirty(TBSE_DATEFORWARD);
 
	}
 

	
 
	virtual void OnTick()
 
	{
 
		if (this->IsWidgetLowered(TBSE_PAUSE) != !!_pause_mode) {
 
			this->ToggleWidgetLoweredState(TBSE_PAUSE);
src/town_cmd.cpp
Show inline comments
 
@@ -336,13 +336,13 @@ void Town::UpdateVirtCoord()
 
	Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE);
 
	SetDParam(0, this->index);
 
	SetDParam(1, this->population);
 
	this->sign.UpdatePosition(pt.x, pt.y - 24,
 
		_settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_VIEWPORT_TOWN);
 

	
 
	InvalidateWindow(WC_TOWN_VIEW, this->index);
 
	SetWindowDirty(WC_TOWN_VIEW, this->index);
 
}
 

	
 
/** Update the virtual coords needed to draw the town sign for all towns. */
 
void UpdateAllTownVirtCoords()
 
{
 
	Town *t;
 
@@ -357,13 +357,13 @@ void UpdateAllTownVirtCoords()
 
 * @param t Town which polulation has changed
 
 * @param mod polulation change (can be positive or negative)
 
 */
 
static void ChangePopulation(Town *t, int mod)
 
{
 
	t->population += mod;
 
	InvalidateWindow(WC_TOWN_VIEW, t->index);
 
	SetWindowDirty(WC_TOWN_VIEW, t->index);
 
	t->UpdateVirtCoord();
 

	
 
	InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 1);
 
}
 

	
 
/**
 
@@ -2468,13 +2468,13 @@ static void TownActionBribe(Town *t)
 
		/* decrease by a lot!
 
		 * ChangeTownRating is only for stuff in demolishing. Bribe failure should
 
		 * be independent of any cheat settings
 
		 */
 
		if (t->ratings[_current_company] > RATING_BRIBE_DOWN_TO) {
 
			t->ratings[_current_company] = RATING_BRIBE_DOWN_TO;
 
			InvalidateWindow(WC_TOWN_AUTHORITY, t->index);
 
			SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
 
		}
 
	} else {
 
		ChangeTownRating(t, RATING_BRIBE_UP_STEP, RATING_BRIBE_MAXIMUM, DC_EXEC);
 
	}
 
}
 

	
 
@@ -2572,13 +2572,13 @@ CommandCost CmdDoTownAction(TileIndex ti
 
	if (!HasBit(GetMaskOfTownActions(NULL, _current_company, t), p2)) return CMD_ERROR;
 

	
 
	CommandCost cost(EXPENSES_OTHER, (_price.build_industry >> 8) * _town_action_costs[p2]);
 

	
 
	if (flags & DC_EXEC) {
 
		_town_action_proc[p2](t);
 
		InvalidateWindow(WC_TOWN_AUTHORITY, p1);
 
		SetWindowDirty(WC_TOWN_AUTHORITY, p1);
 
	}
 

	
 
	return cost;
 
}
 

	
 
static void UpdateTownGrowRate(Town *t)
 
@@ -2613,13 +2613,13 @@ static void UpdateTownGrowRate(Town *t)
 

	
 
	/* clamp all ratings to valid values */
 
	for (uint i = 0; i < MAX_COMPANIES; i++) {
 
		t->ratings[i] = Clamp(t->ratings[i], RATING_MINIMUM, RATING_MAXIMUM);
 
	}
 

	
 
	InvalidateWindow(WC_TOWN_AUTHORITY, t->index);
 
	SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
 

	
 
	ClrBit(t->flags, TOWN_IS_FUNDED);
 
	if (_settings_game.economy.town_growth_rate == 0 && t->fund_buildings_months == 0) return;
 

	
 
	/** Towns are processed every TOWN_GROWTH_FREQUENCY ticks, and this is the
 
	 * number of times towns are processed before a new building is built. */
 
@@ -2672,13 +2672,13 @@ static void UpdateTownAmounts(Town *t)
 

	
 
	/* Using +1 here to prevent overflow and division by zero */
 
	t->pct_mail_transported = t->new_act_mail * 256 / (t->new_max_mail + 1);
 
	t->max_mail = t->new_max_mail; t->new_max_mail = 0;
 
	t->act_mail = t->new_act_mail; t->new_act_mail = 0;
 

	
 
	InvalidateWindow(WC_TOWN_VIEW, t->index);
 
	SetWindowDirty(WC_TOWN_VIEW, t->index);
 
}
 

	
 
static void UpdateTownUnwanted(Town *t)
 
{
 
	const Company *c;
 

	
 
@@ -2818,13 +2818,13 @@ void ChangeTownRating(Town *t, int add, 
 
	}
 
	if (_town_rating_test) {
 
		_town_test_ratings[t] = rating;
 
	} else {
 
		SetBit(t->have_ratings, _current_company);
 
		t->ratings[_current_company] = rating;
 
		InvalidateWindow(WC_TOWN_AUTHORITY, t->index);
 
		SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
 
	}
 
}
 

	
 
bool CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType type)
 
{
 
	/* if magic_bulldozer cheat is active, town doesn't restrict your destructive actions */
src/train_cmd.cpp
Show inline comments
 
@@ -127,14 +127,14 @@ void TrainPowerChanged(Train *v)
 
	if (v->tcache.cached_power != total_power || v->tcache.cached_max_te != max_te) {
 
		/* If it has no power (no catenary), stop the train */
 
		if (total_power == 0) v->vehstatus |= VS_STOPPED;
 

	
 
		v->tcache.cached_power = total_power;
 
		v->tcache.cached_max_te = max_te;
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	}
 
}
 

	
 

	
 
/**
 
 * Recalculates the cached weight of a train and its vehicles. Should be called each time the cargo on
 
@@ -352,13 +352,13 @@ void TrainConsistChanged(Train *v, bool 
 

	
 
	/* recalculate cached weights and power too (we do this *after* the rest, so it is known which wagons are powered and need extra weight added) */
 
	TrainCargoChanged(v);
 

	
 
	if (v->IsFrontEngine()) {
 
		UpdateTrainAcceleration(v);
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 
	}
 
}
 

	
 
enum AccelType {
 
	AM_ACCEL,
 
	AM_BRAKE
 
@@ -765,13 +765,13 @@ static CommandCost CmdBuildRailWagon(Eng
 
		_new_vehicle_id = v->index;
 

	
 
		VehicleMove(v, false);
 
		TrainConsistChanged(v->First(), false);
 
		UpdateTrainGroupID(v->First());
 

	
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
		SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
 
		if (IsLocalCompany()) {
 
			InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Train window
 
		}
 
		Company::Get(_current_company)->num_engines[engine]++;
 

	
 
		CheckConsistencyOfArticulatedVehicle(v);
 
@@ -936,13 +936,13 @@ CommandCost CmdBuildRailVehicle(TileInde
 
		if (!HasBit(p2, 1) && !(flags & DC_AUTOREPLACE)) { // check if the cars should be added to the new vehicle
 
			NormalizeTrainVehInDepot(v);
 
		}
 

	
 
		InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 
		InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
 
		InvalidateWindow(WC_COMPANY, v->owner);
 
		SetWindowDirty(WC_COMPANY, v->owner);
 
		if (IsLocalCompany()) {
 
			InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Train window
 
		}
 

	
 
		Company::Get(_current_company)->num_engines[p1]++;
 

	
 
@@ -1403,30 +1403,30 @@ CommandCost CmdMoveRailVehicle(TileIndex
 
		if (src_head != NULL) {
 
			NormaliseTrainConsist(src_head);
 
			TrainConsistChanged(src_head, false);
 
			UpdateTrainGroupID(src_head);
 
			if (src_head->IsFrontEngine()) {
 
				/* Update the refit button and window */
 
				InvalidateWindow(WC_VEHICLE_REFIT, src_head->index);
 
				InvalidateWindowWidget(WC_VEHICLE_VIEW, src_head->index, VVW_WIDGET_REFIT_VEH);
 
				SetWindowDirty(WC_VEHICLE_REFIT, src_head->index);
 
				SetWindowWidgetDirty(WC_VEHICLE_VIEW, src_head->index, VVW_WIDGET_REFIT_VEH);
 
			}
 
			/* Update the depot window */
 
			InvalidateWindow(WC_VEHICLE_DEPOT, src_head->tile);
 
			SetWindowDirty(WC_VEHICLE_DEPOT, src_head->tile);
 
		}
 

	
 
		if (dst_head != NULL) {
 
			NormaliseTrainConsist(dst_head);
 
			TrainConsistChanged(dst_head, false);
 
			UpdateTrainGroupID(dst_head);
 
			if (dst_head->IsFrontEngine()) {
 
				/* Update the refit button and window */
 
				InvalidateWindowWidget(WC_VEHICLE_VIEW, dst_head->index, VVW_WIDGET_REFIT_VEH);
 
				InvalidateWindow(WC_VEHICLE_REFIT, dst_head->index);
 
				SetWindowWidgetDirty(WC_VEHICLE_VIEW, dst_head->index, VVW_WIDGET_REFIT_VEH);
 
				SetWindowDirty(WC_VEHICLE_REFIT, dst_head->index);
 
			}
 
			/* Update the depot window */
 
			InvalidateWindow(WC_VEHICLE_DEPOT, dst_head->tile);
 
			SetWindowDirty(WC_VEHICLE_DEPOT, dst_head->tile);
 
		}
 

	
 
		InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
 
	}
 

	
 
	return CommandCost();
 
@@ -1467,13 +1467,13 @@ CommandCost CmdSellRailWagon(TileIndex t
 
			DeleteWindowById(WC_VEHICLE_VIEW, first->index);
 
			DeleteWindowById(WC_VEHICLE_ORDERS, first->index);
 
			DeleteWindowById(WC_VEHICLE_REFIT, first->index);
 
			DeleteWindowById(WC_VEHICLE_DETAILS, first->index);
 
			DeleteWindowById(WC_VEHICLE_TIMETABLE, first->index);
 
		}
 
		InvalidateWindow(WC_VEHICLE_DEPOT, first->tile);
 
		SetWindowDirty(WC_VEHICLE_DEPOT, first->tile);
 
		InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
 
	}
 

	
 
	CommandCost cost(EXPENSES_NEW_VEHICLES);
 
	switch (p2) {
 
		case 0: { // Delete given wagon
 
@@ -1543,13 +1543,13 @@ CommandCost CmdSellRailWagon(TileIndex t
 

	
 
				/* 5. If the train still exists, update its acceleration, window, etc. */
 
				if (first != NULL) {
 
					NormaliseTrainConsist(first);
 
					TrainConsistChanged(first, false);
 
					UpdateTrainGroupID(first);
 
					if (first->IsFrontEngine()) InvalidateWindow(WC_VEHICLE_REFIT, first->index);
 
					if (first->IsFrontEngine()) SetWindowDirty(WC_VEHICLE_REFIT, first->index);
 
				}
 

	
 
			}
 
		} break;
 
		case 1: { // Delete wagon and all wagons after it given certain criteria
 
			/* Start deleting every vehicle after the selected one
 
@@ -1594,13 +1594,13 @@ CommandCost CmdSellRailWagon(TileIndex t
 

	
 
			/* 3. If it is still a valid train after selling, update its acceleration and cached values */
 
			if ((flags & DC_EXEC) && first != NULL) {
 
				NormaliseTrainConsist(first);
 
				TrainConsistChanged(first, false);
 
				UpdateTrainGroupID(first);
 
				InvalidateWindow(WC_VEHICLE_REFIT, first->index);
 
				SetWindowDirty(WC_VEHICLE_REFIT, first->index);
 
			}
 
		} break;
 
	}
 
	return cost;
 
}
 

	
 
@@ -1630,13 +1630,13 @@ void Train::UpdateDeltaXY(Direction dire
 
static inline void SetLastSpeed(Train *v, int spd)
 
{
 
	int old = v->tcache.last_speed;
 
	if (spd != old) {
 
		v->tcache.last_speed = spd;
 
		if (_settings_client.gui.vehicle_speed || (old == 0) != (spd == 0)) {
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
			SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		}
 
	}
 
}
 

	
 
/** Mark a train as stuck and stop it if it isn't stopped right now. */
 
static void MarkTrainAsStuck(Train *v)
 
@@ -1652,13 +1652,13 @@ static void MarkTrainAsStuck(Train *v)
 

	
 
		/* Stop train */
 
		v->cur_speed = 0;
 
		v->subspeed = 0;
 
		SetLastSpeed(v, 0);
 

	
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	}
 
}
 

	
 
static void SwapTrainFlags(uint16 *swap_flag1, uint16 *swap_flag2)
 
{
 
	uint16 flag1 = *swap_flag1;
 
@@ -1957,13 +1957,13 @@ static void ReverseTrainDirection(Train 
 
	crossing = TrainApproachingCrossingTile(v);
 
	if (crossing != INVALID_TILE) MaybeBarCrossingWithSound(crossing);
 

	
 
	/* If we are inside a depot after reversing, don't bother with path reserving. */
 
	if (v->track == TRACK_BIT_DEPOT) {
 
		/* Can't be stuck here as inside a depot is always a safe tile. */
 
		if (HasBit(v->flags, VRF_TRAIN_STUCK)) InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		if (HasBit(v->flags, VRF_TRAIN_STUCK)) SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		ClrBit(v->flags, VRF_TRAIN_STUCK);
 
		return;
 
	}
 

	
 
	/* TrainExitDir does not always produce the desired dir for depots and
 
	 * tunnels/bridges that is needed for UpdateSignalsOnSegment. */
 
@@ -2015,14 +2015,14 @@ CommandCost CmdReverseTrainDirection(Til
 
		if (CheckTrainStoppedInDepot(front) < 0) {
 
			return_cmd_error(STR_ERROR_TRAINS_CAN_ONLY_BE_ALTERED_INSIDE_A_DEPOT);
 
		}
 

	
 
		if (flags & DC_EXEC) {
 
			ToggleBit(v->flags, VRF_REVERSE_DIRECTION);
 
			InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
			InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
			SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
 
			SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 
		}
 
	} else {
 
		/* turn the whole train around */
 
		if ((v->vehstatus & VS_CRASHED) || v->breakdown_ctr != 0) return CMD_ERROR;
 

	
 
		if (flags & DC_EXEC) {
 
@@ -2145,14 +2145,14 @@ CommandCost CmdRefitRailVehicle(TileInde
 
			num += amount;
 
			if (flags & DC_EXEC) {
 
				v->cargo.Truncate((v->cargo_type == new_cid) ? amount : 0);
 
				v->cargo_type = new_cid;
 
				v->cargo_cap = amount;
 
				v->cargo_subtype = new_subtype;
 
				InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
				InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
				SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 
				SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
 
				InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
 
			}
 
		}
 
	} while ((v = v->Next()) != NULL && !only_this);
 

	
 
	_returned_refit_capacity = num;
 
@@ -2434,31 +2434,31 @@ static bool CheckTrainStayInDepot(Train 
 
		if (u->track != TRACK_BIT_DEPOT || u->tile != v->tile) return false;
 
	}
 

	
 
	/* if the train got no power, then keep it in the depot */
 
	if (v->tcache.cached_power == 0) {
 
		v->vehstatus |= VS_STOPPED;
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
		SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
 
		return true;
 
	}
 

	
 
	SigSegState seg_state;
 

	
 
	if (v->force_proceed == 0) {
 
		/* force proceed was not pressed */
 
		if (++v->load_unload_time_rem < 37) {
 
			InvalidateWindowClasses(WC_TRAINS_LIST);
 
			SetWindowClassesDirty(WC_TRAINS_LIST);
 
			return true;
 
		}
 

	
 
		v->load_unload_time_rem = 0;
 

	
 
		seg_state = _settings_game.pf.reserve_paths ? SIGSEG_PBS : UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner);
 
		if (seg_state == SIGSEG_FULL || HasDepotReservation(v->tile)) {
 
			/* Full and no PBS signal in block or depot reserved, can't exit. */
 
			InvalidateWindowClasses(WC_TRAINS_LIST);
 
			SetWindowClassesDirty(WC_TRAINS_LIST);
 
			return true;
 
		}
 
	} else {
 
		seg_state = _settings_game.pf.reserve_paths ? SIGSEG_PBS : UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner);
 
	}
 

	
 
@@ -2471,22 +2471,22 @@ static bool CheckTrainStayInDepot(Train 
 
		return true;
 
	}
 

	
 
	/* Only leave when we can reserve a path to our destination. */
 
	if (seg_state == SIGSEG_PBS && !TryPathReserve(v) && v->force_proceed == 0) {
 
		/* No path and no force proceed. */
 
		InvalidateWindowClasses(WC_TRAINS_LIST);
 
		SetWindowClassesDirty(WC_TRAINS_LIST);
 
		MarkTrainAsStuck(v);
 
		return true;
 
	}
 

	
 
	SetDepotReservation(v->tile, true);
 
	if (_settings_client.gui.show_track_reservation) MarkTileDirtyByTile(v->tile);
 

	
 
	VehicleServiceInDepot(v);
 
	InvalidateWindowClasses(WC_TRAINS_LIST);
 
	SetWindowClassesDirty(WC_TRAINS_LIST);
 
	v->PlayLeaveStationSound();
 

	
 
	v->track = TRACK_BIT_X;
 
	if (v->direction & 2) v->track = TRACK_BIT_Y;
 

	
 
	v->vehstatus &= ~VS_HIDDEN;
 
@@ -3166,13 +3166,13 @@ bool TryPathReserve(Train *v, bool mark_
 
		if (mark_as_stuck) MarkTrainAsStuck(v);
 
		return false;
 
	}
 
	/* If we have a reserved path and the path ends at a safe tile, we are finished already. */
 
	if (origin.okay && (v->tile != origin.tile || first_tile_okay)) {
 
		/* Can't be stuck then. */
 
		if (HasBit(v->flags, VRF_TRAIN_STUCK)) InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		if (HasBit(v->flags, VRF_TRAIN_STUCK)) SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		ClrBit(v->flags, VRF_TRAIN_STUCK);
 
		return true;
 
	}
 

	
 
	/* If we are in a depot, tentativly reserve the depot. */
 
	if (v->track == TRACK_BIT_DEPOT) {
 
@@ -3194,13 +3194,13 @@ bool TryPathReserve(Train *v, bool mark_
 
		if (v->track == TRACK_BIT_DEPOT) SetDepotReservation(v->tile, false);
 
		return false;
 
	}
 

	
 
	if (HasBit(v->flags, VRF_TRAIN_STUCK)) {
 
		v->load_unload_time_rem = 0;
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	}
 
	ClrBit(v->flags, VRF_TRAIN_STUCK);
 
	return true;
 
}
 

	
 

	
 
@@ -3533,17 +3533,17 @@ static void SetVehicleCrashed(Train *v)
 

	
 
	/* we may need to update crossing we were approaching */
 
	TileIndex crossing = TrainApproachingCrossingTile(v);
 

	
 
	v->crash_anim_pos++;
 

	
 
	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
	SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 

	
 
	if (v->track == TRACK_BIT_DEPOT) {
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
		SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
 
	}
 

	
 
	InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
 

	
 
	for (; v != NULL; v = v->Next()) {
 
		v->vehstatus |= VS_CRASHED;
 
@@ -4021,13 +4021,13 @@ static void DeleteLastWagon(Train *v)
 
	if (first != v) {
 
		/* Recalculate cached train properties */
 
		TrainConsistChanged(first, false);
 
		/* Update the depot window if the first vehicle is in depot -
 
		 * if v == first, then it is updated in PreDestructor() */
 
		if (first->track == TRACK_BIT_DEPOT) {
 
			InvalidateWindow(WC_VEHICLE_DEPOT, first->tile);
 
			SetWindowDirty(WC_VEHICLE_DEPOT, first->tile);
 
		}
 
	}
 

	
 
	/* 'v' shouldn't be accessed after it has been deleted */
 
	TrackBits trackbits = v->track;
 
	TileIndex tile = v->tile;
 
@@ -4118,13 +4118,13 @@ static bool HandleCrashedTrain(Train *v)
 

	
 
	if (state <= 240 && !(v->tick_counter & 3)) ChangeTrainDirRandomly(v);
 

	
 
	if (state >= 4440 && !(v->tick_counter & 0x1F)) {
 
		bool ret = v->Next() != NULL;
 
		DeleteLastWagon(v);
 
		InvalidateWindow(WC_REPLACE_VEHICLE, (v->group_id << 16) | VEH_TRAIN);
 
		SetWindowDirty(WC_REPLACE_VEHICLE, (v->group_id << 16) | VEH_TRAIN);
 
		return ret;
 
	}
 

	
 
	return true;
 
}
 

	
 
@@ -4134,14 +4134,14 @@ static void HandleBrokenTrain(Train *v)
 
		v->breakdown_ctr = 1;
 
		v->cur_speed = 0;
 

	
 
		if (v->breakdowns_since_last_service != 255)
 
			v->breakdowns_since_last_service++;
 

	
 
		InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		SetWindowDirty(WC_VEHICLE_VIEW, v->index);
 
		SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 

	
 
		if (!PlayVehicleSound(v, VSE_BREAKDOWN)) {
 
			SndPlayVehicleFx((_settings_game.game_creation.landscape != LT_TOYLAND) ?
 
				SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v);
 
		}
 

	
 
@@ -4151,13 +4151,13 @@ static void HandleBrokenTrain(Train *v)
 
		}
 
	}
 

	
 
	if (!(v->tick_counter & 3)) {
 
		if (!--v->breakdown_delay) {
 
			v->breakdown_ctr = 0;
 
			InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
			SetWindowDirty(WC_VEHICLE_VIEW, v->index);
 
		}
 
	}
 
}
 

	
 
/** Maximum speeds for train that is broken down or approaching line end */
 
static const uint16 _breakdown_speeds[16] = {
 
@@ -4327,13 +4327,13 @@ static bool TrainLocoHandler(Train *v, b
 
		return mode ? true : HandleCrashedTrain(v); // 'this' can be deleted here
 
	}
 

	
 
	if (v->force_proceed != 0) {
 
		v->force_proceed--;
 
		ClrBit(v->flags, VRF_TRAIN_STUCK);
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	}
 

	
 
	/* train is broken down? */
 
	if (v->breakdown_ctr != 0) {
 
		if (v->breakdown_ctr <= 2) {
 
			HandleBrokenTrain(v);
 
@@ -4396,27 +4396,27 @@ static bool TrainLocoHandler(Train *v, b
 
				v->load_unload_time_rem = 0;
 
			}
 
			/* Exit if force proceed not pressed, else reset stuck flag anyway. */
 
			if (v->force_proceed == 0) return true;
 
			ClrBit(v->flags, VRF_TRAIN_STUCK);
 
			v->load_unload_time_rem = 0;
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
			SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		}
 
	}
 

	
 
	if (v->current_order.IsType(OT_LEAVESTATION)) {
 
		v->current_order.Free();
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		return true;
 
	}
 

	
 
	int j = UpdateTrainSpeed(v);
 

	
 
	/* we need to invalidate the widget if we are stopping from 'Stopping 0 km/h' to 'Stopped' */
 
	if (v->cur_speed == 0 && v->tcache.last_speed == 0 && (v->vehstatus & VS_STOPPED)) {
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	}
 

	
 
	int adv_spd = (v->direction & 1) ? 192 : 256;
 
	if (j < adv_spd) {
 
		/* if the vehicle has speed 0, update the last_speed field. */
 
		if (v->cur_speed == 0) SetLastSpeed(v, v->cur_speed);
 
@@ -4518,13 +4518,13 @@ static void CheckIfTrainNeedsService(Tra
 
	if (tfdd.best_length == UINT_MAX || tfdd.best_length > MAX_ACCEPTABLE_DEPOT_DIST) {
 
		if (v->current_order.IsType(OT_GOTO_DEPOT)) {
 
			/* If we were already heading for a depot but it has
 
			 * suddenly moved farther away, we continue our normal
 
			 * schedule? */
 
			v->current_order.MakeDummy();
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
			SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		}
 
		return;
 
	}
 

	
 
	DepotID depot = GetDepotIndex(tfdd.tile);
 

	
 
@@ -4533,13 +4533,13 @@ static void CheckIfTrainNeedsService(Tra
 
			!Chance16(3, 16)) {
 
		return;
 
	}
 

	
 
	v->current_order.MakeGoToDepot(depot, ODTFB_SERVICE);
 
	v->dest_tile = tfdd.tile;
 
	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
}
 

	
 
void Train::OnNewDay()
 
{
 
	if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
 

	
 
@@ -4563,14 +4563,14 @@ void Train::OnNewDay()
 

	
 
			this->profit_this_year -= cost.GetCost();
 
			this->running_ticks = 0;
 

	
 
			SubtractMoneyFromCompanyFract(this->owner, cost);
 

	
 
			InvalidateWindow(WC_VEHICLE_DETAILS, this->index);
 
			InvalidateWindowClasses(WC_TRAINS_LIST);
 
			SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
 
			SetWindowClassesDirty(WC_TRAINS_LIST);
 
		}
 
	} else if (this->IsEngine()) {
 
		/* Also age engines that aren't front engines */
 
		AgeVehicle(this);
 
	}
 
}
src/transparency_gui.cpp
Show inline comments
 
@@ -114,13 +114,13 @@ public:
 
			SndPlayFx(SND_15_BEEP);
 

	
 
			/* Redraw whole screen only if transparency is set */
 
			if (IsTransparencySet((TransparencyOption)(i - TTW_WIDGET_BEGIN))) {
 
				MarkWholeScreenDirty();
 
			} else {
 
				this->InvalidateWidget(TTW_WIDGET_BUTTONS);
 
				this->SetWidgetDirty(TTW_WIDGET_BUTTONS);
 
			}
 
		}
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
 
	{
src/tree_gui.cpp
Show inline comments
 
@@ -149,13 +149,13 @@ public:
 
		}
 
	}
 

	
 
	virtual void OnTimeout()
 
	{
 
		this->RaiseWidget(BTW_MANY_RANDOM);
 
		this->InvalidateWidget(BTW_MANY_RANDOM);
 
		this->SetWidgetDirty(BTW_MANY_RANDOM);
 
	}
 

	
 
	virtual void OnPlaceObjectAbort()
 
	{
 
		this->RaiseButtons();
 
	}
src/unmovable_cmd.cpp
Show inline comments
 
@@ -66,13 +66,13 @@ static CommandCost DestroyCompanyHQ(Comp
 

	
 
		DoClearSquare(t);
 
		DoClearSquare(t + TileDiffXY(0, 1));
 
		DoClearSquare(t + TileDiffXY(1, 0));
 
		DoClearSquare(t + TileDiffXY(1, 1));
 
		c->location_of_HQ = INVALID_TILE; // reset HQ position
 
		InvalidateWindow(WC_COMPANY, cid);
 
		SetWindowDirty(WC_COMPANY, cid);
 

	
 
		CargoPacket::InvalidateAllFrom(ST_HEADQUARTERS, cid);
 
	}
 

	
 
	/* cost of relocating company is 1% of company value */
 
	return CommandCost(EXPENSES_PROPERTY, CalculateCompanyValue(c) / 100);
 
@@ -124,13 +124,13 @@ CommandCost CmdBuildCompanyHQ(TileIndex 
 

	
 
		c->location_of_HQ = tile;
 

	
 
		MakeCompanyHQ(tile, _current_company);
 

	
 
		UpdateCompanyHQ(c, score);
 
		InvalidateWindow(WC_COMPANY, c->index);
 
		SetWindowDirty(WC_COMPANY, c->index);
 
	}
 

	
 
	return cost;
 
}
 

	
 
/** Purchase a land area. Actually you only purchase one tile, so
 
@@ -288,13 +288,13 @@ static CommandCost ClearTile_Unmovable(T
 

	
 
	if (IsStatue(tile)) {
 
		if (flags & DC_AUTO) return_cmd_error(STR_ERROR_OBJECT_IN_THE_WAY);
 

	
 
		TownID town = GetStatueTownID(tile);
 
		ClrBit(Town::Get(town)->statues, GetTileOwner(tile));
 
		InvalidateWindow(WC_TOWN_AUTHORITY, town);
 
		SetWindowDirty(WC_TOWN_AUTHORITY, town);
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		DoClearSquare(tile);
 
	}
 

	
 
@@ -483,13 +483,13 @@ static void ChangeTileOwner_Unmovable(Ti
 
			SetBit(t->statues, new_owner);
 
			SetTileOwner(tile, new_owner);
 
		} else {
 
			DoClearSquare(tile);
 
		}
 

	
 
		InvalidateWindow(WC_TOWN_AUTHORITY, town);
 
		SetWindowDirty(WC_TOWN_AUTHORITY, town);
 
	} else {
 
		DoClearSquare(tile);
 
	}
 
}
 

	
 
static CommandCost TerraformTile_Unmovable(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
src/vehicle.cpp
Show inline comments
 
@@ -84,13 +84,13 @@ bool Vehicle::NeedsAutorenewing(const Co
 

	
 
void VehicleServiceInDepot(Vehicle *v)
 
{
 
	v->date_of_last_service = _date;
 
	v->breakdowns_since_last_service = 0;
 
	v->reliability = Engine::Get(v->engine_type)->reliability;
 
	InvalidateWindow(WC_VEHICLE_DETAILS, v->index); // ensure that last service date and reliability are updated
 
	SetWindowDirty(WC_VEHICLE_DETAILS, v->index); // ensure that last service date and reliability are updated
 
}
 

	
 
bool Vehicle::NeedsServicing() const
 
{
 
	if (this->vehstatus & (VS_STOPPED | VS_CRASHED)) return false;
 

	
 
@@ -514,13 +514,13 @@ void Vehicle::PreDestructor()
 
	if (this->IsPrimaryVehicle()) {
 
		DeleteWindowById(WC_VEHICLE_VIEW, this->index);
 
		DeleteWindowById(WC_VEHICLE_ORDERS, this->index);
 
		DeleteWindowById(WC_VEHICLE_REFIT, this->index);
 
		DeleteWindowById(WC_VEHICLE_DETAILS, this->index);
 
		DeleteWindowById(WC_VEHICLE_TIMETABLE, this->index);
 
		InvalidateWindow(WC_COMPANY, this->owner);
 
		SetWindowDirty(WC_COMPANY, this->owner);
 
	}
 
	InvalidateWindowClassesData(GetWindowClassForVehicleType(this->type), 0);
 

	
 
	this->cargo.Truncate(0);
 
	DeleteVehicleOrders(this);
 
	DeleteDepotHighlightOfVehicle(this);
 
@@ -821,13 +821,13 @@ Vehicle *CheckClickOnVehicle(const ViewP
 
	return found;
 
}
 

	
 
void DecreaseVehicleValue(Vehicle *v)
 
{
 
	v->value -= v->value >> 8;
 
	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
	SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 
}
 

	
 
static const byte _breakdown_chance[64] = {
 
	  3,   3,   3,   3,   3,   3,   3,   3,
 
	  4,   4,   5,   5,   6,   6,   7,   7,
 
	  8,   8,   9,   9,  10,  10,  11,  11,
 
@@ -841,13 +841,13 @@ static const byte _breakdown_chance[64] 
 
void CheckVehicleBreakdown(Vehicle *v)
 
{
 
	int rel, rel_old;
 

	
 
	/* decrease reliability */
 
	v->reliability = rel = max((rel_old = v->reliability) - v->reliability_spd_dec, 0);
 
	if ((rel_old >> 8) != (rel >> 8)) InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
	if ((rel_old >> 8) != (rel >> 8)) SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 

	
 
	if (v->breakdown_ctr != 0 || (v->vehstatus & VS_STOPPED) ||
 
			_settings_game.difficulty.vehicle_breakdowns < 1 ||
 
			v->cur_speed < 5 || _game_mode == GM_MENU) {
 
		return;
 
	}
 
@@ -881,13 +881,13 @@ void AgeVehicle(Vehicle *v)
 
	int age = v->age - v->max_age;
 
	if (age == DAYS_IN_LEAP_YEAR * 0 || age == DAYS_IN_LEAP_YEAR * 1 ||
 
			age == DAYS_IN_LEAP_YEAR * 2 || age == DAYS_IN_LEAP_YEAR * 3 || age == DAYS_IN_LEAP_YEAR * 4) {
 
		v->reliability_spd_dec <<= 1;
 
	}
 

	
 
	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
	SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 

	
 
	/* Don't warn about non-primary or not ours vehicles or vehicles that are crashed */
 
	if (v->Previous() != NULL || v->owner != _local_company || (v->vehstatus & VS_CRASHED) != 0) return;
 

	
 
	/* Don't warn if a renew is active */
 
	if (Company::Get(v->owner)->settings.engine_renew && Engine::Get(v->engine_type)->company_avail != 0) return;
 
@@ -957,57 +957,57 @@ void VehicleEnterDepot(Vehicle *v)
 
	/* Always work with the front of the vehicle */
 
	assert(v == v->First());
 

	
 
	switch (v->type) {
 
		case VEH_TRAIN: {
 
			Train *t = Train::From(v);
 
			InvalidateWindowClasses(WC_TRAINS_LIST);
 
			SetWindowClassesDirty(WC_TRAINS_LIST);
 
			/* Clear path reservation */
 
			SetDepotReservation(t->tile, false);
 
			if (_settings_client.gui.show_track_reservation) MarkTileDirtyByTile(t->tile);
 

	
 
			UpdateSignalsOnSegment(t->tile, INVALID_DIAGDIR, t->owner);
 
			t->load_unload_time_rem = 0;
 
			ClrBit(t->flags, VRF_TOGGLE_REVERSE);
 
			TrainConsistChanged(t, true);
 
			break;
 
		}
 

	
 
		case VEH_ROAD:
 
			InvalidateWindowClasses(WC_ROADVEH_LIST);
 
			SetWindowClassesDirty(WC_ROADVEH_LIST);
 
			break;
 

	
 
		case VEH_SHIP:
 
			InvalidateWindowClasses(WC_SHIPS_LIST);
 
			SetWindowClassesDirty(WC_SHIPS_LIST);
 
			Ship::From(v)->state = TRACK_BIT_DEPOT;
 
			RecalcShipStuff(v);
 
			break;
 

	
 
		case VEH_AIRCRAFT:
 
			InvalidateWindowClasses(WC_AIRCRAFT_LIST);
 
			SetWindowClassesDirty(WC_AIRCRAFT_LIST);
 
			HandleAircraftEnterHangar(Aircraft::From(v));
 
			break;
 
		default: NOT_REACHED();
 
	}
 

	
 
	if (v->type != VEH_TRAIN) {
 
		/* Trains update the vehicle list when the first unit enters the depot and calls VehicleEnterDepot() when the last unit enters.
 
		 * We only increase the number of vehicles when the first one enters, so we will not need to search for more vehicles in the depot */
 
		InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 
	}
 
	InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
	SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
 

	
 
	v->vehstatus |= VS_HIDDEN;
 
	v->cur_speed = 0;
 

	
 
	VehicleServiceInDepot(v);
 

	
 
	TriggerVehicle(v, VEHICLE_TRIGGER_DEPOT);
 

	
 
	if (v->current_order.IsType(OT_GOTO_DEPOT)) {
 
		InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
		SetWindowDirty(WC_VEHICLE_VIEW, v->index);
 

	
 
		const Order *real_order = v->GetOrder(v->cur_order_index);
 
		Order t = v->current_order;
 
		v->current_order.MakeDummy();
 

	
 
		/* Test whether we are heading for this depot. If not, do nothing.
 
@@ -1432,16 +1432,16 @@ void Vehicle::BeginLoading()
 
	}
 

	
 
	Station::Get(this->last_station_visited)->loading_vehicles.push_back(this);
 

	
 
	PrepareUnload(this);
 

	
 
	InvalidateWindow(GetWindowClassForVehicleType(this->type), this->owner);
 
	InvalidateWindowWidget(WC_VEHICLE_VIEW, this->index, VVW_WIDGET_START_STOP_VEH);
 
	InvalidateWindow(WC_VEHICLE_DETAILS, this->index);
 
	InvalidateWindow(WC_STATION_VIEW, this->last_station_visited);
 
	SetWindowDirty(GetWindowClassForVehicleType(this->type), this->owner);
 
	SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, VVW_WIDGET_START_STOP_VEH);
 
	SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
 
	SetWindowDirty(WC_STATION_VIEW, this->last_station_visited);
 

	
 
	Station::Get(this->last_station_visited)->MarkTilesDirty(true);
 
	this->cur_speed = 0;
 
	this->MarkDirty();
 
}
 

	
 
@@ -1514,25 +1514,25 @@ CommandCost Vehicle::SendToDepot(DoComma
 
			/* We called with a different DEPOT_SERVICE setting.
 
			 * Now we change the setting to apply the new one and let the vehicle head for the same depot.
 
			 * Note: the if is (true for requesting service == true for ordered to stop in depot)          */
 
			if (flags & DC_EXEC) {
 
				this->current_order.SetDepotOrderType(ODTF_MANUAL);
 
				this->current_order.SetDepotActionType(halt_in_depot ? ODATF_SERVICE_ONLY : ODATFB_HALT);
 
				InvalidateWindowWidget(WC_VEHICLE_VIEW, this->index, VVW_WIDGET_START_STOP_VEH);
 
				SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, VVW_WIDGET_START_STOP_VEH);
 
			}
 
			return CommandCost();
 
		}
 

	
 
		if (command & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of depot orders
 
		if (flags & DC_EXEC) {
 
			/* If the orders to 'goto depot' are in the orders list (forced servicing),
 
			 * then skip to the next order; effectively cancelling this forced service */
 
			if (this->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) this->IncrementOrderIndex();
 

	
 
			this->current_order.MakeDummy();
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, this->index, VVW_WIDGET_START_STOP_VEH);
 
			SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, VVW_WIDGET_START_STOP_VEH);
 
		}
 
		return CommandCost();
 
	}
 

	
 
	TileIndex location;
 
	DestinationID destination;
 
@@ -1543,13 +1543,13 @@ CommandCost Vehicle::SendToDepot(DoComma
 
	if (flags & DC_EXEC) {
 
		if (this->current_order.IsType(OT_LOADING)) this->LeaveStation();
 

	
 
		this->dest_tile = location;
 
		this->current_order.MakeGoToDepot(destination, ODTF_MANUAL);
 
		if (!(command & DEPOT_SERVICE)) this->current_order.SetDepotActionType(ODATFB_HALT);
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, this->index, VVW_WIDGET_START_STOP_VEH);
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, VVW_WIDGET_START_STOP_VEH);
 

	
 
		/* If there is no depot in front, reverse automatically (trains only) */
 
		if (this->type == VEH_TRAIN && reverse) DoCommand(this->tile, this->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION);
 

	
 
		if (this->type == VEH_AIRCRAFT) {
 
			Aircraft *a = Aircraft::From(this);
 
@@ -1642,14 +1642,14 @@ void StopAllVehicles()
 
{
 
	Vehicle *v;
 
	FOR_ALL_VEHICLES(v) {
 
		/* Code ripped from CmdStartStopTrain. Can't call it, because of
 
		 * ownership problems, so we'll duplicate some code, for now */
 
		v->vehstatus |= VS_STOPPED;
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
 
	}
 
}
 

	
 
void VehiclesYearlyLoop()
 
{
 
	Vehicle *v;
 
@@ -1669,13 +1669,13 @@ void VehiclesYearlyLoop()
 
				}
 
				AI::NewEvent(v->owner, new AIEventVehicleUnprofitable(v->index));
 
			}
 

	
 
			v->profit_last_year = v->profit_this_year;
 
			v->profit_this_year = 0;
 
			InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
			SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 
		}
 
	}
 
}
 

	
 

	
 
/**
src/vehicle_cmd.cpp
Show inline comments
 
@@ -103,15 +103,15 @@ CommandCost CmdStartStopVehicle(TileInde
 

	
 
	if (flags & DC_EXEC) {
 
		if (v->IsStoppedInDepot() && (flags & DC_AUTOREPLACE) == 0) DeleteVehicleNews(p1, STR_NEWS_TRAIN_IS_WAITING + v->type);
 

	
 
		v->vehstatus ^= VS_STOPPED;
 
		if (v->type != VEH_TRAIN) v->cur_speed = 0; // trains can stop 'slowly'
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
		InvalidateWindowClasses(GetWindowClassForVehicleType(v->type));
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
 
		SetWindowClassesDirty(GetWindowClassForVehicleType(v->type));
 
	}
 
	return CommandCost();
 
}
 

	
 
/** Starts or stops a lot of vehicles
 
 * @param tile Tile of the depot where the vehicles are started/stopped (only used for depots)
 
@@ -564,11 +564,11 @@ CommandCost CmdChangeServiceInt(TileInde
 

	
 
	uint16 serv_int = GetServiceIntervalClamped(p2, v->owner); // Double check the service interval from the user-input
 
	if (serv_int != p2) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		v->service_interval = serv_int;
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 
	}
 

	
 
	return CommandCost();
 
}
src/viewport.cpp
Show inline comments
 
@@ -459,16 +459,16 @@ Point GetTileZoomCenterWindow(bool in, W
 
 * @param vp pointer to the viewport whose zoom-level the buttons represent
 
 * @param widget_zoom_in widget index for window with zoom-in button
 
 * @param widget_zoom_out widget index for window with zoom-out button */
 
void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out)
 
{
 
	w->SetWidgetDisabledState(widget_zoom_in, vp->zoom == ZOOM_LVL_MIN);
 
	w->InvalidateWidget(widget_zoom_in);
 
	w->SetWidgetDirty(widget_zoom_in);
 

	
 
	w->SetWidgetDisabledState(widget_zoom_out, vp->zoom == ZOOM_LVL_MAX);
 
	w->InvalidateWidget(widget_zoom_out);
 
	w->SetWidgetDirty(widget_zoom_out);
 
}
 

	
 
/**
 
 * Draws a ground sprite at a specific world-coordinate.
 
 *
 
 * @param image the image to draw.
src/water_cmd.cpp
Show inline comments
 
@@ -834,14 +834,14 @@ static void FloodVehicle(Vehicle *v)
 
					break;
 
			}
 
		} else {
 
			return;
 
		}
 

	
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
 

	
 
		AI::NewEvent(v->owner, new AIEventVehicleCrashed(v->index, v->tile, AIEventVehicleCrashed::CRASH_FLOODED));
 
		SetDParam(0, pass);
 
		AddVehicleNewsItem(STR_NEWS_DISASTER_FLOOD_VEHICLE,
 
			NS_ACCIDENT,
 
			v->index);
src/widget.cpp
Show inline comments
 
@@ -988,13 +988,13 @@ inline void NWidgetBase::StoreSizePositi
 
 */
 

	
 
/**
 
 * Mark the widget as 'dirty' (in need of repaint).
 
 * @param w Window owning the widget.
 
 */
 
void NWidgetBase::Invalidate(const Window *w) const
 
void NWidgetBase::SetDirty(const Window *w) const
 
{
 
	int abs_left = w->left + this->pos_x;
 
	int abs_top = w->top + this->pos_y;
 
	SetDirtyBlocks(abs_left, abs_top, abs_left + this->current_x, abs_top + this->current_y);
 
}
 

	
 
@@ -1651,13 +1651,13 @@ void NWidgetSpacer::StoreWidgets(Widget 
 

	
 
void NWidgetSpacer::Draw(const Window *w)
 
{
 
	/* Spacer widget is never visible. */
 
}
 

	
 
void NWidgetSpacer::Invalidate(const Window *w) const
 
void NWidgetSpacer::SetDirty(const Window *w) const
 
{
 
	/* Spacer widget never need repainting. */
 
}
 

	
 
NWidgetCore *NWidgetSpacer::GetWidgetFromPos(int x, int y)
 
{
src/widget_type.h
Show inline comments
 
@@ -206,13 +206,13 @@ public:
 
	};
 

	
 
	inline uint GetHorizontalStepSize(SizingType sizing) const;
 
	inline uint GetVerticalStepSize(SizingType sizing) const;
 

	
 
	virtual void Draw(const Window *w) = 0;
 
	virtual void Invalidate(const Window *w) const;
 
	virtual void SetDirty(const Window *w) const;
 

	
 
	WidgetType type;      ///< Type of the widget / nested widget.
 
	bool fill_x;          ///< Allow horizontal filling from initial size.
 
	bool fill_y;          ///< Allow vertical filling from initial size.
 
	uint resize_x;        ///< Horizontal resize step (\c 0 means not resizable).
 
	uint resize_y;        ///< Vertical resize step (\c 0 means not resizable).
 
@@ -455,13 +455,13 @@ public:
 

	
 
	void SetupSmallestSize(Window *w, bool init_array);
 
	void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl);
 
	/* virtual */ void FillNestedArray(NWidgetCore **array, uint length);
 

	
 
	/* virtual */ void Draw(const Window *w);
 
	/* virtual */ void Invalidate(const Window *w) const;
 
	/* virtual */ void SetDirty(const Window *w) const;
 
	/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
 
};
 

	
 
/** Nested widget with a child.
 
 * @ingroup NestedWidgets */
 
class NWidgetBackground : public NWidgetCore {
src/widgets/dropdown.cpp
Show inline comments
 
@@ -101,13 +101,13 @@ struct DropdownWindow : Window {
 

	
 
	~DropdownWindow()
 
	{
 
		Window *w2 = FindWindowById(this->parent_wnd_class, this->parent_wnd_num);
 
		if (w2 != NULL) {
 
			w2->RaiseWidget(this->parent_button);
 
			w2->InvalidateWidget(this->parent_button);
 
			w2->SetWidgetDirty(this->parent_button);
 
		}
 

	
 
		DeleteDropDownList(this->list);
 
	}
 

	
 
	bool GetDropDownItem(int &value)
 
@@ -249,13 +249,13 @@ void ShowDropDownList(Window *w, DropDow
 
{
 
	static Widget *generated_dropdown_menu_widgets = NULL;
 

	
 
	DeleteWindowById(WC_DROPDOWN_MENU, 0);
 

	
 
	w->LowerWidget(button);
 
	w->InvalidateWidget(button);
 
	w->SetWidgetDirty(button);
 

	
 
	/* Our parent's button widget is used to determine where to place the drop
 
	 * down list window. */
 
	Rect wi_rect;
 
	Colours wi_colour;
 
	if (w->nested_array != NULL) {
src/window.cpp
Show inline comments
 
@@ -104,15 +104,15 @@ void SetFocusedWindow(Window *w)
 
	if (_focused_window == w) return;
 

	
 
	/* Invalidate focused widget */
 
	if (_focused_window != NULL) {
 
		if (_focused_window->focused_widget != NULL) {
 
			uint focused_widget_id = _focused_window->focused_widget - _focused_window->widget;
 
			_focused_window->InvalidateWidget(focused_widget_id);
 
			_focused_window->SetWidgetDirty(focused_widget_id);
 
		}
 
		if (_focused_window->nested_focus != NULL) _focused_window->nested_focus->Invalidate(_focused_window);
 
		if (_focused_window->nested_focus != NULL) _focused_window->nested_focus->SetDirty(_focused_window);
 
	}
 

	
 
	/* Remember which window was previously focused */
 
	Window *old_focused = _focused_window;
 
	_focused_window = w;
 

	
 
@@ -149,13 +149,13 @@ bool Window::SetFocusedWidget(byte widge
 
	if (this->widget != NULL) {
 
		/* Do nothing if widget_index is already focused, or if it wasn't a valid widget. */
 
		if (widget_index >= this->widget_count || this->widget + widget_index == this->focused_widget) return false;
 

	
 
		if (this->focused_widget != NULL) {
 
			/* Repaint the widget that lost focus. A focused edit box may else leave the caret on the screen. */
 
			this->InvalidateWidget(this->focused_widget - this->widget);
 
			this->SetWidgetDirty(this->focused_widget - this->widget);
 
		}
 
		this->focused_widget = &this->widget[widget_index];
 
		return true;
 
	}
 

	
 
	if (this->nested_array != NULL) {
 
@@ -164,13 +164,13 @@ bool Window::SetFocusedWidget(byte widge
 

	
 
		assert(this->nested_array[widget_index] != NULL); // Setting focus to a non-existing widget is a bad idea.
 
		if (this->nested_focus != NULL) {
 
			if (this->nested_array[widget_index] == this->nested_focus) return false;
 

	
 
			/* Repaint the widget that lost focus. A focused edit box may else leave the caret on the screen. */
 
			this->nested_focus->Invalidate(this);
 
			this->nested_focus->SetDirty(this);
 
		}
 
		this->nested_focus = this->nested_array[widget_index];
 
		return true;
 
	}
 
	NOT_REACHED();
 
}
 
@@ -243,53 +243,53 @@ void CDECL Window::SetWidgetsLoweredStat
 
void Window::RaiseButtons(bool autoraise)
 
{
 
	if (this->widget != NULL) {
 
		for (uint i = 0; i < this->widget_count; i++) {
 
			if ((!autoraise || (this->widget[i].type & WWB_PUSHBUTTON)) && this->IsWidgetLowered(i)) {
 
				this->RaiseWidget(i);
 
				this->InvalidateWidget(i);
 
				this->SetWidgetDirty(i);
 
			}
 
		}
 
	}
 
	if (this->nested_array != NULL) {
 
		for (uint i = 0; i < this->nested_array_size; i++) {
 
			if (this->nested_array[i] != NULL && (!autoraise || (this->nested_array[i]->type & WWB_PUSHBUTTON)) && this->IsWidgetLowered(i)) {
 
				this->RaiseWidget(i);
 
				this->InvalidateWidget(i);
 
				this->SetWidgetDirty(i);
 
			}
 
		}
 
	}
 
}
 

	
 
/**
 
 * Invalidate a widget, i.e. mark it as being changed and in need of redraw.
 
 * @param widget_index the widget to redraw.
 
 */
 
void Window::InvalidateWidget(byte widget_index) const
 
void Window::SetWidgetDirty(byte widget_index) const
 
{
 
	if (this->widget != NULL) {
 
		const Widget *wi = &this->widget[widget_index];
 

	
 
		/* Don't redraw the window if the widget is invisible or of no-type */
 
		if (wi->type == WWT_EMPTY || IsWidgetHidden(widget_index)) return;
 

	
 
		SetDirtyBlocks(this->left + wi->left, this->top + wi->top, this->left + wi->right + 1, this->top + wi->bottom + 1);
 
	}
 
	if (this->nested_array != NULL) this->nested_array[widget_index]->Invalidate(this);
 
	if (this->nested_array != NULL) this->nested_array[widget_index]->SetDirty(this);
 
}
 

	
 
/**
 
 * Do all things to make a button look clicked and mark it to be
 
 * unclicked in a few ticks.
 
 * @param widget the widget to "click"
 
 */
 
void Window::HandleButtonClick(byte widget)
 
{
 
	this->LowerWidget(widget);
 
	this->flags4 |= WF_TIMEOUT_BEGIN;
 
	this->InvalidateWidget(widget);
 
	this->SetWidgetDirty(widget);
 
}
 

	
 
/**
 
 * Return a widget of the requested type from the window.
 
 * @param widget_type the widget type to look for
 
 */
 
@@ -406,19 +406,19 @@ static void DispatchLeftClickEvent(Windo
 

	
 
		if ((w->desc_flags & WDF_RESIZABLE) && widget_type == WWT_RESIZEBOX) {
 
			/* When the resize widget is on the left size of the window
 
			 * we assume that that button is used to resize to the left. */
 
			int left_pos = (wi != NULL) ? wi->left : nw->pos_x;
 
			StartWindowSizing(w, left_pos < (w->width / 2));
 
			w->InvalidateWidget(widget_index);
 
			w->SetWidgetDirty(widget_index);
 
			return;
 
		}
 

	
 
		if ((w->desc_flags & WDF_STICKY_BUTTON) && widget_type == WWT_STICKYBOX) {
 
			w->flags4 ^= WF_STICKY;
 
			w->InvalidateWidget(widget_index);
 
			w->SetWidgetDirty(widget_index);
 
			return;
 
		}
 
	}
 

	
 
	Point pt = { x, y };
 

	
 
@@ -2437,13 +2437,13 @@ void UpdateWindows()
 

	
 
/**
 
 * Mark window as dirty (in need of repainting)
 
 * @param cls Window class
 
 * @param number Window number in that class
 
 */
 
void InvalidateWindow(WindowClass cls, WindowNumber number)
 
void SetWindowDirty(WindowClass cls, WindowNumber number)
 
{
 
	const Window *w;
 
	FOR_ALL_WINDOWS_FROM_BACK(w) {
 
		if (w->window_class == cls && w->window_number == number) w->SetDirty();
 
	}
 
}
 
@@ -2451,27 +2451,27 @@ void InvalidateWindow(WindowClass cls, W
 
/**
 
 * Mark a particular widget in a particular window as dirty (in need of repainting)
 
 * @param cls Window class
 
 * @param number Window number in that class
 
 * @param widget_index Index number of the widget that needs repainting
 
 */
 
void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index)
 
void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, byte widget_index)
 
{
 
	const Window *w;
 
	FOR_ALL_WINDOWS_FROM_BACK(w) {
 
		if (w->window_class == cls && w->window_number == number) {
 
			w->InvalidateWidget(widget_index);
 
			w->SetWidgetDirty(widget_index);
 
		}
 
	}
 
}
 

	
 
/**
 
 * Mark all windows of a particular class as dirty (in need of repainting)
 
 * @param cls Window class
 
 */
 
void InvalidateWindowClasses(WindowClass cls)
 
void SetWindowClassesDirty(WindowClass cls)
 
{
 
	Window *w;
 
	FOR_ALL_WINDOWS_FROM_BACK(w) {
 
		if (w->window_class == cls) w->SetDirty();
 
	}
 
}
src/window_func.h
Show inline comments
 
@@ -36,14 +36,14 @@ void DeleteAllNonVitalWindows();
 
void DeleteConstructionWindows();
 
void HideVitalWindows();
 
void ShowVitalWindows();
 

	
 
void ReInitAllWindows();
 

	
 
void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index);
 
void InvalidateWindow(WindowClass cls, WindowNumber number);
 
void InvalidateWindowClasses(WindowClass cls);
 
void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, byte widget_index);
 
void SetWindowDirty(WindowClass cls, WindowNumber number);
 
void SetWindowClassesDirty(WindowClass cls);
 

	
 
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force = true);
 
void DeleteWindowByClass(WindowClass cls);
 

	
 
#endif /* WINDOW_FUNC_H */
src/window_gui.h
Show inline comments
 
@@ -616,13 +616,13 @@ public:
 
	const Widget *GetWidgetOfType(WidgetType widget_type) const;
 

	
 
	void RaiseButtons(bool autoraise = false);
 
	void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets, ...);
 
	void CDECL SetWidgetsHiddenState(bool hidden_stat, int widgets, ...);
 
	void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets, ...);
 
	void InvalidateWidget(byte widget_index) const;
 
	void SetWidgetDirty(byte widget_index) const;
 

	
 
	void DrawWidgets() const;
 
	void DrawViewport() const;
 
	void DrawSortButtonState(int widget, SortButtonState state) const;
 

	
 
	void DeleteChildWindows() const;
0 comments (0 inline, 0 general)