]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
allow listen server owner to pause the game (this also allows rcon pause)
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 8 Nov 2011 11:29:00 +0000 (11:29 +0000)
committerRudolf Polzer <divverent@xonotic.org>
Tue, 8 Nov 2011 20:56:29 +0000 (21:56 +0100)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11533 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=28c03f315bdcb6be7b9c3b06a384a1a905ebfa85

host_cmd.c

index 482d7e589da542ab9202fb05acdda38e4f0f71fe..8843c61b0464cec3e9a3c0f2879b9a9d0a80f647 100644 (file)
@@ -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");