summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--airport_gui.c3
-rw-r--r--dock_gui.c3
-rw-r--r--industry_gui.c2
-rw-r--r--main_gui.c22
-rw-r--r--misc_gui.c1
-rw-r--r--player_gui.c18
-rw-r--r--rail_gui.c2
-rw-r--r--road_gui.c3
-rw-r--r--station_gui.c2
-rw-r--r--terraform_gui.c2
-rw-r--r--vehicle_gui.c5
11 files changed, 35 insertions, 28 deletions
diff --git a/airport_gui.c b/airport_gui.c
index 11acd7a64..0104cc645 100644
--- a/airport_gui.c
+++ b/airport_gui.c
@@ -133,7 +133,8 @@ static const WindowDesc _air_toolbar_desc = {
void ShowBuildAirToolbar(void)
{
- if (_current_player == PLAYER_SPECTATOR) return;
+ if (!IsValidPlayer(_current_player)) return;
+
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
AllocateWindowDescFront(&_air_toolbar_desc, 0);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar();
diff --git a/dock_gui.c b/dock_gui.c
index 571c91985..a58fe29fa 100644
--- a/dock_gui.c
+++ b/dock_gui.c
@@ -214,7 +214,8 @@ static const WindowDesc _build_docks_toolbar_desc = {
void ShowBuildDocksToolbar(void)
{
- if (_current_player == PLAYER_SPECTATOR) return;
+ if (!IsValidPlayer(_current_player)) return;
+
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
AllocateWindowDesc(&_build_docks_toolbar_desc);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar();
diff --git a/industry_gui.c b/industry_gui.c
index b2db3252a..9a650e6ae 100644
--- a/industry_gui.c
+++ b/industry_gui.c
@@ -268,7 +268,7 @@ static const WindowDesc * const _industry_window_desc[2][4] = {
void ShowBuildIndustryWindow(void)
{
- if (_current_player == PLAYER_SPECTATOR) return;
+ if (!IsValidPlayer(_current_player)) return;
AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt_ptr->landscape],0);
}
diff --git a/main_gui.c b/main_gui.c
index bb354e16b..bfaed7ad1 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -1821,30 +1821,26 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e)
} break;
case WE_KEYPRESS: {
- PlayerID local = (_local_player != PLAYER_SPECTATOR) ? _local_player : 0;
-
switch (e->we.keypress.keycode) {
- case WKC_F1: case WKC_PAUSE:
- ToolbarPauseClick(w);
- break;
+ case WKC_F1: case WKC_PAUSE: ToolbarPauseClick(w); break;
case WKC_F2: ShowGameOptions(); break;
case WKC_F3: MenuClickSaveLoad(0); break;
case WKC_F4: ShowSmallMap(); break;
case WKC_F5: ShowTownDirectory(); break;
case WKC_F6: ShowSubsidiesList(); break;
- case WKC_F7: ShowPlayerStations(local); break;
- case WKC_F8: ShowPlayerFinances(local); break;
- case WKC_F9: ShowPlayerCompany(local); break;
+ case WKC_F7: ShowPlayerStations(_local_player); break;
+ case WKC_F8: ShowPlayerFinances(_local_player); break;
+ case WKC_F9: ShowPlayerCompany(_local_player); break;
case WKC_F10:ShowOperatingProfitGraph(); break;
case WKC_F11: ShowCompanyLeagueTable(); break;
case WKC_F12: ShowBuildIndustryWindow(); break;
- case WKC_SHIFT | WKC_F1: ShowVehicleListWindow(local, INVALID_STATION, VEH_Train); break;
- case WKC_SHIFT | WKC_F2: ShowVehicleListWindow(local, INVALID_STATION, VEH_Road); break;
- case WKC_SHIFT | WKC_F3: ShowVehicleListWindow(local, INVALID_STATION, VEH_Ship); break;
- case WKC_SHIFT | WKC_F4: ShowVehicleListWindow(local, INVALID_STATION, VEH_Aircraft); break;
+ case WKC_SHIFT | WKC_F1: ShowVehicleListWindow(_local_player, INVALID_STATION, VEH_Train); break;
+ case WKC_SHIFT | WKC_F2: ShowVehicleListWindow(_local_player, INVALID_STATION, VEH_Road); break;
+ case WKC_SHIFT | WKC_F3: ShowVehicleListWindow(_local_player, INVALID_STATION, VEH_Ship); break;
+ case WKC_SHIFT | WKC_F4: ShowVehicleListWindow(_local_player, INVALID_STATION, VEH_Aircraft); break;
case WKC_SHIFT | WKC_F5: ToolbarZoomInClick(w); break;
case WKC_SHIFT | WKC_F6: ToolbarZoomOutClick(w); break;
- case WKC_SHIFT | WKC_F7: ShowBuildRailToolbar(_last_built_railtype,-1); break;
+ case WKC_SHIFT | WKC_F7: ShowBuildRailToolbar(_last_built_railtype, -1); break;
case WKC_SHIFT | WKC_F8: ShowBuildRoadToolbar(); break;
case WKC_SHIFT | WKC_F9: ShowBuildDocksToolbar(); break;
case WKC_SHIFT | WKC_F10:ShowBuildAirToolbar(); break;
diff --git a/misc_gui.c b/misc_gui.c
index 583f5d571..2db97dac2 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -450,6 +450,7 @@ static const WindowDesc _build_trees_scen_desc = {
void ShowBuildTreesToolbar(void)
{
+ if (!IsValidPlayer(_current_player)) return;
AllocateWindowDescFront(&_build_trees_desc, 0);
}
diff --git a/player_gui.c b/player_gui.c
index 4ec06e7c3..798c805bb 100644
--- a/player_gui.c
+++ b/player_gui.c
@@ -219,24 +219,24 @@ static const WindowDesc _other_player_finances_small_desc = {
PlayerFinancesWndProc
};
-static const WindowDesc * const desc_table[2*2] = {
- &_player_finances_desc,&_player_finances_small_desc,
- &_other_player_finances_desc,&_other_player_finances_small_desc,
-};
-
static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied)
{
Window *w;
int mode;
+ static const WindowDesc * const desc_table[2 * 2] = {
+ &_player_finances_desc, &_player_finances_small_desc,
+ &_other_player_finances_desc, &_other_player_finances_small_desc,
+ };
+
+ if (!IsValidPlayer(player)) return;
+
mode = (player != _local_player) * 2 + show_small;
w = AllocateWindowDescFront(desc_table[mode], player);
if (w != NULL) {
w->caption_color = w->window_number;
WP(w,def_d).data_1 = mode;
- if (show_stickied) {
- w->flags4 |= WF_STICKY;
- }
+ if (show_stickied) w->flags4 |= WF_STICKY;
}
}
@@ -878,6 +878,8 @@ void ShowPlayerCompany(PlayerID player)
{
Window *w;
+ if (!IsValidPlayer(player)) return;
+
w = AllocateWindowDescFront(&_player_company_desc, player);
if (w != NULL) w->caption_color = w->window_number;
}
diff --git a/rail_gui.c b/rail_gui.c
index 60fcdafb9..bf8fb3bcc 100644
--- a/rail_gui.c
+++ b/rail_gui.c
@@ -589,7 +589,7 @@ void ShowBuildRailToolbar(RailType railtype, int button)
{
Window *w;
- if (_current_player == PLAYER_SPECTATOR) return;
+ if (!IsValidPlayer(_current_player)) return;
if (!ValParamRailtype(railtype)) return;
// don't recreate the window if we're clicking on a button and the window exists.
diff --git a/road_gui.c b/road_gui.c
index 8a31ec766..e8dcda448 100644
--- a/road_gui.c
+++ b/road_gui.c
@@ -318,7 +318,8 @@ static const WindowDesc _build_road_desc = {
void ShowBuildRoadToolbar(void)
{
- if (_current_player == PLAYER_SPECTATOR) return;
+ if (!IsValidPlayer(_current_player)) return;
+
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
AllocateWindowDesc(&_build_road_desc);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar();
diff --git a/station_gui.c b/station_gui.c
index ce4cba46e..d69e34297 100644
--- a/station_gui.c
+++ b/station_gui.c
@@ -506,6 +506,8 @@ void ShowPlayerStations(PlayerID player)
{
Window *w;
+ if (!IsValidPlayer(player)) return;
+
w = AllocateWindowDescFront(&_player_stations_desc, player);
if (w != NULL) {
w->caption_color = (byte)w->window_number;
diff --git a/terraform_gui.c b/terraform_gui.c
index 1377a93a3..35549421f 100644
--- a/terraform_gui.c
+++ b/terraform_gui.c
@@ -274,6 +274,6 @@ static const WindowDesc _terraform_desc = {
void ShowTerraformToolbar(void)
{
- if (_current_player == PLAYER_SPECTATOR) return;
+ if (!IsValidPlayer(_current_player)) return;
AllocateWindowDescFront(&_terraform_desc, 0);
}
diff --git a/vehicle_gui.c b/vehicle_gui.c
index df33fd69c..2eaad2ee0 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -1856,8 +1856,11 @@ static const WindowDesc _player_vehicle_list_aircraft_desc = {
static void ShowVehicleListWindowLocal(PlayerID player, byte vehicle_type, StationID station, OrderID order, uint16 depot_airport_index)
{
Window *w;
- WindowNumber num = (vehicle_type << 11) | player;
+ WindowNumber num;
+ if (!IsValidPlayer(player)) return;
+
+ num = (vehicle_type << 11) | player;
if (order != INVALID_ORDER) {
num |= (order << 16) | VLW_SHARED_ORDERS;
} else if (depot_airport_index != INVALID_STATION) {