]> 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)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 8 Nov 2011 11:29:00 +0000 (11:29 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11533 d7cf8633-e32d-0410-b094-e92efae38249

host_cmd.c

index b8c493b27f68cc455b71530488aa5da731cdf4d0..f2d6af53dc5b54caa621c608c9c0960337fc01f0 100644 (file)
@@ -1698,16 +1698,36 @@ Host_Pause_f
 */
 static 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);
 }
 
 /*
@@ -2905,7 +2925,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");