summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-06-10 20:11:50 +0200
committerGitHub <noreply@github.com>2021-06-10 20:11:50 +0200
commit849a10520cc26a98d91981a7705775a2481beef2 (patch)
tree704fe20c9aeb5cb54d9398cf364ea242afcdbae8
parente2417193c9dbe8a7ecf00521bed7bf6c3fb573fc (diff)
downloadopenttd-849a10520cc26a98d91981a7705775a2481beef2.tar.xz
Change: allow pause/unpause console command in single player too (#9342)
-rw-r--r--src/console_cmds.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 7a756a657..b5c1748ab 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -160,11 +160,24 @@ DEF_CONSOLE_HOOK(ConHookNoNetwork)
return CHR_ALLOW;
}
+/**
+ * Check if are either in singleplayer or a server.
+ * @return True iff we are either in singleplayer or a server.
+ */
+DEF_CONSOLE_HOOK(ConHookServerOrNoNetwork)
+{
+ if (_networking && !_network_server) {
+ if (echo) IConsoleError("This command is only available to a network server.");
+ return CHR_DISALLOW;
+ }
+ return CHR_ALLOW;
+}
+
DEF_CONSOLE_HOOK(ConHookNewGRFDeveloperTool)
{
if (_settings_client.gui.newgrf_developer_tools) {
if (_game_mode == GM_MENU) {
- if (echo) IConsoleError("This command is only available in game and editor.");
+ if (echo) IConsoleError("This command is only available in-game and in the editor.");
return CHR_DISALLOW;
}
return ConHookNoNetwork(echo);
@@ -209,7 +222,7 @@ DEF_CONSOLE_CMD(ConResetEnginePool)
}
if (_game_mode == GM_MENU) {
- IConsoleError("This command is only available in game and editor.");
+ IConsoleError("This command is only available in-game and in the editor.");
return true;
}
@@ -622,6 +635,11 @@ DEF_CONSOLE_CMD(ConPauseGame)
return true;
}
+ if (_game_mode == GM_MENU) {
+ IConsoleError("This command is only available in-game and in the editor.");
+ return true;
+ }
+
if ((_pause_mode & PM_PAUSED_NORMAL) == PM_UNPAUSED) {
DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
if (!_networking) IConsolePrint(CC_DEFAULT, "Game paused.");
@@ -639,6 +657,11 @@ DEF_CONSOLE_CMD(ConUnpauseGame)
return true;
}
+ if (_game_mode == GM_MENU) {
+ IConsoleError("This command is only available in-game and in the editor.");
+ return true;
+ }
+
if ((_pause_mode & PM_PAUSED_NORMAL) != PM_UNPAUSED) {
DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE);
if (!_networking) IConsolePrint(CC_DEFAULT, "Game unpaused.");
@@ -2393,8 +2416,8 @@ void IConsoleStdLibRegister()
IConsole::CmdRegister("unban", ConUnBan, ConHookServerOnly);
IConsole::CmdRegister("banlist", ConBanList, ConHookServerOnly);
- IConsole::CmdRegister("pause", ConPauseGame, ConHookServerOnly);
- IConsole::CmdRegister("unpause", ConUnpauseGame, ConHookServerOnly);
+ IConsole::CmdRegister("pause", ConPauseGame, ConHookServerOrNoNetwork);
+ IConsole::CmdRegister("unpause", ConUnpauseGame, ConHookServerOrNoNetwork);
IConsole::CmdRegister("company_pw", ConCompanyPassword, ConHookNeedNetwork);
IConsole::AliasRegister("company_password", "company_pw %+");