summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordarkvater <darkvater@openttd.org>2005-01-24 21:33:44 +0000
committerdarkvater <darkvater@openttd.org>2005-01-24 21:33:44 +0000
commite05f961eed4e8165a5089e5e7bf957fdde82c17e (patch)
tree072693334d01c3db01a4ab15ab7ec9a69ece0bcf
parent6151c1044ad4355570c44c3d6d1a49aaf47c755d (diff)
downloadopenttd-e05f961eed4e8165a5089e5e7bf957fdde82c17e.tar.xz
(svn r1648) -Fix: server can now pause and unpause a game through the console. Use 'pause' and 'unpause'
-rw-r--r--console_cmds.c26
-rw-r--r--main_gui.c2
-rw-r--r--misc_cmd.c4
3 files changed, 29 insertions, 3 deletions
diff --git a/console_cmds.c b/console_cmds.c
index 1b42f8e44..b8ea17826 100644
--- a/console_cmds.c
+++ b/console_cmds.c
@@ -379,6 +379,28 @@ DEF_CONSOLE_CMD(ConBanList)
return NULL;
}
+DEF_CONSOLE_CMD(ConPauseGame)
+{
+ if (_pause == 0) {
+ DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
+ IConsolePrint(_iconsole_color_default, "Game paused.");
+ } else
+ IConsolePrint(_iconsole_color_default, "Game is already paused.");
+
+ return NULL;
+}
+
+DEF_CONSOLE_CMD(ConUnPauseGame)
+{
+ if (_pause != 0) {
+ DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
+ IConsolePrint(_iconsole_color_default, "Game unpaused.");
+ } else
+ IConsolePrint(_iconsole_color_default, "Game is already unpaused.");
+
+ return NULL;
+}
+
DEF_CONSOLE_CMD(ConRcon)
{
if (argc < 3) {
@@ -1264,6 +1286,10 @@ void IConsoleStdLibRegister(void)
IConsoleCmdHook("unban", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetClient);
IConsoleCmdRegister("banlist", ConBanList);
IConsoleCmdHook("banlist", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetClient);
+ IConsoleCmdRegister("pause", ConPauseGame);
+ IConsoleCmdHook("pause", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetClient);
+ IConsoleCmdRegister("unpause", ConUnPauseGame);
+ IConsoleCmdHook("unpause", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetClient);
IConsoleAliasRegister("clean_company", "reset_company %A");
diff --git a/main_gui.c b/main_gui.c
index e4baf33a1..bd81a5269 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -159,7 +159,7 @@ static void ToolbarPauseClick(Window *w)
{
if (_networking && !_network_server) { return;} // only server can pause the game
- if (DoCommandP(0, _pause?0:1, 0, NULL, CMD_PAUSE))
+ if (DoCommandP(0, _pause ? 0 : 1, 0, NULL, CMD_PAUSE))
SndPlayFx(SND_15_BEEP);
}
diff --git a/misc_cmd.c b/misc_cmd.c
index 865324acc..67d4d958f 100644
--- a/misc_cmd.c
+++ b/misc_cmd.c
@@ -175,8 +175,8 @@ int32 CmdChangePresidentName(int x, int y, uint32 flags, uint32 p1, uint32 p2)
int32 CmdPause(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
if (flags & DC_EXEC) {
- _pause += p1?1:-1;
- if(_pause==(byte)-1) _pause = 0;
+ _pause += (p1 == 1) ? 1 : -1;
+ if (_pause == (byte)-1) _pause = 0;
InvalidateWindow(WC_STATUS_BAR, 0);
InvalidateWindow(WC_MAIN_TOOLBAR, 0);
}