]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host_cmd.c
use prog->progs_mempool for server DP_SKELETONOBJECTS storage, not
[xonotic/darkplaces.git] / host_cmd.c
index 0224ec4e362e7ffb933548a4246d043827a1bfbf..350cef0ddf9336d26a27cdd046683009d981f9bf 100644 (file)
@@ -804,7 +804,7 @@ static void Host_Loadgame_f (void)
                Con_Printf("Host_Loadgame_f: loading version\n");
 
        // version
-       COM_ParseToken_Simple(&t, false, false);
+       COM_ParseToken_Simple(&t, false, false, true);
        version = atoi(com_token);
        if (version != SAVEGAME_VERSION)
        {
@@ -817,15 +817,15 @@ static void Host_Loadgame_f (void)
                Con_Printf("Host_Loadgame_f: loading description\n");
 
        // description
-       COM_ParseToken_Simple(&t, false, false);
+       COM_ParseToken_Simple(&t, false, false, true);
 
        for (i = 0;i < NUM_SPAWN_PARMS;i++)
        {
-               COM_ParseToken_Simple(&t, false, false);
+               COM_ParseToken_Simple(&t, false, false, true);
                spawn_parms[i] = atof(com_token);
        }
        // skill
-       COM_ParseToken_Simple(&t, false, false);
+       COM_ParseToken_Simple(&t, false, false, true);
 // this silliness is so we can load 1.06 save files, which have float skill values
        current_skill = (int)(atof(com_token) + 0.5);
        Cvar_SetValue ("skill", (float)current_skill);
@@ -834,14 +834,14 @@ static void Host_Loadgame_f (void)
                Con_Printf("Host_Loadgame_f: loading mapname\n");
 
        // mapname
-       COM_ParseToken_Simple(&t, false, false);
+       COM_ParseToken_Simple(&t, false, false, true);
        strlcpy (mapname, com_token, sizeof(mapname));
 
        if(developer_entityparsing.integer)
                Con_Printf("Host_Loadgame_f: loading time\n");
 
        // time
-       COM_ParseToken_Simple(&t, false, false);
+       COM_ParseToken_Simple(&t, false, false, true);
        time = atof(com_token);
 
        allowcheats = sv_cheats.integer != 0;
@@ -871,7 +871,7 @@ static void Host_Loadgame_f (void)
        {
                // light style
                start = t;
-               COM_ParseToken_Simple(&t, false, false);
+               COM_ParseToken_Simple(&t, false, false, true);
                // if this is a 64 lightstyle savegame produced by Quake, stop now
                // we have to check this because darkplaces may save more than 64
                if (com_token[0] == '{')
@@ -892,7 +892,7 @@ static void Host_Loadgame_f (void)
        for (;;)
        {
                start = t;
-               if (!COM_ParseToken_Simple(&t, false, false))
+               if (!COM_ParseToken_Simple(&t, false, false, true))
                        break;
                if (com_token[0] == '{')
                {
@@ -909,10 +909,10 @@ static void Host_Loadgame_f (void)
        for (;;)
        {
                start = t;
-               while (COM_ParseToken_Simple(&t, false, false))
+               while (COM_ParseToken_Simple(&t, false, false, true))
                        if (!strcmp(com_token, "}"))
                                break;
-               if (!COM_ParseToken_Simple(&start, false, false))
+               if (!COM_ParseToken_Simple(&start, false, false, true))
                {
                        // end of file
                        break;
@@ -988,13 +988,13 @@ static void Host_Loadgame_f (void)
                        memset(sv.lightstyles[0], 0, sizeof(sv.lightstyles));
                        memset(sv.model_precache[0], 0, sizeof(sv.model_precache));
                        memset(sv.sound_precache[0], 0, sizeof(sv.sound_precache));
-                       while (COM_ParseToken_Simple(&t, false, false))
+                       while (COM_ParseToken_Simple(&t, false, false, true))
                        {
                                if (!strcmp(com_token, "sv.lightstyles"))
                                {
-                                       COM_ParseToken_Simple(&t, false, false);
+                                       COM_ParseToken_Simple(&t, false, false, true);
                                        i = atoi(com_token);
-                                       COM_ParseToken_Simple(&t, false, false);
+                                       COM_ParseToken_Simple(&t, false, false, true);
                                        if (i >= 0 && i < MAX_LIGHTSTYLES)
                                                strlcpy(sv.lightstyles[i], com_token, sizeof(sv.lightstyles[i]));
                                        else
@@ -1002,9 +1002,9 @@ static void Host_Loadgame_f (void)
                                }
                                else if (!strcmp(com_token, "sv.model_precache"))
                                {
-                                       COM_ParseToken_Simple(&t, false, false);
+                                       COM_ParseToken_Simple(&t, false, false, true);
                                        i = atoi(com_token);
-                                       COM_ParseToken_Simple(&t, false, false);
+                                       COM_ParseToken_Simple(&t, false, false, true);
                                        if (i >= 0 && i < MAX_MODELS)
                                        {
                                                strlcpy(sv.model_precache[i], com_token, sizeof(sv.model_precache[i]));
@@ -1015,9 +1015,9 @@ static void Host_Loadgame_f (void)
                                }
                                else if (!strcmp(com_token, "sv.sound_precache"))
                                {
-                                       COM_ParseToken_Simple(&t, false, false);
+                                       COM_ParseToken_Simple(&t, false, false, true);
                                        i = atoi(com_token);
-                                       COM_ParseToken_Simple(&t, false, false);
+                                       COM_ParseToken_Simple(&t, false, false, true);
                                        if (i >= 0 && i < MAX_SOUNDS)
                                                strlcpy(sv.sound_precache[i], com_token, sizeof(sv.sound_precache[i]));
                                        else
@@ -1025,11 +1025,11 @@ static void Host_Loadgame_f (void)
                                }
                                else if (!strcmp(com_token, "sv.bufstr"))
                                {
-                                       COM_ParseToken_Simple(&t, false, false);
+                                       COM_ParseToken_Simple(&t, false, false, true);
                                        i = atoi(com_token);
-                                       COM_ParseToken_Simple(&t, false, false);
+                                       COM_ParseToken_Simple(&t, false, false, true);
                                        k = atoi(com_token);
-                                       COM_ParseToken_Simple(&t, false, false);
+                                       COM_ParseToken_Simple(&t, false, false, true);
                                        stringbuffer = (prvm_stringbuffer_t*) Mem_ExpandableArray_RecordAtIndex(&prog->stringbuffersarray, i);
                                        // VorteX: nasty code, cleanup required
                                        // create buffer at this index
@@ -1064,7 +1064,7 @@ static void Host_Loadgame_f (void)
                                        }
                                }       
                                // skip any trailing text or unrecognized commands
-                               while (COM_ParseToken_Simple(&t, true, false) && strcmp(com_token, "\n"))
+                               while (COM_ParseToken_Simple(&t, true, false, true) && strcmp(com_token, "\n"))
                                        ;
                        }
                }
@@ -1698,16 +1698,37 @@ Host_Pause_f
 */
 static void Host_Pause_f (void)
 {
-       if (!pausable.integer)
-               SV_ClientPrint("Pause not allowed.\n");
+       void (*print) (const char *fmt, ...);
+       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);
 }
 
 /*
@@ -1992,7 +2013,7 @@ static void Host_Kick_f (void)
                if (Cmd_Argc() > 2)
                {
                        message = Cmd_Args();
-                       COM_ParseToken_Simple(&message, false, false);
+                       COM_ParseToken_Simple(&message, false, false, true);
                        if (byNumber)
                        {
                                message++;                                                      // skip the #
@@ -2905,7 +2926,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");