-
-
Save Wolfolo/b84764da56d96e08fe6ff29adda839ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/ai/ai_config.cpp b/src/ai/ai_config.cpp | |
index f920d31..57916d1 100644 | |
--- a/src/ai/ai_config.cpp | |
+++ b/src/ai/ai_config.cpp | |
@@ -38,7 +38,7 @@ ScriptConfigItem _start_date_config = { | |
/* static */ AIConfig *AIConfig::GetConfig(CompanyID company, ScriptSettingSource source) | |
{ | |
AIConfig **config; | |
- if (source == SSS_FORCE_NEWGAME || (source == SSS_DEFAULT && _game_mode == GM_MENU)) { | |
+ if (source == SSS_FORCE_NEWGAME || (source == SSS_DEFAULT && Globals::IsGameMode(GM_MENU))) { | |
config = &_settings_newgame.ai_config[company]; | |
} else { | |
config = &_settings_game.ai_config[company]; | |
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp | |
index 101a97d..a376a25 100644 | |
--- a/src/ai/ai_gui.cpp | |
+++ b/src/ai/ai_gui.cpp | |
@@ -222,7 +222,7 @@ struct AIListWindow : public Window { | |
*/ | |
virtual void OnInvalidateData(int data = 0, bool gui_scope = true) | |
{ | |
- if (_game_mode == GM_NORMAL && Company::IsValidID(this->slot)) { | |
+ if (Globals::IsGameMode(GM_NORMAL) && Company::IsValidID(this->slot)) { | |
delete this; | |
return; | |
} | |
@@ -311,7 +311,7 @@ struct AISettingsWindow : public Window { | |
this->vscroll = this->GetScrollbar(WID_AIS_SCROLLBAR); | |
this->FinishInitNested(slot); // Initializes 'this->line_height' as side effect. | |
- this->SetWidgetDisabledState(WID_AIS_RESET, _game_mode != GM_MENU && Company::IsValidID(this->slot)); | |
+ this->SetWidgetDisabledState(WID_AIS_RESET, !Globals::IsGameMode(GM_MENU) && Company::IsValidID(this->slot)); | |
this->RebuildVisibleSettings(); | |
} | |
@@ -377,7 +377,7 @@ struct AISettingsWindow : public Window { | |
for (; this->vscroll->IsVisible(i) && it != visible_settings.end(); i++, it++) { | |
const ScriptConfigItem &config_item = **it; | |
int current_value = config->GetSetting((config_item).name); | |
- bool editable = _game_mode == GM_MENU || ((this->slot != OWNER_DEITY) && !Company::IsValidID(this->slot)) || (config_item.flags & SCRIPTCONFIG_INGAME) != 0; | |
+ bool editable = Globals::IsGameMode(GM_MENU) || ((this->slot != OWNER_DEITY) && !Company::IsValidID(this->slot)) || (config_item.flags & SCRIPTCONFIG_INGAME) != 0; | |
StringID str; | |
TextColour colour; | |
@@ -440,7 +440,7 @@ struct AISettingsWindow : public Window { | |
VisibleSettingsList::const_iterator it = this->visible_settings.begin(); | |
for (int i = 0; i < num; i++) it++; | |
const ScriptConfigItem config_item = **it; | |
- if (_game_mode == GM_NORMAL && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && (config_item.flags & SCRIPTCONFIG_INGAME) == 0) return; | |
+ if (Globals::IsGameMode(GM_NORMAL) && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && (config_item.flags & SCRIPTCONFIG_INGAME) == 0) return; | |
if (this->clicked_row != num) { | |
DeleteChildWindows(WC_QUERY_STRING); | |
@@ -521,7 +521,7 @@ struct AISettingsWindow : public Window { | |
break; | |
case WID_AIS_RESET: | |
- if (_game_mode == GM_MENU || !Company::IsValidID(this->slot)) { | |
+ if (Globals::IsGameMode(GM_MENU) || !Company::IsValidID(this->slot)) { | |
this->ai_config->ResetSettings(); | |
this->SetDirty(); | |
} | |
@@ -535,7 +535,7 @@ struct AISettingsWindow : public Window { | |
VisibleSettingsList::const_iterator it = this->visible_settings.begin(); | |
for (int i = 0; i < this->clicked_row; i++) it++; | |
const ScriptConfigItem config_item = **it; | |
- if (_game_mode == GM_NORMAL && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && (config_item.flags & SCRIPTCONFIG_INGAME) == 0) return; | |
+ if (Globals::IsGameMode(GM_NORMAL) && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && (config_item.flags & SCRIPTCONFIG_INGAME) == 0) return; | |
int32 value = atoi(str); | |
this->ai_config->SetSetting(config_item.name, value); | |
this->SetDirty(); | |
@@ -547,7 +547,7 @@ struct AISettingsWindow : public Window { | |
VisibleSettingsList::const_iterator it = this->visible_settings.begin(); | |
for (int i = 0; i < this->clicked_row; i++) it++; | |
const ScriptConfigItem config_item = **it; | |
- if (_game_mode == GM_NORMAL && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && (config_item.flags & SCRIPTCONFIG_INGAME) == 0) return; | |
+ if (Globals::IsGameMode(GM_NORMAL) && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && (config_item.flags & SCRIPTCONFIG_INGAME) == 0) return; | |
this->ai_config->SetSetting(config_item.name, index); | |
this->SetDirty(); | |
} | |
@@ -796,9 +796,9 @@ struct AIConfigWindow : public Window { | |
*/ | |
static bool IsEditable(CompanyID slot) | |
{ | |
- if (slot == OWNER_DEITY) return _game_mode != GM_NORMAL || Game::GetInstance() != NULL; | |
+ if (slot == OWNER_DEITY) return !Globals::IsGameMode(GM_NORMAL) || Game::GetInstance() != NULL; | |
- if (_game_mode != GM_NORMAL) { | |
+ if (!Globals::IsGameMode(GM_NORMAL)) { | |
return slot > 0 && slot <= GetGameSettings().difficulty.max_no_competitors; | |
} | |
if (Company::IsValidID(slot) || slot < 0) return false; | |
@@ -832,7 +832,7 @@ struct AIConfigWindow : public Window { | |
for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < MAX_COMPANIES; i++) { | |
StringID text; | |
- if ((_game_mode != GM_NORMAL && i == 0) || (_game_mode == GM_NORMAL && Company::IsValidHumanID(i))) { | |
+ if ((!Globals::IsGameMode(GM_NORMAL) && i == 0) || (Globals::IsGameMode(GM_NORMAL) && Company::IsValidHumanID(i))) { | |
text = STR_AI_CONFIG_HUMAN_PLAYER; | |
} else if (AIConfig::GetConfig((CompanyID)i)->GetInfo() != NULL) { | |
SetDParamStr(0, AIConfig::GetConfig((CompanyID)i)->GetInfo()->GetName()); | |
@@ -875,7 +875,7 @@ struct AIConfigWindow : public Window { | |
case WID_AIC_GAMELIST: { | |
this->selected_slot = OWNER_DEITY; | |
this->InvalidateData(); | |
- if (click_count > 1 && this->selected_slot != INVALID_COMPANY && _game_mode != GM_NORMAL) ShowAIListWindow((CompanyID)this->selected_slot); | |
+ if (click_count > 1 && this->selected_slot != INVALID_COMPANY && !Globals::IsGameMode(GM_NORMAL)) ShowAIListWindow((CompanyID)this->selected_slot); | |
break; | |
} | |
@@ -943,7 +943,7 @@ struct AIConfigWindow : public Window { | |
this->SetWidgetDisabledState(WID_AIC_DECREASE, GetGameSettings().difficulty.max_no_competitors == 0); | |
this->SetWidgetDisabledState(WID_AIC_INCREASE, GetGameSettings().difficulty.max_no_competitors == MAX_COMPANIES - 1); | |
- this->SetWidgetDisabledState(WID_AIC_CHANGE, (this->selected_slot == OWNER_DEITY && _game_mode == GM_NORMAL) || this->selected_slot == INVALID_COMPANY); | |
+ this->SetWidgetDisabledState(WID_AIC_CHANGE, (this->selected_slot == OWNER_DEITY && Globals::IsGameMode(GM_NORMAL)) || this->selected_slot == INVALID_COMPANY); | |
this->SetWidgetDisabledState(WID_AIC_CONFIGURE, this->selected_slot == INVALID_COMPANY || GetConfig(this->selected_slot)->GetConfigList()->size() == 0); | |
this->SetWidgetDisabledState(WID_AIC_MOVE_UP, this->selected_slot == OWNER_DEITY || this->selected_slot == INVALID_COMPANY || !IsEditable((CompanyID)(this->selected_slot - 1))); | |
this->SetWidgetDisabledState(WID_AIC_MOVE_DOWN, this->selected_slot == OWNER_DEITY || this->selected_slot == INVALID_COMPANY || !IsEditable((CompanyID)(this->selected_slot + 1))); | |
@@ -1429,7 +1429,7 @@ NWidgetBase *MakeCompanyButtonRowsAIDebug(int *biggest_index) | |
*/ | |
static EventState AIDebugGlobalHotkeys(int hotkey) | |
{ | |
- if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED; | |
+ if (!Globals::IsGameMode(GM_NORMAL)) return ES_NOT_HANDLED; | |
Window *w = ShowAIDebugWindow(INVALID_COMPANY); | |
if (w == NULL) return ES_NOT_HANDLED; | |
return w->OnHotkey(hotkey); | |
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp | |
index 6437f23..79e23a0 100644 | |
--- a/src/airport_gui.cpp | |
+++ b/src/airport_gui.cpp | |
@@ -159,7 +159,7 @@ struct BuildAirToolbarWindow : Window { | |
*/ | |
static EventState AirportToolbarGlobalHotkeys(int hotkey) | |
{ | |
- if (_game_mode != GM_NORMAL || !CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) return ES_NOT_HANDLED; | |
+ if (!Globals::IsGameMode(GM_NORMAL) || !CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) return ES_NOT_HANDLED; | |
Window *w = ShowBuildAirToolbar(); | |
if (w == NULL) return ES_NOT_HANDLED; | |
return w->OnHotkey(hotkey); | |
diff --git a/src/autoslope.h b/src/autoslope.h | |
index e504610..eee9d61 100644 | |
--- a/src/autoslope.h | |
+++ b/src/autoslope.h | |
@@ -47,7 +47,7 @@ static inline bool AutoslopeEnabled() | |
{ | |
return (_settings_game.construction.autoslope && | |
(_current_company < MAX_COMPANIES || | |
- (_current_company == OWNER_NONE && _game_mode == GM_EDITOR))); | |
+ (_current_company == OWNER_NONE && Globals::IsGameMode(GM_EDITOR)))); | |
} | |
#endif /* AUTOSLOPE_H */ | |
diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp | |
index 7abc385..48d646c 100644 | |
--- a/src/bootstrap_gui.cpp | |
+++ b/src/bootstrap_gui.cpp | |
@@ -94,7 +94,7 @@ public: | |
BaseGraphics::FindSets(); | |
/* And continue going into the menu. */ | |
- _game_mode = GM_MENU; | |
+ Globals::SetGameMode(GM_MENU); | |
/* _exit_game is used to break out of the outer video driver's MainLoop. */ | |
_exit_game = true; | |
@@ -224,7 +224,7 @@ bool HandleBootstrap() | |
if (!_network_available) goto failure; | |
/* First tell the game we're bootstrapping. */ | |
- _game_mode = GM_BOOTSTRAP; | |
+ Globals::SetGameMode(GM_BOOTSTRAP); | |
/* Initialise the freetype font code. */ | |
InitializeUnicodeGlyphMap(); | |
@@ -251,14 +251,14 @@ bool HandleBootstrap() | |
/* _exit_game is used to get out of the video driver's main loop. | |
* In case GM_BOOTSTRAP is still set we did not exit it via the | |
* "download complete" event, so it was a manual exit. Obey it. */ | |
- _exit_game = _game_mode == GM_BOOTSTRAP; | |
+ _exit_game = Globals::IsGameMode(GM_BOOTSTRAP); | |
if (_exit_game) return false; | |
/* Try to probe the graphics. Should work this time. */ | |
if (!BaseGraphics::SetSet(NULL)) goto failure; | |
/* Finally we can continue heading for the menu. */ | |
- _game_mode = GM_MENU; | |
+ Globals::SetGameMode(GM_MENU); | |
return true; | |
#endif | |
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp | |
index 797ead1..30c3341 100644 | |
--- a/src/bridge_gui.cpp | |
+++ b/src/bridge_gui.cpp | |
@@ -193,7 +193,7 @@ public: | |
SetDParam(2, this->bridges->Get(i)->cost); | |
SetDParam(1, b->speed); | |
SetDParam(0, b->material); | |
- text_dim = maxdim(text_dim, GetStringBoundingBox(_game_mode == GM_EDITOR ? STR_SELECT_BRIDGE_SCENEDIT_INFO : STR_SELECT_BRIDGE_INFO)); | |
+ text_dim = maxdim(text_dim, GetStringBoundingBox(Globals::IsGameMode(GM_EDITOR) ? STR_SELECT_BRIDGE_SCENEDIT_INFO : STR_SELECT_BRIDGE_INFO)); | |
} | |
sprite_dim.height++; // Sprite is rendered one pixel down in the matrix field. | |
text_dim.height++; // Allowing the bottom row pixels to be rendered on the edge of the matrix field. | |
@@ -235,7 +235,7 @@ public: | |
DrawSprite(b->sprite, b->pal, r.left + WD_MATRIX_LEFT, y + this->resize.step_height - 1 - GetSpriteSize(b->sprite).height); | |
DrawStringMultiLine(r.left + this->bridgetext_offset, r.right, y + 2, y + this->resize.step_height, | |
- _game_mode == GM_EDITOR ? STR_SELECT_BRIDGE_SCENEDIT_INFO : STR_SELECT_BRIDGE_INFO); | |
+ Globals::IsGameMode(GM_EDITOR) ? STR_SELECT_BRIDGE_SCENEDIT_INFO : STR_SELECT_BRIDGE_INFO); | |
y += this->resize.step_height; | |
} | |
break; | |
diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp | |
index f9eb88d..8e2b600 100644 | |
--- a/src/clear_cmd.cpp | |
+++ b/src/clear_cmd.cpp | |
@@ -268,7 +268,7 @@ static void TileLoop_Clear(TileIndex tile) | |
case CLEAR_GRASS: | |
if (GetClearDensity(tile) == 3) return; | |
- if (_game_mode != GM_EDITOR) { | |
+ if (!Globals::IsGameMode(GM_EDITOR)) { | |
if (GetClearCounter(tile) < 7) { | |
AddClearCounter(tile, 1); | |
return; | |
@@ -284,7 +284,7 @@ static void TileLoop_Clear(TileIndex tile) | |
case CLEAR_FIELDS: | |
UpdateFences(tile); | |
- if (_game_mode == GM_EDITOR) return; | |
+ if (Globals::IsGameMode(GM_EDITOR)) return; | |
if (GetClearCounter(tile) < 7) { | |
AddClearCounter(tile, 1); | |
diff --git a/src/command.cpp b/src/command.cpp | |
index 959610c..a6597d9 100644 | |
--- a/src/command.cpp | |
+++ b/src/command.cpp | |
@@ -419,7 +419,7 @@ bool IsCommandAllowedWhilePaused(uint32 cmd) | |
assert_compile(lengthof(command_type_lookup) == CMDT_END); | |
assert(IsValidCommand(cmd)); | |
- return _game_mode == GM_EDITOR || command_type_lookup[_command_proc_table[cmd & CMD_ID_MASK].type] <= _settings_game.construction.command_pause_level; | |
+ return Globals::IsGameMode(GM_EDITOR) || command_type_lookup[_command_proc_table[cmd & CMD_ID_MASK].type] <= _settings_game.construction.command_pause_level; | |
} | |
@@ -583,7 +583,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac | |
} | |
} else if (estimate_only) { | |
ShowEstimatedCostOrIncome(res.GetCost(), x, y); | |
- } else if (!only_sending && res.GetCost() != 0 && tile != 0 && IsLocalCompany() && _game_mode != GM_EDITOR) { | |
+ } else if (!only_sending && res.GetCost() != 0 && tile != 0 && IsLocalCompany() && !Globals::IsGameMode(GM_EDITOR)) { | |
/* Only show the cost animation when we did actually | |
* execute the command, i.e. we're not sending it to | |
* the server, when it has cost the local company | |
@@ -657,7 +657,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, | |
/* If the company isn't valid it may only do server command or start a new company! | |
* The server will ditch any server commands a client sends to it, so effectively | |
* this guards the server from executing functions for an invalid company. */ | |
- if (_game_mode == GM_NORMAL && !exec_as_spectator && !Company::IsValidID(_current_company) && !(_current_company == OWNER_DEITY && (cmd_flags & CMD_DEITY) != 0)) { | |
+ if (Globals::IsGameMode(GM_NORMAL) && !exec_as_spectator && !Company::IsValidID(_current_company) && !(_current_company == OWNER_DEITY && (cmd_flags & CMD_DEITY) != 0)) { | |
return_dcpi(CMD_ERROR); | |
} | |
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp | |
index ee2ed13..e20c53f 100644 | |
--- a/src/company_cmd.cpp | |
+++ b/src/company_cmd.cpp | |
@@ -696,7 +696,7 @@ static void HandleBankruptcyTakeover(Company *c) | |
/** Called every tick for updating some company info. */ | |
void OnTick_Companies() | |
{ | |
- if (_game_mode == GM_EDITOR) return; | |
+ if (Globals::IsGameMode(GM_EDITOR)) return; | |
Company *c = Company::GetIfValid(_cur_company_tick_index); | |
if (c != NULL) { | |
@@ -708,7 +708,7 @@ void OnTick_Companies() | |
_next_competitor_start = AI::GetStartNextTime() * DAY_TICKS; | |
} | |
- if (AI::CanStartNew() && _game_mode != GM_MENU && --_next_competitor_start == 0) { | |
+ if (AI::CanStartNew() && !Globals::IsGameMode(GM_MENU) && --_next_competitor_start == 0) { | |
MaybeStartNewCompany(); | |
} | |
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp | |
index 9cfc8e8..32798dc 100644 | |
--- a/src/console_cmds.cpp | |
+++ b/src/console_cmds.cpp | |
@@ -166,7 +166,7 @@ DEF_CONSOLE_HOOK(ConHookNoNetwork) | |
DEF_CONSOLE_HOOK(ConHookNewGRFDeveloperTool) | |
{ | |
if (_settings_client.gui.newgrf_developer_tools) { | |
- if (_game_mode == GM_MENU) { | |
+ if (Globals::IsGameMode(GM_MENU)) { | |
if (echo) IConsoleError("This command is only available in game and editor."); | |
return CHR_DISALLOW; | |
} | |
@@ -215,7 +215,7 @@ DEF_CONSOLE_CMD(ConResetEnginePool) | |
return true; | |
} | |
- if (_game_mode == GM_MENU) { | |
+ if (Globals::IsGameMode(GM_MENU)) { | |
IConsoleError("This command is only available in game and editor."); | |
return true; | |
} | |
@@ -1127,7 +1127,7 @@ DEF_CONSOLE_CMD(ConStartAI) | |
return true; | |
} | |
- if (_game_mode != GM_NORMAL) { | |
+ if (!Globals::IsGameMode(GM_NORMAL)) { | |
IConsoleWarning("AIs can only be managed in a game."); | |
return true; | |
} | |
@@ -1184,7 +1184,7 @@ DEF_CONSOLE_CMD(ConReloadAI) | |
return true; | |
} | |
- if (_game_mode != GM_NORMAL) { | |
+ if (!Globals::IsGameMode(GM_NORMAL)) { | |
IConsoleWarning("AIs can only be managed in a game."); | |
return true; | |
} | |
@@ -1221,7 +1221,7 @@ DEF_CONSOLE_CMD(ConStopAI) | |
return true; | |
} | |
- if (_game_mode != GM_NORMAL) { | |
+ if (!Globals::IsGameMode(GM_NORMAL)) { | |
IConsoleWarning("AIs can only be managed in a game."); | |
return true; | |
} | |
@@ -1432,7 +1432,7 @@ DEF_CONSOLE_CMD(ConExit) | |
return true; | |
} | |
- if (_game_mode == GM_NORMAL && _settings_client.gui.autosave_on_exit) DoExitSave(); | |
+ if (Globals::IsGameMode(GM_NORMAL) && _settings_client.gui.autosave_on_exit) DoExitSave(); | |
_exit_game = true; | |
return true; | |
@@ -1445,7 +1445,7 @@ DEF_CONSOLE_CMD(ConPart) | |
return true; | |
} | |
- if (_game_mode != GM_NORMAL) return false; | |
+ if (!Globals::IsGameMode(GM_NORMAL)) return false; | |
_switch_mode = SM_MENU; | |
return true; | |
diff --git a/src/date.cpp b/src/date.cpp | |
index 9c25af4..f0277a9 100644 | |
--- a/src/date.cpp | |
+++ b/src/date.cpp | |
@@ -277,7 +277,7 @@ void IncreaseDate() | |
/* increase day, and check if a new day is there? */ | |
_tick_counter++; | |
- if (_game_mode == GM_MENU) return; | |
+ if (Globals::IsGameMode(GM_MENU)) return; | |
_date_fract++; | |
if (_date_fract < DAY_TICKS) return; | |
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp | |
index 79eaa89..dce752b 100644 | |
--- a/src/dock_gui.cpp | |
+++ b/src/dock_gui.cpp | |
@@ -160,7 +160,7 @@ struct BuildDocksToolbarWindow : Window { | |
break; | |
case WID_DT_RIVER: // Build river button (in scenario editor) | |
- if (_game_mode != GM_EDITOR) return; | |
+ if (!Globals::IsGameMode(GM_EDITOR)) return; | |
HandlePlacePushButton(this, WID_DT_RIVER, SPR_CURSOR_RIVER, HT_RECT); | |
break; | |
@@ -177,7 +177,7 @@ struct BuildDocksToolbarWindow : Window { | |
{ | |
switch (this->last_clicked_widget) { | |
case WID_DT_CANAL: // Build canal button | |
- VpStartPlaceSizing(tile, (_game_mode == GM_EDITOR) ? VPM_X_AND_Y : VPM_X_OR_Y, DDSP_CREATE_WATER); | |
+ VpStartPlaceSizing(tile, (Globals::IsGameMode(GM_EDITOR)) ? VPM_X_AND_Y : VPM_X_OR_Y, DDSP_CREATE_WATER); | |
break; | |
case WID_DT_LOCK: // Build lock button | |
@@ -235,7 +235,7 @@ struct BuildDocksToolbarWindow : Window { | |
GUIPlaceProcDragXY(select_proc, start_tile, end_tile); | |
break; | |
case DDSP_CREATE_WATER: | |
- DoCommandP(end_tile, start_tile, (_game_mode == GM_EDITOR && _ctrl_pressed) ? WATER_CLASS_SEA : WATER_CLASS_CANAL, CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_BUILD_CANALS), CcPlaySound_SPLAT_WATER); | |
+ DoCommandP(end_tile, start_tile, (Globals::IsGameMode(GM_EDITOR) && _ctrl_pressed) ? WATER_CLASS_SEA : WATER_CLASS_CANAL, CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_BUILD_CANALS), CcPlaySound_SPLAT_WATER); | |
break; | |
case DDSP_CREATE_RIVER: | |
DoCommandP(end_tile, start_tile, WATER_CLASS_RIVER, CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_PLACE_RIVERS), CcPlaySound_SPLAT_WATER); | |
@@ -285,7 +285,7 @@ struct BuildDocksToolbarWindow : Window { | |
*/ | |
static EventState DockToolbarGlobalHotkeys(int hotkey) | |
{ | |
- if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED; | |
+ if (!Globals::IsGameMode(GM_NORMAL)) return ES_NOT_HANDLED; | |
Window *w = ShowBuildDocksToolbar(); | |
if (w == NULL) return ES_NOT_HANDLED; | |
return w->OnHotkey(hotkey); | |
diff --git a/src/economy.cpp b/src/economy.cpp | |
index 0106e87..4d1300a 100644 | |
--- a/src/economy.cpp | |
+++ b/src/economy.cpp | |
@@ -1863,7 +1863,7 @@ static void LoadUnloadVehicle(Vehicle *front) | |
* if _settings_client.gui.loading_indicators == 1, _local_company must be the owner or must be a spectator to show ind., so 1 > 0 | |
* if _settings_client.gui.loading_indicators == 0, do not display indicators ... 0 is never greater than anything | |
*/ | |
- if (_game_mode != GM_MENU && (_settings_client.gui.loading_indicators > (uint)(front->owner != _local_company && _local_company != COMPANY_SPECTATOR))) { | |
+ if (!Globals::IsGameMode(GM_MENU) && (_settings_client.gui.loading_indicators > (uint)(front->owner != _local_company && _local_company != COMPANY_SPECTATOR))) { | |
StringID percent_up_down = STR_NULL; | |
int percent = CalcPercentVehicleFilled(front, &percent_up_down); | |
if (front->fill_percent_te_id == INVALID_TE_ID) { | |
diff --git a/src/fios.cpp b/src/fios.cpp | |
index 0d30e09..c8ba334 100644 | |
--- a/src/fios.cpp | |
+++ b/src/fios.cpp | |
@@ -242,7 +242,7 @@ static void FiosMakeFilename(char *buf, const char *path, const char *name, cons | |
*/ | |
void FiosMakeSavegameName(char *buf, const char *name, const char *last) | |
{ | |
- const char *extension = (_game_mode == GM_EDITOR) ? ".scn" : ".sav"; | |
+ const char *extension = (Globals::IsGameMode(GM_EDITOR)) ? ".scn" : ".sav"; | |
FiosMakeFilename(buf, _fios_path, name, extension, last); | |
} | |
diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp | |
index f20cfd7..fc6711a 100644 | |
--- a/src/fios_gui.cpp | |
+++ b/src/fios_gui.cpp | |
@@ -299,7 +299,7 @@ public: | |
/* pause is only used in single-player, non-editor mode, non-menu mode. It | |
* will be unpaused in the WE_DESTROY event handler. */ | |
- if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) { | |
+ if (!Globals::IsGameMode(GM_MENU) && !_networking && !Globals::IsGameMode(GM_EDITOR)) { | |
DoCommandP(0, PM_PAUSED_SAVELOAD, 1, CMD_PAUSE); | |
} | |
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0); | |
@@ -334,7 +334,7 @@ public: | |
virtual ~SaveLoadWindow() | |
{ | |
/* pause is only used in single-player, non-editor mode, non menu mode */ | |
- if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) { | |
+ if (!_networking && !Globals::IsGameMode(GM_EDITOR) && !Globals::IsGameMode(GM_MENU)) { | |
DoCommandP(0, PM_PAUSED_SAVELOAD, 0, CMD_PAUSE); | |
} | |
} | |
@@ -545,7 +545,7 @@ public: | |
ShowHeightmapLoad(); | |
} else if (!_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs()) { | |
- _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD_GAME; | |
+ _switch_mode = (Globals::IsGameMode(GM_EDITOR)) ? SM_LOAD_SCENARIO : SM_LOAD_GAME; | |
ClearErrorMessages(); | |
delete this; | |
} | |
@@ -674,7 +674,7 @@ public: | |
} | |
/* In the editor set up the vehicle engines correctly (date might have changed) */ | |
- if (_game_mode == GM_EDITOR) StartupEngines(); | |
+ if (Globals::IsGameMode(GM_EDITOR)) StartupEngines(); | |
} | |
} | |
diff --git a/src/game/game_config.cpp b/src/game/game_config.cpp | |
index 50cd5da..a104d8b 100644 | |
--- a/src/game/game_config.cpp | |
+++ b/src/game/game_config.cpp | |
@@ -20,7 +20,7 @@ | |
/* static */ GameConfig *GameConfig::GetConfig(ScriptSettingSource source) | |
{ | |
GameConfig **config; | |
- if (source == SSS_FORCE_NEWGAME || (source == SSS_DEFAULT && _game_mode == GM_MENU)) { | |
+ if (source == SSS_FORCE_NEWGAME || (source == SSS_DEFAULT && Globals::IsGameMode(GM_MENU))) { | |
config = &_settings_newgame.game_config; | |
} else { | |
config = &_settings_game.game_config; | |
diff --git a/src/gamelog.cpp b/src/gamelog.cpp | |
index 400c0d2..9151e76 100644 | |
--- a/src/gamelog.cpp | |
+++ b/src/gamelog.cpp | |
@@ -431,7 +431,7 @@ void GamelogMode() | |
LoggedChange *lc = GamelogChange(GLCT_MODE); | |
if (lc == NULL) return; | |
- lc->mode.mode = _game_mode; | |
+ lc->mode.mode = Globals::GetGameMode(); | |
lc->mode.landscape = _settings_game.game_creation.landscape; | |
} | |
@@ -507,7 +507,7 @@ void GamelogTestMode() | |
} | |
} | |
- if (mode == NULL || mode->mode.mode != _game_mode || mode->mode.landscape != _settings_game.game_creation.landscape) GamelogMode(); | |
+ if (mode == NULL || mode->mode.mode != Globals::GetGameMode() || mode->mode.landscape != _settings_game.game_creation.landscape) GamelogMode(); | |
} | |
diff --git a/src/genworld.cpp b/src/genworld.cpp | |
index 5cdb129..413c919 100644 | |
--- a/src/genworld.cpp | |
+++ b/src/genworld.cpp | |
@@ -79,7 +79,7 @@ static void CleanupGeneration() | |
SetMouseCursorBusy(false); | |
/* Show all vital windows again, because we have hidden them */ | |
- if (_gw.threaded && _game_mode != GM_MENU) ShowVitalWindows(); | |
+ if (_gw.threaded && !Globals::IsGameMode(GM_MENU)) ShowVitalWindows(); | |
SetModalProgress(false); | |
_gw.proc = NULL; | |
_gw.abortp = NULL; | |
@@ -125,7 +125,7 @@ static void _GenerateWorld(void *) | |
} | |
/* Make the map the height of the setting */ | |
- if (_game_mode != GM_MENU) FlatEmptyWorld(_settings_game.game_creation.se_flat_world_height); | |
+ if (!Globals::IsGameMode(GM_MENU)) FlatEmptyWorld(_settings_game.game_creation.se_flat_world_height); | |
ConvertGroundTilesIntoWaterTiles(); | |
IncreaseGeneratingWorldProgress(GWP_OBJECT); | |
@@ -134,7 +134,7 @@ static void _GenerateWorld(void *) | |
GenerateClearTile(); | |
/* only generate towns, tree and industries in newgame mode. */ | |
- if (_game_mode != GM_EDITOR) { | |
+ if (!Globals::IsGameMode(GM_EDITOR)) { | |
if (!GenerateTowns(_settings_game.economy.town_layout)) { | |
_cur_company.Restore(); | |
HandleGeneratingWorldAbortion(); | |
@@ -166,7 +166,7 @@ static void _GenerateWorld(void *) | |
IncreaseGeneratingWorldProgress(GWP_RUNTILELOOP); | |
} | |
- if (_game_mode != GM_EDITOR) { | |
+ if (!Globals::IsGameMode(GM_EDITOR)) { | |
Game::StartNew(); | |
if (Game::GetInstance() != NULL) { | |
@@ -277,7 +277,7 @@ bool IsGeneratingWorldAborted() | |
void HandleGeneratingWorldAbortion() | |
{ | |
/* Clean up - in SE create an empty map, otherwise, go to intro menu */ | |
- _switch_mode = (_game_mode == GM_EDITOR) ? SM_EDITOR : SM_MENU; | |
+ _switch_mode = (Globals::IsGameMode(GM_EDITOR)) ? SM_EDITOR : SM_MENU; | |
if (_gw.abortp != NULL) _gw.abortp(); | |
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp | |
index 359709e..35dbb2e 100644 | |
--- a/src/genworld_gui.cpp | |
+++ b/src/genworld_gui.cpp | |
@@ -270,8 +270,8 @@ static void StartGeneratingLandscape(GenerateLandscapeWindowMode mode) | |
if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP); | |
switch (mode) { | |
- case GLWM_GENERATE: _switch_mode = (_game_mode == GM_EDITOR) ? SM_GENRANDLAND : SM_NEWGAME; break; | |
- case GLWM_HEIGHTMAP: _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_HEIGHTMAP : SM_START_HEIGHTMAP; break; | |
+ case GLWM_GENERATE: _switch_mode = (Globals::IsGameMode(GM_EDITOR)) ? SM_GENRANDLAND : SM_NEWGAME; break; | |
+ case GLWM_HEIGHTMAP: _switch_mode = (Globals::IsGameMode(GM_EDITOR)) ? SM_LOAD_HEIGHTMAP : SM_START_HEIGHTMAP; break; | |
case GLWM_SCENARIO: _switch_mode = SM_EDITOR; break; | |
default: NOT_REACHED(); | |
} | |
@@ -324,9 +324,9 @@ struct GenerateLandscapeWindow : public Window { | |
this->mode = (GenerateLandscapeWindowMode)this->window_number; | |
/* Disable town, industry and trees in SE */ | |
- this->SetWidgetDisabledState(WID_GL_TOWN_PULLDOWN, _game_mode == GM_EDITOR); | |
- this->SetWidgetDisabledState(WID_GL_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR); | |
- this->SetWidgetDisabledState(WID_GL_TREE_PULLDOWN, _game_mode == GM_EDITOR); | |
+ this->SetWidgetDisabledState(WID_GL_TOWN_PULLDOWN, Globals::IsGameMode(GM_EDITOR)); | |
+ this->SetWidgetDisabledState(WID_GL_INDUSTRY_PULLDOWN, Globals::IsGameMode(GM_EDITOR)); | |
+ this->SetWidgetDisabledState(WID_GL_TREE_PULLDOWN, Globals::IsGameMode(GM_EDITOR)); | |
this->OnInvalidateData(); | |
} | |
@@ -342,7 +342,7 @@ struct GenerateLandscapeWindow : public Window { | |
case WID_GL_SNOW_LEVEL_TEXT: SetDParam(0, _settings_newgame.game_creation.snow_line_height); break; | |
case WID_GL_TOWN_PULLDOWN: | |
- if (_game_mode == GM_EDITOR) { | |
+ if (Globals::IsGameMode(GM_EDITOR)) { | |
SetDParam(0, STR_CONFIG_SETTING_OFF); | |
} else if (_settings_newgame.difficulty.number_towns == CUSTOM_TOWN_NUMBER_DIFFICULTY) { | |
SetDParam(0, STR_NUM_CUSTOM_NUMBER); | |
@@ -352,7 +352,7 @@ struct GenerateLandscapeWindow : public Window { | |
} | |
break; | |
- case WID_GL_INDUSTRY_PULLDOWN: SetDParam(0, _game_mode == GM_EDITOR ? STR_CONFIG_SETTING_OFF : _num_inds[_settings_newgame.difficulty.industry_density]); break; | |
+ case WID_GL_INDUSTRY_PULLDOWN: SetDParam(0, Globals::IsGameMode(GM_EDITOR) ? STR_CONFIG_SETTING_OFF : _num_inds[_settings_newgame.difficulty.industry_density]); break; | |
case WID_GL_LANDSCAPE_PULLDOWN: SetDParam(0, _landscape[_settings_newgame.game_creation.land_generator]); break; | |
case WID_GL_TREE_PULLDOWN: SetDParam(0, _tree_placer[_settings_newgame.game_creation.tree_placer]); break; | |
case WID_GL_TERRAIN_PULLDOWN: SetDParam(0, _elevations[_settings_newgame.difficulty.terrain_type]); break; | |
diff --git a/src/gfx.cpp b/src/gfx.cpp | |
index 7195051..bd01dd1 100644 | |
--- a/src/gfx.cpp | |
+++ b/src/gfx.cpp | |
@@ -43,7 +43,6 @@ bool _right_button_clicked; ///< Is right mouse button clicked? | |
DrawPixelInfo _screen; | |
bool _screen_disable_anim = false; ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot) | |
bool _exit_game; | |
-GameMode _game_mode; | |
SwitchMode _switch_mode; ///< The next mainloop command. | |
PauseModeByte _pause_mode; | |
Palette _cur_palette; | |
diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp | |
index c67aaa1..4dda69e 100644 | |
--- a/src/highscore_gui.cpp | |
+++ b/src/highscore_gui.cpp | |
@@ -162,7 +162,7 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow { | |
if (!_networking && !this->game_paused_by_player) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE); | |
/* Close all always on-top windows to get a clean screen */ | |
- if (_game_mode != GM_MENU) HideVitalWindows(); | |
+ if (!Globals::IsGameMode(GM_MENU)) HideVitalWindows(); | |
MarkWholeScreenDirty(); | |
this->window_number = difficulty; // show highscore chart for difficulty... | |
@@ -172,7 +172,7 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow { | |
~HighScoreWindow() | |
{ | |
- if (_game_mode != GM_MENU) ShowVitalWindows(); | |
+ if (!Globals::IsGameMode(GM_MENU)) ShowVitalWindows(); | |
if (!_networking && !this->game_paused_by_player) DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE); // unpause | |
} | |
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp | |
index 8fea695..b14cbac 100644 | |
--- a/src/industry_cmd.cpp | |
+++ b/src/industry_cmd.cpp | |
@@ -473,7 +473,7 @@ static CommandCost ClearTile_Industry(TileIndex tile, DoCommandFlag flags) | |
* with magic_bulldozer cheat you can destroy industries | |
* (area around OILRIG is water, so water shouldn't flood it | |
*/ | |
- if ((_current_company != OWNER_WATER && _game_mode != GM_EDITOR && | |
+ if ((_current_company != OWNER_WATER && !Globals::IsGameMode(GM_EDITOR) && | |
!_cheats.magic_bulldozer.value) || | |
((flags & DC_AUTO) != 0) || | |
(_current_company == OWNER_WATER && | |
@@ -808,7 +808,7 @@ static void TileLoop_Industry(TileIndex tile) | |
return; | |
} | |
- if (_game_mode == GM_EDITOR) return; | |
+ if (Globals::IsGameMode(GM_EDITOR)) return; | |
TransportIndustryGoods(tile); | |
@@ -1164,7 +1164,7 @@ void OnTick_Industry() | |
} | |
} | |
- if (_game_mode == GM_EDITOR) return; | |
+ if (Globals::IsGameMode(GM_EDITOR)) return; | |
Industry *i; | |
FOR_ALL_INDUSTRIES(i) { | |
@@ -1204,7 +1204,7 @@ static CommandCost CheckNewIndustry_Forest(TileIndex tile) | |
*/ | |
static CommandCost CheckNewIndustry_OilRefinery(TileIndex tile) | |
{ | |
- if (_game_mode == GM_EDITOR) return CommandCost(); | |
+ if (Globals::IsGameMode(GM_EDITOR)) return CommandCost(); | |
if (DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < _settings_game.game_creation.oil_refinery_limit) return CommandCost(); | |
return_cmd_error(STR_ERROR_CAN_ONLY_BE_POSITIONED); | |
@@ -1219,7 +1219,7 @@ extern bool _ignore_restrictions; | |
*/ | |
static CommandCost CheckNewIndustry_OilRig(TileIndex tile) | |
{ | |
- if (_game_mode == GM_EDITOR && _ignore_restrictions) return CommandCost(); | |
+ if (Globals::IsGameMode(GM_EDITOR) && _ignore_restrictions) return CommandCost(); | |
if (TileHeight(tile) == 0 && | |
DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < _settings_game.game_creation.oil_refinery_limit) return CommandCost(); | |
@@ -1681,7 +1681,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, | |
i->founder = founder; | |
i->construction_date = _date; | |
- i->construction_type = (_game_mode == GM_EDITOR) ? ICT_SCENARIO_EDITOR : | |
+ i->construction_type = (Globals::IsGameMode(GM_EDITOR)) ? ICT_SCENARIO_EDITOR : | |
(_generating_world ? ICT_MAP_GENERATION : ICT_NORMAL_GAMEPLAY); | |
/* Adding 1 here makes it conform to specs of var44 of varaction2 for industries | |
@@ -1867,11 +1867,11 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin | |
/* If the setting for raw-material industries is not on, you cannot build raw-material industries. | |
* Raw material industries are industries that do not accept cargo (at least for now) */ | |
- if (_game_mode != GM_EDITOR && _current_company != OWNER_DEITY && _settings_game.construction.raw_industry_construction == 0 && indspec->IsRawIndustry()) { | |
+ if (!Globals::IsGameMode(GM_EDITOR) && _current_company != OWNER_DEITY && _settings_game.construction.raw_industry_construction == 0 && indspec->IsRawIndustry()) { | |
return CMD_ERROR; | |
} | |
- if (_game_mode != GM_EDITOR && GetIndustryProbabilityCallback(it, _current_company == OWNER_DEITY ? IACT_RANDOMCREATION : IACT_USERCREATION, 1) == 0) { | |
+ if (!Globals::IsGameMode(GM_EDITOR) && GetIndustryProbabilityCallback(it, _current_company == OWNER_DEITY ? IACT_RANDOMCREATION : IACT_USERCREATION, 1) == 0) { | |
return CMD_ERROR; | |
} | |
@@ -1884,7 +1884,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin | |
const bool deity_prospect = _current_company == OWNER_DEITY && !HasBit(p1, 16); | |
Industry *ind = NULL; | |
- if (deity_prospect || (_game_mode != GM_EDITOR && _current_company != OWNER_DEITY && _settings_game.construction.raw_industry_construction == 2 && indspec->IsRawIndustry())) { | |
+ if (deity_prospect || (!Globals::IsGameMode(GM_EDITOR) && _current_company != OWNER_DEITY && _settings_game.construction.raw_industry_construction == 2 && indspec->IsRawIndustry())) { | |
if (flags & DC_EXEC) { | |
/* Prospected industries are build as OWNER_TOWN to not e.g. be build on owned land of the founder */ | |
Backup<CompanyByte> cur_company(_current_company, OWNER_TOWN, FILE_LINE); | |
@@ -1925,7 +1925,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin | |
if (ret.Failed()) return ret; | |
} | |
- if ((flags & DC_EXEC) && ind != NULL && _game_mode != GM_EDITOR) { | |
+ if ((flags & DC_EXEC) && ind != NULL && !Globals::IsGameMode(GM_EDITOR)) { | |
AdvertiseIndustryOpening(ind); | |
} | |
@@ -1963,7 +1963,7 @@ static uint32 GetScaledIndustryGenerationProbability(IndustryType it, bool *forc | |
const IndustrySpec *ind_spc = GetIndustrySpec(it); | |
uint32 chance = ind_spc->appear_creation[_settings_game.game_creation.landscape] * 16; // * 16 to increase precision | |
if (!ind_spc->enabled || ind_spc->num_table == 0 || | |
- (_game_mode != GM_EDITOR && _settings_game.difficulty.industry_density == ID_FUND_ONLY) || | |
+ (!Globals::IsGameMode(GM_EDITOR) && _settings_game.difficulty.industry_density == ID_FUND_ONLY) || | |
(chance = GetIndustryProbabilityCallback(it, IACT_MAPGENERATION, chance)) == 0) { | |
*force_at_least_one = false; | |
return 0; | |
@@ -1972,7 +1972,7 @@ static uint32 GetScaledIndustryGenerationProbability(IndustryType it, bool *forc | |
* For simplicity we scale in both cases, though scaling the probabilities of all industries has no effect. */ | |
chance = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(chance) : ScaleByMapSize(chance); | |
- *force_at_least_one = (chance > 0) && !(ind_spc->behaviour & INDUSTRYBEH_NOBUILT_MAPCREATION) && (_game_mode != GM_EDITOR); | |
+ *force_at_least_one = (chance > 0) && !(ind_spc->behaviour & INDUSTRYBEH_NOBUILT_MAPCREATION) && (!Globals::IsGameMode(GM_EDITOR)); | |
return chance; | |
} | |
} | |
@@ -2020,7 +2020,7 @@ static uint GetNumberOfIndustries() | |
}; | |
assert(lengthof(numof_industry_table) == ID_END); | |
- uint difficulty = (_game_mode != GM_EDITOR) ? _settings_game.difficulty.industry_density : (uint)ID_VERY_LOW; | |
+ uint difficulty = (!Globals::IsGameMode(GM_EDITOR)) ? _settings_game.difficulty.industry_density : (uint)ID_VERY_LOW; | |
return min(IndustryPool::MAX_SIZE, ScaleByMapSize(numof_industry_table[difficulty])); | |
} | |
@@ -2109,7 +2109,7 @@ void IndustryBuildData::MonthlyLoop() | |
*/ | |
void GenerateIndustries() | |
{ | |
- if (_game_mode != GM_EDITOR && _settings_game.difficulty.industry_density == ID_FUND_ONLY) return; // No industries in the game. | |
+ if (!Globals::IsGameMode(GM_EDITOR) && _settings_game.difficulty.industry_density == ID_FUND_ONLY) return; // No industries in the game. | |
uint32 industry_probs[NUM_INDUSTRYTYPES]; | |
bool force_at_least_one[NUM_INDUSTRYTYPES]; | |
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp | |
index 41b3c57..06e9523 100644 | |
--- a/src/industry_gui.cpp | |
+++ b/src/industry_gui.cpp | |
@@ -264,7 +264,7 @@ class BuildIndustryWindow : public Window { | |
this->enabled[i] = false; | |
} | |
- if (_game_mode == GM_EDITOR) { // give room for the Many Random "button" | |
+ if (Globals::IsGameMode(GM_EDITOR)) { // give room for the Many Random "button" | |
this->index[this->count] = INVALID_INDUSTRYTYPE; | |
this->enabled[this->count] = true; | |
this->count++; | |
@@ -281,13 +281,13 @@ class BuildIndustryWindow : public Window { | |
/* Rule is that editor mode loads all industries. | |
* In game mode, all non raw industries are loaded too | |
* and raw ones are loaded only when setting allows it */ | |
- if (_game_mode != GM_EDITOR && indsp->IsRawIndustry() && _settings_game.construction.raw_industry_construction == 0) { | |
+ if (!Globals::IsGameMode(GM_EDITOR) && indsp->IsRawIndustry() && _settings_game.construction.raw_industry_construction == 0) { | |
/* Unselect if the industry is no longer in the list */ | |
if (this->selected_type == ind) this->selected_index = -1; | |
continue; | |
} | |
this->index[this->count] = ind; | |
- this->enabled[this->count] = (_game_mode == GM_EDITOR) || GetIndustryProbabilityCallback(ind, IACT_USERCREATION, 1) > 0; | |
+ this->enabled[this->count] = (Globals::IsGameMode(GM_EDITOR)) || GetIndustryProbabilityCallback(ind, IACT_USERCREATION, 1) > 0; | |
/* Keep the selection to the correct line */ | |
if (this->selected_type == ind) this->selected_index = this->count; | |
this->count++; | |
@@ -351,7 +351,7 @@ public: | |
case WID_DPI_INFOPANEL: { | |
/* Extra line for cost outside of editor + extra lines for 'extra' information for NewGRFs. */ | |
- int height = 2 + (_game_mode == GM_EDITOR ? 0 : 1) + (_loaded_newgrf_features.has_newindustries ? 4 : 0); | |
+ int height = 2 + (Globals::IsGameMode(GM_EDITOR) ? 0 : 1) + (_loaded_newgrf_features.has_newindustries ? 4 : 0); | |
Dimension d = {0, 0}; | |
for (byte i = 0; i < this->count; i++) { | |
if (this->index[i] == INVALID_INDUSTRYTYPE) continue; | |
@@ -411,7 +411,7 @@ public: | |
case WID_DPI_FUND_WIDGET: | |
/* Raw industries might be prospected. Show this fact by changing the string | |
* In Editor, you just build, while ingame, or you fund or you prospect */ | |
- if (_game_mode == GM_EDITOR) { | |
+ if (Globals::IsGameMode(GM_EDITOR)) { | |
/* We've chosen many random industries but no industries have been specified */ | |
SetDParam(0, STR_FUND_INDUSTRY_BUILD_NEW_INDUSTRY); | |
} else { | |
@@ -470,7 +470,7 @@ public: | |
const IndustrySpec *indsp = GetIndustrySpec(this->selected_type); | |
- if (_game_mode != GM_EDITOR) { | |
+ if (!Globals::IsGameMode(GM_EDITOR)) { | |
SetDParam(0, indsp->GetConstructionCost()); | |
DrawString(left, right, y, STR_FUND_INDUSTRY_INDUSTRY_BUILD_COST); | |
y += FONT_HEIGHT_NORMAL; | |
@@ -542,7 +542,7 @@ public: | |
this->SetDirty(); | |
if (_thd.GetCallbackWnd() == this && | |
- ((_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && indsp != NULL && indsp->IsRawIndustry()) || | |
+ ((!Globals::IsGameMode(GM_EDITOR) && _settings_game.construction.raw_industry_construction == 2 && indsp != NULL && indsp->IsRawIndustry()) || | |
this->selected_type == INVALID_INDUSTRYTYPE || | |
!this->enabled[this->selected_index])) { | |
/* Reset the button state if going to prospecting or "build many industries" */ | |
@@ -572,7 +572,7 @@ public: | |
GenerateIndustries(); | |
_generating_world = false; | |
} | |
- } else if (_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && GetIndustrySpec(this->selected_type)->IsRawIndustry()) { | |
+ } else if (!Globals::IsGameMode(GM_EDITOR) && _settings_game.construction.raw_industry_construction == 2 && GetIndustrySpec(this->selected_type)->IsRawIndustry()) { | |
DoCommandP(0, this->selected_type, InteractiveRandom(), CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY)); | |
this->HandleButtonClick(WID_DPI_FUND_WIDGET); | |
} else { | |
@@ -596,7 +596,7 @@ public: | |
const IndustrySpec *indsp = GetIndustrySpec(this->selected_type); | |
uint32 seed = InteractiveRandom(); | |
- if (_game_mode == GM_EDITOR) { | |
+ if (Globals::IsGameMode(GM_EDITOR)) { | |
/* Show error if no town exists at all */ | |
if (Town::GetNumItems() == 0) { | |
SetDParam(0, indsp->name); | |
@@ -674,7 +674,7 @@ public: | |
void ShowBuildIndustryWindow() | |
{ | |
- if (_game_mode != GM_EDITOR && !Company::IsValidID(_local_company)) return; | |
+ if (!Globals::IsGameMode(GM_EDITOR) && !Company::IsValidID(_local_company)) return; | |
if (BringWindowToFrontById(WC_BUILD_INDUSTRY, 0)) return; | |
new BuildIndustryWindow(); | |
} | |
@@ -684,7 +684,7 @@ static void UpdateIndustryProduction(Industry *i); | |
static inline bool IsProductionAlterable(const Industry *i) | |
{ | |
const IndustrySpec *is = GetIndustrySpec(i->type); | |
- return ((_game_mode == GM_EDITOR || _cheats.setup_prod.value) && | |
+ return ((Globals::IsGameMode(GM_EDITOR) || _cheats.setup_prod.value) && | |
(is->production_rate[0] != 0 || is->production_rate[1] != 0 || is->IsRawIndustry()) && | |
!_networking); | |
} | |
diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp | |
index 3659b03..d9c46c4 100644 | |
--- a/src/intro_gui.cpp | |
+++ b/src/intro_gui.cpp | |
@@ -331,7 +331,7 @@ void AskExitToGameMenu() | |
{ | |
ShowQuery( | |
STR_ABANDON_GAME_CAPTION, | |
- (_game_mode != GM_EDITOR) ? STR_ABANDON_GAME_QUERY : STR_ABANDON_SCENARIO_QUERY, | |
+ (!Globals::IsGameMode(GM_EDITOR)) ? STR_ABANDON_GAME_QUERY : STR_ABANDON_SCENARIO_QUERY, | |
NULL, | |
AskExitToGameMenuCallback | |
); | |
diff --git a/src/main_gui.cpp b/src/main_gui.cpp | |
index b13920a..27b9300 100644 | |
--- a/src/main_gui.cpp | |
+++ b/src/main_gui.cpp | |
@@ -191,7 +191,7 @@ void ZoomInOrOutToCursorWindow(bool in, Window *w) | |
{ | |
assert(w != NULL); | |
- if (_game_mode != GM_MENU) { | |
+ if (!Globals::IsGameMode(GM_MENU)) { | |
ViewPort *vp = w->viewport; | |
if ((in && vp->zoom <= _settings_client.gui.zoom_min) || (!in && vp->zoom >= _settings_client.gui.zoom_max)) return; | |
@@ -271,7 +271,7 @@ struct MainWindow : Window | |
virtual void OnPaint() | |
{ | |
this->DrawWidgets(); | |
- if (_game_mode == GM_MENU) { | |
+ if (Globals::IsGameMode(GM_MENU)) { | |
static const SpriteID title_sprites[] = {SPR_OTTD_O, SPR_OTTD_P, SPR_OTTD_E, SPR_OTTD_N, SPR_OTTD_T, SPR_OTTD_T, SPR_OTTD_D}; | |
static const uint LETTER_SPACING = 10; | |
int name_width = (lengthof(title_sprites) - 1) * LETTER_SPACING; | |
@@ -304,7 +304,7 @@ struct MainWindow : Window | |
switch (hotkey) { | |
case GHK_ABANDON: | |
/* No point returning from the main menu to itself */ | |
- if (_game_mode == GM_MENU) return ES_HANDLED; | |
+ if (Globals::IsGameMode(GM_MENU)) return ES_HANDLED; | |
if (_settings_client.gui.autosave_on_exit) { | |
DoExitSave(); | |
_switch_mode = SM_MENU; | |
@@ -326,7 +326,7 @@ struct MainWindow : Window | |
return ES_HANDLED; | |
} | |
- if (_game_mode == GM_MENU) return ES_NOT_HANDLED; | |
+ if (Globals::IsGameMode(GM_MENU)) return ES_NOT_HANDLED; | |
switch (hotkey) { | |
case GHK_CENTER: | |
@@ -558,7 +558,7 @@ void SetupColoursAndInitialWindow() | |
new MainWindow(&_main_window_desc); | |
/* XXX: these are not done */ | |
- switch (_game_mode) { | |
+ switch (Globals::GetGameMode()) { | |
default: NOT_REACHED(); | |
case GM_MENU: | |
ShowSelectGameWindow(); | |
@@ -579,7 +579,7 @@ void ShowVitalWindows() | |
AllocateToolbar(); | |
/* Status bad only for normal games */ | |
- if (_game_mode == GM_EDITOR) return; | |
+ if (Globals::IsGameMode(GM_EDITOR)) return; | |
ShowStatusBar(); | |
} | |
diff --git a/src/music_gui.cpp b/src/music_gui.cpp | |
index 279f376..f6cc65a 100644 | |
--- a/src/music_gui.cpp | |
+++ b/src/music_gui.cpp | |
@@ -217,7 +217,7 @@ static void SelectSongToPlay() | |
} while (_playlists[_settings_client.music.playlist][++i] != 0 && j < lengthof(_cur_playlist) - 1); | |
/* Do not shuffle when on the intro-start window, as the song to play has to be the original TTD Theme*/ | |
- if (_settings_client.music.shuffle && _game_mode != GM_MENU) { | |
+ if (_settings_client.music.shuffle && !Globals::IsGameMode(GM_MENU)) { | |
i = 500; | |
do { | |
uint32 r = InteractiveRandom(); | |
@@ -279,7 +279,7 @@ void MusicLoop() | |
if (!_song_is_active) return; | |
if (!MusicDriver::GetInstance()->IsSongPlaying()) { | |
- if (_game_mode != GM_MENU) { | |
+ if (!Globals::IsGameMode(GM_MENU)) { | |
StopMusic(); | |
SkipToNextSong(); | |
PlayPlaylistSong(); | |
diff --git a/src/newgrf.cpp b/src/newgrf.cpp | |
index 24b0238..958b45b 100644 | |
--- a/src/newgrf.cpp | |
+++ b/src/newgrf.cpp | |
@@ -5770,7 +5770,7 @@ bool GetGlobalVariable(byte param, uint32 *value, const GRFFile *grffile) | |
return true; | |
case 0x12: // Game mode | |
- *value = _game_mode; | |
+ *value = Globals::GetGameMode(); | |
return true; | |
/* case 0x13: // Tile refresh offset to left not implemented */ | |
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp | |
index c0aa160..27913ff 100644 | |
--- a/src/newgrf_gui.cpp | |
+++ b/src/newgrf_gui.cpp | |
@@ -45,7 +45,7 @@ | |
void ShowNewGRFError() | |
{ | |
/* Do not show errors when entering the main screen */ | |
- if (_game_mode == GM_MENU) return; | |
+ if (Globals::IsGameMode(GM_MENU)) return; | |
for (const GRFConfig *c = _grfconfig; c != NULL; c = c->next) { | |
/* We only want to show fatal errors */ | |
diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp | |
index 2bc85f9..ecf001c 100644 | |
--- a/src/newgrf_house.cpp | |
+++ b/src/newgrf_house.cpp | |
@@ -537,7 +537,7 @@ bool CanDeleteHouse(TileIndex tile) | |
/* Humans are always allowed to remove buildings, as is water and disasters and | |
* anyone using the scenario editor. */ | |
- if (Company::IsValidHumanID(_current_company) || _current_company == OWNER_WATER || _current_company == OWNER_NONE || _game_mode == GM_EDITOR || _generating_world) { | |
+ if (Company::IsValidHumanID(_current_company) || _current_company == OWNER_WATER || _current_company == OWNER_NONE || Globals::IsGameMode(GM_EDITOR) || _generating_world) { | |
return true; | |
} | |
diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp | |
index 058d5e0..bdb82c3 100644 | |
--- a/src/newgrf_object.cpp | |
+++ b/src/newgrf_object.cpp | |
@@ -61,7 +61,7 @@ ObjectSpec _object_specs[NUM_OBJECTS]; | |
bool ObjectSpec::IsEverAvailable() const | |
{ | |
return this->enabled && HasBit(this->climate, _settings_game.game_creation.landscape) && | |
- (this->flags & ((_game_mode != GM_EDITOR && !_generating_world) ? OBJECT_FLAG_ONLY_IN_SCENEDIT : OBJECT_FLAG_ONLY_IN_GAME)) == 0; | |
+ (this->flags & ((!Globals::IsGameMode(GM_EDITOR) && !_generating_world) ? OBJECT_FLAG_ONLY_IN_SCENEDIT : OBJECT_FLAG_ONLY_IN_GAME)) == 0; | |
} | |
/** | |
diff --git a/src/news_gui.cpp b/src/news_gui.cpp | |
index 6338b76..7e5fe93 100644 | |
--- a/src/news_gui.cpp | |
+++ b/src/news_gui.cpp | |
@@ -644,7 +644,7 @@ static void MoveToNextItem() | |
*/ | |
void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1, uint32 ref1, NewsReferenceType reftype2, uint32 ref2, void *free_data) | |
{ | |
- if (_game_mode == GM_MENU) return; | |
+ if (Globals::IsGameMode(GM_MENU)) return; | |
/* Create new news item node */ | |
NewsItem *ni = new NewsItem; | |
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp | |
index f7ba0d9..3d17113 100644 | |
--- a/src/object_cmd.cpp | |
+++ b/src/object_cmd.cpp | |
@@ -211,11 +211,11 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 | |
if (type >= NUM_OBJECTS) return CMD_ERROR; | |
uint8 view = GB(p2, 0, 2); | |
const ObjectSpec *spec = ObjectSpec::Get(type); | |
- if (_game_mode == GM_NORMAL && !spec->IsAvailable() && !_generating_world) return CMD_ERROR; | |
- if ((_game_mode == GM_EDITOR || _generating_world) && !spec->WasEverAvailable()) return CMD_ERROR; | |
+ if (Globals::IsGameMode(GM_NORMAL) && !spec->IsAvailable() && !_generating_world) return CMD_ERROR; | |
+ if ((Globals::IsGameMode(GM_EDITOR) || _generating_world) && !spec->WasEverAvailable()) return CMD_ERROR; | |
- if ((spec->flags & OBJECT_FLAG_ONLY_IN_SCENEDIT) != 0 && ((!_generating_world && _game_mode != GM_EDITOR) || _current_company != OWNER_NONE)) return CMD_ERROR; | |
- if ((spec->flags & OBJECT_FLAG_ONLY_IN_GAME) != 0 && (_generating_world || _game_mode != GM_NORMAL || _current_company > MAX_COMPANIES)) return CMD_ERROR; | |
+ if ((spec->flags & OBJECT_FLAG_ONLY_IN_SCENEDIT) != 0 && ((!_generating_world && !Globals::IsGameMode(GM_EDITOR)) || _current_company != OWNER_NONE)) return CMD_ERROR; | |
+ if ((spec->flags & OBJECT_FLAG_ONLY_IN_GAME) != 0 && (_generating_world || !Globals::IsGameMode(GM_NORMAL) || _current_company > MAX_COMPANIES)) return CMD_ERROR; | |
if (view >= spec->views) return CMD_ERROR; | |
if (!Object::CanAllocateItem()) return_cmd_error(STR_ERROR_TOO_MANY_OBJECTS); | |
@@ -485,7 +485,7 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags) | |
} else if (!(spec->flags & OBJECT_FLAG_AUTOREMOVE) && (flags & DC_AUTO)) { | |
/* No automatic removal by overbuilding stuff. */ | |
return_cmd_error(type == OBJECT_HQ ? STR_ERROR_COMPANY_HEADQUARTERS_IN : STR_ERROR_OBJECT_IN_THE_WAY); | |
- } else if (_game_mode == GM_EDITOR) { | |
+ } else if (Globals::IsGameMode(GM_EDITOR)) { | |
/* No further limitations for the editor. */ | |
} else if (GetTileOwner(tile) == OWNER_NONE) { | |
/* Owned by nobody and unremovable, so we can only remove it with brute force! */ | |
diff --git a/src/openttd.cpp b/src/openttd.cpp | |
index 10c31e9..0b7cca5 100644 | |
--- a/src/openttd.cpp | |
+++ b/src/openttd.cpp | |
@@ -305,7 +305,7 @@ static void ShutdownGame() | |
PoolBase::Clean(PT_ALL); | |
/* No NewGRFs were loaded when it was still bootstrapping. */ | |
- if (_game_mode != GM_BOOTSTRAP) ResetNewGRFData(); | |
+ if (!Globals::IsGameMode(GM_BOOTSTRAP)) ResetNewGRFData(); | |
/* Close all and any open filehandles */ | |
FioCloseAll(); | |
@@ -319,7 +319,7 @@ static void ShutdownGame() | |
*/ | |
static void LoadIntroGame(bool load_newgrfs = true) | |
{ | |
- _game_mode = GM_MENU; | |
+ Globals::SetGameMode(GM_MENU); | |
if (load_newgrfs) ResetGRFConfig(false); | |
@@ -552,7 +552,7 @@ int openttd_main(int argc, char *argv[]) | |
_dedicated_forks = false; | |
#endif /* ENABLE_NETWORK */ | |
- _game_mode = GM_MENU; | |
+ Globals::SetGameMode(GM_MENU); | |
_switch_mode = SM_MENU; | |
_config_file = NULL; | |
@@ -913,7 +913,7 @@ exit_normal: | |
void HandleExitGameRequest() | |
{ | |
- if (_game_mode == GM_MENU || _game_mode == GM_BOOTSTRAP) { // do not ask to quit on the main screen | |
+ if (Globals::IsGameMode(GM_MENU) || Globals::IsGameMode(GM_BOOTSTRAP)) { // do not ask to quit on the main screen | |
_exit_game = true; | |
} else if (_settings_client.gui.autosave_on_exit) { | |
DoExitSave(); | |
@@ -964,7 +964,7 @@ static void MakeNewGameDone() | |
static void MakeNewGame(bool from_heightmap, bool reset_settings) | |
{ | |
- _game_mode = GM_NORMAL; | |
+ Globals::SetGameMode(GM_NORMAL); | |
ResetGRFConfig(true); | |
@@ -979,7 +979,7 @@ static void MakeNewEditorWorldDone() | |
static void MakeNewEditorWorld() | |
{ | |
- _game_mode = GM_EDITOR; | |
+ Globals::SetGameMode(GM_EDITOR); | |
ResetGRFConfig(true); | |
@@ -1001,9 +1001,9 @@ bool SafeLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, | |
{ | |
assert(fop == SLO_LOAD); | |
assert(dft == DFT_GAME_FILE || (lf == NULL && dft == DFT_OLD_GAME_FILE)); | |
- GameMode ogm = _game_mode; | |
- _game_mode = newgm; | |
+ Globals::BackupGameMode(); | |
+ Globals::SetGameMode(newgm); | |
switch (lf == NULL ? SaveOrLoad(filename, fop, dft, subdir) : LoadWithFilter(lf)) { | |
case SL_OK: return true; | |
@@ -1027,7 +1027,7 @@ bool SafeLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, | |
} | |
#endif /* ENABLE_NETWORK */ | |
- switch (ogm) { | |
+ switch (Globals::GetOldGameMode()) { | |
default: | |
case GM_MENU: LoadIntroGame(); break; | |
case GM_EDITOR: MakeNewEditorWorld(); break; | |
@@ -1035,7 +1035,7 @@ bool SafeLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, | |
return false; | |
default: | |
- _game_mode = ogm; | |
+ Globals::RestoreGameMode(); | |
return false; | |
} | |
} | |
@@ -1353,7 +1353,7 @@ void StateGameLoop() | |
Layouter::ReduceLineCache(); | |
- if (_game_mode == GM_EDITOR) { | |
+ if (Globals::IsGameMode(GM_EDITOR)) { | |
BasePersistentStorageArray::SwitchMode(PSM_ENTER_GAMELOOP); | |
RunTileLoop(); | |
CallVehicleTicks(); | |
@@ -1432,7 +1432,7 @@ static void DoAutosave() | |
void GameLoop() | |
{ | |
- if (_game_mode == GM_BOOTSTRAP) { | |
+ if (Globals::IsGameMode(GM_BOOTSTRAP)) { | |
#ifdef ENABLE_NETWORK | |
/* Check for UDP stuff */ | |
if (_network_available) NetworkBackgroundLoop(); | |
@@ -1492,10 +1492,43 @@ void GameLoop() | |
if (!_pause_mode && HasBit(_display_opt, DO_FULL_ANIMATION)) DoPaletteAnimations(); | |
- if (!_pause_mode || _game_mode == GM_EDITOR || _settings_game.construction.command_pause_level > CMDPL_NO_CONSTRUCTION) MoveAllTextEffects(); | |
+ if (!_pause_mode || Globals::IsGameMode(GM_EDITOR) || _settings_game.construction.command_pause_level > CMDPL_NO_CONSTRUCTION) MoveAllTextEffects(); | |
InputLoop(); | |
SoundDriver::GetInstance()->MainLoop(); | |
MusicLoop(); | |
} | |
+ | |
+/* static */ GameMode Globals::game_mode = GM_MENU; | |
+/* static */ GameMode Globals::backup_game_mode = GM_MENU; | |
+ | |
+/* static */ bool Globals::IsGameMode(GameMode mode) | |
+{ | |
+ return Globals::game_mode == mode; | |
+} | |
+ | |
+/* static */ void Globals::SetGameMode(GameMode mode) | |
+{ | |
+ Globals::game_mode = mode; | |
+} | |
+ | |
+/* static */ void Globals::BackupGameMode() | |
+{ | |
+ Globals::backup_game_mode = Globals::game_mode; | |
+} | |
+ | |
+/* static */ void Globals::RestoreGameMode() | |
+{ | |
+ Globals::game_mode = Globals::backup_game_mode; | |
+} | |
+ | |
+/* static */ GameMode Globals::GetGameMode() | |
+{ | |
+ return Globals::game_mode; | |
+} | |
+ | |
+/* static */ GameMode Globals::GetOldGameMode() | |
+{ | |
+ return Globals::backup_game_mode; | |
+} | |
diff --git a/src/openttd.h b/src/openttd.h | |
index 5e360d6..f0f3598 100644 | |
--- a/src/openttd.h | |
+++ b/src/openttd.h | |
@@ -49,7 +49,6 @@ enum DisplayOptions { | |
DO_SHOW_COMPETITOR_SIGNS = 7, ///< Display signs, station names and waypoint names of opponent companies. Buoys and oilrig-stations are always shown, even if this option is turned off. | |
}; | |
-extern GameMode _game_mode; | |
extern SwitchMode _switch_mode; | |
extern bool _exit_game; | |
@@ -80,4 +79,18 @@ void HandleExitGameRequest(); | |
void SwitchToMode(SwitchMode new_mode); | |
-#endif /* OPENTTD_H */ | |
+class Globals { | |
+public: | |
+ static bool IsGameMode(GameMode mode); | |
+ static void SetGameMode(GameMode mode); | |
+ static void BackupGameMode(); | |
+ static void RestoreGameMode(); | |
+ static GameMode GetGameMode(); | |
+ static GameMode GetOldGameMode(); | |
+ | |
+private: | |
+ static GameMode game_mode; ///< Current game mode | |
+ static GameMode backup_game_mode; ///< Backup game mode, used for brief game changes. | |
+}; | |
+ | |
+#endif /* OPENTTD_H */ | |
\ No newline at end of file | |
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp | |
index 9f284fc..1beb303 100644 | |
--- a/src/rail_cmd.cpp | |
+++ b/src/rail_cmd.cpp | |
@@ -2312,7 +2312,7 @@ static void DrawTrackBits(TileInfo *ti, TrackBits track) | |
} | |
/* PBS debugging, draw reserved tracks darker */ | |
- if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation) { | |
+ if (!Globals::IsGameMode(GM_MENU) && _settings_client.gui.show_track_reservation) { | |
/* Get reservation, but mask track on halftile slope */ | |
TrackBits pbs = GetRailReservationTrackBits(ti->tile) & track; | |
if (pbs & TRACK_BIT_X) { | |
@@ -2350,7 +2350,7 @@ static void DrawTrackBits(TileInfo *ti, TrackBits track) | |
} | |
DrawGroundSprite(image, pal, &(_halftile_sub_sprite[halftile_corner])); | |
- if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasReservedTracks(ti->tile, CornerToTrackBits(halftile_corner))) { | |
+ if (!Globals::IsGameMode(GM_MENU) && _settings_client.gui.show_track_reservation && HasReservedTracks(ti->tile, CornerToTrackBits(halftile_corner))) { | |
static const byte _corner_to_track_sprite[] = {3, 1, 2, 0}; | |
DrawGroundSprite(_corner_to_track_sprite[halftile_corner] + rti->base_sprites.single_n, PALETTE_CRASH, NULL, 0, -(int)TILE_HEIGHT); | |
} | |
@@ -2482,7 +2482,7 @@ static void DrawTile_Track(TileInfo *ti) | |
} | |
} else { | |
/* PBS debugging, draw reserved tracks darker */ | |
- if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasDepotReservation(ti->tile)) { | |
+ if (!Globals::IsGameMode(GM_MENU) && _settings_client.gui.show_track_reservation && HasDepotReservation(ti->tile)) { | |
switch (GetRailDepotDirection(ti->tile)) { | |
case DIAGDIR_NE: | |
if (!IsInvisibilitySet(TO_BUILDINGS)) break; | |
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp | |
index 73fe29d..3603f89 100644 | |
--- a/src/rail_gui.cpp | |
+++ b/src/rail_gui.cpp | |
@@ -778,7 +778,7 @@ struct BuildRailToolbarWindow : Window { | |
*/ | |
static EventState RailToolbarGlobalHotkeys(int hotkey) | |
{ | |
- if (_game_mode != GM_NORMAL || !CanBuildVehicleInfrastructure(VEH_TRAIN)) return ES_NOT_HANDLED; | |
+ if (!Globals::IsGameMode(GM_NORMAL) || !CanBuildVehicleInfrastructure(VEH_TRAIN)) return ES_NOT_HANDLED; | |
extern RailType _last_built_railtype; | |
Window *w = ShowBuildRailToolbar(_last_built_railtype); | |
if (w == NULL) return ES_NOT_HANDLED; | |
diff --git a/src/road.cpp b/src/road.cpp | |
index f515975..8df8d34 100644 | |
--- a/src/road.cpp | |
+++ b/src/road.cpp | |
@@ -111,7 +111,7 @@ bool HasRoadTypesAvail(const CompanyID company, const RoadTypes rts) | |
{ | |
RoadTypes avail_roadtypes; | |
- if (company == OWNER_DEITY || company == OWNER_TOWN || _game_mode == GM_EDITOR || _generating_world) { | |
+ if (company == OWNER_DEITY || company == OWNER_TOWN || Globals::IsGameMode(GM_EDITOR) || _generating_world) { | |
avail_roadtypes = ROADTYPES_ROAD; | |
} else { | |
Company *c = Company::GetIfValid(company); | |
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp | |
index 5e432a2..895b4b1 100644 | |
--- a/src/road_cmd.cpp | |
+++ b/src/road_cmd.cpp | |
@@ -115,7 +115,7 @@ static Foundation GetRoadFoundation(Slope tileh, RoadBits bits); | |
*/ | |
CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadType rt, DoCommandFlag flags, bool town_check) | |
{ | |
- if (_game_mode == GM_EDITOR || remove == ROAD_NONE) return CommandCost(); | |
+ if (Globals::IsGameMode(GM_EDITOR) || remove == ROAD_NONE) return CommandCost(); | |
/* Water can always flood and towns can always remove "normal" road pieces. | |
* Towns are not be allowed to remove non "normal" road pieces, like tram | |
@@ -1356,7 +1356,7 @@ static void DrawTile_Road(TileInfo *ti) | |
SpriteID rail = GetCustomRailSprite(rti, ti->tile, RTSG_CROSSING) + axis; | |
/* Draw tracks, but draw PBS reserved tracks darker. */ | |
- pal = (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasCrossingReservation(ti->tile)) ? PALETTE_CRASH : PAL_NONE; | |
+ pal = (!Globals::IsGameMode(GM_MENU) && _settings_client.gui.show_track_reservation && HasCrossingReservation(ti->tile)) ? PALETTE_CRASH : PAL_NONE; | |
DrawGroundSprite(rail, pal); | |
DrawRailTileSeq(ti, &_crossing_layout, TO_CATENARY, rail, 0, PAL_NONE); | |
@@ -1381,7 +1381,7 @@ static void DrawTile_Road(TileInfo *ti) | |
DrawGroundSprite(image, pal); | |
/* PBS debugging, draw reserved tracks darker */ | |
- if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasCrossingReservation(ti->tile)) { | |
+ if (!Globals::IsGameMode(GM_MENU) && _settings_client.gui.show_track_reservation && HasCrossingReservation(ti->tile)) { | |
DrawGroundSprite(GetCrossingRoadAxis(ti->tile) == AXIS_Y ? GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.single_x : GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.single_y, PALETTE_CRASH); | |
} | |
} | |
diff --git a/src/road_gui.cpp b/src/road_gui.cpp | |
index 801d334..37544a5 100644 | |
--- a/src/road_gui.cpp | |
+++ b/src/road_gui.cpp | |
@@ -429,7 +429,7 @@ struct BuildRoadToolbarWindow : Window { | |
break; | |
case WID_ROT_DEPOT: | |
- if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return; | |
+ if (Globals::IsGameMode(GM_EDITOR) || !CanBuildVehicleInfrastructure(VEH_ROAD)) return; | |
if (HandlePlacePushButton(this, WID_ROT_DEPOT, SPR_CURSOR_ROAD_DEPOT, HT_RECT)) { | |
ShowRoadDepotPicker(this); | |
this->last_started_action = widget; | |
@@ -437,7 +437,7 @@ struct BuildRoadToolbarWindow : Window { | |
break; | |
case WID_ROT_BUS_STATION: | |
- if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return; | |
+ if (Globals::IsGameMode(GM_EDITOR) || !CanBuildVehicleInfrastructure(VEH_ROAD)) return; | |
if (HandlePlacePushButton(this, WID_ROT_BUS_STATION, SPR_CURSOR_BUS_STATION, HT_RECT)) { | |
ShowRVStationPicker(this, ROADSTOP_BUS); | |
this->last_started_action = widget; | |
@@ -445,7 +445,7 @@ struct BuildRoadToolbarWindow : Window { | |
break; | |
case WID_ROT_TRUCK_STATION: | |
- if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return; | |
+ if (Globals::IsGameMode(GM_EDITOR) || !CanBuildVehicleInfrastructure(VEH_ROAD)) return; | |
if (HandlePlacePushButton(this, WID_ROT_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, HT_RECT)) { | |
ShowRVStationPicker(this, ROADSTOP_TRUCK); | |
this->last_started_action = widget; | |
@@ -678,7 +678,7 @@ struct BuildRoadToolbarWindow : Window { | |
static EventState RoadToolbarGlobalHotkeys(int hotkey) | |
{ | |
Window *w = NULL; | |
- switch (_game_mode) { | |
+ switch (Globals::GetGameMode()) { | |
case GM_NORMAL: { | |
extern RoadType _last_built_roadtype; | |
w = ShowBuildRoadToolbar(_last_built_roadtype); | |
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp | |
index d5d9bc3..e803a76 100644 | |
--- a/src/saveload/afterload.cpp | |
+++ b/src/saveload/afterload.cpp | |
@@ -786,7 +786,7 @@ bool AfterLoadGame() | |
} | |
/* make sure there is a town in the game */ | |
- if (_game_mode == GM_NORMAL && Town::GetNumItems() == 0) { | |
+ if (Globals::IsGameMode(GM_NORMAL) && Town::GetNumItems() == 0) { | |
SetSaveLoadError(STR_ERROR_NO_TOWN_IN_SCENARIO); | |
/* Restore the signals */ | |
ResetSignalHandlers(); | |
diff --git a/src/saveload/newgrf_sl.cpp b/src/saveload/newgrf_sl.cpp | |
index de261f0..bbcb9af 100644 | |
--- a/src/saveload/newgrf_sl.cpp | |
+++ b/src/saveload/newgrf_sl.cpp | |
@@ -96,7 +96,7 @@ static void Load_NGRF() | |
{ | |
Load_NGRF_common(_grfconfig); | |
- if (_game_mode == GM_MENU) { | |
+ if (Globals::IsGameMode(GM_MENU)) { | |
/* Intro game must not have NewGRF. */ | |
if (_grfconfig != NULL) SlErrorCorrupt("The intro game must not use NewGRF"); | |
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp | |
index dfa3be7..6dcf67d 100644 | |
--- a/src/saveload/saveload.cpp | |
+++ b/src/saveload/saveload.cpp | |
@@ -2478,7 +2478,7 @@ static void SaveFileStart() | |
/** Update the gui accordingly when saving is done and release locks on saveload. */ | |
static void SaveFileDone() | |
{ | |
- if (_game_mode != GM_MENU) _fast_forward = _sl.ff_state; | |
+ if (!Globals::IsGameMode(GM_MENU)) _fast_forward = _sl.ff_state; | |
SetMouseCursorBusy(false); | |
InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SAVELOAD_FINISH); | |
diff --git a/src/screenshot.cpp b/src/screenshot.cpp | |
index a24cc6b..1722914 100644 | |
--- a/src/screenshot.cpp | |
+++ b/src/screenshot.cpp | |
@@ -318,7 +318,7 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user | |
char *p = buf; | |
p += seprintf(p, lastof(buf), "Graphics set: %s (%u)\n", BaseGraphics::GetUsedSet()->name, BaseGraphics::GetUsedSet()->version); | |
p = strecpy(p, "NewGRFs:\n", lastof(buf)); | |
- for (const GRFConfig *c = _game_mode == GM_MENU ? NULL : _grfconfig; c != NULL; c = c->next) { | |
+ for (const GRFConfig *c = Globals::IsGameMode(GM_MENU) ? NULL : _grfconfig; c != NULL; c = c->next) { | |
p += seprintf(p, lastof(buf), "%08X ", BSWAP32(c->ident.grfid)); | |
p = md5sumToString(p, lastof(buf), c->ident.md5sum); | |
p += seprintf(p, lastof(buf), " %s\n", c->filename); | |
@@ -676,7 +676,7 @@ static const char *MakeScreenshotName(const char *default_fn, const char *ext, b | |
bool generate = StrEmpty(_screenshot_name); | |
if (generate) { | |
- if (_game_mode == GM_EDITOR || _game_mode == GM_MENU || _local_company == COMPANY_SPECTATOR) { | |
+ if (Globals::IsGameMode(GM_EDITOR) || Globals::IsGameMode(GM_MENU) || _local_company == COMPANY_SPECTATOR) { | |
strecpy(_screenshot_name, default_fn, lastof(_screenshot_name)); | |
} else { | |
GenerateDefaultSaveName(_screenshot_name, lastof(_screenshot_name)); | |
diff --git a/src/script/script_config.cpp b/src/script/script_config.cpp | |
index a6e4147..f123d6f 100644 | |
--- a/src/script/script_config.cpp | |
+++ b/src/script/script_config.cpp | |
@@ -31,7 +31,7 @@ void ScriptConfig::Change(const char *name, int version, bool force_exact_match, | |
this->ClearConfigList(); | |
- if (_game_mode == GM_NORMAL && this->info != NULL) { | |
+ if (Globals::IsGameMode(GM_NORMAL) && this->info != NULL) { | |
/* If we're in an existing game and the Script is changed, set all settings | |
* for the Script that have the random flag to a random value. */ | |
for (ScriptConfigItemList::const_iterator it = this->info->GetConfigList()->begin(); it != this->info->GetConfigList()->end(); it++) { | |
diff --git a/src/settings.cpp b/src/settings.cpp | |
index d819450..2baf31d 100644 | |
--- a/src/settings.cpp | |
+++ b/src/settings.cpp | |
@@ -765,11 +765,11 @@ void IniSaveWindowSettings(IniFile *ini, const char *grpname, void *desc) | |
bool SettingDesc::IsEditable(bool do_command) const | |
{ | |
if (!do_command && !(this->save.conv & SLF_NO_NETWORK_SYNC) && _networking && !_network_server && !(this->desc.flags & SGF_PER_COMPANY)) return false; | |
- if ((this->desc.flags & SGF_NETWORK_ONLY) && !_networking && _game_mode != GM_MENU) return false; | |
+ if ((this->desc.flags & SGF_NETWORK_ONLY) && !_networking && !Globals::IsGameMode(GM_MENU)) return false; | |
if ((this->desc.flags & SGF_NO_NETWORK) && _networking) return false; | |
if ((this->desc.flags & SGF_NEWGAME_ONLY) && | |
- (_game_mode == GM_NORMAL || | |
- (_game_mode == GM_EDITOR && !(this->desc.flags & SGF_SCENEDIT_TOO)))) return false; | |
+ (Globals::IsGameMode(GM_NORMAL) || | |
+ (Globals::IsGameMode(GM_EDITOR) && !(this->desc.flags & SGF_SCENEDIT_TOO)))) return false; | |
return true; | |
} | |
@@ -788,14 +788,14 @@ SettingType SettingDesc::GetType() const | |
/** Reposition the main toolbar as the setting changed. */ | |
static bool v_PositionMainToolbar(int32 p1) | |
{ | |
- if (_game_mode != GM_MENU) PositionMainToolbar(NULL); | |
+ if (!Globals::IsGameMode(GM_MENU)) PositionMainToolbar(NULL); | |
return true; | |
} | |
/** Reposition the statusbar as the setting changed. */ | |
static bool v_PositionStatusbar(int32 p1) | |
{ | |
- if (_game_mode != GM_MENU) { | |
+ if (!Globals::IsGameMode(GM_MENU)) { | |
PositionStatusbar(NULL); | |
PositionNewsMessage(NULL); | |
PositionNetworkChatWindow(NULL); | |
@@ -883,7 +883,7 @@ static bool CheckInterval(int32 p1) | |
{ | |
bool update_vehicles; | |
VehicleDefaultSettings *vds; | |
- if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) { | |
+ if (Globals::IsGameMode(GM_MENU) || !Company::IsValidID(_current_company)) { | |
vds = &_settings_client.company.vehicle; | |
update_vehicles = false; | |
} else { | |
@@ -923,7 +923,7 @@ static bool UpdateInterval(VehicleType type, int32 p1) | |
{ | |
bool update_vehicles; | |
VehicleDefaultSettings *vds; | |
- if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) { | |
+ if (Globals::IsGameMode(GM_MENU) || !Company::IsValidID(_current_company)) { | |
vds = &_settings_client.company.vehicle; | |
update_vehicles = false; | |
} else { | |
@@ -1050,7 +1050,7 @@ static bool DragSignalsDensityChanged(int32) | |
static bool TownFoundingChanged(int32 p1) | |
{ | |
- if (_game_mode != GM_EDITOR && _settings_game.economy.found_town == TF_FORBIDDEN) { | |
+ if (!Globals::IsGameMode(GM_EDITOR) && _settings_game.economy.found_town == TF_FORBIDDEN) { | |
DeleteWindowById(WC_FOUND_TOWN, 0); | |
return true; | |
} | |
@@ -1156,7 +1156,7 @@ static void ValidateSettings() | |
static bool DifficultyNoiseChange(int32 i) | |
{ | |
- if (_game_mode == GM_NORMAL) { | |
+ if (Globals::IsGameMode(GM_NORMAL)) { | |
UpdateAirportsNoise(); | |
if (_settings_game.economy.station_noise_level) { | |
InvalidateWindowClassesData(WC_TOWN_VIEW, 0); | |
@@ -1185,7 +1185,7 @@ static bool MaxNoAIsChange(int32 i) | |
static bool CheckRoadSide(int p1) | |
{ | |
extern bool RoadVehiclesAreBuilt(); | |
- return _game_mode == GM_MENU || !RoadVehiclesAreBuilt(); | |
+ return Globals::IsGameMode(GM_MENU) || !RoadVehiclesAreBuilt(); | |
} | |
/** | |
@@ -1203,7 +1203,7 @@ static size_t ConvertLandscape(const char *value) | |
static bool CheckFreeformEdges(int32 p1) | |
{ | |
- if (_game_mode == GM_MENU) return true; | |
+ if (Globals::IsGameMode(GM_MENU)) return true; | |
if (p1 != 0) { | |
Ship *s; | |
FOR_ALL_SHIPS(s) { | |
@@ -1268,7 +1268,7 @@ static bool CheckFreeformEdges(int32 p1) | |
*/ | |
static bool ChangeDynamicEngines(int32 p1) | |
{ | |
- if (_game_mode == GM_MENU) return true; | |
+ if (Globals::IsGameMode(GM_MENU)) return true; | |
if (!EngineOverrideManager::ResetToCurrentNewGRFConfig()) { | |
ShowErrorMessage(STR_CONFIG_SETTING_DYNAMIC_ENGINES_EXISTING_VEHICLES, INVALID_STRING_ID, WL_ERROR); | |
@@ -1280,8 +1280,8 @@ static bool ChangeDynamicEngines(int32 p1) | |
static bool ChangeMaxHeightLevel(int32 p1) | |
{ | |
- if (_game_mode == GM_NORMAL) return false; | |
- if (_game_mode != GM_EDITOR) return true; | |
+ if (Globals::IsGameMode(GM_NORMAL)) return false; | |
+ if (!Globals::IsGameMode(GM_EDITOR)) return true; | |
/* Check if at least one mountain on the map is higher than the new value. | |
* If yes, disallow the change. */ | |
@@ -1927,7 +1927,7 @@ bool SetSettingValue(uint index, int32 value, bool force_newgame) | |
void *var = GetVariableAddress(&GetGameSettings(), &sd->save); | |
Write_ValidateSetting(var, sd, value); | |
- if (_game_mode != GM_MENU) { | |
+ if (!Globals::IsGameMode(GM_MENU)) { | |
void *var2 = GetVariableAddress(&_settings_newgame, &sd->save); | |
Write_ValidateSetting(var2, sd, value); | |
} | |
@@ -1960,7 +1960,7 @@ bool SetSettingValue(uint index, int32 value, bool force_newgame) | |
void SetCompanySetting(uint index, int32 value) | |
{ | |
const SettingDesc *sd = &_company_settings[index]; | |
- if (Company::IsValidID(_local_company) && _game_mode != GM_MENU) { | |
+ if (Company::IsValidID(_local_company) && !Globals::IsGameMode(GM_MENU)) { | |
DoCommandP(0, index, value, CMD_CHANGE_COMPANY_SETTING); | |
} else { | |
void *var = GetVariableAddress(&_settings_client.company, &sd->save); | |
@@ -2026,7 +2026,7 @@ bool SetSettingValue(uint index, const char *value, bool force_newgame) | |
assert(sd->save.conv & SLF_NO_NETWORK_SYNC); | |
if (GetVarMemType(sd->save.conv) == SLE_VAR_STRQ) { | |
- char **var = (char**)GetVariableAddress((_game_mode == GM_MENU || force_newgame) ? &_settings_newgame : &_settings_game, &sd->save); | |
+ char **var = (char**)GetVariableAddress((Globals::IsGameMode(GM_MENU) || force_newgame) ? &_settings_newgame : &_settings_game, &sd->save); | |
free(*var); | |
*var = strcmp(value, "(null)") == 0 ? NULL : stredup(value); | |
} else { | |
@@ -2136,7 +2136,7 @@ void IConsoleGetSetting(const char *name, bool force_newgame) | |
return; | |
} | |
- ptr = GetVariableAddress((_game_mode == GM_MENU || force_newgame) ? &_settings_newgame : &_settings_game, &sd->save); | |
+ ptr = GetVariableAddress((Globals::IsGameMode(GM_MENU) || force_newgame) ? &_settings_newgame : &_settings_game, &sd->save); | |
if (sd->desc.cmd == SDT_STRING) { | |
IConsolePrintF(CC_WARNING, "Current value for '%s' is: '%s'", name, (GetVarMemType(sd->save.conv) == SLE_VAR_STRQ) ? *(const char * const *)ptr : (const char *)ptr); | |
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp | |
index 0420ba1..d36454e 100644 | |
--- a/src/settings_gui.cpp | |
+++ b/src/settings_gui.cpp | |
@@ -121,7 +121,7 @@ static DropDownList *BuiltSetDropDownList(int *selected_index) | |
DropDownList *list = new DropDownList(); | |
for (int i = 0; i < n; i++) { | |
- *list->Append() = new DropDownListCharStringItem(T::GetSet(i)->name, i, (_game_mode == GM_MENU) ? false : (*selected_index != i)); | |
+ *list->Append() = new DropDownListCharStringItem(T::GetSet(i)->name, i, (Globals::IsGameMode(GM_MENU)) ? false : (*selected_index != i)); | |
} | |
return list; | |
@@ -194,7 +194,7 @@ struct GameOptionsWindow : Window { | |
list = new DropDownList(); | |
*selected_index = this->opt->locale.currency; | |
StringID *items = BuildCurrencyDropdown(); | |
- uint64 disabled = _game_mode == GM_MENU ? 0LL : ~GetMaskOfAllowedCurrencies(); | |
+ uint64 disabled = Globals::IsGameMode(GM_MENU) ? 0LL : ~GetMaskOfAllowedCurrencies(); | |
/* Add non-custom currencies; sorted naturally */ | |
for (uint i = 0; i < CURRENCY_END; items++, i++) { | |
@@ -218,7 +218,7 @@ struct GameOptionsWindow : Window { | |
/* You can only change the drive side if you are in the menu or ingame with | |
* no vehicles present. In a networking game only the server can change it */ | |
extern bool RoadVehiclesAreBuilt(); | |
- if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server)) { | |
+ if ((!Globals::IsGameMode(GM_MENU) && RoadVehiclesAreBuilt()) || (_networking && !_network_server)) { | |
disabled = ~(1 << this->opt->vehicle.road_side); // disable the other value | |
} | |
@@ -232,7 +232,7 @@ struct GameOptionsWindow : Window { | |
list = new DropDownList(); | |
*selected_index = this->opt->game_creation.town_name; | |
- int enabled_item = (_game_mode == GM_MENU || Town::GetNumItems() == 0) ? -1 : *selected_index; | |
+ int enabled_item = (Globals::IsGameMode(GM_MENU) || Town::GetNumItems() == 0) ? -1 : *selected_index; | |
/* Add and sort newgrf townnames generators */ | |
for (int i = 0; i < _nb_grf_names; i++) { | |
@@ -471,7 +471,7 @@ struct GameOptionsWindow : Window { | |
template <class T> | |
void SetMediaSet(int index) | |
{ | |
- if (_game_mode == GM_MENU) { | |
+ if (Globals::IsGameMode(GM_MENU)) { | |
const char *name = T::GetSet(index)->name; | |
free(T::ini_set); | |
@@ -502,7 +502,7 @@ struct GameOptionsWindow : Window { | |
break; | |
case WID_GO_TOWNNAME_DROPDOWN: // Town names | |
- if (_game_mode == GM_MENU || Town::GetNumItems() == 0) { | |
+ if (Globals::IsGameMode(GM_MENU) || Town::GetNumItems() == 0) { | |
this->opt->game_creation.town_name = index; | |
SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_OPTIONS); | |
} | |
@@ -1067,7 +1067,7 @@ bool SettingEntry::UpdateFilterState(SettingFilter &filter, bool force_visible) | |
static const void *ResolveVariableAddress(const GameSettings *settings_ptr, const SettingDesc *sd) | |
{ | |
if ((sd->desc.flags & SGF_PER_COMPANY) != 0) { | |
- if (Company::IsValidID(_local_company) && _game_mode != GM_MENU) { | |
+ if (Company::IsValidID(_local_company) && !Globals::IsGameMode(GM_MENU)) { | |
return GetVariableAddress(&Company::Get(_local_company)->settings, &sd->save); | |
} else { | |
return GetVariableAddress(&_settings_client.company, &sd->save); | |
@@ -1905,8 +1905,8 @@ struct GameSettingsWindow : Window { | |
case WID_GS_TYPE_DROPDOWN: | |
switch (this->filter.type) { | |
- case ST_GAME: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME); break; | |
- case ST_COMPANY: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME); break; | |
+ case ST_GAME: SetDParam(0, Globals::IsGameMode(GM_MENU) ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME); break; | |
+ case ST_COMPANY: SetDParam(0, Globals::IsGameMode(GM_MENU) ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME); break; | |
case ST_CLIENT: SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT); break; | |
default: SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL); break; | |
} | |
@@ -1933,8 +1933,8 @@ struct GameSettingsWindow : Window { | |
case WID_GS_TYPE_DROPDOWN: | |
list = new DropDownList(); | |
*list->Append() = new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL, ST_ALL, false); | |
- *list->Append() = new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME, ST_GAME, false); | |
- *list->Append() = new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME, ST_COMPANY, false); | |
+ *list->Append() = new DropDownListStringItem(Globals::IsGameMode(GM_MENU) ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME, ST_GAME, false); | |
+ *list->Append() = new DropDownListStringItem(Globals::IsGameMode(GM_MENU) ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME, ST_COMPANY, false); | |
*list->Append() = new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT, ST_CLIENT, false); | |
break; | |
} | |
@@ -1959,9 +1959,9 @@ struct GameSettingsWindow : Window { | |
int y = r.top; | |
switch (sd->GetType()) { | |
- case ST_COMPANY: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_COMPANY_INGAME); break; | |
+ case ST_COMPANY: SetDParam(0, Globals::IsGameMode(GM_MENU) ? STR_CONFIG_SETTING_TYPE_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_COMPANY_INGAME); break; | |
case ST_CLIENT: SetDParam(0, STR_CONFIG_SETTING_TYPE_CLIENT); break; | |
- case ST_GAME: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_GAME_MENU : STR_CONFIG_SETTING_TYPE_GAME_INGAME); break; | |
+ case ST_GAME: SetDParam(0, Globals::IsGameMode(GM_MENU) ? STR_CONFIG_SETTING_TYPE_GAME_MENU : STR_CONFIG_SETTING_TYPE_GAME_INGAME); break; | |
default: NOT_REACHED(); | |
} | |
DrawString(r.left, r.right, y, STR_CONFIG_SETTING_TYPE); | |
diff --git a/src/settings_type.h b/src/settings_type.h | |
index 2dc9ec9..4708b68 100644 | |
--- a/src/settings_type.h | |
+++ b/src/settings_type.h | |
@@ -584,7 +584,7 @@ extern VehicleDefaultSettings _old_vds; | |
*/ | |
static inline GameSettings &GetGameSettings() | |
{ | |
- return (_game_mode == GM_MENU) ? _settings_newgame : _settings_game; | |
+ return (Globals::IsGameMode(GM_MENU)) ? _settings_newgame : _settings_game; | |
} | |
#endif /* SETTINGS_TYPE_H */ | |
diff --git a/src/signs_cmd.cpp b/src/signs_cmd.cpp | |
index 4badd36..f092d34 100644 | |
--- a/src/signs_cmd.cpp | |
+++ b/src/signs_cmd.cpp | |
@@ -47,7 +47,7 @@ CommandCost CmdPlaceSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 | |
/* When we execute, really make the sign */ | |
if (flags & DC_EXEC) { | |
- Sign *si = new Sign(_game_mode == GM_EDITOR ? OWNER_DEITY : _current_company); | |
+ Sign *si = new Sign(Globals::IsGameMode(GM_EDITOR) ? OWNER_DEITY : _current_company); | |
int x = TileX(tile) * TILE_SIZE; | |
int y = TileY(tile) * TILE_SIZE; | |
@@ -80,7 +80,7 @@ CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 | |
{ | |
Sign *si = Sign::GetIfValid(p1); | |
if (si == NULL) return CMD_ERROR; | |
- if (si->owner == OWNER_DEITY && _current_company != OWNER_DEITY && _game_mode != GM_EDITOR) return CMD_ERROR; | |
+ if (si->owner == OWNER_DEITY && _current_company != OWNER_DEITY && !Globals::IsGameMode(GM_EDITOR)) return CMD_ERROR; | |
/* Rename the signs when empty, otherwise remove it */ | |
if (!StrEmpty(text)) { | |
@@ -91,7 +91,7 @@ CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 | |
free(si->name); | |
/* Assign the new one */ | |
si->name = stredup(text); | |
- if (_game_mode != GM_EDITOR) si->owner = _current_company; | |
+ if (!Globals::IsGameMode(GM_EDITOR)) si->owner = _current_company; | |
si->UpdateVirtCoord(); | |
InvalidateWindowData(WC_SIGN_LIST, 0, 1); | |
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp | |
index 15adef0..ebd8751 100644 | |
--- a/src/signs_gui.cpp | |
+++ b/src/signs_gui.cpp | |
@@ -131,7 +131,7 @@ struct SignList { | |
void FilterSignList() | |
{ | |
this->signs.Filter(&SignNameFilter, this->string_filter); | |
- if (_game_mode != GM_EDITOR) this->signs.Filter(&OwnerDeityFilter, this->string_filter); | |
+ if (!Globals::IsGameMode(GM_EDITOR)) this->signs.Filter(&OwnerDeityFilter, this->string_filter); | |
if (!HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS)) { | |
this->signs.Filter(&OwnerVisibilityFilter, this->string_filter); | |
} | |
@@ -346,7 +346,7 @@ struct SignListWindow : Window, SignList { | |
*/ | |
static EventState SignListGlobalHotkeys(int hotkey) | |
{ | |
- if (_game_mode == GM_MENU) return ES_NOT_HANDLED; | |
+ if (Globals::IsGameMode(GM_MENU)) return ES_NOT_HANDLED; | |
Window *w = ShowSignList(); | |
if (w == NULL) return ES_NOT_HANDLED; | |
return w->OnHotkey(hotkey); | |
@@ -554,7 +554,7 @@ static WindowDesc _query_sign_edit_desc( | |
*/ | |
void HandleClickOnSign(const Sign *si) | |
{ | |
- if (_ctrl_pressed && (si->owner == _local_company || (si->owner == OWNER_DEITY && _game_mode == GM_EDITOR))) { | |
+ if (_ctrl_pressed && (si->owner == _local_company || (si->owner == OWNER_DEITY && Globals::IsGameMode(GM_EDITOR)))) { | |
RenameSign(si->index, NULL); | |
return; | |
} | |
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp | |
index 5fd865a..93d05c5 100644 | |
--- a/src/station_cmd.cpp | |
+++ b/src/station_cmd.cpp | |
@@ -2884,7 +2884,7 @@ draw_default_foundation: | |
DrawGroundSprite(image, PAL_NONE); | |
DrawGroundSprite(ground + overlay_offset, PAL_NONE); | |
- if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasStationReservation(ti->tile)) { | |
+ if (!Globals::IsGameMode(GM_MENU) && _settings_client.gui.show_track_reservation && HasStationReservation(ti->tile)) { | |
SpriteID overlay = GetCustomRailSprite(rti, ti->tile, RTSG_OVERLAY); | |
DrawGroundSprite(overlay + overlay_offset, PALETTE_CRASH); | |
} | |
@@ -2894,7 +2894,7 @@ draw_default_foundation: | |
DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, palette)); | |
/* PBS debugging, draw reserved tracks darker */ | |
- if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasStationRail(ti->tile) && HasStationReservation(ti->tile)) { | |
+ if (!Globals::IsGameMode(GM_MENU) && _settings_client.gui.show_track_reservation && HasStationRail(ti->tile) && HasStationReservation(ti->tile)) { | |
const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile)); | |
DrawGroundSprite(GetRailStationAxis(ti->tile) == AXIS_X ? rti->base_sprites.single_x : rti->base_sprites.single_y, PALETTE_CRASH); | |
} | |
@@ -3622,7 +3622,7 @@ static void StationHandleSmallTick(BaseStation *st) | |
void OnTick_Station() | |
{ | |
- if (_game_mode == GM_EDITOR) return; | |
+ if (Globals::IsGameMode(GM_EDITOR)) return; | |
BaseStation *st; | |
FOR_ALL_BASE_STATIONS(st) { | |
diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp | |
index aad9822..944879a 100644 | |
--- a/src/terraform_cmd.cpp | |
+++ b/src/terraform_cmd.cpp | |
@@ -282,7 +282,7 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin | |
/* Check tiletype-specific things, and add extra-cost */ | |
const bool curr_gen = _generating_world; | |
- if (_game_mode == GM_EDITOR) _generating_world = true; // used to create green terraformed land | |
+ if (Globals::IsGameMode(GM_EDITOR)) _generating_world = true; // used to create green terraformed land | |
DoCommandFlag tile_flags = flags | DC_AUTO | DC_FORCE_CLEAR_TILE; | |
if (pass == 0) { | |
tile_flags &= ~DC_EXEC; | |
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp | |
index 97749a8..c8276ce 100644 | |
--- a/src/terraform_gui.cpp | |
+++ b/src/terraform_gui.cpp | |
@@ -54,7 +54,7 @@ void CcTerraform(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2 | |
/** Scenario editor command that generates desert areas */ | |
static void GenerateDesertArea(TileIndex end, TileIndex start) | |
{ | |
- if (_game_mode != GM_EDITOR) return; | |
+ if (!Globals::IsGameMode(GM_EDITOR)) return; | |
_generating_world = true; | |
@@ -71,7 +71,7 @@ static void GenerateDesertArea(TileIndex end, TileIndex start) | |
/** Scenario editor command that generates rocky areas */ | |
static void GenerateRockyArea(TileIndex end, TileIndex start) | |
{ | |
- if (_game_mode != GM_EDITOR) return; | |
+ if (!Globals::IsGameMode(GM_EDITOR)) return; | |
bool success = false; | |
TileArea ta(start, end); | |
@@ -292,7 +292,7 @@ struct TerraformToolbarWindow : Window { | |
*/ | |
static EventState TerraformToolbarGlobalHotkeys(int hotkey) | |
{ | |
- if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED; | |
+ if (!Globals::IsGameMode(GM_NORMAL)) return ES_NOT_HANDLED; | |
Window *w = ShowTerraformToolbar(NULL); | |
if (w == NULL) return ES_NOT_HANDLED; | |
return w->OnHotkey(hotkey); | |
@@ -718,7 +718,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { | |
*/ | |
static EventState TerraformToolbarEditorGlobalHotkeys(int hotkey) | |
{ | |
- if (_game_mode != GM_EDITOR) return ES_NOT_HANDLED; | |
+ if (!Globals::IsGameMode(GM_EDITOR)) return ES_NOT_HANDLED; | |
Window *w = ShowEditorTerraformToolbar(); | |
if (w == NULL) return ES_NOT_HANDLED; | |
return w->OnHotkey(hotkey); | |
diff --git a/src/texteff.cpp b/src/texteff.cpp | |
index cdb8b8c..96bc171 100644 | |
--- a/src/texteff.cpp | |
+++ b/src/texteff.cpp | |
@@ -41,7 +41,7 @@ static SmallVector<struct TextEffect, 32> _text_effects; ///< Text effects are s | |
/* Text Effects */ | |
TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, TextEffectMode mode) | |
{ | |
- if (_game_mode == GM_MENU) return INVALID_TE_ID; | |
+ if (Globals::IsGameMode(GM_MENU)) return INVALID_TE_ID; | |
TextEffectID i; | |
for (i = 0; i < _text_effects.Length(); i++) { | |
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp | |
index f253be8..02f7903 100644 | |
--- a/src/toolbar_gui.cpp | |
+++ b/src/toolbar_gui.cpp | |
@@ -425,7 +425,7 @@ static CallBackFunction ToolbarScenSaveOrLoad(Window *w) | |
*/ | |
static CallBackFunction MenuClickSaveLoad(int index = 0) | |
{ | |
- if (_game_mode == GM_EDITOR) { | |
+ if (Globals::IsGameMode(GM_EDITOR)) { | |
switch (index) { | |
case SLEME_SAVE_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_SAVE); break; | |
case SLEME_LOAD_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_LOAD); break; | |
@@ -847,7 +847,7 @@ static CallBackFunction MenuClickShowAir(int index) | |
static CallBackFunction ToolbarZoomInClick(Window *w) | |
{ | |
if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) { | |
- w->HandleButtonClick((_game_mode == GM_EDITOR) ? (byte)WID_TE_ZOOM_IN : (byte)WID_TN_ZOOM_IN); | |
+ w->HandleButtonClick((Globals::IsGameMode(GM_EDITOR)) ? (byte)WID_TE_ZOOM_IN : (byte)WID_TN_ZOOM_IN); | |
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); | |
} | |
return CBF_NONE; | |
@@ -858,7 +858,7 @@ static CallBackFunction ToolbarZoomInClick(Window *w) | |
static CallBackFunction ToolbarZoomOutClick(Window *w) | |
{ | |
if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) { | |
- w->HandleButtonClick((_game_mode == GM_EDITOR) ? (byte)WID_TE_ZOOM_OUT : (byte)WID_TN_ZOOM_OUT); | |
+ w->HandleButtonClick((Globals::IsGameMode(GM_EDITOR)) ? (byte)WID_TE_ZOOM_OUT : (byte)WID_TN_ZOOM_OUT); | |
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); | |
} | |
return CBF_NONE; | |
@@ -2013,7 +2013,7 @@ struct MainToolbarWindow : Window { | |
virtual void OnClick(Point pt, int widget, int click_count) | |
{ | |
- if (_game_mode != GM_MENU && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](this); | |
+ if (!Globals::IsGameMode(GM_MENU) && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](this); | |
} | |
virtual void OnDropdownSelect(int widget, int index) | |
@@ -2369,7 +2369,7 @@ struct ScenarioEditorToolbarWindow : Window { | |
virtual void OnClick(Point pt, int widget, int click_count) | |
{ | |
- if (_game_mode == GM_MENU) return; | |
+ if (Globals::IsGameMode(GM_MENU)) return; | |
CallBackFunction cbf = _scen_toolbar_button_procs[widget](this); | |
if (cbf != CBF_NONE) _last_started_action = cbf; | |
} | |
@@ -2571,7 +2571,7 @@ void AllocateToolbar() | |
/* Clean old GUI values; railtype is (re)set by rail_gui.cpp */ | |
_last_built_roadtype = ROADTYPE_ROAD; | |
- if (_game_mode == GM_EDITOR) { | |
+ if (Globals::IsGameMode(GM_EDITOR)) { | |
new ScenarioEditorToolbarWindow(&_toolb_scen_desc); | |
} else { | |
new MainToolbarWindow(&_toolb_normal_desc); | |
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp | |
index daaad7e..6f7f4ee 100644 | |
--- a/src/town_cmd.cpp | |
+++ b/src/town_cmd.cpp | |
@@ -794,7 +794,7 @@ static void TownTickHandler(Town *t) | |
void OnTick_Town() | |
{ | |
- if (_game_mode == GM_EDITOR) return; | |
+ if (Globals::IsGameMode(GM_EDITOR)) return; | |
Town *t; | |
FOR_ALL_TOWNS(t) { | |
@@ -1407,7 +1407,7 @@ static bool GrowTownAtRoad(Town *t, TileIndex tile) | |
/* Don't allow building over roads of other cities */ | |
if (IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN) && Town::GetByTile(tile) != t) { | |
return false; | |
- } else if (IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_NONE) && _game_mode == GM_EDITOR) { | |
+ } else if (IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_NONE) && Globals::IsGameMode(GM_EDITOR)) { | |
/* If we are in the SE, and this road-piece has no town owner yet, it just found an | |
* owner :) (happy happy happy road now) */ | |
SetRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN); | |
@@ -1611,7 +1611,7 @@ static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts, TownSize | |
int x = (int)size * 16 + 3; | |
if (size == TSZ_RANDOM) x = (Random() & 0xF) + 8; | |
/* Don't create huge cities when founding town in-game */ | |
- if (city && (!manual || _game_mode == GM_EDITOR)) x *= _settings_game.economy.initial_city_size; | |
+ if (city && (!manual || Globals::IsGameMode(GM_EDITOR))) x *= _settings_game.economy.initial_city_size; | |
t->cache.num_houses += x; | |
UpdateTownRadius(t); | |
@@ -1693,7 +1693,7 @@ CommandCost CmdFoundTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 | |
if (layout >= NUM_TLS) return CMD_ERROR; | |
/* Some things are allowed only in the scenario editor and for game scripts. */ | |
- if (_game_mode != GM_EDITOR && _current_company != OWNER_DEITY) { | |
+ if (!Globals::IsGameMode(GM_EDITOR) && _current_company != OWNER_DEITY) { | |
if (_settings_game.economy.found_town == TF_FORBIDDEN) return CMD_ERROR; | |
if (size == TSZ_LARGE) return CMD_ERROR; | |
if (random) return CMD_ERROR; | |
@@ -1760,7 +1760,7 @@ CommandCost CmdFoundTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 | |
t->UpdateVirtCoord(); | |
} | |
- if (_game_mode != GM_EDITOR) { | |
+ if (!Globals::IsGameMode(GM_EDITOR)) { | |
/* 't' can't be NULL since 'random' is false outside scenedit */ | |
assert(!random); | |
char company_name[MAX_LENGTH_COMPANY_NAME_CHARS * MAX_CHAR_LENGTH]; | |
@@ -1895,7 +1895,7 @@ static TileIndex FindNearestGoodCoastalTownSpot(TileIndex tile, TownLayout layou | |
static Town *CreateRandomTown(uint attempts, uint32 townnameparts, TownSize size, bool city, TownLayout layout) | |
{ | |
- assert(_game_mode == GM_EDITOR || _generating_world); // These are the preconditions for CMD_DELETE_TOWN | |
+ assert(Globals::IsGameMode(GM_EDITOR) || _generating_world); // These are the preconditions for CMD_DELETE_TOWN | |
if (!Town::CanAllocateItem()) return NULL; | |
@@ -1949,7 +1949,7 @@ static const byte _num_initial_towns[4] = {5, 11, 23, 46}; // very low, low, no | |
bool GenerateTowns(TownLayout layout) | |
{ | |
uint current_number = 0; | |
- uint difficulty = (_game_mode != GM_EDITOR) ? _settings_game.difficulty.number_towns : 0; | |
+ uint difficulty = (!Globals::IsGameMode(GM_EDITOR)) ? _settings_game.difficulty.number_towns : 0; | |
uint total = (difficulty == (uint)CUSTOM_TOWN_NUMBER_DIFFICULTY) ? _settings_game.game_creation.custom_town_number : ScaleByMapSize(_num_initial_towns[difficulty] + (Random() & 7)); | |
total = min(TownPool::MAX_SIZE, total); | |
uint32 townnameparts; | |
@@ -1981,7 +1981,7 @@ bool GenerateTowns(TownLayout layout) | |
} | |
/* If there are no towns at all and we are generating new game, bail out */ | |
- if (Town::GetNumItems() == 0 && _game_mode != GM_EDITOR) { | |
+ if (Town::GetNumItems() == 0 && !Globals::IsGameMode(GM_EDITOR)) { | |
ShowErrorMessage(STR_ERROR_COULD_NOT_CREATE_TOWN, INVALID_STRING_ID, WL_CRITICAL); | |
} | |
@@ -2319,7 +2319,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile) | |
const HouseSpec *hs = HouseSpec::Get(house); | |
if (_loaded_newgrf_features.has_newhouses && !_generating_world && | |
- _game_mode != GM_EDITOR && (hs->extra_flags & BUILDING_IS_HISTORICAL) != 0) { | |
+ !Globals::IsGameMode(GM_EDITOR) && (hs->extra_flags & BUILDING_IS_HISTORICAL) != 0) { | |
continue; | |
} | |
@@ -2366,7 +2366,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile) | |
byte construction_counter = 0; | |
byte construction_stage = 0; | |
- if (_generating_world || _game_mode == GM_EDITOR) { | |
+ if (_generating_world || Globals::IsGameMode(GM_EDITOR)) { | |
uint32 r = Random(); | |
construction_stage = TOWN_HOUSE_COMPLETED; | |
@@ -2628,7 +2628,7 @@ CommandCost CmdTownGrowthRate(TileIndex tile, DoCommandFlag flags, uint32 p1, ui | |
*/ | |
CommandCost CmdExpandTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) | |
{ | |
- if (_game_mode != GM_EDITOR && _current_company != OWNER_DEITY) return CMD_ERROR; | |
+ if (!Globals::IsGameMode(GM_EDITOR) && _current_company != OWNER_DEITY) return CMD_ERROR; | |
Town *t = Town::GetIfValid(p1); | |
if (t == NULL) return CMD_ERROR; | |
@@ -2668,7 +2668,7 @@ CommandCost CmdExpandTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 | |
*/ | |
CommandCost CmdDeleteTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) | |
{ | |
- if (_game_mode != GM_EDITOR && !_generating_world) return CMD_ERROR; | |
+ if (!Globals::IsGameMode(GM_EDITOR) && !_generating_world) return CMD_ERROR; | |
Town *t = Town::GetIfValid(p1); | |
if (t == NULL) return CMD_ERROR; | |
diff --git a/src/town_gui.cpp b/src/town_gui.cpp | |
index 696b71a..2e91763 100644 | |
--- a/src/town_gui.cpp | |
+++ b/src/town_gui.cpp | |
@@ -596,7 +596,7 @@ static WindowDesc _town_editor_view_desc( | |
void ShowTownViewWindow(TownID town) | |
{ | |
- if (_game_mode == GM_EDITOR) { | |
+ if (Globals::IsGameMode(GM_EDITOR)) { | |
AllocateWindowDescFront<TownViewWindow>(&_town_editor_view_desc, town); | |
} else { | |
AllocateWindowDescFront<TownViewWindow>(&_town_game_view_desc, town); | |
@@ -772,7 +772,7 @@ public: | |
assert(t->xy != INVALID_TILE); | |
/* Draw rating icon. */ | |
- if (_game_mode == GM_EDITOR || !HasBit(t->have_ratings, _local_company)) { | |
+ if (Globals::IsGameMode(GM_EDITOR) || !HasBit(t->have_ratings, _local_company)) { | |
DrawSprite(SPR_TOWN_RATING_NA, PAL_NONE, icon_x, y + (this->resize.step_height - icon_size.height) / 2); | |
} else { | |
SpriteID icon = SPR_TOWN_RATING_APALLING; | |
@@ -1078,7 +1078,7 @@ public: | |
void UpdateButtons(bool check_availability) | |
{ | |
- if (check_availability && _game_mode != GM_EDITOR) { | |
+ if (check_availability && !Globals::IsGameMode(GM_EDITOR)) { | |
this->SetWidgetsDisabledState(true, WID_TF_RANDOM_TOWN, WID_TF_MANY_RANDOM_TOWNS, WID_TF_SIZE_LARGE, WIDGET_LIST_END); | |
this->SetWidgetsDisabledState(_settings_game.economy.found_town != TF_CUSTOM_LAYOUT, | |
WID_TF_LAYOUT_ORIGINAL, WID_TF_LAYOUT_BETTER, WID_TF_LAYOUT_GRID2, WID_TF_LAYOUT_GRID3, WID_TF_LAYOUT_RANDOM, WIDGET_LIST_END); | |
@@ -1195,6 +1195,6 @@ static WindowDesc _found_town_desc( | |
void ShowFoundTownWindow() | |
{ | |
- if (_game_mode != GM_EDITOR && !Company::IsValidID(_local_company)) return; | |
+ if (!Globals::IsGameMode(GM_EDITOR) && !Company::IsValidID(_local_company)) return; | |
AllocateWindowDescFront<FoundTownWindow>(&_found_town_desc, 0); | |
} | |
diff --git a/src/transparency.h b/src/transparency.h | |
index ab6f9a6..425181c 100644 | |
--- a/src/transparency.h | |
+++ b/src/transparency.h | |
@@ -49,7 +49,7 @@ extern byte _display_opt; | |
*/ | |
static inline bool IsTransparencySet(TransparencyOption to) | |
{ | |
- return (HasBit(_transparency_opt, to) && _game_mode != GM_MENU); | |
+ return (HasBit(_transparency_opt, to) && !Globals::IsGameMode(GM_MENU)); | |
} | |
/** | |
@@ -60,7 +60,7 @@ static inline bool IsTransparencySet(TransparencyOption to) | |
*/ | |
static inline bool IsInvisibilitySet(TransparencyOption to) | |
{ | |
- return (HasBit(_transparency_opt & _invisibility_opt, to) && _game_mode != GM_MENU); | |
+ return (HasBit(_transparency_opt & _invisibility_opt, to) && !Globals::IsGameMode(GM_MENU)); | |
} | |
/** | |
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp | |
index 7240cf8..7e02eac 100644 | |
--- a/src/tree_cmd.cpp | |
+++ b/src/tree_cmd.cpp | |
@@ -248,7 +248,7 @@ void PlaceTreesRandomly() | |
int i, j, ht; | |
i = ScaleByMapSize(DEFAULT_TREE_STEPS); | |
- if (_game_mode == GM_EDITOR) i /= EDITOR_TREE_DIV; | |
+ if (Globals::IsGameMode(GM_EDITOR)) i /= EDITOR_TREE_DIV; | |
do { | |
uint32 r = Random(); | |
TileIndex tile = RandomTileSeed(r); | |
@@ -276,7 +276,7 @@ void PlaceTreesRandomly() | |
/* place extra trees at rainforest area */ | |
if (_settings_game.game_creation.landscape == LT_TROPIC) { | |
i = ScaleByMapSize(DEFAULT_RAINFOREST_TREE_STEPS); | |
- if (_game_mode == GM_EDITOR) i /= EDITOR_TREE_DIV; | |
+ if (Globals::IsGameMode(GM_EDITOR)) i /= EDITOR_TREE_DIV; | |
do { | |
uint32 r = Random(); | |
@@ -342,7 +342,7 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 | |
/* Check the tree type within the current climate */ | |
if (tree_to_plant != TREE_INVALID && !IsInsideBS(tree_to_plant, _tree_base_by_landscape[_settings_game.game_creation.landscape], _tree_count_by_landscape[_settings_game.game_creation.landscape])) return CMD_ERROR; | |
- Company *c = (_game_mode != GM_EDITOR) ? Company::GetIfValid(_current_company) : NULL; | |
+ Company *c = (!Globals::IsGameMode(GM_EDITOR)) ? Company::GetIfValid(_current_company) : NULL; | |
int limit = (c == NULL ? INT32_MAX : GB(c->tree_limit, 16, 16)); | |
TileArea ta(tile, p2); | |
@@ -350,7 +350,7 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 | |
switch (GetTileType(tile)) { | |
case MP_TREES: | |
/* no more space for trees? */ | |
- if (_game_mode != GM_EDITOR && GetTreeCount(tile) == 4) { | |
+ if (!Globals::IsGameMode(GM_EDITOR) && GetTreeCount(tile) == 4) { | |
msg = STR_ERROR_TREE_ALREADY_HERE; | |
continue; | |
} | |
@@ -389,7 +389,7 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 | |
/* No cacti outside the desert */ | |
(treetype == TREE_CACTUS && GetTropicZone(tile) != TROPICZONE_DESERT) || | |
/* No rain forest trees outside the rain forest, except in the editor mode where it makes those tiles rain forest tile */ | |
- (IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS) && GetTropicZone(tile) != TROPICZONE_RAINFOREST && _game_mode != GM_EDITOR) || | |
+ (IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS) && GetTropicZone(tile) != TROPICZONE_RAINFOREST && !Globals::IsGameMode(GM_EDITOR)) || | |
/* And no subtropical trees in the desert/rain forest */ | |
(IsInsideMM(treetype, TREE_SUB_TROPICAL, TREE_TOYLAND) && GetTropicZone(tile) != TROPICZONE_NORMAL))) { | |
msg = STR_ERROR_TREE_WRONG_TERRAIN_FOR_TREE_TYPE; | |
@@ -417,7 +417,7 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 | |
} | |
} | |
- if (_game_mode != GM_EDITOR && Company::IsValidID(_current_company)) { | |
+ if (!Globals::IsGameMode(GM_EDITOR) && Company::IsValidID(_current_company)) { | |
Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority); | |
if (t != NULL) ChangeTownRating(t, RATING_TREE_UP_STEP, RATING_TREE_MAXIMUM, flags); | |
} | |
@@ -429,12 +429,12 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 | |
} | |
/* Plant full grown trees in scenario editor */ | |
- PlantTreesOnTile(tile, treetype, 0, _game_mode == GM_EDITOR ? 3 : 0); | |
+ PlantTreesOnTile(tile, treetype, 0, Globals::IsGameMode(GM_EDITOR) ? 3 : 0); | |
MarkTileDirtyByTile(tile); | |
if (c != NULL) c->tree_limit -= 1 << 16; | |
/* When planting rainforest-trees, set tropiczone to rainforest in editor. */ | |
- if (_game_mode == GM_EDITOR && IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS)) { | |
+ if (Globals::IsGameMode(GM_EDITOR) && IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS)) { | |
SetTropicZone(tile, TROPICZONE_RAINFOREST); | |
} | |
} | |
diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp | |
index f21eeae..7611e8b 100644 | |
--- a/src/tree_gui.cpp | |
+++ b/src/tree_gui.cpp | |
@@ -96,7 +96,7 @@ public: | |
if (widget != WID_BT_MANY_RANDOM) return; | |
- if (_game_mode != GM_EDITOR) { | |
+ if (!Globals::IsGameMode(GM_EDITOR)) { | |
size->width = 0; | |
size->height = 0; | |
} | |
@@ -244,6 +244,6 @@ static WindowDesc _build_trees_desc( | |
void ShowBuildTreesToolbar() | |
{ | |
- if (_game_mode != GM_EDITOR && !Company::IsValidID(_local_company)) return; | |
+ if (!Globals::IsGameMode(GM_EDITOR) && !Company::IsValidID(_local_company)) return; | |
AllocateWindowDescFront<BuildTreesWindow>(&_build_trees_desc, 0); | |
} | |
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp | |
index 9ba9b26..e5228a3 100644 | |
--- a/src/tunnelbridge_cmd.cpp | |
+++ b/src/tunnelbridge_cmd.cpp | |
@@ -338,7 +338,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u | |
/* Do not replace town bridges with lower speed bridges, unless in scenario editor. */ | |
if (!(flags & DC_QUERY_COST) && IsTileOwner(tile_start, OWNER_TOWN) && | |
GetBridgeSpec(bridge_type)->speed < GetBridgeSpec(GetBridgeType(tile_start))->speed && | |
- _game_mode != GM_EDITOR) { | |
+ !Globals::IsGameMode(GM_EDITOR)) { | |
Town *t = ClosestTownFromTile(tile_start, UINT_MAX); | |
if (t == NULL) { | |
@@ -749,7 +749,7 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, | |
static inline CommandCost CheckAllowRemoveTunnelBridge(TileIndex tile) | |
{ | |
/* Floods can remove anything as well as the scenario editor */ | |
- if (_current_company == OWNER_WATER || _game_mode == GM_EDITOR) return CommandCost(); | |
+ if (_current_company == OWNER_WATER || Globals::IsGameMode(GM_EDITOR)) return CommandCost(); | |
switch (GetTunnelBridgeTransportType(tile)) { | |
case TRANSPORT_ROAD: { | |
@@ -806,7 +806,7 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags) | |
_build_tunnel_endtile = endtile; | |
Town *t = NULL; | |
- if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { | |
+ if (IsTileOwner(tile, OWNER_TOWN) && !Globals::IsGameMode(GM_EDITOR)) { | |
t = ClosestTownFromTile(tile, UINT_MAX); // town penalty rating | |
/* Check if you are allowed to remove the tunnel owned by a town | |
@@ -817,7 +817,7 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags) | |
/* checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until | |
* you have a "Poor" (0) town rating */ | |
- if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { | |
+ if (IsTileOwner(tile, OWNER_TOWN) && !Globals::IsGameMode(GM_EDITOR)) { | |
ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM, flags); | |
} | |
@@ -891,7 +891,7 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags) | |
TileIndexDiff delta = TileOffsByDiagDir(direction); | |
Town *t = NULL; | |
- if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { | |
+ if (IsTileOwner(tile, OWNER_TOWN) && !Globals::IsGameMode(GM_EDITOR)) { | |
t = ClosestTownFromTile(tile, UINT_MAX); // town penalty rating | |
/* Check if you are allowed to remove the bridge owned by a town | |
@@ -902,7 +902,7 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags) | |
/* checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until | |
* you have a "Poor" (0) town rating */ | |
- if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { | |
+ if (IsTileOwner(tile, OWNER_TOWN) && !Globals::IsGameMode(GM_EDITOR)) { | |
ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM, flags); | |
} | |
@@ -1207,7 +1207,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti) | |
} | |
/* PBS debugging, draw reserved tracks darker */ | |
- if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasTunnelBridgeReservation(ti->tile)) { | |
+ if (!Globals::IsGameMode(GM_MENU) && _settings_client.gui.show_track_reservation && HasTunnelBridgeReservation(ti->tile)) { | |
if (rti->UsesOverlay()) { | |
SpriteID overlay = GetCustomRailSprite(rti, ti->tile, RTSG_OVERLAY); | |
DrawGroundSprite(overlay + RTO_X + DiagDirToAxis(tunnelbridge_direction), PALETTE_CRASH); | |
@@ -1323,7 +1323,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti) | |
} | |
/* PBS debugging, draw reserved tracks darker */ | |
- if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasTunnelBridgeReservation(ti->tile)) { | |
+ if (!Globals::IsGameMode(GM_MENU) && _settings_client.gui.show_track_reservation && HasTunnelBridgeReservation(ti->tile)) { | |
if (rti->UsesOverlay()) { | |
SpriteID overlay = GetCustomRailSprite(rti, ti->tile, RTSG_OVERLAY); | |
if (HasBridgeFlatRamp(ti->tileh, DiagDirToAxis(tunnelbridge_direction))) { | |
@@ -1480,7 +1480,7 @@ void DrawBridgeMiddle(const TileInfo *ti) | |
} | |
} | |
- if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && !IsInvisibilitySet(TO_BRIDGES) && HasTunnelBridgeReservation(rampnorth)) { | |
+ if (!Globals::IsGameMode(GM_MENU) && _settings_client.gui.show_track_reservation && !IsInvisibilitySet(TO_BRIDGES) && HasTunnelBridgeReservation(rampnorth)) { | |
if (rti->UsesOverlay()) { | |
SpriteID overlay = GetCustomRailSprite(rti, ti->tile, RTSG_OVERLAY); | |
AddSortableSpriteToDraw(overlay + RTO_X + axis, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, bridge_z, IsTransparencySet(TO_BRIDGES)); | |
diff --git a/src/vehicle.cpp b/src/vehicle.cpp | |
index dff9feb..33f5d2b 100644 | |
--- a/src/vehicle.cpp | |
+++ b/src/vehicle.cpp | |
@@ -888,7 +888,7 @@ void VehicleEnteredDepotThisTick(Vehicle *v) | |
*/ | |
static void RunVehicleDayProc() | |
{ | |
- if (_game_mode != GM_NORMAL) return; | |
+ if (!Globals::IsGameMode(GM_NORMAL)) return; | |
/* Run the day_proc for every DAY_TICKS vehicle starting at _date_fract. */ | |
for (size_t i = _date_fract; i < Vehicle::GetPoolSize(); i += DAY_TICKS) { | |
@@ -1196,7 +1196,7 @@ void CheckVehicleBreakdown(Vehicle *v) | |
if (v->breakdown_ctr != 0 || (v->vehstatus & VS_STOPPED) || | |
_settings_game.difficulty.vehicle_breakdowns < 1 || | |
- v->cur_speed < 5 || _game_mode == GM_MENU) { | |
+ v->cur_speed < 5 || Globals::IsGameMode(GM_MENU)) { | |
return; | |
} | |
diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp | |
index 5e2be48..5860358 100644 | |
--- a/src/video/dedicated_v.cpp | |
+++ b/src/video/dedicated_v.cpp | |
@@ -71,7 +71,7 @@ static void OS2_SwitchToConsoleMode() | |
/* Signal handlers */ | |
static void DedicatedSignalHandler(int sig) | |
{ | |
- if (_game_mode == GM_NORMAL && _settings_client.gui.autosave_on_exit) DoExitSave(); | |
+ if (Globals::IsGameMode(GM_NORMAL) && _settings_client.gui.autosave_on_exit) DoExitSave(); | |
_exit_game = true; | |
signal(sig, DedicatedSignalHandler); | |
} | |
diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp | |
index 3668f86..8e26016 100644 | |
--- a/src/video/sdl_v.cpp | |
+++ b/src/video/sdl_v.cpp | |
@@ -715,7 +715,7 @@ void VideoDriver_SDL::MainLoop() | |
#endif /* SDL_VERSION_ATLEAST(1, 3, 0) */ | |
#endif /* defined(_DEBUG) */ | |
{ | |
- if (!_networking && _game_mode != GM_MENU) _fast_forward |= 2; | |
+ if (!_networking && !Globals::IsGameMode(GM_MENU)) _fast_forward |= 2; | |
} else if (_fast_forward & 2) { | |
_fast_forward = 0; | |
} | |
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp | |
index 4a9861b..da3f2a7 100644 | |
--- a/src/video/win32_v.cpp | |
+++ b/src/video/win32_v.cpp | |
@@ -1236,7 +1236,7 @@ void VideoDriver_Win32::MainLoop() | |
/* Speed up using TAB, but disable for ALT+TAB of course */ | |
if (_wnd.has_focus && GetAsyncKeyState(VK_TAB) < 0 && GetAsyncKeyState(VK_MENU) >= 0 && | |
#endif | |
- !_networking && _game_mode != GM_MENU) { | |
+ !_networking && !Globals::IsGameMode(GM_MENU)) { | |
_fast_forward |= 2; | |
} else if (_fast_forward & 2) { | |
_fast_forward = 0; | |
diff --git a/src/viewport.cpp b/src/viewport.cpp | |
index df431ff..0e1c3df 100644 | |
--- a/src/viewport.cpp | |
+++ b/src/viewport.cpp | |
@@ -1250,7 +1250,7 @@ void ViewportAddString(const DrawPixelInfo *dpi, ZoomLevel small_from, const Vie | |
static void ViewportAddTownNames(DrawPixelInfo *dpi) | |
{ | |
- if (!HasBit(_display_opt, DO_SHOW_TOWN_NAMES) || _game_mode == GM_MENU) return; | |
+ if (!HasBit(_display_opt, DO_SHOW_TOWN_NAMES) || Globals::IsGameMode(GM_MENU)) return; | |
const Town *t; | |
FOR_ALL_TOWNS(t) { | |
@@ -1264,7 +1264,7 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi) | |
static void ViewportAddStationNames(DrawPixelInfo *dpi) | |
{ | |
- if (!(HasBit(_display_opt, DO_SHOW_STATION_NAMES) || HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES)) || _game_mode == GM_MENU) return; | |
+ if (!(HasBit(_display_opt, DO_SHOW_STATION_NAMES) || HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES)) || Globals::IsGameMode(GM_MENU)) return; | |
const BaseStation *st; | |
FOR_ALL_BASE_STATIONS(st) { | |
@@ -2125,7 +2125,7 @@ static bool CheckClickOnSign(const ViewPort *vp, int x, int y) | |
FOR_ALL_SIGNS(si) { | |
/* If competitor signs are hidden, don't check signs that aren't owned by local company */ | |
if (!HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS) && _local_company != si->owner && si->owner != OWNER_DEITY) continue; | |
- if (si->owner == OWNER_DEITY && _game_mode != GM_EDITOR) continue; | |
+ if (si->owner == OWNER_DEITY && !Globals::IsGameMode(GM_EDITOR)) continue; | |
if (CheckClickOnViewportSign(vp, x, y, &si->sign)) { | |
HandleClickOnSign(si); | |
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp | |
index edce4cd..e60b498 100644 | |
--- a/src/water_cmd.cpp | |
+++ b/src/water_cmd.cpp | |
@@ -397,12 +397,12 @@ CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 | |
if (p1 >= MapSize() || wc == WATER_CLASS_INVALID) return CMD_ERROR; | |
/* Outside of the editor you can only build canals, not oceans */ | |
- if (wc != WATER_CLASS_CANAL && _game_mode != GM_EDITOR) return CMD_ERROR; | |
+ if (wc != WATER_CLASS_CANAL && !Globals::IsGameMode(GM_EDITOR)) return CMD_ERROR; | |
TileArea ta(tile, p1); | |
/* Outside the editor you can only drag canals, and not areas */ | |
- if (_game_mode != GM_EDITOR && ta.w != 1 && ta.h != 1) return CMD_ERROR; | |
+ if (!Globals::IsGameMode(GM_EDITOR) && ta.w != 1 && ta.h != 1) return CMD_ERROR; | |
CommandCost cost(EXPENSES_CONSTRUCTION); | |
TILE_AREA_LOOP(tile, ta) { | |
@@ -426,7 +426,7 @@ CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 | |
switch (wc) { | |
case WATER_CLASS_RIVER: | |
MakeRiver(tile, Random()); | |
- if (_game_mode == GM_EDITOR) { | |
+ if (Globals::IsGameMode(GM_EDITOR)) { | |
TileIndex tile2 = tile; | |
CircularTileSearch(&tile2, 5, RiverModifyDesertZone, NULL); | |
} | |
diff --git a/src/window.cpp b/src/window.cpp | |
index 6538caf..d128851 100644 | |
--- a/src/window.cpp | |
+++ b/src/window.cpp | |
@@ -2703,7 +2703,7 @@ static int _input_events_this_tick = 0; | |
*/ | |
static void HandleAutoscroll() | |
{ | |
- if (_game_mode == GM_MENU || HasModalProgress()) return; | |
+ if (Globals::IsGameMode(GM_MENU) || HasModalProgress()) return; | |
if (_settings_client.gui.auto_scrolling == VA_DISABLED) return; | |
if (_settings_client.gui.auto_scrolling == VA_MAIN_VIEWPORT_FULLSCREEN && !_fullscreen) return; | |
@@ -2749,7 +2749,7 @@ extern EventState VpHandlePlaceSizingDrag(); | |
static void ScrollMainViewport(int x, int y) | |
{ | |
- if (_game_mode != GM_MENU) { | |
+ if (!Globals::IsGameMode(GM_MENU)) { | |
Window *w = FindWindowById(WC_MAIN_WINDOW, 0); | |
assert(w); | |
@@ -2827,7 +2827,7 @@ static void MouseLoop(MouseClick click, int mousewheel) | |
ViewPort *vp = IsPtInWindowViewport(w, x, y); | |
/* Don't allow any action in a viewport if either in menu or when having a modal progress window */ | |
- if (vp != NULL && (_game_mode == GM_MENU || HasModalProgress())) return; | |
+ if (vp != NULL && (Globals::IsGameMode(GM_MENU) || HasModalProgress())) return; | |
if (mousewheel != 0) { | |
/* Send mousewheel event to window */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment