From 4438e45a4339acd227c772b371722d852e1679b9 Mon Sep 17 00:00:00 2001 From: divverent Date: Tue, 8 Nov 2011 11:29:00 +0000 Subject: [PATCH] allow listen server owner to pause the game (this also allows rcon pause) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11533 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=28c03f315bdcb6be7b9c3b06a384a1a905ebfa85 --- host_cmd.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/host_cmd.c b/host_cmd.c index 482d7e58..8843c61b 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -1699,16 +1699,36 @@ Host_Pause_f */ void Host_Pause_f (void) { - if (!pausable.integer) - SV_ClientPrint("Pause not allowed.\n"); + if (cmd_source == src_command) + { + // if running a client, try to send over network so the pause is handled by the server + if (cls.state == ca_connected) + { + Cmd_ForwardToServer (); + return; + } + print = Con_Printf; + } else + print = SV_ClientPrintf; + + if (!pausable.integer) { - sv.paused ^= 1; - SV_BroadcastPrintf("%s %spaused the game\n", host_client->name, sv.paused ? "" : "un"); - // send notification to all clients - MSG_WriteByte(&sv.reliable_datagram, svc_setpause); - MSG_WriteByte(&sv.reliable_datagram, sv.paused); + if (cmd_source == src_client) + { + if(cls.state == ca_dedicated || host_client == &svs.clients[0]) // non-admin + { + print("Pause not allowed.\n"); + return; + } + } } + + sv.paused ^= 1; + SV_BroadcastPrintf("%s %spaused the game\n", host_client->name, sv.paused ? "" : "un"); + // send notification to all clients + MSG_WriteByte(&sv.reliable_datagram, svc_setpause); + MSG_WriteByte(&sv.reliable_datagram, sv.paused); } /* @@ -2904,7 +2924,7 @@ void Host_InitCommands (void) Cmd_AddCommand_WithClientCommand ("say_team", Host_Say_Team_f, Host_Say_Team_f, "send a chat message to your team on the server"); Cmd_AddCommand_WithClientCommand ("tell", Host_Tell_f, Host_Tell_f, "send a chat message to only one person on the server"); Cmd_AddCommand_WithClientCommand ("kill", NULL, Host_Kill_f, "die instantly"); - Cmd_AddCommand_WithClientCommand ("pause", NULL, Host_Pause_f, "pause the game (if the server allows pausing)"); + Cmd_AddCommand_WithClientCommand ("pause", Host_Pause_f, Host_Pause_f, "pause the game (if the server allows pausing)"); Cmd_AddCommand ("kick", Host_Kick_f, "kick a player off the server by number or name"); Cmd_AddCommand_WithClientCommand ("ping", Host_Ping_f, Host_Ping_f, "print ping times of all players on the server"); Cmd_AddCommand ("load", Host_Loadgame_f, "load a saved game file"); -- 2.39.2