]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
- add debug prints for saving/loading games for prvm_entityparsing
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 16 Dec 2008 07:01:36 +0000 (07:01 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 16 Dec 2008 07:01:36 +0000 (07:01 +0000)
- make PRVM_UglyValueString escape " to \" (note that loading does not match that, as parsebackslash is off in the call to COM_ParseToken_Simple - why?)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8590 d7cf8633-e32d-0410-b094-e92efae38249

host_cmd.c
prvm_edict.c

index c0a38fca9f3799a96fe68a1d1424979764ff29f3..6b4fbe6f52f4d99c7f1b22e09ea4b358f529824b 100644 (file)
@@ -35,6 +35,7 @@ cvar_t r_fixtrans_auto = {0, "r_fixtrans_auto", "0", "automatically fixtrans tex
 qboolean allowcheats = false;
 
 extern qboolean host_shuttingdown;
+extern cvar_t developer_entityparsing;
 
 /*
 ==================
@@ -636,6 +637,9 @@ void Host_Loadgame_f (void)
                return;
        }
 
+       if(developer_entityparsing.integer)
+               Con_Printf("Host_Loadgame_f: loading version\n");
+
        // version
        COM_ParseToken_Simple(&t, false, false);
        version = atoi(com_token);
@@ -646,6 +650,9 @@ void Host_Loadgame_f (void)
                return;
        }
 
+       if(developer_entityparsing.integer)
+               Con_Printf("Host_Loadgame_f: loading description\n");
+
        // description
        COM_ParseToken_Simple(&t, false, false);
 
@@ -660,16 +667,25 @@ void Host_Loadgame_f (void)
        current_skill = (int)(atof(com_token) + 0.5);
        Cvar_SetValue ("skill", (float)current_skill);
 
+       if(developer_entityparsing.integer)
+               Con_Printf("Host_Loadgame_f: loading mapname\n");
+
        // mapname
        COM_ParseToken_Simple(&t, false, false);
        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);
        time = atof(com_token);
 
        allowcheats = sv_cheats.integer != 0;
 
+       if(developer_entityparsing.integer)
+               Con_Printf("Host_Loadgame_f: spawning server\n");
+
        SV_SpawnServer (mapname);
        if (!sv.active)
        {
@@ -680,6 +696,9 @@ void Host_Loadgame_f (void)
        sv.paused = true;               // pause until all clients connect
        sv.loadgame = true;
 
+       if(developer_entityparsing.integer)
+               Con_Printf("Host_Loadgame_f: loading light styles\n");
+
 // load the light styles
 
        SV_VM_Begin();
@@ -701,6 +720,9 @@ void Host_Loadgame_f (void)
                strlcpy(sv.lightstyles[i], com_token, sizeof(sv.lightstyles[i]));
        }
 
+       if(developer_entityparsing.integer)
+               Con_Printf("Host_Loadgame_f: skipping until globals\n");
+
        // now skip everything before the first opening brace
        // (this is for forward compatibility, so that older versions (at
        // least ones with this fix) can load savegames with extra data before the
@@ -738,6 +760,9 @@ void Host_Loadgame_f (void)
 
                if (entnum == -1)
                {
+                       if(developer_entityparsing.integer)
+                               Con_Printf("Host_Loadgame_f: loading globals\n");
+
                        // parse the global vars
                        PRVM_ED_ParseGlobals (start);
                }
@@ -754,6 +779,10 @@ void Host_Loadgame_f (void)
                        ent = PRVM_EDICT_NUM(entnum);
                        memset (ent->fields.server, 0, prog->progs->entityfields * 4);
                        ent->priv.server->free = false;
+
+                       if(developer_entityparsing.integer)
+                               Con_Printf("Host_Loadgame_f: loading edict %d\n", entnum);
+
                        PRVM_ED_ParseEdict (start, ent);
 
                        // link it into the bsp tree
@@ -772,6 +801,9 @@ void Host_Loadgame_f (void)
        for (i = 0;i < NUM_SPAWN_PARMS;i++)
                svs.clients[0].spawn_parms[i] = spawn_parms[i];
 
+       if(developer_entityparsing.integer)
+               Con_Printf("Host_Loadgame_f: skipping until extended data\n");
+
        // read extended data if present
        // the extended data is stored inside a /* */ comment block, which the
        // parser intentionally skips, so we have to check for it manually here
@@ -779,6 +811,9 @@ void Host_Loadgame_f (void)
                end++;
        if (end[0] == '/' && end[1] == '*' && (end[2] == '\r' || end[2] == '\n'))
        {
+               if(developer_entityparsing.integer)
+                       Con_Printf("Host_Loadgame_f: loading extended data\n");
+
                Con_Printf("Loading extended DarkPlaces savegame\n");
                t = end + 2;
                memset(sv.lightstyles[0], 0, sizeof(sv.lightstyles));
@@ -825,6 +860,9 @@ void Host_Loadgame_f (void)
                }
        }
 
+       if(developer_entityparsing.integer)
+               Con_Printf("Host_Loadgame_f: finished\n");
+
        SV_VM_End();
 
        // make sure we're connected to loopback
index 7c6e16ce3eff009f21b462068d8f9c46c1cbc51e..742e4b988b9ee3ae77aecb1f9b183fb408a1e287 100644 (file)
@@ -507,6 +507,11 @@ char *PRVM_UglyValueString (etype_t type, prvm_eval_t *val)
                                line[i++] = '\\';
                                line[i++] = '\\';
                        }
+                       else if (*s == '"')
+                       {
+                               line[i++] = '\\';
+                               line[i++] = '"';
+                       }
                        else
                                line[i++] = *s;
                        s++;
@@ -686,6 +691,7 @@ PRVM_ED_Write
 For savegames
 =============
 */
+extern cvar_t developer_entityparsing;
 void PRVM_ED_Write (qfile_t *f, prvm_edict_t *ed)
 {
        ddef_t  *d;
@@ -706,6 +712,10 @@ void PRVM_ED_Write (qfile_t *f, prvm_edict_t *ed)
        {
                d = &prog->fielddefs[i];
                name = PRVM_GetString(d->s_name);
+
+               if(developer_entityparsing.integer)
+                       Con_Printf("PRVM_ED_Write: at entity %d field %s\n", PRVM_NUM_FOR_EDICT(ed), name);
+
                if (name[strlen(name)-2] == '_')
                        continue;       // skip _x, _y, _z vars
 
@@ -884,6 +894,10 @@ void PRVM_ED_WriteGlobals (qfile_t *f)
                        continue;
 
                name = PRVM_GetString(def->s_name);
+
+               if(developer_entityparsing.integer)
+                       Con_Printf("PRVM_ED_WriteGlobals: at global %s\n", name);
+
                FS_Printf(f,"\"%s\" ", name);
                FS_Printf(f,"\"%s\"\n", PRVM_UglyValueString((etype_t)type, (prvm_eval_t *)&prog->globals.generic[def->ofs]));
        }
@@ -908,12 +922,18 @@ void PRVM_ED_ParseGlobals (const char *data)
                if (com_token[0] == '}')
                        break;
 
+               if (developer_entityparsing.integer)
+                       Con_Printf("Key: \"%s\"", com_token);
+
                strlcpy (keyname, com_token, sizeof(keyname));
 
                // parse value
                if (!COM_ParseToken_Simple(&data, false, true))
                        PRVM_ERROR ("PRVM_ED_ParseGlobals: EOF without closing brace");
 
+               if (developer_entityparsing.integer)
+                       Con_Printf(" \"%s\"\n", com_token);
+
                if (com_token[0] == '}')
                        PRVM_ERROR ("PRVM_ED_ParseGlobals: closing brace without data");
 
@@ -1150,7 +1170,6 @@ ed should be a properly initialized empty edict.
 Used for initial level load and for savegames.
 ====================
 */
-extern cvar_t developer_entityparsing;
 const char *PRVM_ED_ParseEdict (const char *data, prvm_edict_t *ent)
 {
        ddef_t *key;