changeset 9116:44beb31166aa draft

(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
author rubidium <rubidium@openttd.org>
date Tue, 06 May 2008 22:08:18 +0000
parents c93fe0a517f2
children 453c3d26f4bc
files src/airport_gui.cpp src/autoreplace_gui.cpp src/build_vehicle_gui.cpp src/cheat_gui.cpp src/console.cpp src/depot_gui.cpp src/dock_gui.cpp src/genworld_gui.cpp src/graph_gui.cpp src/group_gui.cpp src/industry_gui.cpp src/main_gui.cpp src/misc_gui.cpp src/music_gui.cpp src/newgrf_gui.cpp src/news_gui.cpp src/order_gui.cpp src/osk_gui.cpp src/player_gui.cpp src/rail_gui.cpp src/road_gui.cpp src/settings.cpp src/settings_gui.cpp src/smallmap_gui.cpp src/station_gui.cpp src/statusbar_gui.cpp src/terraform_gui.cpp src/timetable_gui.cpp src/toolbar_gui.cpp src/town_gui.cpp src/transparency_gui.cpp src/vehicle_gui.cpp src/widget.cpp src/window.cpp
diffstat 34 files changed, 241 insertions(+), 246 deletions(-) [+]
line wrap: on
line diff
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -205,9 +205,9 @@
 			int text_end = DrawStationCoverageAreaText(2, 206, SCT_ALL, rad, false);
 			text_end = DrawStationCoverageAreaText(2, text_end + 4, SCT_ALL, rad, true) + 4;
 			if (text_end != w->widget[BAW_BOTTOMPANEL].bottom) {
-				SetWindowDirty(w);
+				w->SetDirty();
 				ResizeWindowForWidget(w, BAW_BOTTOMPANEL, 0, text_end - w->widget[BAW_BOTTOMPANEL].bottom);
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 			break;
 		}
@@ -221,7 +221,7 @@
 					_selected_airport_type = e->we.click.widget - BAW_SMALL_AIRPORT;
 					w->LowerWidget(_selected_airport_type + BAW_SMALL_AIRPORT);
 					SndPlayFx(SND_15_BEEP);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case BAW_BTN_DONTHILIGHT: case BAW_BTN_DOHILIGHT:
@@ -229,7 +229,7 @@
 					w->SetWidgetLoweredState(BAW_BTN_DONTHILIGHT, !_station_show_coverage);
 					w->SetWidgetLoweredState(BAW_BTN_DOHILIGHT, _station_show_coverage);
 					SndPlayFx(SND_15_BEEP);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 			}
 		} break;
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -368,9 +368,9 @@
 					int text_end = DrawVehiclePurchaseInfo(wi->left + 2, wi->top + 1, wi->right - wi->left - 2, WP(w, replaceveh_d).sel_engine[i]);
 
 					if (text_end > wi->bottom) {
-						SetWindowDirty(w);
+						w->SetDirty();
 						ResizeWindowForWidget(w, i == 0 ? RVW_WIDGET_LEFT_DETAILS : RVW_WIDGET_RIGHT_DETAILS, 0, text_end - wi->bottom);
-						SetWindowDirty(w);
+						w->SetDirty();
 					}
 				}
 			}
@@ -383,7 +383,7 @@
 					WP(w, replaceveh_d).wagon_btnstate = !(WP(w, replaceveh_d).wagon_btnstate);
 					WP(w, replaceveh_d).update_left = true;
 					WP(w, replaceveh_d).init_lists  = true;
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case RVW_WIDGET_TRAIN_RAILTYPE_DROPDOWN: /* Railtype selection dropdown menu */
@@ -422,7 +422,7 @@
 							WP(w, replaceveh_d).update_right = true;
 							WP(w, replaceveh_d).init_lists   = true;
 						}
-						SetWindowDirty(w);
+						w->SetDirty();
 						}
 					break;
 					}
@@ -441,7 +441,7 @@
 			WP(w, replaceveh_d).update_left  = true;
 			WP(w, replaceveh_d).update_right = true;
 			WP(w, replaceveh_d).init_lists   = true;
-			SetWindowDirty(w);
+			w->SetDirty();
 		} break;
 
 		case WE_RESIZE:
@@ -472,7 +472,7 @@
 		case WE_INVALIDATE_DATA:
 			if (_rebuild_left_list) WP(w, replaceveh_d).update_left = true;
 			if (_rebuild_right_list) WP(w, replaceveh_d).update_right = true;
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_DESTROY:
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -1011,9 +1011,9 @@
 		int text_end = DrawVehiclePurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, bv->sel_engine);
 
 		if (text_end > wi->bottom) {
-			SetWindowDirty(w);
+			w->SetDirty();
 			ResizeWindowForWidget(w, BUILD_VEHICLE_WIDGET_PANEL, 0, text_end - wi->bottom);
-			SetWindowDirty(w);
+			w->SetDirty();
 		}
 	}
 
@@ -1029,14 +1029,14 @@
 			bv->descending_sort_order ^= true;
 			_last_sort_order[bv->vehicle_type] = bv->descending_sort_order;
 			bv->regenerate_list = true;
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case BUILD_VEHICLE_WIDGET_LIST: {
 			uint i = (e->we.click.pt.y - w->widget[BUILD_VEHICLE_WIDGET_LIST].top) / GetVehicleListHeight(bv->vehicle_type) + w->vscroll.pos;
 			uint num_items = EngList_Count(&bv->eng_list);
 			bv->sel_engine = (i < num_items) ? bv->eng_list[i] : INVALID_ENGINE;
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 		}
 
@@ -1108,7 +1108,7 @@
 
 		case WE_INVALIDATE_DATA:
 			bv->regenerate_list = true;
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_DESTROY:
@@ -1157,7 +1157,7 @@
 				_last_sort_criteria[bv->vehicle_type] = bv->sort_criteria;
 				bv->regenerate_list = true;
 			}
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_RESIZE:
--- a/src/cheat_gui.cpp
+++ b/src/cheat_gui.cpp
@@ -207,12 +207,12 @@
 
 			w->flags4 |= 5 << WF_TIMEOUT_SHL;
 
-			SetWindowDirty(w);
+			w->SetDirty();
 		} break;
 
 		case WE_TIMEOUT:
 			WP(w, def_d).data_1 = 0;
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 	}
 }
--- a/src/console.cpp
+++ b/src/console.cpp
@@ -107,8 +107,7 @@
 			break;
 		}
 		case WE_MOUSELOOP:
-			if (HandleCaret(&_iconsole_cmdline))
-				SetWindowDirty(w);
+			if (HandleCaret(&_iconsole_cmdline)) w->SetDirty();
 			break;
 		case WE_DESTROY:
 			_iconsole_mode = ICONSOLE_CLOSED;
@@ -118,11 +117,11 @@
 			switch (e->we.keypress.keycode) {
 				case WKC_UP:
 					IConsoleHistoryNavigate(+1);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				case WKC_DOWN:
 					IConsoleHistoryNavigate(-1);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				case WKC_SHIFT | WKC_PAGEUP:
 					if (iconsole_scroll - (w->height / ICON_LINE_HEIGHT) - 1 < 0) {
@@ -130,7 +129,7 @@
 					} else {
 						iconsole_scroll -= (w->height / ICON_LINE_HEIGHT) - 1;
 					}
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				case WKC_SHIFT | WKC_PAGEDOWN:
 					if (iconsole_scroll + (w->height / ICON_LINE_HEIGHT) - 1 > ICON_BUFFER) {
@@ -138,7 +137,7 @@
 					} else {
 						iconsole_scroll += (w->height / ICON_LINE_HEIGHT) - 1;
 					}
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				case WKC_SHIFT | WKC_UP:
 					if (iconsole_scroll <= 0) {
@@ -146,7 +145,7 @@
 					} else {
 						--iconsole_scroll;
 					}
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				case WKC_SHIFT | WKC_DOWN:
 					if (iconsole_scroll >= ICON_BUFFER) {
@@ -154,7 +153,7 @@
 					} else {
 						++iconsole_scroll;
 					}
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				case WKC_BACKQUOTE:
 					IConsoleSwitch();
@@ -174,7 +173,7 @@
 				case (WKC_CTRL | 'V'):
 					if (InsertTextBufferClipboard(&_iconsole_cmdline)) {
 						IConsoleResetHistoryPos();
-						SetWindowDirty(w);
+						w->SetDirty();
 					}
 					break;
 				case (WKC_CTRL | 'L'):
@@ -182,18 +181,18 @@
 					break;
 				case (WKC_CTRL | 'U'):
 					DeleteTextBufferAll(&_iconsole_cmdline);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				case WKC_BACKSPACE: case WKC_DELETE:
 					if (DeleteTextBufferChar(&_iconsole_cmdline, e->we.keypress.keycode)) {
 						IConsoleResetHistoryPos();
-						SetWindowDirty(w);
+						w->SetDirty();
 					}
 					break;
 				case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
 					if (MoveTextBufferPos(&_iconsole_cmdline, e->we.keypress.keycode)) {
 						IConsoleResetHistoryPos();
-						SetWindowDirty(w);
+						w->SetDirty();
 					}
 					break;
 				default:
@@ -201,7 +200,7 @@
 						iconsole_scroll = ICON_BUFFER;
 						InsertTextBufferChar(&_iconsole_cmdline, e->we.keypress.key);
 						IConsoleResetHistoryPos();
-						SetWindowDirty(w);
+						w->SetDirty();
 					} else {
 						e->we.keypress.cont = true;
 					}
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -440,7 +440,7 @@
 				int image = v->GetImage(DIR_W);
 
 				WP(w, depot_d).sel = v->index;
-				SetWindowDirty(w);
+				w->SetDirty();
 				SetObjectToPlaceWnd(image, GetVehiclePalette(v), VHM_DRAG, w);
 				_cursor.vehchain = _ctrl_pressed;
 			}
@@ -903,7 +903,7 @@
 					VehicleID sel = WP(w, depot_d).sel;
 
 					WP(w, depot_d).sel = INVALID_VEHICLE;
-					SetWindowDirty(w);
+					w->SetDirty();
 
 					if (WP(w, depot_d).type == VEH_TRAIN) {
 						GetDepotVehiclePtData gdvp;
@@ -940,7 +940,7 @@
 
 						v = GetVehicle(WP(w, depot_d).sel);
 						WP(w, depot_d).sel = INVALID_VEHICLE;
-						SetWindowDirty(w);
+						w->SetDirty();
 
 						sell_cmd = (v->type == VEH_TRAIN && (e->we.click.widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0;
 
@@ -964,7 +964,7 @@
 					break;
 				default:
 					WP(w, depot_d).sel = INVALID_VEHICLE;
-					SetWindowDirty(w);
+					w->SetDirty();
 			}
 			_cursor.vehchain = false;
 			break;
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -257,9 +257,9 @@
 		int text_end = DrawStationCoverageAreaText(4, 50, SCT_ALL, rad, false);
 		text_end = DrawStationCoverageAreaText(4, text_end + 4, SCT_ALL, rad, true) + 4;
 		if (text_end != w->widget[2].bottom) {
-			SetWindowDirty(w);
+			w->SetDirty();
 			ResizeWindowForWidget(w, 2, 0, text_end - w->widget[2].bottom);
-			SetWindowDirty(w);
+			w->SetDirty();
 		}
 
 		break;
@@ -273,7 +273,7 @@
 				_station_show_coverage = (e->we.click.widget != 3);
 				w->LowerWidget(_station_show_coverage + 3);
 				SndPlayFx(SND_15_BEEP);
-				SetWindowDirty(w);
+				w->SetDirty();
 				break;
 		}
 		break;
@@ -348,7 +348,7 @@
 			w->LowerWidget(_ship_depot_direction + 3);
 			SndPlayFx(SND_15_BEEP);
 			UpdateDocksDirection();
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 		}
 	} break;
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -372,7 +372,7 @@
 					_patches_newgame.generation_seed = InteractiveRandom();
 					snprintf(_genseed_buffer, lengthof(_genseed_buffer), "%u", _patches_newgame.generation_seed);
 					UpdateTextBufferSize(&_genseed_query.text);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case GLAND_RANDOM_EDITBOX: // edit box for random seed
@@ -408,7 +408,7 @@
 					/* Don't allow too fast scrolling */
 					if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
 						w->HandleButtonClick(e->we.click.widget);
-						SetWindowDirty(w);
+						w->SetDirty();
 
 						_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + e->we.click.widget - GLAND_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
 					}
@@ -426,7 +426,7 @@
 					/* Don't allow too fast scrolling */
 					if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
 						w->HandleButtonClick(e->we.click.widget);
-						SetWindowDirty(w);
+						w->SetDirty();
 
 						_patches_newgame.snow_line_height = Clamp(_patches_newgame.snow_line_height + e->we.click.widget - GLAND_SNOW_LEVEL_TEXT, 2, MAX_SNOWLINE_HEIGHT);
 					}
@@ -520,7 +520,7 @@
 					DoCommandP(0, 13, _opt_newgame.diff.quantity_sea_lakes, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
 					break;
 			}
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_ON_EDIT_TEXT:
@@ -539,7 +539,7 @@
 						break;
 				}
 
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 			break;
 	}
@@ -697,7 +697,7 @@
 					/* Don't allow too fast scrolling */
 					if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
 						w->HandleButtonClick(e->we.click.widget);
-						SetWindowDirty(w);
+						w->SetDirty();
 
 						_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + e->we.click.widget - CSCEN_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
 					}
@@ -715,7 +715,7 @@
 					/* Don't allow too fast scrolling */
 					if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
 						w->HandleButtonClick(e->we.click.widget);
-						SetWindowDirty(w);
+						w->SetDirty();
 
 						_patches_newgame.se_flat_world_height = Clamp(_patches_newgame.se_flat_world_height + e->we.click.widget - CSCEN_FLAT_LAND_HEIGHT_TEXT, 0, MAX_TILE_HEIGHT);
 					}
@@ -735,7 +735,7 @@
 				case CSCEN_MAPSIZE_X_PULLDOWN: _patches_newgame.map_x = e->we.dropdown.index; break;
 				case CSCEN_MAPSIZE_Y_PULLDOWN: _patches_newgame.map_y = e->we.dropdown.index; break;
 			}
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_ON_EDIT_TEXT:
@@ -754,7 +754,7 @@
 						break;
 				}
 
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 			break;
 	}
@@ -865,7 +865,7 @@
 			SetDParam(1, _tp.total);
 			DrawStringCentered(90, 58, STR_GENERATION_PROGRESS, TC_FROMSTRING);
 
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 	}
 }
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -304,7 +304,7 @@
 
 			ToggleBit(_legend_excluded_players, e->we.click.widget - 3);
 			w->ToggleWidgetLoweredState(e->we.click.widget);
-			SetWindowDirty(w);
+			w->SetDirty();
 			InvalidateWindow(WC_INCOME_GRAPH, 0);
 			InvalidateWindow(WC_OPERATING_PROFIT, 0);
 			InvalidateWindow(WC_DELIVERED_CARGO, 0);
@@ -783,7 +783,7 @@
 			if (e->we.click.widget >= 3) {
 				ToggleBit(_legend_excluded_cargo, e->we.click.widget - 3);
 				w->ToggleWidgetLoweredState(e->we.click.widget);
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 			break;
 	}
@@ -840,7 +840,7 @@
 		if (!HasBit(_legend_excluded_cargo, i)) w->LowerWidget(i + 3);
 	}
 
-	SetWindowDirty(w);
+	w->SetDirty();
 }
 
 /************************/
@@ -955,7 +955,7 @@
 					/* Raise and disable the widget for the previous selection. */
 					w->RaiseWidget(_performance_rating_detail_player + 13);
 					w->DisableWidget(_performance_rating_detail_player + 13);
-					SetWindowDirty(w);
+					w->SetDirty();
 
 					_performance_rating_detail_player = INVALID_PLAYER;
 				}
@@ -964,7 +964,7 @@
 					if (GetPlayer(i)->is_active) {
 						/* Lower the widget corresponding to this player. */
 						w->LowerWidget(i + 13);
-						SetWindowDirty(w);
+						w->SetDirty();
 
 						_performance_rating_detail_player = i;
 						break;
@@ -984,7 +984,7 @@
 						w->DisableWidget(i + 13);
 
 						/* We need a repaint */
-						SetWindowDirty(w);
+						w->SetDirty();
 					}
 					continue;
 				}
@@ -994,7 +994,7 @@
 					/* New player! Yippie :p */
 					w->EnableWidget(i + 13);
 					/* We need a repaint */
-					SetWindowDirty(w);
+					w->SetDirty();
 				}
 
 				x = (i == _performance_rating_detail_player) ? 1 : 0;
@@ -1077,7 +1077,7 @@
 					w->RaiseWidget(_performance_rating_detail_player + 13);
 					_performance_rating_detail_player = (PlayerID)(e->we.click.widget - 13);
 					w->LowerWidget(_performance_rating_detail_player + 13);
-					SetWindowDirty(w);
+					w->SetDirty();
 				}
 			}
 			break;
@@ -1099,7 +1099,7 @@
 			w->custom[1] = 5;
 
 			if (_performance_rating_detail_player != INVALID_PLAYER) w->LowerWidget(_performance_rating_detail_player + 13);
-			SetWindowDirty(w);
+			w->SetDirty();
 
 			break;
 		}
@@ -1118,7 +1118,7 @@
 						/* Skip if player is not active */
 						if (p2->is_active) UpdateCompanyRatingAndValue(p2, false);
 					}
-					SetWindowDirty(w);
+					w->SetDirty();
 				}
 			}
 
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -317,7 +317,7 @@
 				gv->group_sel = ALL_GROUP;
 				HideDropDownMenu(w);
 			}
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_CREATE:
@@ -519,7 +519,7 @@
 					gv->l.flags |= VL_RESORT;
 
 					gv->_sorting->order = !!(gv->l.flags & VL_DESC);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case GRP_WIDGET_SORT_BY_DROPDOWN: // Select sorting criteria dropdown menu
@@ -530,7 +530,7 @@
 					if (!IsAllGroupID(gv->group_sel)) {
 						gv->group_sel = ALL_GROUP;
 						gv->l.flags |= VL_REBUILD;
-						SetWindowDirty(w);
+						w->SetDirty();
 					}
 					break;
 
@@ -538,7 +538,7 @@
 					if (!IsDefaultGroupID(gv->group_sel)) {
 						gv->group_sel = DEFAULT_GROUP;
 						gv->l.flags |= VL_REBUILD;
-						SetWindowDirty(w);
+						w->SetDirty();
 					}
 					break;
 
@@ -554,7 +554,7 @@
 					gv->group_sel = gl->sort_list[id_g]->index;;
 
 					gv->l.flags |= VL_REBUILD;
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				}
 
@@ -577,7 +577,7 @@
 						_cursor.vehchain = true;
 					}
 
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				}
 
@@ -640,7 +640,7 @@
 
 					gv->vehicle_sel = INVALID_VEHICLE;
 
-					SetWindowDirty(w);
+					w->SetDirty();
 
 					break;
 
@@ -650,7 +650,7 @@
 
 					gv->vehicle_sel = INVALID_VEHICLE;
 
-					SetWindowDirty(w);
+					w->SetDirty();
 
 					if (id_g >= w->vscroll.cap) return;
 
@@ -670,7 +670,7 @@
 
 					gv->vehicle_sel = INVALID_VEHICLE;
 
-					SetWindowDirty(w);
+					w->SetDirty();
 
 					if (id_v >= w->vscroll2.cap) return; // click out of bounds
 
@@ -752,7 +752,7 @@
 				default: NOT_REACHED();
 			}
 
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 
@@ -767,12 +767,12 @@
 			if (--gv->l.resort_timer == 0) {
 				gv->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
 				gv->l.flags |= VL_RESORT;
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 			if (--gl->l.resort_timer == 0) {
 				gl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
 				gl->l.flags |= VL_RESORT;
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 			break;
 
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -269,7 +269,7 @@
 						WP(w, fnd_d).select = _fund_gui.index[WP(w, fnd_d).index];
 						indsp = (WP(w, fnd_d).select == INVALID_INDUSTRYTYPE) ? NULL : GetIndustrySpec(WP(w, fnd_d).select);
 
-						SetWindowDirty(w);
+						w->SetDirty();
 
 						if ((_game_mode != GM_EDITOR && _patches.raw_industry_construction == 2 && indsp != NULL && indsp->IsRawIndustry()) ||
 								WP(w, fnd_d).select == INVALID_INDUSTRYTYPE) {
@@ -357,7 +357,7 @@
 					/* Only if result does match the previous state would it require a redraw. */
 					if (call_back_result != _fund_gui.enabled[WP(w, fnd_d).index]) {
 						_fund_gui.enabled[WP(w, fnd_d).index] = call_back_result;
-						SetWindowDirty(w);
+						w->SetDirty();
 					}
 				}
 			}
@@ -524,9 +524,9 @@
 			}
 
 			if (y > w->widget[IVW_INFO].bottom) {
-				SetWindowDirty(w);
+				w->SetDirty();
 				ResizeWindowForWidget(w, IVW_INFO, 0, y - w->widget[IVW_INFO].top);
-				SetWindowDirty(w);
+				w->SetDirty();
 				return;
 			}
 
@@ -560,7 +560,7 @@
 							}
 
 							UpdateIndustryProduction(i);
-							SetWindowDirty(w);
+							w->SetDirty();
 							w->flags4 |= 5 << WF_TIMEOUT_SHL;
 							WP(w, indview_d).clicked_line = line + 1;
 							WP(w, indview_d).clicked_button = (x < 15 ? 1 : 2);
@@ -587,7 +587,7 @@
 		case WE_TIMEOUT:
 			WP(w, indview_d).clicked_line = 0;
 			WP(w, indview_d).clicked_button = 0;
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_ON_EDIT_TEXT:
@@ -597,7 +597,7 @@
 
 				i->production_rate[line] = ClampU(atoi(e->we.edittext.str), 0, 255);
 				UpdateIndustryProduction(i);
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 	}
 }
@@ -842,25 +842,25 @@
 				case IDW_SORTBYNAME: {
 					_industry_sort_order = _industry_sort_order == 0 ? 1 : 0;
 					_industry_sort_dirty = true;
-					SetWindowDirty(w);
+					w->SetDirty();
 				} break;
 
 				case IDW_SORTBYTYPE: {
 					_industry_sort_order = _industry_sort_order == 2 ? 3 : 2;
 					_industry_sort_dirty = true;
-					SetWindowDirty(w);
+					w->SetDirty();
 				} break;
 
 				case IDW_SORTBYPROD: {
 					_industry_sort_order = _industry_sort_order == 4 ? 5 : 4;
 					_industry_sort_dirty = true;
-					SetWindowDirty(w);
+					w->SetDirty();
 				} break;
 
 				case IDW_SORTBYTRANSPORT: {
 					_industry_sort_order = _industry_sort_order == 6 ? 7 : 6;
 					_industry_sort_dirty = true;
-					SetWindowDirty(w);
+					w->SetDirty();
 				} break;
 
 				case IDW_INDUSRTY_LIST: {
@@ -881,7 +881,7 @@
 			break;
 
 		case WE_4:
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_RESIZE:
@@ -907,6 +907,6 @@
 		w->vscroll.cap = 16;
 		w->resize.height = w->height - 6 * 10; // minimum 10 items
 		w->resize.step_height = 10;
-		SetWindowDirty(w);
+		w->SetDirty();
 	}
 }
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -103,7 +103,7 @@
 	if (w->IsWidgetDisabled(widget)) return false;
 
 	SndPlayFx(SND_15_BEEP);
-	SetWindowDirty(w);
+	w->SetDirty();
 
 	if (w->IsWidgetLowered(widget)) {
 		ResetObjectToPlace();
@@ -187,7 +187,7 @@
 		vp->virtual_left = WP(w, vp_d).scrollpos_x;
 		vp->virtual_top = WP(w, vp_d).scrollpos_y;
 	}
-	SetWindowDirty(w);
+	w->SetDirty();
 	/* Update the windows that have zoom-buttons to perhaps disable their buttons */
 	SendWindowMessageClass(w->window_class, how, w->window_number, 0);
 	return true;
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -291,7 +291,7 @@
 			if (--WP(w, scroller_d).counter == 0) {
 				WP(w, scroller_d).counter = 5;
 				WP(w, scroller_d).height--;
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 			break;
 	}
@@ -1547,19 +1547,19 @@
 					_savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ?
 						SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME;
 					_savegame_sort_dirty = true;
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case 3: // Sort save names by date
 					_savegame_sort_order = (_savegame_sort_order == SORT_BY_DATE) ?
 						SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE;
 					_savegame_sort_dirty = true;
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case 6: // OpenTTD 'button', jumps to OpenTTD directory
 					FiosBrowseTo(&o_dir);
-					SetWindowDirty(w);
+					w->SetDirty();
 					BuildFileList();
 					break;
 
@@ -1597,7 +1597,7 @@
 						}
 					} else {
 						/* Changed directory, need repaint. */
-						SetWindowDirty(w);
+						w->SetDirty();
 						BuildFileList();
 					}
 					break;
@@ -1645,7 +1645,7 @@
 				}
 
 				UpdateTextBufferSize(&WP(w, querystr_d).text);
-				SetWindowDirty(w);
+				w->SetDirty();
 			} else if (w->IsWidgetLowered(12)) { // Save button clicked
 				_switch_mode = SM_SAVE;
 				FiosMakeSavegameName(_file_to_saveload.name, WP(w, querystr_d).text.buf, sizeof(_file_to_saveload.name));
--- a/src/music_gui.cpp
+++ b/src/music_gui.cpp
@@ -256,7 +256,7 @@
 				if (p[i] == 0) {
 					p[i] = y + 1;
 					p[i + 1] = 0;
-					SetWindowDirty(w);
+					w->SetDirty();
 					SelectSongToPlay();
 					break;
 				}
@@ -276,13 +276,13 @@
 				p[i] = p[i + 1];
 				}
 
-			SetWindowDirty(w);
+			w->SetDirty();
 			SelectSongToPlay();
 		} break;
 
 		case 11: // clear
 			_playlists[msf.playlist][0] = 0;
-			SetWindowDirty(w);
+			w->SetDirty();
 			StopMusic();
 			SelectSongToPlay();
 			break;
@@ -295,7 +295,7 @@
 
 		case 5: case 6: case 7: case 8: case 9: case 10: /* set playlist */
 			msf.playlist = e->we.click.widget - 5;
-			SetWindowDirty(w);
+			w->SetDirty();
 			InvalidateWindow(WC_MUSIC_WINDOW, 0);
 			StopMusic();
 			SelectSongToPlay();
@@ -440,7 +440,7 @@
 				*vol = new_vol;
 				if (vol == &msf.music_vol)
 					MusicVolumeChanged(new_vol);
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 
 			_left_button_clicked = false;
@@ -455,7 +455,7 @@
 			break;
 		case 12: case 13: case 14: case 15: case 16: case 17: // playlist
 			msf.playlist = e->we.click.widget - 12;
-			SetWindowDirty(w);
+			w->SetDirty();
 			InvalidateWindow(WC_MUSIC_TRACK_SELECTION, 0);
 			StopMusic();
 			SelectSongToPlay();
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -182,7 +182,7 @@
 
 					for (c = _all_grfs; c != NULL && i > 0; c = c->next, i--) {}
 					WP(w, newgrf_add_d).sel = c;
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				}
 
@@ -218,7 +218,7 @@
 				case ANGRFW_RESCAN: // Rescan list
 					WP(w, newgrf_add_d).sel = NULL;
 					ScanNewGRFFiles();
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 			}
 			break;
@@ -333,7 +333,7 @@
 		for (c = *nd->list; c != NULL && i > 0; c = c->next, i--) {}
 		nd->sel = c;
 
-		SetWindowDirty(w);
+		w->SetDirty();
 	}
 }
 
@@ -435,7 +435,7 @@
 
 					WP(w, newgrf_d).sel = newsel;
 					SetupNewGRFWindow(w);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				}
 
@@ -451,7 +451,7 @@
 							break;
 						}
 					}
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				}
 
@@ -467,7 +467,7 @@
 							break;
 						}
 					}
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				}
 
@@ -478,7 +478,7 @@
 					for (c = *WP(w, newgrf_d).list; c != NULL && i > 0; c = c->next, i--) {}
 					WP(w, newgrf_d).sel = c;
 
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				}
 
@@ -517,7 +517,7 @@
 				/* parse_intlist returns -1 on error */
 				if (c->num_params == (byte)-1) c->num_params = 0;
 			}
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_DESTROY:
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -345,7 +345,7 @@
 
 	Window *w = FindWindowById(WC_MESSAGE_HISTORY, 0);
 	if (w == NULL) return;
-	SetWindowDirty(w);
+	w->SetDirty();
 	w->vscroll.count = _total_news;
 }
 
@@ -520,7 +520,7 @@
 
 				if (w != NULL) {
 					WP(w, def_d).data_2 = 91;
-					SetWindowDirty(w);
+					w->SetDirty();
 				}
 				break;
 			}
@@ -721,7 +721,7 @@
 	w->resize.height = w->height - 12 * 6; // minimum of 4 items in the list, each item 12 high
 	w->resize.step_width = 1;
 	w->resize.width = 200; // can't make window any smaller than 200 pixel
-	SetWindowDirty(w);
+	w->SetDirty();
 }
 
 
@@ -809,7 +809,7 @@
 
 						SetMessageButtonStates(w, val, element);
 						_news_type_data[element].display = (NewsDisplay)val;
-						SetWindowDirty(w);
+						w->SetDirty();
 					}
 					break;
 				}
@@ -823,7 +823,7 @@
 				SetMessageButtonStates(w, e->we.dropdown.index, i);
 				_news_type_data[i].display = (NewsDisplay)e->we.dropdown.index;
 			}
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 	}
 }
@@ -990,7 +990,7 @@
 
 			Window *w = FindWindowById(WC_MESSAGE_HISTORY, 0);
 			if (w != NULL) {
-				SetWindowDirty(w);
+				w->SetDirty();
 				w->vscroll.count = _total_news;
 			}
 		}
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -799,7 +799,7 @@
 						/* This was a click on an empty part of the orders window, so
 						* deselect the currently selected order. */
 						WP(w, order_d).sel = -1;
-						SetWindowDirty(w);
+						w->SetDirty();
 						return;
 					}
 
@@ -831,7 +831,7 @@
 						}
 					}
 
-					SetWindowDirty(w);
+					w->SetDirty();
 				} break;
 
 				case ORDER_WIDGET_SKIP:
--- a/src/osk_gui.cpp
+++ b/src/osk_gui.cpp
@@ -113,7 +113,7 @@
 				if (HasBit(_keystate, KEYS_SHIFT)) {
 					ToggleBit(_keystate, KEYS_SHIFT);
 					w->widget[OSK_WIDGET_SHIFT].color = HasBit(_keystate, KEYS_SHIFT) ? 15 : 14;
-					SetWindowDirty(w);
+					w->SetDirty();
 				}
 				break;
 			}
@@ -133,12 +133,12 @@
 
 				case OSK_WIDGET_CAPS:
 					ToggleBit(_keystate, KEYS_CAPS);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case OSK_WIDGET_SHIFT:
 					ToggleBit(_keystate, KEYS_SHIFT);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case OSK_WIDGET_SPACE:
--- a/src/player_gui.cpp
+++ b/src/player_gui.cpp
@@ -166,9 +166,9 @@
 			int new_height = ((player != _local_player) ? 0 : 12) + ((WP(w, def_d).data_1 != 0) ? 48 : 74 + 10 * EXPENSES_END);
 			if (w->height != new_height) {
 				/* Make window dirty before and after resizing */
-				SetWindowDirty(w);
+				w->SetDirty();
 				w->height = new_height;
-				SetWindowDirty(w);
+				w->SetDirty();
 
 				w->SetWidgetHiddenState(PFW_WIDGET_INCREASE_LOAN, player != _local_player);
 				w->SetWidgetHiddenState(PFW_WIDGET_REPAY_LOAN,    player != _local_player);
@@ -488,7 +488,7 @@
 					} else {
 						WP(w, livery_d).sel = 1 << j;
 					}
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				}
 			}
@@ -892,7 +892,7 @@
 					*pf = _player_face;
 					ScaleAllPlayerFaceBits(*pf);
 					ShowErrorMessage(INVALID_STRING_ID, STR_FACE_LOAD_DONE, 0, 0);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				/* 'Player face number' button, view and/or set player face number */
@@ -912,13 +912,13 @@
 				case PFW_WIDGET_FEMALE:
 					SetPlayerFaceBits(*pf, PFV_GENDER, ge, e->we.click.widget - PFW_WIDGET_MALE);
 					ScaleAllPlayerFaceBits(*pf);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				/* Randomize face button */
 				case PFW_WIDGET_RANDOM_NEW_FACE:
 					RandomPlayerFaceBits(*pf, ge, WP(w, facesel_d).advanced);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				/* Toggle ethnicity (european/african) button */
@@ -926,7 +926,7 @@
 				case PFW_WIDGET_ETHNICITY_AFR:
 					SetPlayerFaceBits(*pf, PFV_ETHNICITY, ge, e->we.click.widget - PFW_WIDGET_ETHNICITY_EUR);
 					ScaleAllPlayerFaceBits(*pf);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				default:
@@ -965,7 +965,7 @@
 							IncreasePlayerFaceBits(*pf, pfv, ge, (((e->we.click.widget - PFW_WIDGET_EYECOLOUR_L) % 3) != 0) ? 1 : -1);
 						}
 
-						SetWindowDirty(w);
+						w->SetDirty();
 					}
 					break;
 			}
@@ -977,7 +977,7 @@
 				*pf = strtoul(e->we.edittext.str, NULL, 10);
 				ScaleAllPlayerFaceBits(*pf);
 				ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_SET, 0, 0);
-				SetWindowDirty(w);
+				w->SetDirty();
 			} else {
 				ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_ERR, 0, 0);
 			}
@@ -1304,7 +1304,7 @@
 
 		case WE_MOUSELOOP:
 			/* redraw the window every now and then */
-			if ((++w->vscroll.pos & 0x1F) == 0) SetWindowDirty(w);
+			if ((++w->vscroll.pos & 0x1F) == 0) w->SetDirty();
 			break;
 
 		case WE_PLACE_OBJ:
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -940,9 +940,9 @@
 		int text_end = DrawStationCoverageAreaText(2, 166 + y_offset, SCT_ALL, rad, false);
 		text_end = DrawStationCoverageAreaText(2, text_end + 4, SCT_ALL, rad, true) + 4;
 		if (text_end != w->widget[BRSW_BACKGROUND].bottom) {
-			SetWindowDirty(w);
+			w->SetDirty();
 			ResizeWindowForWidget(w, BRSW_BACKGROUND, 0, text_end - w->widget[BRSW_BACKGROUND].bottom);
-			SetWindowDirty(w);
+			w->SetDirty();
 		}
 
 		if (newstations) {
@@ -974,7 +974,7 @@
 			_railstation.orientation = e->we.click.widget - BRSW_PLATFORM_DIR_X;
 			w->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X);
 			SndPlayFx(SND_15_BEEP);
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case BRSW_PLATFORM_NUM_1:
@@ -1005,7 +1005,7 @@
 			w->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
 			w->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
 			SndPlayFx(SND_15_BEEP);
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 		}
 
@@ -1037,7 +1037,7 @@
 			w->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
 			w->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
 			SndPlayFx(SND_15_BEEP);
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 		}
 
@@ -1069,7 +1069,7 @@
 			w->SetWidgetLoweredState(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN, !_railstation.dragdrop);
 			w->SetWidgetLoweredState(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN, !_railstation.dragdrop);
 			SndPlayFx(SND_15_BEEP);
-			SetWindowDirty(w);
+			w->SetDirty();
 		} break;
 
 		case BRSW_HIGHLIGHT_OFF:
@@ -1078,7 +1078,7 @@
 			w->SetWidgetLoweredState(BRSW_HIGHLIGHT_OFF, !_station_show_coverage);
 			w->SetWidgetLoweredState(BRSW_HIGHLIGHT_ON, _station_show_coverage);
 			SndPlayFx(SND_15_BEEP);
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case BRSW_NEWST_DROPDOWN:
@@ -1104,7 +1104,7 @@
 			CheckSelectedSize(w, statspec);
 
 			SndPlayFx(SND_15_BEEP);
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 		}
 		}
@@ -1123,7 +1123,7 @@
 		}
 
 		SndPlayFx(SND_15_BEEP);
-		SetWindowDirty(w);
+		w->SetDirty();
 		break;
 
 	case WE_MOUSELOOP:
@@ -1332,23 +1332,21 @@
 				case BSW_DRAG_SIGNALS_DENSITY_DECREASE:
 					if (_patches.drag_signals_density > 1) {
 						_patches.drag_signals_density--;
-						const Window *w = FindWindowById(WC_GAME_OPTIONS, 0);
-						if (w != NULL) SetWindowDirty(w);
+						SetWindowDirty(FindWindowById(WC_GAME_OPTIONS, 0));
 					}
 					break;
 
 				case BSW_DRAG_SIGNALS_DENSITY_INCREASE:
 					if (_patches.drag_signals_density < 20) {
 						_patches.drag_signals_density++;
-						const Window *w = FindWindowById(WC_GAME_OPTIONS, 0);
-						if (w != NULL) SetWindowDirty(w);
+						SetWindowDirty(FindWindowById(WC_GAME_OPTIONS, 0));
 					}
 					break;
 
 				default: break;
 			}
 
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_MOUSELOOP:
@@ -1437,7 +1435,7 @@
 				_build_depot_direction = (DiagDirection)(e->we.click.widget - BRDW_DEPOT_NE);
 				w->LowerWidget(_build_depot_direction + BRDW_DEPOT_NE);
 				SndPlayFx(SND_15_BEEP);
-				SetWindowDirty(w);
+				w->SetDirty();
 				break;
 		}
 		break;
@@ -1534,7 +1532,7 @@
 
 				_cur_waypoint_type = type;
 				SndPlayFx(SND_15_BEEP);
-				SetWindowDirty(w);
+				w->SetDirty();
 				break;
 			}
 		}
@@ -1600,7 +1598,7 @@
 		w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL);
 		if (w != NULL) {
 			SetupRailToolbar(_cur_railtype, w);
-			SetWindowDirty(w);
+			w->SetDirty();
 		}
 	}
 	MarkWholeScreenDirty();
@@ -1651,7 +1649,7 @@
 	Window *w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL);
 	if (w != NULL) {
 		SetupRailToolbar(_cur_railtype, w);
-		SetWindowDirty(w);
+		w->SetDirty();
 	}
 }
 
@@ -1668,7 +1666,7 @@
 	if (new_variant != _cur_signal_variant) {
 		Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
 		if (w != NULL) {
-			SetWindowDirty(w);
+			w->SetDirty();
 			w->RaiseWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
 		}
 		_cur_signal_variant = new_variant;
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -352,7 +352,7 @@
 static void BuildRoadClick_OneWay(Window *w)
 {
 	if (w->IsWidgetDisabled(RTW_ONE_WAY)) return;
-	SetWindowDirty(w);
+	w->SetDirty();
 	w->ToggleWidgetLoweredState(RTW_ONE_WAY);
 	SetSelectionRed(false);
 }
@@ -758,7 +758,7 @@
 					_road_depot_orientation = (DiagDirection)(e->we.click.widget - BRDW_DEPOT_NE);
 					w->LowerWidget(_road_depot_orientation + BRDW_DEPOT_NE);
 					SndPlayFx(SND_15_BEEP);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				default:
@@ -888,9 +888,9 @@
 				(w->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY,
 				3, true) + 4;
 			if (text_end > w->widget[BRSW_BACKGROUND].bottom) {
-				SetWindowDirty(w);
+				w->SetDirty();
 				ResizeWindowForWidget(w, BRSW_BACKGROUND, 0, text_end - w->widget[BRSW_BACKGROUND].bottom);
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 		} break;
 
@@ -906,7 +906,7 @@
 					_road_station_picker_orientation = (DiagDirection)(e->we.click.widget - BRSW_STATION_NE);
 					w->LowerWidget(_road_station_picker_orientation + BRSW_STATION_NE);
 					SndPlayFx(SND_15_BEEP);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case BRSW_LT_OFF:
@@ -915,7 +915,7 @@
 					_station_show_coverage = (e->we.click.widget != BRSW_LT_OFF);
 					w->LowerWidget(_station_show_coverage + BRSW_LT_OFF);
 					SndPlayFx(SND_15_BEEP);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				default:
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1211,9 +1211,7 @@
 
 static int32 DragSignalsDensityChanged(int32)
 {
-	const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
-
-	if (w != NULL) SetWindowDirty(w);
+	SetWindowDirty(FindWindowById(WC_BUILD_SIGNAL, 0));
 
 	return 0;
 }
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -248,7 +248,7 @@
 						ShowErrorMessage(INVALID_STRING_ID, STR_FULLSCREEN_FAILED, 0, 0);
 					}
 					w->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case GAMEOPT_SCREENSHOT_BTN: /* Setup screenshot format dropdown */
@@ -296,7 +296,7 @@
 
 				case GAMEOPT_AUTOSAVE_BTN: /* Autosave options */
 					_opt.autosave = _opt_newgame.autosave = e->we.dropdown.index;
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case GAMEOPT_LANG_BTN: /* Change interface language */
@@ -309,12 +309,12 @@
 
 				case GAMEOPT_RESOLUTION_BTN: /* Change resolution */
 					if (e->we.dropdown.index < _num_resolutions && ChangeResInGame(_resolutions[e->we.dropdown.index][0], _resolutions[e->we.dropdown.index][1]))
-						SetWindowDirty(w);
+						w->SetDirty();
 					break;
 
 				case GAMEOPT_SCREENSHOT_BTN: /* Change screenshot format */
 					SetScreenshotFormat(e->we.dropdown.index);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 			}
 			break;
@@ -615,7 +615,7 @@
 					w->RaiseWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level);
 					SetDifficultyLevel(3, &_opt_mod_temp); // set difficulty level to custom
 					w->LowerWidget(GDW_LVL_CUSTOM);
-					SetWindowDirty(w);
+					w->SetDirty();
 				} break;
 
 				case GDW_LVL_EASY:
@@ -626,7 +626,7 @@
 					w->RaiseWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level);
 					SetDifficultyLevel(e->we.click.widget - GDW_LVL_EASY, &_opt_mod_temp);
 					w->LowerWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case GDW_HIGHSCORE: // Highscore Table
@@ -659,7 +659,7 @@
 			if (diffic_d->timeout != 0) {
 				diffic_d->timeout--;
 				if (diffic_d->timeout == 0) diffic_d->clicked_button = NO_SETTINGS_BUTTON;
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 			break;
 	}
@@ -1027,7 +1027,7 @@
 
 						if (value != oldvalue) {
 							SetPatchValue(page->entries[btn].index, patches_ptr, value);
-							SetWindowDirty(w);
+							w->SetDirty();
 						}
 					} else {
 						/* only open editbox for types that its sensible for */
@@ -1048,14 +1048,14 @@
 					WP(w, def_d).data_1 = e->we.click.widget - PATCHSEL_INTERFACE;
 					w->LowerWidget(WP(w, def_d).data_1 + PATCHSEL_INTERFACE);
 					DeleteWindowById(WC_QUERY_STRING, 0);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 			}
 			break;
 
 		case WE_TIMEOUT:
 			WP(w, def_d).data_2 = 0;
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_ON_EDIT_TEXT:
@@ -1068,7 +1068,7 @@
 				if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate;
 
 				SetPatchValue(pe->index, patches_ptr, value);
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 			break;
 
@@ -1267,7 +1267,7 @@
 			}
 
 			w->flags4 |= 5 << WF_TIMEOUT_SHL;
-			SetWindowDirty(w);
+			w->SetDirty();
 		} break;
 
 		case WE_ON_EDIT_TEXT: {
@@ -1303,7 +1303,7 @@
 
 		case WE_TIMEOUT:
 			WP(w, def_d).data_1 = 0;
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_DESTROY:
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -785,7 +785,7 @@
 	y  = ((vp->virtual_height - (w->widget[SM_WIDGET_MAP].bottom - w->widget[SM_WIDGET_MAP].top ) * TILE_SIZE) / 2 + vp->virtual_top ) / 2 - TILE_SIZE * 2;
 	WP(w, smallmap_d).scroll_x = (y - x) & ~0xF;
 	WP(w, smallmap_d).scroll_y = (x + y) & ~0xF;
-	SetWindowDirty(w);
+	w->SetDirty();
 }
 
 enum {
@@ -879,7 +879,7 @@
 					WP(w2, vp_d).dest_scrollpos_x = pt.x + ((_cursor.pos.x - w->left + 2) << 4) - (w2->viewport->virtual_width >> 1);
 					WP(w2, vp_d).dest_scrollpos_y = pt.y + ((_cursor.pos.y - w->top - 16) << 4) - (w2->viewport->virtual_height >> 1);
 
-					SetWindowDirty(w);
+					w->SetDirty();
 				} break;
 
 				case SM_WIDGET_CONTOUR:    // Show land contours
@@ -892,14 +892,14 @@
 					_smallmap_type = e->we.click.widget - SM_WIDGET_CONTOUR;
 					w->LowerWidget(_smallmap_type + SM_WIDGET_CONTOUR);
 
-					SetWindowDirty(w);
+					w->SetDirty();
 					SndPlayFx(SND_15_BEEP);
 					break;
 
 				case SM_WIDGET_CENTERMAP: // Center the smallmap again
 					SmallMapCenterOnCurrentPos(w);
 
-					SetWindowDirty(w);
+					w->SetDirty();
 					SndPlayFx(SND_15_BEEP);
 					break;
 
@@ -907,7 +907,7 @@
 					w->ToggleWidgetLoweredState(SM_WIDGET_TOGGLETOWNNAME);
 					_smallmap_show_towns = w->IsWidgetLowered(SM_WIDGET_TOGGLETOWNNAME);
 
-					SetWindowDirty(w);
+					w->SetDirty();
 					SndPlayFx(SND_15_BEEP);
 					break;
 
@@ -939,7 +939,7 @@
 						/* Raise the two buttons "all", as we have done a specific choice */
 						w->RaiseWidget(SM_WIDGET_ENABLEINDUSTRIES);
 						w->RaiseWidget(SM_WIDGET_DISABLEINDUSTRIES);
-						SetWindowDirty(w);
+						w->SetDirty();
 					}
 					break;
 
@@ -950,7 +950,7 @@
 					/* toggle appeareance indicating the choice */
 					w->LowerWidget(SM_WIDGET_ENABLEINDUSTRIES);
 					w->RaiseWidget(SM_WIDGET_DISABLEINDUSTRIES);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case SM_WIDGET_DISABLEINDUSTRIES: // disable all industries
@@ -960,7 +960,7 @@
 					/* toggle appeareance indicating the choice */
 					w->RaiseWidget(SM_WIDGET_ENABLEINDUSTRIES);
 					w->LowerWidget(SM_WIDGET_DISABLEINDUSTRIES);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				}
 			break;
@@ -976,7 +976,7 @@
 
 		case WE_MOUSELOOP:
 			/* update the window every now and then */
-			if ((++w->vscroll.pos & 0x1F) == 0) SetWindowDirty(w);
+			if ((++w->vscroll.pos & 0x1F) == 0) w->SetDirty();
 			break;
 
 		case WE_SCROLL: {
@@ -1037,7 +1037,7 @@
 			WP(w, smallmap_d).scroll_y = y;
 			WP(w, smallmap_d).subscroll = sub;
 
-			SetWindowDirty(w);
+			w->SetDirty();
 		} break;
 	}
 }
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -195,7 +195,7 @@
 		Window *w = *wz;
 		if (w->window_class == WC_STATION_LIST) {
 			WP(w, plstations_d).flags |= sl_flag;
-			SetWindowDirty(w);
+			w->SetDirty();
 		}
 	}
 }
@@ -449,7 +449,7 @@
 					}
 					w->SetWidgetLoweredState(SLW_FACILALL, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
 					sl->flags |= SL_REBUILD;
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case SLW_FACILALL:
@@ -460,7 +460,7 @@
 
 					facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
 					sl->flags |= SL_REBUILD;
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case SLW_CARGOALL: {
@@ -476,7 +476,7 @@
 					_cargo_filter = _cargo_mask;
 					include_empty = true;
 					sl->flags |= SL_REBUILD;
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				}
 
@@ -486,7 +486,7 @@
 					sl->flags |= SL_RESORT;
 					w->flags4 |= 5 << WF_TIMEOUT_SHL;
 					w->LowerWidget(SLW_SORTBY);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case SLW_SORTDROPBTN: // select sorting criteria dropdown menu
@@ -509,7 +509,7 @@
 					}
 					sl->flags |= SL_REBUILD;
 					w->SetWidgetLoweredState(SLW_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				default:
@@ -540,7 +540,7 @@
 						}
 						sl->flags |= SL_REBUILD;
 						w->SetWidgetLoweredState(SLW_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
-						SetWindowDirty(w);
+						w->SetDirty();
 					}
 					break;
 			}
@@ -553,7 +553,7 @@
 				station_sort.criteria = sl->sort_type;
 				sl->flags |= SL_RESORT;
 			}
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_TICK:
@@ -562,13 +562,13 @@
 				DEBUG(misc, 3, "Periodic rebuild station list player %d", owner);
 				sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
 				sl->flags |= SL_REBUILD;
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 			break;
 
 		case WE_TIMEOUT:
 			w->RaiseWidget(SLW_SORTBY);
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_RESIZE:
@@ -949,7 +949,7 @@
 					break;
 
 				case SVW_RATINGS:
-					SetWindowDirty(w);
+					w->SetDirty();
 
 					if (w->widget[SVW_RATINGS].data == STR_3032_RATINGS) {
 						/* Switch to ratings view */
@@ -963,7 +963,7 @@
 						ResizeWindowForWidget(w, SVW_ACCEPTLIST, 0, -100);
 					}
 
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case SVW_RENAME:
--- a/src/statusbar_gui.cpp
+++ b/src/statusbar_gui.cpp
@@ -114,7 +114,7 @@
 
 		case WE_MESSAGE:
 			w->message.msg = e->we.message.msg;
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_CLICK:
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -310,7 +310,7 @@
 		w->top = 22;
 		link->left = w->left - link->width;
 
-		SetWindowDirty(link);
+		link->SetDirty();
 	}
 }
 
@@ -609,7 +609,7 @@
 					_terraform_size = size;
 
 					SndPlayFx(SND_15_BEEP);
-					SetWindowDirty(w);
+					w->SetDirty();
 				} break;
 				case 15: // gen random land
 					w->HandleButtonClick(15);
@@ -662,7 +662,7 @@
 
 		case WE_ABORT_PLACE_OBJ:
 			w->RaiseButtons();
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 	}
 }
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -245,7 +245,7 @@
 					break;
 			}
 
-			SetWindowDirty(w);
+			w->SetDirty();
 		} break;
 
 		case WE_ON_EDIT_TEXT: {
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -520,7 +520,7 @@
 	/* don't allow too fast scrolling */
 	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
 		w->HandleButtonClick(6);
-		SetWindowDirty(w);
+		w->SetDirty();
 
 		_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year - 1, MIN_YEAR, MAX_YEAR);
 		SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
@@ -533,7 +533,7 @@
 	/* don't allow too fast scrolling */
 	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
 		w->HandleButtonClick(7);
-		SetWindowDirty(w);
+		w->SetDirty();
 
 		_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + 1, MIN_YEAR, MAX_YEAR);
 		SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
@@ -721,7 +721,7 @@
 
 		case WE_ABORT_PLACE_OBJ:
 			w->RaiseWidget(25);
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_MOUSELOOP:
@@ -927,7 +927,7 @@
 
 		case WE_ABORT_PLACE_OBJ:
 			w->RaiseWidget(25);
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_RESIZE: {
@@ -999,12 +999,12 @@
 		case WE_MOUSELOOP:
 			if (w->IsWidgetLowered(0) != !!_pause_game) {
 				w->ToggleWidgetLoweredState(0);
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 
 			if (w->IsWidgetLowered(1) != !!_fast_forward) {
 				w->ToggleWidgetLoweredState(1);
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 			break;
 
@@ -1128,7 +1128,7 @@
 		case WE_DESTROY: {
 				Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0);
 				v->RaiseWidget(WP(w, menu_d).main_button);
-				SetWindowDirty(v);
+				w->SetDirty();
 				return;
 			}
 
@@ -1157,7 +1157,7 @@
 			if (index == -1 || index == WP(w, menu_d).sel_index) return;
 
 			WP(w, menu_d).sel_index = index;
-			SetWindowDirty(w);
+			w->SetDirty();
 			return;
 		}
 	}
@@ -1269,12 +1269,12 @@
 
 	if (WP(w, menu_d).item_count != num) {
 		WP(w, menu_d).item_count = num;
-		SetWindowDirty(w);
+		w->SetDirty();
 		num = num * 10 + 2;
 		w->height = num;
 		w->widget[0].bottom = w->widget[0].top + num - 1;
 		w->top = GetToolbarDropdownPos(0, w->width, w->height).y;
-		SetWindowDirty(w);
+		w->SetDirty();
 	}
 }
 
@@ -1325,7 +1325,7 @@
 		case WE_DESTROY: {
 			Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0);
 			v->RaiseWidget(WP(w, menu_d).main_button);
-			SetWindowDirty(v);
+			w->SetDirty();
 			return;
 		}
 
@@ -1371,7 +1371,7 @@
 			if (index == -1 || index == WP(w, menu_d).sel_index) return;
 
 			WP(w, menu_d).sel_index = index;
-			SetWindowDirty(w);
+			w->SetDirty();
 			return;
 		}
 	}
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -239,7 +239,7 @@
 					y = GetNthSetBit(GetMaskOfTownActions(NULL, _local_player, t), y + w->vscroll.pos - 1);
 					if (y >= 0) {
 						WP(w, def_d).data_1 = y;
-						SetWindowDirty(w);
+						w->SetDirty();
 					}
 					/* Fall through to clicking in case we are double-clicked */
 					if (e->event != WE_DOUBLE_CLICK || y < 0) break;
@@ -252,7 +252,7 @@
 			break;
 
 		case WE_4:
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 	}
 }
@@ -523,13 +523,13 @@
 				case TDW_SORTNAME: /* Sort by Name ascending/descending */
 					_town_sort_order = (_town_sort_order == 0) ? 1 : 0;
 					_town_sort_dirty = true;
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case TDW_SORTPOPULATION: /* Sort by Population ascending/descending */
 					_town_sort_order = (_town_sort_order == 2) ? 3 : 2;
 					_town_sort_dirty = true;
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 
 				case TDW_CENTERTOWN: { /* Click on Town Matrix */
@@ -555,7 +555,7 @@
 			break;
 
 		case WE_4:
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_RESIZE:
@@ -671,14 +671,14 @@
 					w->RaiseWidget(_scengen_town_size + TSEW_SMALLTOWN);
 					_scengen_town_size = e->we.click.widget - TSEW_SMALLTOWN;
 					w->LowerWidget(_scengen_town_size + TSEW_SMALLTOWN);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 			} break;
 
 		case WE_TIMEOUT:
 			w->RaiseWidget(TSEW_RANDOMTOWN);
 			w->RaiseWidget(TSEW_MANYRANDOMTOWNS);
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_PLACE_OBJ:
@@ -688,7 +688,7 @@
 		case WE_ABORT_PLACE_OBJ:
 			w->RaiseButtons();
 			w->LowerWidget(_scengen_town_size + TSEW_SMALLTOWN);
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 	}
 }
--- a/src/transparency_gui.cpp
+++ b/src/transparency_gui.cpp
@@ -66,7 +66,7 @@
 				if (_ctrl_pressed) {
 					/* toggle the bit of the transparencies lock variable */
 					ToggleTransparencyLock((TransparencyOption)(e->we.click.widget - TTW_WIDGET_SIGNS));
-					SetWindowDirty(w);
+					w->SetDirty();
 				} else {
 					/* toggle the bit of the transparencies variable and play a sound */
 					ToggleTransparency((TransparencyOption)(e->we.click.widget - TTW_WIDGET_SIGNS));
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -119,7 +119,7 @@
 			case WC_SHIPS_LIST:
 			case WC_AIRCRAFT_LIST:
 				WP(w, vehiclelist_d).l.flags |= sl_flag;
-				SetWindowDirty(w);
+				w->SetDirty();
 				break;
 
 			default: break;
@@ -381,7 +381,7 @@
 					int y = e->we.click.pt.y - w->widget[3].top;
 					if (y >= 0) {
 						WP(w, refit_d).sel = (y / (int)w->resize.step_height) + w->vscroll.pos;
-						SetWindowDirty(w);
+						w->SetDirty();
 					}
 				} break;
 				case 6: // refit button
@@ -741,30 +741,30 @@
 	if (w != NULL) {
 		w->window_number = to_index;
 		WP(w, vp_d).follow_vehicle = to_index;
-		SetWindowDirty(w);
+		w->SetDirty();
 
 		w = FindWindowById(WC_VEHICLE_ORDERS, from_index);
 		if (w != NULL) {
 			w->window_number = to_index;
-			SetWindowDirty(w);
+			w->SetDirty();
 		}
 
 		w = FindWindowById(WC_VEHICLE_REFIT, from_index);
 		if (w != NULL) {
 			w->window_number = to_index;
-			SetWindowDirty(w);
+			w->SetDirty();
 		}
 
 		w = FindWindowById(WC_VEHICLE_DETAILS, from_index);
 		if (w != NULL) {
 			w->window_number = to_index;
-			SetWindowDirty(w);
+			w->SetDirty();
 		}
 
 		w = FindWindowById(WC_VEHICLE_TIMETABLE, from_index);
 		if (w != NULL) {
 			w->window_number = to_index;
-			SetWindowDirty(w);
+			w->SetDirty();
 		}
 	}
 }
@@ -1082,7 +1082,7 @@
 					vl->l.flags |= VL_RESORT;
 
 					vl->_sorting->order = !!(vl->l.flags & VL_DESC);
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 				case VLW_WIDGET_SORT_BY_PULLDOWN:/* Select sorting criteria dropdown menu */
 					ShowDropDownMenu(w, _vehicle_sort_listing, vl->l.sort_type, VLW_WIDGET_SORT_BY_PULLDOWN, 0, (vl->vehicle_type == VEH_TRAIN || vl->vehicle_type == VEH_ROAD) ? 0 : (1 << 10));
@@ -1169,7 +1169,7 @@
 					break;
 				default: NOT_REACHED();
 			}
-			SetWindowDirty(w);
+			w->SetDirty();
 			break;
 
 		case WE_DESTROY:
@@ -1185,7 +1185,7 @@
 				DEBUG(misc, 3, "Periodic resort %d list player %d at station %d", vl->vehicle_type, owner, station);
 				vl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
 				vl->l.flags |= VL_RESORT;
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 			break;
 
@@ -1634,7 +1634,7 @@
 						WIDGET_LIST_END);
 
 					WP(w, vehicledetails_d).tab = e->we.click.widget - VLD_WIDGET_DETAILS_CARGO_CARRIED;
-					SetWindowDirty(w);
+					w->SetDirty();
 					break;
 			}
 		} break;
@@ -2168,7 +2168,7 @@
 					w->SetWidgetHiddenState( VVW_WIDGET_REFIT_VEH, !veh_stopped); // refit
 					w->SetWidgetHiddenState(VVW_WIDGET_TURN_AROUND, veh_stopped);  // force turn around
 				}
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 		} break;
 	}
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -123,7 +123,7 @@
 		}
 	}
 
-	SetWindowDirty(w);
+	w->SetDirty();
 }
 
 /** Returns the index for the widget located at the given position
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -252,7 +252,7 @@
 			int pos = Clamp(sb->pos + wheel, 0, sb->count - sb->cap);
 			if (pos != sb->pos) {
 				sb->pos = pos;
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 		}
 	}
@@ -564,7 +564,7 @@
 	if (w != NULL) {
 		w->flags4 |= WF_WHITE_BORDER_MASK;
 		BringWindowToFront(w);
-		SetWindowDirty(w);
+		w->SetDirty();
 	}
 
 	return w;
@@ -602,7 +602,7 @@
 	memmove(wz, wz + 1, (byte*)vz - (byte*)wz);
 	*vz = tempz;
 
-	SetWindowDirty(w);
+	w->SetDirty();
 }
 
 /** We have run out of windows, so find a suitable candidate for replacement.
@@ -795,7 +795,7 @@
 	w->left = nx;
 	w->top = ny;
 
-	SetWindowDirty(w);
+	w->SetDirty();
 
 	return w;
 }
@@ -1117,7 +1117,7 @@
 		/* Unclick scrollbar buttons if they are pressed. */
 		if (w->flags4 & (WF_SCROLL_DOWN | WF_SCROLL_UP)) {
 			w->flags4 &= ~(WF_SCROLL_DOWN | WF_SCROLL_UP);
-			SetWindowDirty(w);
+			w->SetDirty();
 		}
 		CallWindowEventNP(w, WE_MOUSELOOP);
 	}
@@ -1259,7 +1259,7 @@
 
 	if (x == 0 && y == 0) return;
 
-	SetWindowDirty(w);
+	w->SetDirty();
 	for (wi = w->widget; wi->type != WWT_LAST; wi++) {
 		/* Isolate the resizing flags */
 		byte rsizeflag = GB(wi->display_flags, 0, 4);
@@ -1292,7 +1292,7 @@
 	if (resize_width)  w->width  += x;
 	if (resize_height) w->height += y;
 
-	SetWindowDirty(w);
+	w->SetDirty();
 }
 
 static bool _dragging_window;
@@ -1321,7 +1321,7 @@
 				break;
 			}
 
-			SetWindowDirty(w);
+			w->SetDirty();
 
 			x = _cursor.pos.x + _drag_delta.x;
 			y = _cursor.pos.y + _drag_delta.y;
@@ -1442,7 +1442,7 @@
 			w->left = nx;
 			w->top  = ny;
 
-			SetWindowDirty(w);
+			w->SetDirty();
 			return false;
 		} else if (w->flags4 & WF_SIZING) {
 			WindowEvent e;
@@ -1451,7 +1451,7 @@
 			/* Stop the sizing if the left mouse button was released */
 			if (!_left_button_down) {
 				w->flags4 &= ~WF_SIZING;
-				SetWindowDirty(w);
+				w->SetDirty();
 				break;
 			}
 
@@ -1547,7 +1547,7 @@
 			/* Abort if no button is clicked any more. */
 			if (!_left_button_down) {
 				w->flags4 &= ~WF_SCROLL_MIDDLE;
-				SetWindowDirty(w);
+				w->SetDirty();
 				break;
 			}
 
@@ -1566,7 +1566,7 @@
 			pos = min(max(0, i + _scrollbar_start_pos) * sb->count / _scrollbar_size, max(0, sb->count - sb->cap));
 			if (pos != sb->pos) {
 				sb->pos = pos;
-				SetWindowDirty(w);
+				w->SetDirty();
 			}
 			return false;
 		}
@@ -1652,7 +1652,7 @@
 		/* A modal child will prevent the activation of the parent window */
 		if (u->parent == w && (u->desc_flags & WDF_MODAL)) {
 			u->flags4 |= WF_WHITE_BORDER_MASK;
-			SetWindowDirty(u);
+			u->SetDirty();
 			return false;
 		}
 
@@ -2059,7 +2059,7 @@
 		if (w->flags4 & WF_WHITE_BORDER_MASK) {
 			w->flags4 -= WF_WHITE_BORDER_ONE;
 
-			if (!(w->flags4 & WF_WHITE_BORDER_MASK)) SetWindowDirty(w);
+			if (!(w->flags4 & WF_WHITE_BORDER_MASK)) w->SetDirty();
 		}
 	}
 
@@ -2105,7 +2105,7 @@
 
 	FOR_ALL_WINDOWS(wz) {
 		const Window *w = *wz;
-		if (w->window_class == cls && w->window_number == number) SetWindowDirty(w);
+		if (w->window_class == cls && w->window_number == number) w->SetDirty();
 	}
 }
 
@@ -2136,7 +2136,7 @@
 	Window* const *wz;
 
 	FOR_ALL_WINDOWS(wz) {
-		if ((*wz)->window_class == cls) SetWindowDirty(*wz);
+		if ((*wz)->window_class == cls) (*wz)->SetDirty();
 	}
 }
 
@@ -2147,7 +2147,7 @@
 void InvalidateThisWindowData(Window *w)
 {
 	CallWindowEventNP(w, WE_INVALIDATE_DATA);
-	SetWindowDirty(w);
+	w->SetDirty();
 }
 
 /**