-
-
Save Wolfolo/cff2dfcdda79d54a098e579a1327a7f0 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/projects/openttd_vs100.vcxproj b/projects/openttd_vs100.vcxproj | |
index 9c3b107..933ab13 100644 | |
--- a/projects/openttd_vs100.vcxproj | |
+++ b/projects/openttd_vs100.vcxproj | |
@@ -339,6 +339,7 @@ | |
<ClCompile Include="..\src\gfx.cpp" /> | |
<ClCompile Include="..\src\gfxinit.cpp" /> | |
<ClCompile Include="..\src\gfx_layout.cpp" /> | |
+ <ClCompile Include="..\src\globals.cpp" /> | |
<ClCompile Include="..\src\goal.cpp" /> | |
<ClCompile Include="..\src\ground_vehicle.cpp" /> | |
<ClCompile Include="..\src\heightmap.cpp" /> | |
@@ -477,6 +478,7 @@ | |
<ClInclude Include="..\src\gfx_layout.h" /> | |
<ClInclude Include="..\src\gfx_type.h" /> | |
<ClInclude Include="..\src\gfxinit.h" /> | |
+ <ClInclude Include="..\src\globals.h" /> | |
<ClInclude Include="..\src\goal_base.h" /> | |
<ClInclude Include="..\src\goal_type.h" /> | |
<ClInclude Include="..\src\graph_gui.h" /> | |
diff --git a/projects/openttd_vs100.vcxproj.filters b/projects/openttd_vs100.vcxproj.filters | |
index 06800ff..2bba823 100644 | |
--- a/projects/openttd_vs100.vcxproj.filters | |
+++ b/projects/openttd_vs100.vcxproj.filters | |
@@ -210,6 +210,9 @@ | |
<ClCompile Include="..\src\gfx_layout.cpp"> | |
<Filter>Source Files</Filter> | |
</ClCompile> | |
+ <ClCompile Include="..\src\globals.cpp"> | |
+ <Filter>Source Files</Filter> | |
+ </ClCompile> | |
<ClCompile Include="..\src\goal.cpp"> | |
<Filter>Source Files</Filter> | |
</ClCompile> | |
@@ -624,6 +627,9 @@ | |
<ClInclude Include="..\src\gfxinit.h"> | |
<Filter>Header Files</Filter> | |
</ClInclude> | |
+ <ClInclude Include="..\src\globals.h"> | |
+ <Filter>Header Files</Filter> | |
+ </ClInclude> | |
<ClInclude Include="..\src\goal_base.h"> | |
<Filter>Header Files</Filter> | |
</ClInclude> | |
diff --git a/projects/openttd_vs140.vcxproj b/projects/openttd_vs140.vcxproj | |
index eb84941..9348398 100644 | |
--- a/projects/openttd_vs140.vcxproj | |
+++ b/projects/openttd_vs140.vcxproj | |
@@ -356,6 +356,7 @@ | |
<ClCompile Include="..\src\gfx.cpp" /> | |
<ClCompile Include="..\src\gfxinit.cpp" /> | |
<ClCompile Include="..\src\gfx_layout.cpp" /> | |
+ <ClCompile Include="..\src\globals.cpp" /> | |
<ClCompile Include="..\src\goal.cpp" /> | |
<ClCompile Include="..\src\ground_vehicle.cpp" /> | |
<ClCompile Include="..\src\heightmap.cpp" /> | |
@@ -494,6 +495,7 @@ | |
<ClInclude Include="..\src\gfx_layout.h" /> | |
<ClInclude Include="..\src\gfx_type.h" /> | |
<ClInclude Include="..\src\gfxinit.h" /> | |
+ <ClInclude Include="..\src\globals.h" /> | |
<ClInclude Include="..\src\goal_base.h" /> | |
<ClInclude Include="..\src\goal_type.h" /> | |
<ClInclude Include="..\src\graph_gui.h" /> | |
diff --git a/projects/openttd_vs140.vcxproj.filters b/projects/openttd_vs140.vcxproj.filters | |
index 06800ff..2bba823 100644 | |
--- a/projects/openttd_vs140.vcxproj.filters | |
+++ b/projects/openttd_vs140.vcxproj.filters | |
@@ -210,6 +210,9 @@ | |
<ClCompile Include="..\src\gfx_layout.cpp"> | |
<Filter>Source Files</Filter> | |
</ClCompile> | |
+ <ClCompile Include="..\src\globals.cpp"> | |
+ <Filter>Source Files</Filter> | |
+ </ClCompile> | |
<ClCompile Include="..\src\goal.cpp"> | |
<Filter>Source Files</Filter> | |
</ClCompile> | |
@@ -624,6 +627,9 @@ | |
<ClInclude Include="..\src\gfxinit.h"> | |
<Filter>Header Files</Filter> | |
</ClInclude> | |
+ <ClInclude Include="..\src\globals.h"> | |
+ <Filter>Header Files</Filter> | |
+ </ClInclude> | |
<ClInclude Include="..\src\goal_base.h"> | |
<Filter>Header Files</Filter> | |
</ClInclude> | |
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj | |
index 70dcab2..d60a3ba 100644 | |
--- a/projects/openttd_vs80.vcproj | |
+++ b/projects/openttd_vs80.vcproj | |
@@ -579,6 +579,10 @@ | |
> | |
</File> | |
<File | |
+ RelativePath=".\..\src\globals.cpp" | |
+ > | |
+ </File> | |
+ <File | |
RelativePath=".\..\src\goal.cpp" | |
> | |
</File> | |
@@ -1135,6 +1139,10 @@ | |
> | |
</File> | |
<File | |
+ RelativePath=".\..\src\globals.h" | |
+ > | |
+ </File> | |
+ <File | |
RelativePath=".\..\src\goal_base.h" | |
> | |
</File> | |
diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj | |
index dd722d0..970c5d7 100644 | |
--- a/projects/openttd_vs90.vcproj | |
+++ b/projects/openttd_vs90.vcproj | |
@@ -576,6 +576,10 @@ | |
> | |
</File> | |
<File | |
+ RelativePath=".\..\src\globals.cpp" | |
+ > | |
+ </File> | |
+ <File | |
RelativePath=".\..\src\goal.cpp" | |
> | |
</File> | |
@@ -1132,6 +1136,10 @@ | |
> | |
</File> | |
<File | |
+ RelativePath=".\..\src\globals.h" | |
+ > | |
+ </File> | |
+ <File | |
RelativePath=".\..\src\goal_base.h" | |
> | |
</File> | |
diff --git a/source.list b/source.list | |
index df35cdd..1242841 100644 | |
--- a/source.list | |
+++ b/source.list | |
@@ -35,6 +35,7 @@ genworld.cpp | |
gfx.cpp | |
gfxinit.cpp | |
gfx_layout.cpp | |
+globals.cpp | |
goal.cpp | |
ground_vehicle.cpp | |
heightmap.cpp | |
@@ -204,6 +205,7 @@ gfx_func.h | |
gfx_layout.h | |
gfx_type.h | |
gfxinit.h | |
+globals.h | |
goal_base.h | |
goal_type.h | |
graph_gui.h | |
diff --git a/src/ai/ai_config.cpp b/src/ai/ai_config.cpp | |
index f920d31..0d205d7 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..9a25b73 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..17d31a2 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..4c5d8fb 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..e125283 100644 | |
--- a/src/bootstrap_gui.cpp | |
+++ b/src/bootstrap_gui.cpp | |
@@ -20,7 +20,7 @@ | |
#include "gfx_func.h" | |
#include "network/network.h" | |
#include "network/network_content_gui.h" | |
-#include "openttd.h" | |
+#include "globals.h" | |
#include "strings_func.h" | |
#include "video/video_driver.hpp" | |
#include "window_func.h" | |
@@ -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..87eb5c6 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..64dc50b 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..5005207 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..232262c 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..62b4b1a 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..2351542 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..7b7315f 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..b9b2c3f 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/elrail.cpp b/src/elrail.cpp | |
index 9fdfb57..c7ec2de 100644 | |
--- a/src/elrail.cpp | |
+++ b/src/elrail.cpp | |
@@ -262,7 +262,7 @@ void DrawRailCatenaryOnTunnel(const TileInfo *ti) | |
wire_base + sss->image_offset, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset, | |
BB_data[2] - sss->x_offset, BB_data[3] - sss->y_offset, BB_Z_SEPARATOR - sss->z_offset + 1, | |
GetTilePixelZ(ti->tile) + sss->z_offset, | |
- IsTransparencySet(TO_CATENARY), | |
+ _globals->IsTransparencySet(TO_CATENARY), | |
BB_data[0] - sss->x_offset, BB_data[1] - sss->y_offset, BB_Z_SEPARATOR - sss->z_offset | |
); | |
} | |
@@ -435,7 +435,7 @@ static void DrawRailCatenaryRailway(const TileInfo *ti) | |
} | |
AddSortableSpriteToDraw(pylon_base + pylon_sprites[temp], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, | |
- elevation, IsTransparencySet(TO_CATENARY), -1, -1); | |
+ elevation, _globals->IsTransparencySet(TO_CATENARY), -1, -1); | |
break; // We already have drawn a pylon, bail out | |
} | |
@@ -447,7 +447,7 @@ static void DrawRailCatenaryRailway(const TileInfo *ti) | |
if (IsTunnelTile(ti->tile)) return; | |
/* Don't draw a wire under a low bridge */ | |
- if (IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_BRIDGES)) { | |
+ if (IsBridgeAbove(ti->tile) && !_globals->IsTransparencySet(TO_BRIDGES)) { | |
int height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); | |
if (height <= GetTileMaxZ(ti->tile) + 1) return; | |
@@ -488,7 +488,7 @@ static void DrawRailCatenaryRailway(const TileInfo *ti) | |
*/ | |
AddSortableSpriteToDraw(wire_base + sss->image_offset, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset, | |
sss->x_size, sss->y_size, sss->z_size, GetSlopePixelZ(ti->x + sss->x_offset, ti->y + sss->y_offset) + sss->z_offset, | |
- IsTransparencySet(TO_CATENARY)); | |
+ _globals->IsTransparencySet(TO_CATENARY)); | |
} | |
} | |
@@ -529,7 +529,7 @@ void DrawRailCatenaryOnBridge(const TileInfo *ti) | |
AddSortableSpriteToDraw(wire_base + sss->image_offset, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset, | |
sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset, | |
- IsTransparencySet(TO_CATENARY) | |
+ _globals->IsTransparencySet(TO_CATENARY) | |
); | |
SpriteID pylon_base = GetPylonBase(end, TCX_ON_BRIDGE); | |
@@ -542,7 +542,7 @@ void DrawRailCatenaryOnBridge(const TileInfo *ti) | |
if (HasBit(tlg, (axis == AXIS_X ? 0 : 1))) PPPpos = ReverseDir(PPPpos); | |
uint x = ti->x + x_pcp_offsets[PCPpos] + x_ppp_offsets[PPPpos]; | |
uint y = ti->y + y_pcp_offsets[PCPpos] + y_ppp_offsets[PPPpos]; | |
- AddSortableSpriteToDraw(pylon_base + pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_CATENARY), -1, -1); | |
+ AddSortableSpriteToDraw(pylon_base + pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, _globals->IsTransparencySet(TO_CATENARY), -1, -1); | |
} | |
/* need a pylon on the southern end of the bridge */ | |
@@ -552,7 +552,7 @@ void DrawRailCatenaryOnBridge(const TileInfo *ti) | |
if (HasBit(tlg, (axis == AXIS_X ? 0 : 1))) PPPpos = ReverseDir(PPPpos); | |
uint x = ti->x + x_pcp_offsets[PCPpos] + x_ppp_offsets[PPPpos]; | |
uint y = ti->y + y_pcp_offsets[PCPpos] + y_ppp_offsets[PPPpos]; | |
- AddSortableSpriteToDraw(pylon_base + pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_CATENARY), -1, -1); | |
+ AddSortableSpriteToDraw(pylon_base + pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, _globals->IsTransparencySet(TO_CATENARY), -1, -1); | |
} | |
} | |
@@ -575,7 +575,7 @@ void DrawRailCatenary(const TileInfo *ti) | |
wire_base + sss->image_offset, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset, | |
sss->x_size, sss->y_size, sss->z_size, | |
GetTileMaxPixelZ(ti->tile) + sss->z_offset, | |
- IsTransparencySet(TO_CATENARY) | |
+ _globals->IsTransparencySet(TO_CATENARY) | |
); | |
return; | |
} | |
diff --git a/src/elrail_func.h b/src/elrail_func.h | |
index 5cdae20..62c2d65 100644 | |
--- a/src/elrail_func.h | |
+++ b/src/elrail_func.h | |
@@ -31,7 +31,7 @@ static inline bool HasRailCatenary(RailType rt) | |
*/ | |
static inline bool HasRailCatenaryDrawn(RailType rt) | |
{ | |
- return HasRailCatenary(rt) && !IsInvisibilitySet(TO_CATENARY) && !_settings_game.vehicle.disable_elrails; | |
+ return HasRailCatenary(rt) && !_globals->IsInvisibilitySet(TO_CATENARY) && !_settings_game.vehicle.disable_elrails; | |
} | |
void DrawRailCatenary(const TileInfo *ti); | |
diff --git a/src/fios.cpp b/src/fios.cpp | |
index 0d30e09..50eb0e6 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..2fd31b6 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..3549095 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..ad8b80c 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..77d12ed 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..2eeb5cf 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/globals.cpp b/src/globals.cpp | |
new file mode 100644 | |
index 0000000..562ae7a | |
--- /dev/null | |
+++ b/src/globals.cpp | |
@@ -0,0 +1,46 @@ | |
+/* $Id$ */ | |
+ | |
+/* | |
+ * This file is part of OpenTTD. | |
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. | |
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. | |
+ */ | |
+ | |
+/** @file globals.cpp Functions related to the old global variables of OpenTTD. */ | |
+ | |
+#include "stdafx.h" | |
+#include "globals.h" | |
+ | |
+/* static */ Globals *Globals::instance; | |
+ | |
+/* Public accessors to Globals */ | |
+bool Globals::IsGameMode(GameMode mode) | |
+{ | |
+ return Globals::game_mode == mode; | |
+} | |
+ | |
+void Globals::SetGameMode(GameMode mode) | |
+{ | |
+ Globals::game_mode = mode; | |
+} | |
+ | |
+void Globals::BackupGameMode() | |
+{ | |
+ Globals::backup_game_mode = Globals::game_mode; | |
+} | |
+ | |
+void Globals::RestoreGameMode() | |
+{ | |
+ Globals::game_mode = Globals::backup_game_mode; | |
+} | |
+ | |
+GameMode Globals::GetGameMode() | |
+{ | |
+ return Globals::game_mode; | |
+} | |
+ | |
+GameMode Globals::GetOldGameMode() | |
+{ | |
+ return Globals::backup_game_mode; | |
+} | |
diff --git a/src/globals.h b/src/globals.h | |
new file mode 100644 | |
index 0000000..2d15e77 | |
--- /dev/null | |
+++ b/src/globals.h | |
@@ -0,0 +1,133 @@ | |
+/* $Id$ */ | |
+ | |
+/* | |
+ * This file is part of OpenTTD. | |
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. | |
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. | |
+ */ | |
+ | |
+/** @file globals.h Some generic types. */ | |
+ | |
+#ifndef GLOBALS_H | |
+#define GLOBALS_H | |
+ | |
+#include "core/enum_type.hpp" | |
+#include "transparency.h" | |
+ | |
+/** Mode which defines the state of the game. */ | |
+enum GameMode { | |
+ GM_MENU, | |
+ GM_NORMAL, | |
+ GM_EDITOR, | |
+ GM_BOOTSTRAP | |
+}; | |
+ | |
+/** Mode which defines what mode we're switching to. */ | |
+enum SwitchMode { | |
+ SM_NONE, | |
+ SM_NEWGAME, ///< New Game --> 'Random game'. | |
+ SM_RESTARTGAME, ///< Restart --> 'Random game' with current settings. | |
+ SM_EDITOR, ///< Switch to scenario editor. | |
+ SM_LOAD_GAME, ///< Load game, Play Scenario. | |
+ SM_MENU, ///< Switch to game intro menu. | |
+ SM_SAVE_GAME, ///< Save game. | |
+ SM_SAVE_HEIGHTMAP, ///< Save heightmap. | |
+ SM_GENRANDLAND, ///< Generate random land within scenario editor. | |
+ SM_LOAD_SCENARIO, ///< Load scenario from scenario editor. | |
+ SM_START_HEIGHTMAP, ///< Load a heightmap and start a new game from it. | |
+ SM_LOAD_HEIGHTMAP, ///< Load heightmap from scenario editor. | |
+}; | |
+ | |
+/** Display Options */ | |
+enum DisplayOptions { | |
+ DO_SHOW_TOWN_NAMES = 0, ///< Display town names. | |
+ DO_SHOW_STATION_NAMES = 1, ///< Display station names. | |
+ DO_SHOW_SIGNS = 2, ///< Display signs. | |
+ DO_FULL_ANIMATION = 3, ///< Perform palette animation. | |
+ DO_FULL_DETAIL = 5, ///< Also draw details of track and roads. | |
+ DO_SHOW_WAYPOINT_NAMES = 6, ///< Display waypoint names. | |
+ 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 SwitchMode _switch_mode; | |
+extern bool _exit_game; | |
+ | |
+/** Modes of pausing we've got */ | |
+enum PauseMode { | |
+ PM_UNPAUSED = 0, ///< A normal unpaused game | |
+ PM_PAUSED_NORMAL = 1 << 0, ///< A game normally paused | |
+ PM_PAUSED_SAVELOAD = 1 << 1, ///< A game paused for saving/loading | |
+ PM_PAUSED_JOIN = 1 << 2, ///< A game paused for 'pause_on_join' | |
+ PM_PAUSED_ERROR = 1 << 3, ///< A game paused because a (critical) error | |
+ PM_PAUSED_ACTIVE_CLIENTS = 1 << 4, ///< A game paused for 'min_active_clients' | |
+ PM_PAUSED_GAME_SCRIPT = 1 << 5, ///< A game paused by a game script | |
+ | |
+ /** Pause mode bits when paused for network reasons. */ | |
+ PMB_PAUSED_NETWORK = PM_PAUSED_ACTIVE_CLIENTS | PM_PAUSED_JOIN, | |
+}; | |
+DECLARE_ENUM_AS_BIT_SET(PauseMode) | |
+typedef SimpleTinyEnumT<PauseMode, byte> PauseModeByte; | |
+ | |
+/** The current pause mode */ | |
+extern PauseModeByte _pause_mode; | |
+ | |
+void SwitchToMode(SwitchMode new_mode); | |
+ | |
+class Globals { | |
+public: | |
+ static Globals *GetInstance() | |
+ { | |
+ if (!instance) { | |
+ instance = new Globals(); | |
+ } | |
+ | |
+ return instance; | |
+ } | |
+ | |
+ /* Public accessors */ | |
+ virtual bool IsGameMode(GameMode mode); | |
+ virtual void SetGameMode(GameMode mode); | |
+ virtual void BackupGameMode(); | |
+ virtual void RestoreGameMode(); | |
+ virtual GameMode GetGameMode(); | |
+ virtual GameMode GetOldGameMode(); | |
+ | |
+ /* Transparency */ | |
+ virtual bool IsTransparencySet(TransparencyOption to); | |
+ virtual bool IsTransparencySetNoMenuCheck(TransparencyOption to); ///< To be removed or renamed | |
+ virtual bool IsTransparencyLockSet(TransparencyOption to); | |
+ virtual bool IsTransparencyLockSetNoMenuCheck(TransparencyOption to); ///< To be removed or renamed | |
+ virtual bool IsInvisibilitySet(TransparencyOption to); | |
+ virtual bool IsInvisibilitySetNoMenuCheck(TransparencyOption to); ///< To be removed or renamed | |
+ virtual void ToggleTransparency(TransparencyOption to); | |
+ virtual void ToggleInvisibility(TransparencyOption to); | |
+ virtual void ToggleInvisibilityWithTransparency(TransparencyOption to); | |
+ virtual void ToggleTransparencyLock(TransparencyOption to); | |
+ virtual void ResetRestoreAllTransparency(); | |
+ virtual TransparencyOptionBits GetTransparency(); | |
+ virtual TransparencyOptionBits GetTransparencyLock(); | |
+ virtual TransparencyOptionBits GetInvisibility(); | |
+ virtual void BackupTransparency(); | |
+ virtual void RestoreTransparency(); | |
+ virtual void MakeTextTransparent(); | |
+ | |
+private: | |
+ static Globals *instance; | |
+ Globals() {} | |
+ Globals(Globals const&); | |
+ Globals &operator=(const Globals&); | |
+ | |
+ GameMode game_mode; | |
+ GameMode backup_game_mode; | |
+ | |
+ TransparencyOptionBits backup_transparency_opt; | |
+public: /* Needed for settings: don't use them in code, please */ | |
+ TransparencyOptionBits transparency_opt; ///< The bits that should be transparent. | |
+ TransparencyOptionBits transparency_lock; ///< Prevent these bits from flipping with X. | |
+ TransparencyOptionBits invisibility_opt; ///< The bits that should be invisible. | |
+}; | |
+ | |
+extern Globals *_globals; | |
+ | |
+#endif /* GLOBALS_H */ | |
diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp | |
index c67aaa1..9ef15b7 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..92f9c5b 100644 | |
--- a/src/industry_cmd.cpp | |
+++ b/src/industry_cmd.cpp | |
@@ -344,7 +344,7 @@ static void DrawTile_Industry(TileInfo *ti) | |
} | |
/* If industries are transparent and invisible, do not draw the upper part */ | |
- if (IsInvisibilitySet(TO_INDUSTRIES)) return; | |
+ if (_globals->IsInvisibilitySet(TO_INDUSTRIES)) return; | |
/* Add industry on top of the ground? */ | |
image = dits->building.sprite; | |
@@ -356,9 +356,9 @@ static void DrawTile_Industry(TileInfo *ti) | |
dits->height, | |
dits->dz, | |
ti->z, | |
- IsTransparencySet(TO_INDUSTRIES)); | |
+ _globals->IsTransparencySet(TO_INDUSTRIES)); | |
- if (IsTransparencySet(TO_INDUSTRIES)) return; | |
+ if (_globals->IsTransparencySet(TO_INDUSTRIES)) return; | |
} | |
{ | |
@@ -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..9320ade 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..a359209 100644 | |
--- a/src/intro_gui.cpp | |
+++ b/src/intro_gui.cpp | |
@@ -27,6 +27,7 @@ | |
#include "language.h" | |
#include "rev.h" | |
#include "highscore.h" | |
+#include "openttd.h" | |
#include "widgets/intro_widget.h" | |
@@ -331,7 +332,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..72eeff6 100644 | |
--- a/src/main_gui.cpp | |
+++ b/src/main_gui.cpp | |
@@ -32,6 +32,7 @@ | |
#include "linkgraph/linkgraph_gui.h" | |
#include "tilehighlight_func.h" | |
#include "hotkeys.h" | |
+#include "openttd.h" | |
#include "saveload/saveload.h" | |
@@ -191,7 +192,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 +272,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 +305,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 +327,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: | |
@@ -368,7 +369,7 @@ struct MainWindow : Window | |
case GHK_TOGGLE_TRANSPARENCY + 7: | |
case GHK_TOGGLE_TRANSPARENCY + 8: | |
/* Transparency toggle hot keys */ | |
- ToggleTransparency((TransparencyOption)(hotkey - GHK_TOGGLE_TRANSPARENCY)); | |
+ _globals->ToggleTransparency((TransparencyOption)(hotkey - GHK_TOGGLE_TRANSPARENCY)); | |
MarkWholeScreenDirty(); | |
break; | |
@@ -381,7 +382,7 @@ struct MainWindow : Window | |
case GHK_TOGGLE_INVISIBILITY + 6: | |
case GHK_TOGGLE_INVISIBILITY + 7: | |
/* Invisibility toggle hot keys */ | |
- ToggleInvisibilityWithTransparency((TransparencyOption)(hotkey - GHK_TOGGLE_INVISIBILITY)); | |
+ _globals->ToggleInvisibilityWithTransparency((TransparencyOption)(hotkey - GHK_TOGGLE_INVISIBILITY)); | |
MarkWholeScreenDirty(); | |
break; | |
@@ -390,7 +391,7 @@ struct MainWindow : Window | |
break; | |
case GHK_TRANSPARANCY: | |
- ResetRestoreAllTransparency(); | |
+ _globals->ResetRestoreAllTransparency(); | |
break; | |
#ifdef ENABLE_NETWORK | |
@@ -558,7 +559,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 +580,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..0068c38 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/network/network_func.h b/src/network/network_func.h | |
index 4f1525b..95b3ea4 100644 | |
--- a/src/network/network_func.h | |
+++ b/src/network/network_func.h | |
@@ -23,7 +23,7 @@ | |
#include "network_type.h" | |
#include "../console_type.h" | |
#include "../gfx_type.h" | |
-#include "../openttd.h" | |
+#include "../globals.h" | |
#include "../company_type.h" | |
#ifdef ENABLE_NETWORK | |
diff --git a/src/newgrf.cpp b/src/newgrf.cpp | |
index 24b0238..5ef5503 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..716c6f2 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..3f6cf75 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..1ff4c99 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..4b8892e 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..05d8c06 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); | |
@@ -392,7 +392,7 @@ static void DrawTile_Object(TileInfo *ti) | |
DrawGroundSprite(dts->ground.sprite, palette); | |
} | |
- if (!IsInvisibilitySet(TO_STRUCTURES)) { | |
+ if (!_globals->IsInvisibilitySet(TO_STRUCTURES)) { | |
const DrawTileSeqStruct *dtss; | |
foreach_draw_tile_seq(dtss, dts->seq) { | |
AddSortableSpriteToDraw( | |
@@ -400,7 +400,7 @@ static void DrawTile_Object(TileInfo *ti) | |
ti->x + dtss->delta_x, ti->y + dtss->delta_y, | |
dtss->size_x, dtss->size_y, | |
dtss->size_z, ti->z + dtss->delta_z, | |
- IsTransparencySet(TO_STRUCTURES) | |
+ _globals->IsTransparencySet(TO_STRUCTURES) | |
); | |
} | |
} | |
@@ -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..56f2956 100644 | |
--- a/src/openttd.cpp | |
+++ b/src/openttd.cpp | |
@@ -63,6 +63,7 @@ | |
#include "subsidy_func.h" | |
#include "gfx_layout.h" | |
#include "viewport_sprite_sorter.h" | |
+#include "openttd.h" | |
#include "linkgraph/linkgraphschedule.h" | |
@@ -81,6 +82,7 @@ bool HandleBootstrap(); | |
extern Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY); | |
extern void ShowOSErrorBox(const char *buf, bool system); | |
extern char *_config_file; | |
+Globals *_globals; | |
/** | |
* Error handling for fatal user errors. | |
@@ -305,7 +307,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 +321,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 +554,8 @@ int openttd_main(int argc, char *argv[]) | |
_dedicated_forks = false; | |
#endif /* ENABLE_NETWORK */ | |
- _game_mode = GM_MENU; | |
+ _globals = _globals->GetInstance(); | |
+ _globals->SetGameMode(GM_MENU); | |
_switch_mode = SM_MENU; | |
_config_file = NULL; | |
@@ -913,7 +916,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 +967,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 +982,7 @@ static void MakeNewEditorWorldDone() | |
static void MakeNewEditorWorld() | |
{ | |
- _game_mode = GM_EDITOR; | |
+ _globals->SetGameMode(GM_EDITOR); | |
ResetGRFConfig(true); | |
@@ -1001,9 +1004,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 +1030,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 +1038,7 @@ bool SafeLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, | |
return false; | |
default: | |
- _game_mode = ogm; | |
+ _globals->RestoreGameMode(); | |
return false; | |
} | |
} | |
@@ -1353,7 +1356,7 @@ void StateGameLoop() | |
Layouter::ReduceLineCache(); | |
- if (_game_mode == GM_EDITOR) { | |
+ if (_globals->IsGameMode(GM_EDITOR)) { | |
BasePersistentStorageArray::SwitchMode(PSM_ENTER_GAMELOOP); | |
RunTileLoop(); | |
CallVehicleTicks(); | |
@@ -1432,7 +1435,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,7 +1495,7 @@ 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(); | |
diff --git a/src/openttd.h b/src/openttd.h | |
index 5e360d6..68972b5 100644 | |
--- a/src/openttd.h | |
+++ b/src/openttd.h | |
@@ -7,77 +7,15 @@ | |
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. | |
*/ | |
-/** @file openttd.h Some generic types. */ | |
+/** @file openttd.h Main entry point and some functions. */ | |
#ifndef OPENTTD_H | |
#define OPENTTD_H | |
-#include "core/enum_type.hpp" | |
- | |
-/** Mode which defines the state of the game. */ | |
-enum GameMode { | |
- GM_MENU, | |
- GM_NORMAL, | |
- GM_EDITOR, | |
- GM_BOOTSTRAP | |
-}; | |
- | |
-/** Mode which defines what mode we're switching to. */ | |
-enum SwitchMode { | |
- SM_NONE, | |
- SM_NEWGAME, ///< New Game --> 'Random game'. | |
- SM_RESTARTGAME, ///< Restart --> 'Random game' with current settings. | |
- SM_EDITOR, ///< Switch to scenario editor. | |
- SM_LOAD_GAME, ///< Load game, Play Scenario. | |
- SM_MENU, ///< Switch to game intro menu. | |
- SM_SAVE_GAME, ///< Save game. | |
- SM_SAVE_HEIGHTMAP, ///< Save heightmap. | |
- SM_GENRANDLAND, ///< Generate random land within scenario editor. | |
- SM_LOAD_SCENARIO, ///< Load scenario from scenario editor. | |
- SM_START_HEIGHTMAP, ///< Load a heightmap and start a new game from it. | |
- SM_LOAD_HEIGHTMAP, ///< Load heightmap from scenario editor. | |
-}; | |
- | |
-/** Display Options */ | |
-enum DisplayOptions { | |
- DO_SHOW_TOWN_NAMES = 0, ///< Display town names. | |
- DO_SHOW_STATION_NAMES = 1, ///< Display station names. | |
- DO_SHOW_SIGNS = 2, ///< Display signs. | |
- DO_FULL_ANIMATION = 3, ///< Perform palette animation. | |
- DO_FULL_DETAIL = 5, ///< Also draw details of track and roads. | |
- DO_SHOW_WAYPOINT_NAMES = 6, ///< Display waypoint names. | |
- 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; | |
- | |
-/** Modes of pausing we've got */ | |
-enum PauseMode { | |
- PM_UNPAUSED = 0, ///< A normal unpaused game | |
- PM_PAUSED_NORMAL = 1 << 0, ///< A game normally paused | |
- PM_PAUSED_SAVELOAD = 1 << 1, ///< A game paused for saving/loading | |
- PM_PAUSED_JOIN = 1 << 2, ///< A game paused for 'pause_on_join' | |
- PM_PAUSED_ERROR = 1 << 3, ///< A game paused because a (critical) error | |
- PM_PAUSED_ACTIVE_CLIENTS = 1 << 4, ///< A game paused for 'min_active_clients' | |
- PM_PAUSED_GAME_SCRIPT = 1 << 5, ///< A game paused by a game script | |
- | |
- /** Pause mode bits when paused for network reasons. */ | |
- PMB_PAUSED_NETWORK = PM_PAUSED_ACTIVE_CLIENTS | PM_PAUSED_JOIN, | |
-}; | |
-DECLARE_ENUM_AS_BIT_SET(PauseMode) | |
-typedef SimpleTinyEnumT<PauseMode, byte> PauseModeByte; | |
- | |
-/** The current pause mode */ | |
-extern PauseModeByte _pause_mode; | |
- | |
void AskExitGame(); | |
void AskExitToGameMenu(); | |
int openttd_main(int argc, char *argv[]); | |
void HandleExitGameRequest(); | |
-void SwitchToMode(SwitchMode new_mode); | |
- | |
-#endif /* OPENTTD_H */ | |
+#endif /* OPENTTD_H */ | |
\ No newline at end of file | |
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp | |
index 9f284fc..6057a71 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); | |
} | |
@@ -2413,7 +2413,7 @@ static void DrawTile_Track(TileInfo *ti) | |
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED); | |
- if (IsInvisibilitySet(TO_BUILDINGS)) { | |
+ if (_globals->IsInvisibilitySet(TO_BUILDINGS)) { | |
/* Draw rail instead of depot */ | |
dts = &_depot_invisible_gfx_table[GetRailDepotDirection(ti->tile)]; | |
} else { | |
@@ -2445,13 +2445,13 @@ static void DrawTile_Track(TileInfo *ti) | |
switch (GetRailDepotDirection(ti->tile)) { | |
case DIAGDIR_NE: | |
- if (!IsInvisibilitySet(TO_BUILDINGS)) break; | |
+ if (!_globals->IsInvisibilitySet(TO_BUILDINGS)) break; | |
FALLTHROUGH; | |
case DIAGDIR_SW: | |
DrawGroundSprite(ground + RTO_X, PAL_NONE); | |
break; | |
case DIAGDIR_NW: | |
- if (!IsInvisibilitySet(TO_BUILDINGS)) break; | |
+ if (!_globals->IsInvisibilitySet(TO_BUILDINGS)) break; | |
FALLTHROUGH; | |
case DIAGDIR_SE: | |
DrawGroundSprite(ground + RTO_Y, PAL_NONE); | |
@@ -2465,13 +2465,13 @@ static void DrawTile_Track(TileInfo *ti) | |
switch (GetRailDepotDirection(ti->tile)) { | |
case DIAGDIR_NE: | |
- if (!IsInvisibilitySet(TO_BUILDINGS)) break; | |
+ if (!_globals->IsInvisibilitySet(TO_BUILDINGS)) break; | |
FALLTHROUGH; | |
case DIAGDIR_SW: | |
DrawGroundSprite(overlay + RTO_X, PALETTE_CRASH); | |
break; | |
case DIAGDIR_NW: | |
- if (!IsInvisibilitySet(TO_BUILDINGS)) break; | |
+ if (!_globals->IsInvisibilitySet(TO_BUILDINGS)) break; | |
FALLTHROUGH; | |
case DIAGDIR_SE: | |
DrawGroundSprite(overlay + RTO_Y, PALETTE_CRASH); | |
@@ -2482,16 +2482,16 @@ 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; | |
+ if (!_globals->IsInvisibilitySet(TO_BUILDINGS)) break; | |
FALLTHROUGH; | |
case DIAGDIR_SW: | |
DrawGroundSprite(rti->base_sprites.single_x, PALETTE_CRASH); | |
break; | |
case DIAGDIR_NW: | |
- if (!IsInvisibilitySet(TO_BUILDINGS)) break; | |
+ if (!_globals->IsInvisibilitySet(TO_BUILDINGS)) break; | |
FALLTHROUGH; | |
case DIAGDIR_SE: | |
DrawGroundSprite(rti->base_sprites.single_y, PALETTE_CRASH); | |
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp | |
index 73fe29d..8dd9fa2 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..f992bbe 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..23a6b24 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 | |
@@ -1194,10 +1194,10 @@ static bool DrawRoadAsSnowDesert(TileIndex tile, Roadside roadside) | |
void DrawRoadCatenary(const TileInfo *ti, RoadBits tram) | |
{ | |
/* Do not draw catenary if it is invisible */ | |
- if (IsInvisibilitySet(TO_CATENARY)) return; | |
+ if (_globals->IsInvisibilitySet(TO_CATENARY)) return; | |
/* Don't draw the catenary under a low bridge */ | |
- if (IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_CATENARY)) { | |
+ if (IsBridgeAbove(ti->tile) && !_globals->IsTransparencySet(TO_CATENARY)) { | |
int height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); | |
if (height <= GetTileMaxZ(ti->tile) + 1) return; | |
@@ -1214,8 +1214,8 @@ void DrawRoadCatenary(const TileInfo *ti, RoadBits tram) | |
front = SPR_TRAMWAY_BASE + _road_frontwire_sprites_1[tram]; | |
} | |
- AddSortableSpriteToDraw(back, PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_CATENARY)); | |
- AddSortableSpriteToDraw(front, PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_CATENARY)); | |
+ AddSortableSpriteToDraw(back, PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, _globals->IsTransparencySet(TO_CATENARY)); | |
+ AddSortableSpriteToDraw(front, PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, _globals->IsTransparencySet(TO_CATENARY)); | |
} | |
/** | |
@@ -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..91bf139 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..5a725a0 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..d9fa851 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..f0d5b06 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..55d019d 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..4dfabea 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..0aed432 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..b8b0df5 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..2f2565e 100644 | |
--- a/src/settings_type.h | |
+++ b/src/settings_type.h | |
@@ -20,7 +20,7 @@ | |
#include "cargotype.h" | |
#include "linkgraph/linkgraph_type.h" | |
#include "zoom_type.h" | |
-#include "openttd.h" | |
+#include "globals.h" | |
/** Settings profiles and highscore tables. */ | |
@@ -578,13 +578,16 @@ extern GameSettings _settings_newgame; | |
/** Old vehicle settings, which were game settings before, and are company settings now. (Needed for savegame conversion) */ | |
extern VehicleDefaultSettings _old_vds; | |
+/* The current globals states */ | |
+extern Globals *_globals; | |
+ | |
/** | |
* Get the settings-object applicable for the current situation: the newgame settings | |
* when we're in the main menu and otherwise the settings of the current game. | |
*/ | |
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..54b0a4b 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..d440557 100644 | |
--- a/src/signs_gui.cpp | |
+++ b/src/signs_gui.cpp | |
@@ -26,7 +26,7 @@ | |
#include "string_func.h" | |
#include "core/geometry_func.hpp" | |
#include "hotkeys.h" | |
-#include "transparency.h" | |
+#include "globals.h" | |
#include "widgets/sign_widget.h" | |
@@ -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/sprite.cpp b/src/sprite.cpp | |
index 2221071..11f3cad 100644 | |
--- a/src/sprite.cpp | |
+++ b/src/sprite.cpp | |
@@ -45,7 +45,7 @@ void DrawCommonTileSeq(const TileInfo *ti, const DrawTileSprites *dts, Transpare | |
/* TTD sprite 0 means no sprite */ | |
if ((GB(image, 0, SPRITE_WIDTH) == 0 && !HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) || | |
- (IsInvisibilitySet(to) && !HasBit(image, SPRITE_MODIFIER_OPAQUE))) { | |
+ (_globals->IsInvisibilitySet(to) && !HasBit(image, SPRITE_MODIFIER_OPAQUE))) { | |
skip_childs = dtss->IsParentSprite(); | |
continue; | |
} | |
@@ -62,12 +62,12 @@ void DrawCommonTileSeq(const TileInfo *ti, const DrawTileSprites *dts, Transpare | |
ti->x + dtss->delta_x, ti->y + dtss->delta_y, | |
dtss->size_x, dtss->size_y, | |
dtss->size_z, ti->z + dtss->delta_z, | |
- !HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(to) | |
+ !HasBit(image, SPRITE_MODIFIER_OPAQUE) && _globals->IsTransparencySet(to) | |
); | |
} else { | |
int offs_x = child_offset_is_unsigned ? (uint8)dtss->delta_x : dtss->delta_x; | |
int offs_y = child_offset_is_unsigned ? (uint8)dtss->delta_y : dtss->delta_y; | |
- bool transparent = !HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(to); | |
+ bool transparent = !HasBit(image, SPRITE_MODIFIER_OPAQUE) && _globals->IsTransparencySet(to); | |
if (parent_sprite_encountered) { | |
AddChildSpriteScreen(image, pal, offs_x, offs_y, transparent); | |
} else { | |
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp | |
index 5fd865a..c75e3a9 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/table/misc_settings.ini b/src/table/misc_settings.ini | |
index 52ca2d1..c824c41 100644 | |
--- a/src/table/misc_settings.ini | |
+++ b/src/table/misc_settings.ini | |
@@ -252,7 +252,7 @@ cat = SC_BASIC | |
[SDTG_VAR] | |
name = ""transparency_options"" | |
type = SLE_UINT | |
-var = _transparency_opt | |
+var = _globals->GetInstance()->transparency_opt | |
def = 0 | |
min = 0 | |
max = 0x1FF | |
@@ -261,7 +261,7 @@ cat = SC_BASIC | |
[SDTG_VAR] | |
name = ""transparency_locks"" | |
type = SLE_UINT | |
-var = _transparency_lock | |
+var = _globals->GetInstance()->transparency_lock | |
def = 0 | |
min = 0 | |
max = 0x1FF | |
@@ -270,7 +270,7 @@ cat = SC_BASIC | |
[SDTG_VAR] | |
name = ""invisibility_options"" | |
type = SLE_UINT | |
-var = _invisibility_opt | |
+var = _globals->GetInstance()->invisibility_opt | |
def = 0 | |
min = 0 | |
max = 0xFF | |
diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp | |
index aad9822..a2eb11f 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..94dd117 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..9e8c9b8 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++) { | |
@@ -113,7 +113,7 @@ void DrawTextEffects(DrawPixelInfo *dpi) | |
const TextEffect *end = _text_effects.End(); | |
for (TextEffect *te = _text_effects.Begin(); te != end; te++) { | |
if (te->string_id == INVALID_STRING_ID) continue; | |
- if (te->mode == TE_RISING || (_settings_client.gui.loading_indicators && !IsTransparencySet(TO_LOADING))) { | |
+ if (te->mode == TE_RISING || (_settings_client.gui.loading_indicators && !_globals->IsTransparencySet(TO_LOADING))) { | |
ViewportAddString(dpi, ZOOM_LVL_OUT_8X, te, te->string_id, te->string_id - 1, STR_NULL, te->params_1, te->params_2); | |
} | |
} | |
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp | |
index f253be8..51d4735 100644 | |
--- a/src/toolbar_gui.cpp | |
+++ b/src/toolbar_gui.cpp | |
@@ -47,6 +47,7 @@ | |
#include "goal_base.h" | |
#include "story_base.h" | |
#include "toolbar_gui.h" | |
+#include "openttd.h" | |
#include "widgets/toolbar_widget.h" | |
@@ -329,8 +330,8 @@ static CallBackFunction ToolbarOptionsClick(Window *w) | |
*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_SHOW_COMPETITOR_SIGNS, OME_SHOW_COMPETITOR_SIGNS, false, HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS)); | |
*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_ANIMATION, OME_FULL_ANIMATION, false, HasBit(_display_opt, DO_FULL_ANIMATION)); | |
*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_DETAIL, OME_FULL_DETAILS, false, HasBit(_display_opt, DO_FULL_DETAIL)); | |
- *list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS, false, IsTransparencySet(TO_HOUSES)); | |
- *list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS, false, IsTransparencySet(TO_SIGNS)); | |
+ *list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS, false, _globals->IsTransparencySet(TO_HOUSES)); | |
+ *list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS, false, _globals->IsTransparencySet(TO_SIGNS)); | |
ShowDropDownList(w, list, 0, WID_TN_SETTINGS, 140, true, true); | |
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); | |
@@ -362,8 +363,8 @@ static CallBackFunction MenuClickSettings(int index) | |
break; | |
case OME_FULL_ANIMATION: ToggleBit(_display_opt, DO_FULL_ANIMATION); CheckBlitter(); break; | |
case OME_FULL_DETAILS: ToggleBit(_display_opt, DO_FULL_DETAIL); break; | |
- case OME_TRANSPARENTBUILDINGS: ToggleTransparency(TO_HOUSES); break; | |
- case OME_SHOW_STATIONSIGNS: ToggleTransparency(TO_SIGNS); break; | |
+ case OME_TRANSPARENTBUILDINGS: _globals->ToggleTransparency(TO_HOUSES); break; | |
+ case OME_SHOW_STATIONSIGNS: _globals->ToggleTransparency(TO_SIGNS); break; | |
} | |
MarkWholeScreenDirty(); | |
return CBF_NONE; | |
@@ -425,7 +426,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 +848,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 +859,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 +2014,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 +2370,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 +2572,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..f7c610f 100644 | |
--- a/src/town_cmd.cpp | |
+++ b/src/town_cmd.cpp | |
@@ -233,7 +233,7 @@ static void DrawTile_Town(TileInfo *ti) | |
DrawGroundSprite(dcts->ground.sprite, dcts->ground.pal); | |
/* If houses are invisible, do not draw the upper part */ | |
- if (IsInvisibilitySet(TO_HOUSES)) return; | |
+ if (_globals->IsInvisibilitySet(TO_HOUSES)) return; | |
/* Add a house on top of the ground? */ | |
SpriteID image = dcts->building.sprite; | |
@@ -245,10 +245,10 @@ static void DrawTile_Town(TileInfo *ti) | |
dcts->height, | |
dcts->dz, | |
ti->z, | |
- IsTransparencySet(TO_HOUSES) | |
+ _globals->IsTransparencySet(TO_HOUSES) | |
); | |
- if (IsTransparencySet(TO_HOUSES)) return; | |
+ if (_globals->IsTransparencySet(TO_HOUSES)) return; | |
} | |
{ | |
@@ -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..83e235f 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..c9329e4 100644 | |
--- a/src/transparency.h | |
+++ b/src/transparency.h | |
@@ -13,7 +13,6 @@ | |
#define TRANSPARENCY_H | |
#include "gfx_func.h" | |
-#include "openttd.h" | |
#include "core/bitmath_func.hpp" | |
/** | |
@@ -36,94 +35,6 @@ enum TransparencyOption { | |
}; | |
typedef uint TransparencyOptionBits; ///< transparency option bits | |
-extern TransparencyOptionBits _transparency_opt; | |
-extern TransparencyOptionBits _transparency_lock; | |
-extern TransparencyOptionBits _invisibility_opt; | |
extern byte _display_opt; | |
-/** | |
- * Check if the transparency option bit is set | |
- * and if we aren't in the game menu (there's never transparency) | |
- * | |
- * @param to the structure which transparency option is ask for | |
- */ | |
-static inline bool IsTransparencySet(TransparencyOption to) | |
-{ | |
- return (HasBit(_transparency_opt, to) && _game_mode != GM_MENU); | |
-} | |
- | |
-/** | |
- * Check if the invisibility option bit is set | |
- * and if we aren't in the game menu (there's never transparency) | |
- * | |
- * @param to the structure which invisibility option is ask for | |
- */ | |
-static inline bool IsInvisibilitySet(TransparencyOption to) | |
-{ | |
- return (HasBit(_transparency_opt & _invisibility_opt, to) && _game_mode != GM_MENU); | |
-} | |
- | |
-/** | |
- * Toggle the transparency option bit | |
- * | |
- * @param to the transparency option to be toggled | |
- */ | |
-static inline void ToggleTransparency(TransparencyOption to) | |
-{ | |
- ToggleBit(_transparency_opt, to); | |
-} | |
- | |
-/** | |
- * Toggle the invisibility option bit | |
- * | |
- * @param to the structure which invisibility option is toggle | |
- */ | |
-static inline void ToggleInvisibility(TransparencyOption to) | |
-{ | |
- ToggleBit(_invisibility_opt, to); | |
-} | |
- | |
-/** | |
- * Toggles between invisible and solid state. | |
- * If object is transparent, then it is made invisible. | |
- * Used by the keyboard shortcuts. | |
- * | |
- * @param to the object type which invisibility option to toggle | |
- */ | |
-static inline void ToggleInvisibilityWithTransparency(TransparencyOption to) | |
-{ | |
- if (IsInvisibilitySet(to)) { | |
- ClrBit(_invisibility_opt, to); | |
- ClrBit(_transparency_opt, to); | |
- } else { | |
- SetBit(_invisibility_opt, to); | |
- SetBit(_transparency_opt, to); | |
- } | |
-} | |
- | |
-/** | |
- * Toggle the transparency lock bit | |
- * | |
- * @param to the transparency option to be locked or unlocked | |
- */ | |
-static inline void ToggleTransparencyLock(TransparencyOption to) | |
-{ | |
- ToggleBit(_transparency_lock, to); | |
-} | |
- | |
-/** Set or clear all non-locked transparency options */ | |
-static inline void ResetRestoreAllTransparency() | |
-{ | |
- /* if none of the non-locked options are set */ | |
- if ((_transparency_opt & ~_transparency_lock) == 0) { | |
- /* set all non-locked options */ | |
- _transparency_opt |= GB(~_transparency_lock, 0, TO_END); | |
- } else { | |
- /* clear all non-locked options */ | |
- _transparency_opt &= _transparency_lock; | |
- } | |
- | |
- MarkWholeScreenDirty(); | |
-} | |
- | |
#endif /* TRANSPARENCY_H */ | |
diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp | |
index 4bad2b0..0f912dc 100644 | |
--- a/src/transparency_gui.cpp | |
+++ b/src/transparency_gui.cpp | |
@@ -14,6 +14,7 @@ | |
#include "transparency.h" | |
#include "sound_func.h" | |
#include "settings_type.h" | |
+#include "globals.h" | |
#include "widgets/transparency_widget.h" | |
@@ -22,11 +23,144 @@ | |
#include "safeguards.h" | |
-TransparencyOptionBits _transparency_opt; ///< The bits that should be transparent. | |
-TransparencyOptionBits _transparency_lock; ///< Prevent these bits from flipping with X. | |
-TransparencyOptionBits _invisibility_opt; ///< The bits that should be invisible. | |
byte _display_opt; ///< What do we want to draw/do? | |
+ | |
+/** | |
+ * Check if the transparency option bit is set | |
+ * and if we aren't in the game menu (there's never transparency) | |
+ * | |
+ * @param to the structure which transparency option is ask for | |
+ */ | |
+bool Globals::IsTransparencySet(TransparencyOption to) | |
+{ | |
+ return (HasBit(transparency_opt, to) && !this->IsGameMode(GM_MENU)); | |
+} | |
+ | |
+bool Globals::IsTransparencySetNoMenuCheck(TransparencyOption to) | |
+{ | |
+ return (HasBit(transparency_opt, to)); | |
+} | |
+ | |
+bool Globals::IsTransparencyLockSet(TransparencyOption to) | |
+{ | |
+ return (HasBit(transparency_lock, to) && !this->IsGameMode(GM_MENU)); | |
+} | |
+ | |
+bool Globals::IsTransparencyLockSetNoMenuCheck(TransparencyOption to) | |
+{ | |
+ return (HasBit(transparency_lock, to)); | |
+} | |
+ | |
+/** | |
+ * Check if the invisibility option bit is set | |
+ * and if we aren't in the game menu (there's never transparency) | |
+ * | |
+ * @param to the structure which invisibility option is ask for | |
+ */ | |
+bool Globals::IsInvisibilitySet(TransparencyOption to) | |
+{ | |
+ return (HasBit(transparency_opt & invisibility_opt, to) && !this->IsGameMode(GM_MENU)); | |
+} | |
+ | |
+bool Globals::IsInvisibilitySetNoMenuCheck(TransparencyOption to) | |
+{ | |
+ return (HasBit(transparency_opt & invisibility_opt, to)); | |
+} | |
+ | |
+/** | |
+ * Toggle the transparency option bit | |
+ * | |
+ * @param to the transparency option to be toggled | |
+ */ | |
+void Globals::ToggleTransparency(TransparencyOption to) | |
+{ | |
+ ToggleBit(transparency_opt, to); | |
+} | |
+ | |
+/** | |
+ * Toggle the invisibility option bit | |
+ * | |
+ * @param to the structure which invisibility option is toggle | |
+ */ | |
+void Globals::ToggleInvisibility(TransparencyOption to) | |
+{ | |
+ ToggleBit(invisibility_opt, to); | |
+} | |
+ | |
+/** | |
+ * Toggles between invisible and solid state. | |
+ * If object is transparent, then it is made invisible. | |
+ * Used by the keyboard shortcuts. | |
+ * | |
+ * @param to the object type which invisibility option to toggle | |
+ */ | |
+void Globals::ToggleInvisibilityWithTransparency(TransparencyOption to) | |
+{ | |
+ if (IsInvisibilitySet(to)) { | |
+ ClrBit(invisibility_opt, to); | |
+ ClrBit(transparency_opt, to); | |
+ } else { | |
+ SetBit(invisibility_opt, to); | |
+ SetBit(transparency_opt, to); | |
+ } | |
+} | |
+ | |
+/** | |
+ * Toggle the transparency lock bit | |
+ * | |
+ * @param to the transparency option to be locked or unlocked | |
+ */ | |
+void Globals::ToggleTransparencyLock(TransparencyOption to) | |
+{ | |
+ ToggleBit(transparency_lock, to); | |
+} | |
+ | |
+/** Set or clear all non-locked transparency options */ | |
+void Globals::ResetRestoreAllTransparency() | |
+{ | |
+ /* if none of the non-locked options are set */ | |
+ if ((transparency_opt & ~transparency_lock) == 0) { | |
+ /* set all non-locked options */ | |
+ transparency_opt |= GB(~transparency_lock, 0, TO_END); | |
+ } else { | |
+ /* clear all non-locked options */ | |
+ transparency_opt &= transparency_lock; | |
+ } | |
+ | |
+ MarkWholeScreenDirty(); | |
+} | |
+ | |
+TransparencyOptionBits Globals::GetTransparency() | |
+{ | |
+ return transparency_opt; | |
+} | |
+ | |
+TransparencyOptionBits Globals::GetTransparencyLock() | |
+{ | |
+ return transparency_lock; | |
+} | |
+ | |
+TransparencyOptionBits Globals::GetInvisibility() | |
+{ | |
+ return invisibility_opt; | |
+} | |
+ | |
+void Globals::BackupTransparency() | |
+{ | |
+ backup_transparency_opt = transparency_opt; | |
+} | |
+ | |
+void Globals::RestoreTransparency() | |
+{ | |
+ transparency_opt = backup_transparency_opt; | |
+} | |
+ | |
+void Globals::MakeTextTransparent() | |
+{ | |
+ transparency_opt &= (1 << TO_SIGNS) | (1 << TO_LOADING); // Disable all transparency, except textual stuff | |
+} | |
+ | |
class TransparenciesWindow : public Window | |
{ | |
public: | |
@@ -54,7 +188,7 @@ public: | |
case WID_TT_CATENARY: | |
case WID_TT_LOADING: { | |
uint i = widget - WID_TT_BEGIN; | |
- if (HasBit(_transparency_lock, i)) DrawSprite(SPR_LOCK, PAL_NONE, r.left + 1, r.top + 1); | |
+ if (_globals->IsTransparencyLockSetNoMenuCheck((TransparencyOption)i)) DrawSprite(SPR_LOCK, PAL_NONE, r.left + 1, r.top + 1); | |
break; | |
} | |
case WID_TT_BUTTONS: | |
@@ -63,7 +197,7 @@ public: | |
const NWidgetBase *wi = this->GetWidget<NWidgetBase>(i); | |
DrawFrameRect(wi->pos_x + 1, r.top + 2, wi->pos_x + wi->current_x - 2, r.bottom - 2, COLOUR_PALE_GREEN, | |
- HasBit(_invisibility_opt, i - WID_TT_BEGIN) ? FR_LOWERED : FR_NONE); | |
+ _globals->IsInvisibilitySetNoMenuCheck((TransparencyOption)(i - WID_TT_BEGIN)) ? FR_LOWERED : FR_NONE); | |
} | |
break; | |
} | |
@@ -74,11 +208,11 @@ public: | |
if (widget >= WID_TT_BEGIN && widget < WID_TT_END) { | |
if (_ctrl_pressed) { | |
/* toggle the bit of the transparencies lock variable */ | |
- ToggleTransparencyLock((TransparencyOption)(widget - WID_TT_BEGIN)); | |
+ _globals->ToggleTransparencyLock((TransparencyOption)(widget - WID_TT_BEGIN)); | |
this->SetDirty(); | |
} else { | |
/* toggle the bit of the transparencies variable and play a sound */ | |
- ToggleTransparency((TransparencyOption)(widget - WID_TT_BEGIN)); | |
+ _globals->ToggleTransparency((TransparencyOption)(widget - WID_TT_BEGIN)); | |
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); | |
MarkWholeScreenDirty(); | |
} | |
@@ -92,11 +226,11 @@ public: | |
} | |
if (i == WID_TT_LOADING || i == WID_TT_END) return; | |
- ToggleInvisibility((TransparencyOption)(i - WID_TT_BEGIN)); | |
+ _globals->ToggleInvisibility((TransparencyOption)(i - WID_TT_BEGIN)); | |
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); | |
/* Redraw whole screen only if transparency is set */ | |
- if (IsTransparencySet((TransparencyOption)(i - WID_TT_BEGIN))) { | |
+ if (_globals->IsTransparencySet((TransparencyOption)(i - WID_TT_BEGIN))) { | |
MarkWholeScreenDirty(); | |
} else { | |
this->SetWidgetDirty(WID_TT_BUTTONS); | |
@@ -120,7 +254,7 @@ public: | |
{ | |
if (!gui_scope) return; | |
for (uint i = WID_TT_BEGIN; i < WID_TT_END; i++) { | |
- this->SetWidgetLoweredState(i, IsTransparencySet((TransparencyOption)(i - WID_TT_BEGIN))); | |
+ this->SetWidgetLoweredState(i, _globals->IsTransparencySet((TransparencyOption)(i - WID_TT_BEGIN))); | |
} | |
} | |
}; | |
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp | |
index 7240cf8..0bdf08c 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); | |
} | |
} | |
@@ -472,7 +472,7 @@ static void DrawTile_Trees(TileInfo *ti) | |
} | |
/* Do not draw trees when the invisible trees setting is set */ | |
- if (IsInvisibilitySet(TO_TREES)) return; | |
+ if (_globals->IsInvisibilitySet(TO_TREES)) return; | |
uint tmp = CountBits(ti->tile + ti->x + ti->y); | |
uint index = GB(tmp, 0, 2) + (GetTreeType(ti->tile) << 2); | |
@@ -523,7 +523,7 @@ static void DrawTile_Trees(TileInfo *ti) | |
} | |
} | |
- AddSortableSpriteToDraw(te[mi].sprite, te[mi].pal, ti->x + te[mi].x, ti->y + te[mi].y, 16 - te[mi].x, 16 - te[mi].y, 0x30, z, IsTransparencySet(TO_TREES), -te[mi].x, -te[mi].y); | |
+ AddSortableSpriteToDraw(te[mi].sprite, te[mi].pal, ti->x + te[mi].x, ti->y + te[mi].y, 16 - te[mi].x, 16 - te[mi].y, 0x30, z, _globals->IsTransparencySet(TO_TREES), -te[mi].x, -te[mi].y); | |
/* replace the removed one with the last one */ | |
te[mi] = te[trees - 1]; | |
diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp | |
index f21eeae..3bc7f98 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..4839ae0 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); | |
} | |
@@ -997,7 +997,7 @@ static CommandCost ClearTile_TunnelBridge(TileIndex tile, DoCommandFlag flags) | |
static inline void DrawPillar(const PalSpriteID *psid, int x, int y, int z, int w, int h, const SubSprite *subsprite) | |
{ | |
static const int PILLAR_Z_OFFSET = TILE_HEIGHT - BRIDGE_Z_START; ///< Start offset of pillar wrt. bridge (downwards) | |
- AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, w, h, BB_HEIGHT_UNDER_BRIDGE - PILLAR_Z_OFFSET, z, IsTransparencySet(TO_BRIDGES), 0, 0, -PILLAR_Z_OFFSET, subsprite); | |
+ AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, w, h, BB_HEIGHT_UNDER_BRIDGE - PILLAR_Z_OFFSET, z, _globals->IsTransparencySet(TO_BRIDGES), 0, 0, -PILLAR_Z_OFFSET, subsprite); | |
} | |
/** | |
@@ -1100,17 +1100,17 @@ static void DrawBridgeTramBits(int x, int y, int z, int offset, bool overlay, bo | |
/* The sprites under the vehicles are drawn as SpriteCombine. StartSpriteCombine() has already been called | |
* The bounding boxes here are the same as for bridge front/roof */ | |
- if (head || !IsInvisibilitySet(TO_BRIDGES)) { | |
+ if (head || !_globals->IsInvisibilitySet(TO_BRIDGES)) { | |
AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, | |
x, y, size_x[offset], size_y[offset], 0x28, z, | |
- !head && IsTransparencySet(TO_BRIDGES)); | |
+ !head && _globals->IsTransparencySet(TO_BRIDGES)); | |
} | |
/* Do not draw catenary if it is set invisible */ | |
- if (!IsInvisibilitySet(TO_CATENARY)) { | |
+ if (!_globals->IsInvisibilitySet(TO_CATENARY)) { | |
AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset], PAL_NONE, | |
x, y, size_x[offset], size_y[offset], 0x28, z, | |
- IsTransparencySet(TO_CATENARY)); | |
+ _globals->IsTransparencySet(TO_CATENARY)); | |
} | |
/* Start a new SpriteCombine for the front part */ | |
@@ -1118,10 +1118,10 @@ static void DrawBridgeTramBits(int x, int y, int z, int offset, bool overlay, bo | |
StartSpriteCombine(); | |
/* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */ | |
- if (!IsInvisibilitySet(TO_CATENARY)) { | |
+ if (!_globals->IsInvisibilitySet(TO_CATENARY)) { | |
AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + front_offsets[offset], PAL_NONE, | |
x, y, size_x[offset] + front_bb_offset_x[offset], size_y[offset] + front_bb_offset_y[offset], 0x28, z, | |
- IsTransparencySet(TO_CATENARY), front_bb_offset_x[offset], front_bb_offset_y[offset]); | |
+ _globals->IsTransparencySet(TO_CATENARY), front_bb_offset_x[offset], front_bb_offset_y[offset]); | |
} | |
} | |
@@ -1193,10 +1193,10 @@ static void DrawTile_TunnelBridge(TileInfo *ti) | |
DrawGroundSprite(SPR_TRAMWAY_BASE + tunnel_sprites[rts - ROADTYPES_TRAM][tunnelbridge_direction], PAL_NONE); | |
/* Do not draw wires if they are invisible */ | |
- if (!IsInvisibilitySet(TO_CATENARY)) { | |
+ if (!_globals->IsInvisibilitySet(TO_CATENARY)) { | |
catenary = true; | |
StartSpriteCombine(); | |
- AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + tunnelbridge_direction, PAL_NONE, ti->x, ti->y, BB_data[10], BB_data[11], TILE_HEIGHT, ti->z, IsTransparencySet(TO_CATENARY), BB_data[8], BB_data[9], BB_Z_SEPARATOR); | |
+ AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + tunnelbridge_direction, PAL_NONE, ti->x, ti->y, BB_data[10], BB_data[11], TILE_HEIGHT, ti->z, _globals->IsTransparencySet(TO_CATENARY), BB_data[8], BB_data[9], BB_Z_SEPARATOR); | |
} | |
} | |
} else { | |
@@ -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))) { | |
@@ -1451,11 +1451,11 @@ void DrawBridgeMiddle(const TileInfo *ti) | |
if (transport_type == TRANSPORT_ROAD || transport_type == TRANSPORT_RAIL) StartSpriteCombine(); | |
/* Draw floor and far part of bridge*/ | |
- if (!IsInvisibilitySet(TO_BRIDGES)) { | |
+ if (!_globals->IsInvisibilitySet(TO_BRIDGES)) { | |
if (axis == AXIS_X) { | |
- AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 1, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START); | |
+ AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 1, 0x28, z, _globals->IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START); | |
} else { | |
- AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 1, 16, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START); | |
+ AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 1, 16, 0x28, z, _globals->IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START); | |
} | |
} | |
@@ -1473,19 +1473,19 @@ void DrawBridgeMiddle(const TileInfo *ti) | |
} | |
} else if (transport_type == TRANSPORT_RAIL) { | |
const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(rampsouth)); | |
- if (rti->UsesOverlay() && !IsInvisibilitySet(TO_BRIDGES)) { | |
+ if (rti->UsesOverlay() && !_globals->IsInvisibilitySet(TO_BRIDGES)) { | |
SpriteID surface = GetCustomRailSprite(rti, rampsouth, RTSG_BRIDGE, TCX_ON_BRIDGE); | |
if (surface != 0) { | |
- AddSortableSpriteToDraw(surface + axis, PAL_NONE, x, y, 16, 16, 0, bridge_z, IsTransparencySet(TO_BRIDGES)); | |
+ AddSortableSpriteToDraw(surface + axis, PAL_NONE, x, y, 16, 16, 0, bridge_z, _globals->IsTransparencySet(TO_BRIDGES)); | |
} | |
} | |
- 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 && !_globals->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)); | |
+ AddSortableSpriteToDraw(overlay + RTO_X + axis, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, bridge_z, _globals->IsTransparencySet(TO_BRIDGES)); | |
} else { | |
- AddSortableSpriteToDraw(axis == AXIS_X ? rti->base_sprites.single_x : rti->base_sprites.single_y, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, bridge_z, IsTransparencySet(TO_BRIDGES)); | |
+ AddSortableSpriteToDraw(axis == AXIS_X ? rti->base_sprites.single_x : rti->base_sprites.single_y, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, bridge_z, _globals->IsTransparencySet(TO_BRIDGES)); | |
} | |
} | |
@@ -1497,13 +1497,13 @@ void DrawBridgeMiddle(const TileInfo *ti) | |
} | |
/* draw roof, the component of the bridge which is logically between the vehicle and the camera */ | |
- if (!IsInvisibilitySet(TO_BRIDGES)) { | |
+ if (!_globals->IsInvisibilitySet(TO_BRIDGES)) { | |
if (axis == AXIS_X) { | |
y += 12; | |
- if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 4, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 3, BRIDGE_Z_START); | |
+ if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 4, 0x28, z, _globals->IsTransparencySet(TO_BRIDGES), 0, 3, BRIDGE_Z_START); | |
} else { | |
x += 12; | |
- if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 4, 16, 0x28, z, IsTransparencySet(TO_BRIDGES), 3, 0, BRIDGE_Z_START); | |
+ if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 4, 16, 0x28, z, _globals->IsTransparencySet(TO_BRIDGES), 3, 0, BRIDGE_Z_START); | |
} | |
} | |
@@ -1511,7 +1511,7 @@ void DrawBridgeMiddle(const TileInfo *ti) | |
if (transport_type == TRANSPORT_ROAD) EndSpriteCombine(); | |
/* Do not draw anything more if bridges are invisible */ | |
- if (IsInvisibilitySet(TO_BRIDGES)) return; | |
+ if (_globals->IsInvisibilitySet(TO_BRIDGES)) return; | |
psid++; | |
if (ti->z + 5 == z) { | |
@@ -1519,7 +1519,7 @@ void DrawBridgeMiddle(const TileInfo *ti) | |
if (psid->sprite != 0) { | |
SpriteID image = psid->sprite; | |
SpriteID pal = psid->pal; | |
- if (IsTransparencySet(TO_BRIDGES)) { | |
+ if (_globals->IsTransparencySet(TO_BRIDGES)) { | |
SetBit(image, PALETTE_MODIFIER_TRANSPARENT); | |
pal = PALETTE_TO_TRANSPARENT; | |
} | |
diff --git a/src/vehicle.cpp b/src/vehicle.cpp | |
index dff9feb..579641d 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) { | |
@@ -1060,7 +1060,7 @@ static void DoDrawVehicle(const Vehicle *v) | |
/* Check whether the vehicle shall be transparent/invisible due to GUI settings. | |
* However, transparent smoke and bubbles look weird, so always hide them. */ | |
TransparencyOption to = EffectVehicle::From(v)->GetTransparencyOption(); | |
- if (to != TO_INVALID && (IsTransparencySet(to) || IsInvisibilitySet(to))) return; | |
+ if (to != TO_INVALID && (_globals->IsTransparencySet(to) || _globals->IsInvisibilitySet(to))) return; | |
} | |
StartSpriteCombine(); | |
@@ -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..151040d 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..5bc32c4 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..4d617df 100644 | |
--- a/src/video/win32_v.cpp | |
+++ b/src/video/win32_v.cpp | |
@@ -23,6 +23,7 @@ | |
#include "../progress.h" | |
#include "../window_gui.h" | |
#include "../window_func.h" | |
+#include "../globals.h" | |
#include "win32_v.h" | |
#include <windows.h> | |
#include <imm.h> | |
@@ -1236,7 +1237,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..86ebbfe 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) { | |
@@ -1288,7 +1288,7 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi) | |
static void ViewportAddSigns(DrawPixelInfo *dpi) | |
{ | |
/* Signs are turned off or are invisible */ | |
- if (!HasBit(_display_opt, DO_SHOW_SIGNS) || IsInvisibilitySet(TO_SIGNS)) return; | |
+ if (!HasBit(_display_opt, DO_SHOW_SIGNS) || _globals->IsInvisibilitySet(TO_SIGNS)) return; | |
const Sign *si; | |
FOR_ALL_SIGNS(si) { | |
@@ -1299,7 +1299,7 @@ static void ViewportAddSigns(DrawPixelInfo *dpi) | |
ViewportAddString(dpi, ZOOM_LVL_OUT_16X, &si->sign, | |
STR_WHITE_SIGN, | |
- (IsTransparencySet(TO_SIGNS) || si->owner == OWNER_DEITY) ? STR_VIEWPORT_SIGN_SMALL_WHITE : STR_VIEWPORT_SIGN_SMALL_BLACK, STR_NULL, | |
+ (_globals->IsTransparencySet(TO_SIGNS) || si->owner == OWNER_DEITY) ? STR_VIEWPORT_SIGN_SMALL_WHITE : STR_VIEWPORT_SIGN_SMALL_BLACK, STR_NULL, | |
si->index, 0, (si->owner == OWNER_NONE) ? COLOUR_GREY : (si->owner == OWNER_DEITY ? INVALID_COLOUR : _company_colours[si->owner])); | |
} | |
} | |
@@ -1508,9 +1508,9 @@ static void ViewportDrawStrings(ZoomLevel zoom, const StringSpriteToDrawVector * | |
if (ss->colour != INVALID_COLOUR) { | |
/* Do not draw signs nor station names if they are set invisible */ | |
- if (IsInvisibilitySet(TO_SIGNS) && ss->string != STR_WHITE_SIGN) continue; | |
+ if (_globals->IsInvisibilitySet(TO_SIGNS) && ss->string != STR_WHITE_SIGN) continue; | |
- if (IsTransparencySet(TO_SIGNS) && ss->string != STR_WHITE_SIGN) { | |
+ if (_globals->IsTransparencySet(TO_SIGNS) && ss->string != STR_WHITE_SIGN) { | |
/* Don't draw the rectangle. | |
* Real colours need the TC_IS_PALETTE_COLOUR flag. | |
* Otherwise colours from _string_colourmap are assumed. */ | |
@@ -1520,7 +1520,7 @@ static void ViewportDrawStrings(ZoomLevel zoom, const StringSpriteToDrawVector * | |
* or if we are drawing a general text sign (STR_WHITE_SIGN). */ | |
DrawFrameRect( | |
x, y, x + w, y + h, ss->colour, | |
- IsTransparencySet(TO_SIGNS) ? FR_TRANSPARENT : FR_NONE | |
+ _globals->IsTransparencySet(TO_SIGNS) ? FR_TRANSPARENT : FR_NONE | |
); | |
} | |
} | |
@@ -2089,7 +2089,7 @@ static bool CheckClickOnTown(const ViewPort *vp, int x, int y) | |
static bool CheckClickOnStation(const ViewPort *vp, int x, int y) | |
{ | |
- if (!(HasBit(_display_opt, DO_SHOW_STATION_NAMES) || HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES)) || IsInvisibilitySet(TO_SIGNS)) return false; | |
+ if (!(HasBit(_display_opt, DO_SHOW_STATION_NAMES) || HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES)) || _globals->IsInvisibilitySet(TO_SIGNS)) return false; | |
const BaseStation *st; | |
FOR_ALL_BASE_STATIONS(st) { | |
@@ -2119,13 +2119,13 @@ static bool CheckClickOnStation(const ViewPort *vp, int x, int y) | |
static bool CheckClickOnSign(const ViewPort *vp, int x, int y) | |
{ | |
/* Signs are turned off, or they are transparent and invisibility is ON, or company is a spectator */ | |
- if (!HasBit(_display_opt, DO_SHOW_SIGNS) || IsInvisibilitySet(TO_SIGNS) || _local_company == COMPANY_SPECTATOR) return false; | |
+ if (!HasBit(_display_opt, DO_SHOW_SIGNS) || _globals->IsInvisibilitySet(TO_SIGNS) || _local_company == COMPANY_SPECTATOR) return false; | |
const Sign *si; | |
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..90ca48b 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); | |
} | |
@@ -717,7 +717,7 @@ static void DrawCanalWater(TileIndex tile) | |
static void DrawWaterTileStruct(const TileInfo *ti, const DrawTileSeqStruct *dtss, SpriteID base, uint offset, PaletteID palette, CanalFeature feature) | |
{ | |
/* Don't draw if buildings are invisible. */ | |
- if (IsInvisibilitySet(TO_BUILDINGS)) return; | |
+ if (_globals->IsInvisibilitySet(TO_BUILDINGS)) return; | |
for (; !dtss->IsTerminator(); dtss++) { | |
uint tile_offs = offset + dtss->image.sprite; | |
@@ -726,7 +726,7 @@ static void DrawWaterTileStruct(const TileInfo *ti, const DrawTileSeqStruct *dts | |
ti->x + dtss->delta_x, ti->y + dtss->delta_y, | |
dtss->size_x, dtss->size_y, | |
dtss->size_z, ti->z + dtss->delta_z, | |
- IsTransparencySet(TO_BUILDINGS)); | |
+ _globals->IsTransparencySet(TO_BUILDINGS)); | |
} | |
} | |
diff --git a/src/widget.cpp b/src/widget.cpp | |
index 4e411ad..c40b388 100644 | |
--- a/src/widget.cpp | |
+++ b/src/widget.cpp | |
@@ -1903,10 +1903,9 @@ void NWidgetViewport::SetupSmallestSize(Window *w, bool init_array) | |
void NWidgetViewport::Draw(const Window *w) | |
{ | |
if (this->disp_flags & ND_NO_TRANSPARENCY) { | |
- TransparencyOptionBits to_backup = _transparency_opt; | |
- _transparency_opt &= (1 << TO_SIGNS) | (1 << TO_LOADING); // Disable all transparency, except textual stuff | |
+ _globals->MakeTextTransparent(); | |
w->DrawViewport(); | |
- _transparency_opt = to_backup; | |
+ _globals->RestoreTransparency(); | |
} else { | |
w->DrawViewport(); | |
} | |
diff --git a/src/window.cpp b/src/window.cpp | |
index 6538caf..030f7c4 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