summaryrefslogtreecommitdiff
path: root/src/console_cmds.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2019-03-20 17:01:13 +0100
committerPatric Stout <truebrain@openttd.org>2019-03-20 19:24:55 +0100
commite3c639a09f1d2251477f69496120d057dd8320a9 (patch)
tree7d66891ae41db811e1edd13647b05092dca54b5a /src/console_cmds.cpp
parent72c5f2b3eed77120d86ecf636e07c71eb23b4bd5 (diff)
downloadopenttd-e3c639a09f1d2251477f69496120d057dd8320a9.tar.xz
Remove: ENABLE_NETWORK switch
This switch has been a pain for years. Often disabling broke compilation, as no developer compiles OpenTTD without, neither do any of our official binaries. Additionaly, it has grown so hugely in our codebase, that it clearly shows that the current solution was a poor one. 350+ instances of "#ifdef ENABLE_NETWORK" were in the code, of which only ~30 in the networking code itself. The rest were all around the code to do the right thing, from GUI to NewGRF. A more proper solution would be to stub all the functions, and make sure the rest of the code can simply assume network is available. This was also partially done, and most variables were correct if networking was disabled. Despite that, often the #ifdefs were still used. With the recent removal of DOS, there is also no platform anymore which we support where networking isn't working out-of-the-box. All in all, it is time to remove the ENABLE_NETWORK switch. No replacement is planned, but if you feel we really need this option, we welcome any Pull Request which implements this in a way that doesn't crawl through the code like this diff shows we used to.
Diffstat (limited to 'src/console_cmds.cpp')
-rw-r--r--src/console_cmds.cpp24
1 files changed, 2 insertions, 22 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 732ace6a2..6c8e927c9 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -86,8 +86,6 @@ static ConsoleFileList _console_file_list; ///< File storage cache for the conso
* command hooks
****************/
-#ifdef ENABLE_NETWORK
-
/**
* Check network availability and inform in console about failure of detection.
* @return Network availability.
@@ -159,10 +157,6 @@ DEF_CONSOLE_HOOK(ConHookNoNetwork)
return CHR_ALLOW;
}
-#else
-# define ConHookNoNetwork NULL
-#endif /* ENABLE_NETWORK */
-
DEF_CONSOLE_HOOK(ConHookNewGRFDeveloperTool)
{
if (_settings_client.gui.newgrf_developer_tools) {
@@ -170,11 +164,7 @@ DEF_CONSOLE_HOOK(ConHookNewGRFDeveloperTool)
if (echo) IConsoleError("This command is only available in game and editor.");
return CHR_DISALLOW;
}
-#ifdef ENABLE_NETWORK
return ConHookNoNetwork(echo);
-#else
- return CHR_ALLOW;
-#endif
}
return CHR_HIDE;
}
@@ -479,7 +469,6 @@ DEF_CONSOLE_CMD(ConClearBuffer)
/**********************************
* Network Core Console Commands
**********************************/
-#ifdef ENABLE_NETWORK
static bool ConKickOrBan(const char *argv, bool ban)
{
@@ -930,8 +919,6 @@ DEF_CONSOLE_CMD(ConNetworkConnect)
return true;
}
-#endif /* ENABLE_NETWORK */
-
/*********************************
* script file console commands
*********************************/
@@ -1547,12 +1534,9 @@ DEF_CONSOLE_CMD(ConCompanies)
const char *password_state = "";
if (c->is_ai) {
password_state = "AI";
- }
-#ifdef ENABLE_NETWORK
- else if (_network_server) {
+ } else if (_network_server) {
password_state = StrEmpty(_network_company_states[c->index].password) ? "unprotected" : "protected";
}
-#endif
char colour[512];
GetString(colour, STR_COLOUR_DARK_BLUE + _company_colours[c->index], lastof(colour));
@@ -1569,8 +1553,6 @@ DEF_CONSOLE_CMD(ConCompanies)
return true;
}
-#ifdef ENABLE_NETWORK
-
DEF_CONSOLE_CMD(ConSay)
{
if (argc == 0) {
@@ -1812,7 +1794,6 @@ DEF_CONSOLE_CMD(ConContent)
return false;
}
#endif /* defined(WITH_ZLIB) */
-#endif /* ENABLE_NETWORK */
DEF_CONSOLE_CMD(ConSetting)
{
@@ -1992,7 +1973,7 @@ void IConsoleStdLibRegister()
IConsoleAliasRegister("players", "companies");
/* networking functions */
-#ifdef ENABLE_NETWORK
+
/* Content downloading is only available with ZLIB */
#if defined(WITH_ZLIB)
IConsoleCmdRegister("content", ConContent);
@@ -2050,7 +2031,6 @@ void IConsoleStdLibRegister()
IConsoleAliasRegister("restart_game_year", "setting restart_game_year %+");
IConsoleAliasRegister("min_players", "setting min_active_clients %+");
IConsoleAliasRegister("reload_cfg", "setting reload_cfg %+");
-#endif /* ENABLE_NETWORK */
/* debugging stuff */
#ifdef _DEBUG