(svn r1648) -Fix: server can now pause and unpause a game through the console. Use 'pause' and 'unpause'
authordarkvater
Mon, 24 Jan 2005 21:33:44 +0000
changeset 1147 786d631229d8
parent 1146 9561b9668dc6
child 1148 c7ffa9f5adc1
(svn r1648) -Fix: server can now pause and unpause a game through the console. Use 'pause' and 'unpause'
console_cmds.c
main_gui.c
misc_cmd.c
--- a/console_cmds.c	Mon Jan 24 20:55:54 2005 +0000
+++ b/console_cmds.c	Mon Jan 24 21:33:44 2005 +0000
@@ -379,6 +379,28 @@
 	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 @@
 	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");
 
--- a/main_gui.c	Mon Jan 24 20:55:54 2005 +0000
+++ b/main_gui.c	Mon Jan 24 21:33:44 2005 +0000
@@ -159,7 +159,7 @@
 {
 	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);
 }
 
--- a/misc_cmd.c	Mon Jan 24 20:55:54 2005 +0000
+++ b/misc_cmd.c	Mon Jan 24 21:33:44 2005 +0000
@@ -175,8 +175,8 @@
 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);
 	}