changed COM_ParseToken_Simple to have a parsebackslash option, usually
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 24 Sep 2007 18:45:51 +0000 (18:45 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 24 Sep 2007 18:45:51 +0000 (18:45 +0000)
false, this fixes the problem with broken wad names in hlbsp

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

13 files changed:
cl_parse.c
cl_particles.c
common.c
common.h
console.c
host_cmd.c
libcurl.c
menu.c
model_brush.c
prvm_cmds.c
prvm_edict.c
r_shadow.c
sv_main.c

index e0c102e..cb93348 100644 (file)
@@ -336,13 +336,13 @@ void CL_ParseEntityLump(char *entdata)
        data = entdata;
        if (!data)
                return;
-       if (!COM_ParseToken_Simple(&data, false))
+       if (!COM_ParseToken_Simple(&data, false, false))
                return; // error
        if (com_token[0] != '{')
                return; // error
        while (1)
        {
-               if (!COM_ParseToken_Simple(&data, false))
+               if (!COM_ParseToken_Simple(&data, false, false))
                        return; // error
                if (com_token[0] == '}')
                        break; // end of worldspawn
@@ -352,7 +352,7 @@ void CL_ParseEntityLump(char *entdata)
                        strlcpy (key, com_token, sizeof (key));
                while (key[strlen(key)-1] == ' ') // remove trailing spaces
                        key[strlen(key)-1] = 0;
-               if (!COM_ParseToken_Simple(&data, false))
+               if (!COM_ParseToken_Simple(&data, false, false))
                        return; // error
                strlcpy (value, com_token, sizeof (value));
                if (!strcmp("sky", key))
index ad30b92..0a24cf7 100644 (file)
@@ -209,7 +209,7 @@ void CL_Particles_ParseEffectInfo(const char *textstart, const char *textend)
                        argv[arrayindex][0] = 0;
                for (;;)
                {
-                       if (!COM_ParseToken_Simple(&text, true))
+                       if (!COM_ParseToken_Simple(&text, true, false))
                                return;
                        if (!strcmp(com_token, "\n"))
                                break;
index e0154ee..6c59c33 100644 (file)
--- a/common.c
+++ b/common.c
@@ -670,7 +670,7 @@ COM_ParseToken_Simple
 Parse a token out of a string
 ==============
 */
-int COM_ParseToken_Simple(const char **datapointer, int returnnewline)
+int COM_ParseToken_Simple(const char **datapointer, qboolean returnnewline, qboolean parsebackslash)
 {
        int len;
        int c;
@@ -730,7 +730,7 @@ skipwhite:
                for (data++;*data && *data != '\"';data++)
                {
                        c = *data;
-                       if (*data == '\\')
+                       if (*data == '\\' && parsebackslash)
                        {
                                data++;
                                c = *data;
@@ -783,7 +783,7 @@ COM_ParseToken_QuakeC
 Parse a token out of a string
 ==============
 */
-int COM_ParseToken_QuakeC(const char **datapointer, int returnnewline)
+int COM_ParseToken_QuakeC(const char **datapointer, qboolean returnnewline)
 {
        int len;
        int c;
@@ -897,7 +897,7 @@ COM_ParseToken_VM_Tokenize
 Parse a token out of a string
 ==============
 */
-int COM_ParseToken_VM_Tokenize(const char **datapointer, int returnnewline)
+int COM_ParseToken_VM_Tokenize(const char **datapointer, qboolean returnnewline)
 {
        int len;
        int c;
index 47f62bb..0eaa2e2 100644 (file)
--- a/common.h
+++ b/common.h
@@ -202,9 +202,9 @@ float MSG_ReadAngle (protocolversion_t protocol);
 
 extern char com_token[MAX_INPUTLINE];
 
-int COM_ParseToken_Simple(const char **datapointer, int returnnewline);
-int COM_ParseToken_QuakeC(const char **datapointer, int returnnewline);
-int COM_ParseToken_VM_Tokenize(const char **datapointer, int returnnewline);
+int COM_ParseToken_Simple(const char **datapointer, qboolean returnnewline, qboolean parsebackslash);
+int COM_ParseToken_QuakeC(const char **datapointer, qboolean returnnewline);
+int COM_ParseToken_VM_Tokenize(const char **datapointer, qboolean returnnewline);
 int COM_ParseToken_Console(const char **datapointer);
 
 extern int com_argc;
index d7e614a..4c99296 100644 (file)
--- a/console.c
+++ b/console.c
@@ -1282,7 +1282,7 @@ qboolean GetMapList (const char *s, char *completedname, int completednamebuffer
                                for (;;)
                                {
                                        int l;
-                                       if (!COM_ParseToken_Simple(&data, false))
+                                       if (!COM_ParseToken_Simple(&data, false, false))
                                                break;
                                        if (com_token[0] == '{')
                                                continue;
@@ -1293,7 +1293,7 @@ qboolean GetMapList (const char *s, char *completedname, int completednamebuffer
                                        for (l = 0;l < (int)sizeof(keyname) - 1 && com_token[k+l] && com_token[k+l] > ' ';l++)
                                                keyname[l] = com_token[k+l];
                                        keyname[l] = 0;
-                                       if (!COM_ParseToken_Simple(&data, false))
+                                       if (!COM_ParseToken_Simple(&data, false, false))
                                                break;
                                        if (developer.integer >= 100)
                                                Con_Printf("key: %s %s\n", keyname, com_token);
index dbd917d..21c8690 100644 (file)
@@ -569,7 +569,7 @@ void Host_Loadgame_f (void)
        }
 
        // version
-       COM_ParseToken_Simple(&t, false);
+       COM_ParseToken_Simple(&t, false, false);
        version = atoi(com_token);
        if (version != SAVEGAME_VERSION)
        {
@@ -579,25 +579,25 @@ void Host_Loadgame_f (void)
        }
 
        // description
-       COM_ParseToken_Simple(&t, false);
+       COM_ParseToken_Simple(&t, false, false);
 
        for (i = 0;i < NUM_SPAWN_PARMS;i++)
        {
-               COM_ParseToken_Simple(&t, false);
+               COM_ParseToken_Simple(&t, false, false);
                spawn_parms[i] = atof(com_token);
        }
        // skill
-       COM_ParseToken_Simple(&t, false);
+       COM_ParseToken_Simple(&t, false, false);
 // 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);
 
        // mapname
-       COM_ParseToken_Simple(&t, false);
+       COM_ParseToken_Simple(&t, false, false);
        strlcpy (mapname, com_token, sizeof(mapname));
 
        // time
-       COM_ParseToken_Simple(&t, false);
+       COM_ParseToken_Simple(&t, false, false);
        time = atof(com_token);
 
        allowcheats = sv_cheats.integer != 0;
@@ -618,7 +618,7 @@ void Host_Loadgame_f (void)
        {
                // light style
                oldt = t;
-               COM_ParseToken_Simple(&t, false);
+               COM_ParseToken_Simple(&t, false, false);
                // if this is a 64 lightstyle savegame produced by Quake, stop now
                // we have to check this because darkplaces saves 256 lightstyle savegames
                if (com_token[0] == '{')
@@ -636,7 +636,7 @@ void Host_Loadgame_f (void)
        for(;;)
        {
                oldt = t;
-               COM_ParseToken_Simple(&t, false);
+               COM_ParseToken_Simple(&t, false, false);
                if (com_token[0] == '{')
                {
                        t = oldt;
@@ -651,10 +651,10 @@ void Host_Loadgame_f (void)
        for (;;)
        {
                start = t;
-               while (COM_ParseToken_Simple(&t, false))
+               while (COM_ParseToken_Simple(&t, false, false))
                        if (!strcmp(com_token, "}"))
                                break;
-               if (!COM_ParseToken_Simple(&start, false))
+               if (!COM_ParseToken_Simple(&start, false, false))
                {
                        // end of file
                        break;
@@ -1585,7 +1585,7 @@ void Host_Kick_f (void)
                if (Cmd_Argc() > 2)
                {
                        message = Cmd_Args();
-                       COM_ParseToken_Simple(&message, false);
+                       COM_ParseToken_Simple(&message, false, false);
                        if (byNumber)
                        {
                                message++;                                                      // skip the #
index 301a81b..843fb74 100644 (file)
--- a/libcurl.c
+++ b/libcurl.c
@@ -1276,7 +1276,7 @@ void Curl_ClearRequirements()
        }
        p = sv_curl_serverpackages.string;
        Con_DPrintf("Require all of: %s\n", p);
-       while(COM_ParseToken_Simple(&p, false))
+       while(COM_ParseToken_Simple(&p, false, false))
        {
                Con_DPrintf("Require: %s\n", com_token);
                Curl_RequireFile(com_token);
diff --git a/menu.c b/menu.c
index 1b0a0b2..aa2d6e3 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -897,10 +897,10 @@ static void M_ScanSaves (void)
                buf[sizeof(buf) - 1] = 0;
                t = buf;
                // version
-               COM_ParseToken_Simple(&t, false);
+               COM_ParseToken_Simple(&t, false, false);
                version = atoi(com_token);
                // description
-               COM_ParseToken_Simple(&t, false);
+               COM_ParseToken_Simple(&t, false, false);
                strlcpy (m_filenames[i], com_token, sizeof (m_filenames[i]));
 
        // change _ back to space
index 6c776b3..ffefe93 100644 (file)
@@ -1761,13 +1761,13 @@ static void Mod_Q1BSP_ParseWadsFromEntityLump(const char *data)
        int i, j, k;
        if (!data)
                return;
-       if (!COM_ParseToken_Simple(&data, false))
+       if (!COM_ParseToken_Simple(&data, false, false))
                return; // error
        if (com_token[0] != '{')
                return; // error
        while (1)
        {
-               if (!COM_ParseToken_Simple(&data, false))
+               if (!COM_ParseToken_Simple(&data, false, false))
                        return; // error
                if (com_token[0] == '}')
                        break; // end of worldspawn
@@ -1777,7 +1777,7 @@ static void Mod_Q1BSP_ParseWadsFromEntityLump(const char *data)
                        strlcpy(key, com_token, sizeof(key));
                while (key[strlen(key)-1] == ' ') // remove trailing spaces
                        key[strlen(key)-1] = 0;
-               if (!COM_ParseToken_Simple(&data, false))
+               if (!COM_ParseToken_Simple(&data, false, false))
                        return; // error
                dpsnprintf(value, sizeof(value), "%s", com_token);
                if (!strcmp("wad", key)) // for HalfLife maps
@@ -2716,12 +2716,12 @@ static void Mod_Q1BSP_LoadMapBrushes(void)
        if (!maptext)
                return;
        text = maptext;
-       if (!COM_ParseToken_Simple(&data, false))
+       if (!COM_ParseToken_Simple(&data, false, false))
                return; // error
        submodel = 0;
        for (;;)
        {
-               if (!COM_ParseToken_Simple(&data, false))
+               if (!COM_ParseToken_Simple(&data, false, false))
                        break;
                if (com_token[0] != '{')
                        return; // error
@@ -2732,7 +2732,7 @@ static void Mod_Q1BSP_LoadMapBrushes(void)
                brushes = Mem_Alloc(loadmodel->mempool, maxbrushes * sizeof(mbrush_t));
                for (;;)
                {
-                       if (!COM_ParseToken_Simple(&data, false))
+                       if (!COM_ParseToken_Simple(&data, false, false))
                                return; // error
                        if (com_token[0] == '}')
                                break; // end of entity
@@ -2756,7 +2756,7 @@ static void Mod_Q1BSP_LoadMapBrushes(void)
                                }
                                for (;;)
                                {
-                                       if (!COM_ParseToken_Simple(&data, false))
+                                       if (!COM_ParseToken_Simple(&data, false, false))
                                                return; // error
                                        if (com_token[0] == '}')
                                                break; // end of brush
@@ -2765,25 +2765,25 @@ static void Mod_Q1BSP_LoadMapBrushes(void)
                                        // FIXME: support hl .map format
                                        for (pointnum = 0;pointnum < 3;pointnum++)
                                        {
-                                               COM_ParseToken_Simple(&data, false);
+                                               COM_ParseToken_Simple(&data, false, false);
                                                for (componentnum = 0;componentnum < 3;componentnum++)
                                                {
-                                                       COM_ParseToken_Simple(&data, false);
+                                                       COM_ParseToken_Simple(&data, false, false);
                                                        point[pointnum][componentnum] = atof(com_token);
                                                }
-                                               COM_ParseToken_Simple(&data, false);
+                                               COM_ParseToken_Simple(&data, false, false);
                                        }
-                                       COM_ParseToken_Simple(&data, false);
+                                       COM_ParseToken_Simple(&data, false, false);
                                        strlcpy(facetexture, com_token, sizeof(facetexture));
-                                       COM_ParseToken_Simple(&data, false);
+                                       COM_ParseToken_Simple(&data, false, false);
                                        //scroll_s = atof(com_token);
-                                       COM_ParseToken_Simple(&data, false);
+                                       COM_ParseToken_Simple(&data, false, false);
                                        //scroll_t = atof(com_token);
-                                       COM_ParseToken_Simple(&data, false);
+                                       COM_ParseToken_Simple(&data, false, false);
                                        //rotate = atof(com_token);
-                                       COM_ParseToken_Simple(&data, false);
+                                       COM_ParseToken_Simple(&data, false, false);
                                        //scale_s = atof(com_token);
-                                       COM_ParseToken_Simple(&data, false);
+                                       COM_ParseToken_Simple(&data, false, false);
                                        //scale_t = atof(com_token);
                                        TriangleNormal(point[0], point[1], point[2], planenormal);
                                        VectorNormalizeDouble(planenormal);
@@ -4135,11 +4135,11 @@ static void Mod_Q3BSP_LoadEntities(lump_t *l)
        memcpy(loadmodel->brush.entities, mod_base + l->fileofs, l->filelen);
        data = loadmodel->brush.entities;
        // some Q3 maps override the lightgrid_cellsize with a worldspawn key
-       if (data && COM_ParseToken_Simple(&data, false) && com_token[0] == '{')
+       if (data && COM_ParseToken_Simple(&data, false, false) && com_token[0] == '{')
        {
                while (1)
                {
-                       if (!COM_ParseToken_Simple(&data, false))
+                       if (!COM_ParseToken_Simple(&data, false, false))
                                break; // error
                        if (com_token[0] == '}')
                                break; // end of worldspawn
@@ -4149,7 +4149,7 @@ static void Mod_Q3BSP_LoadEntities(lump_t *l)
                                strlcpy(key, com_token, sizeof(key));
                        while (key[strlen(key)-1] == ' ') // remove trailing spaces
                                key[strlen(key)-1] = 0;
-                       if (!COM_ParseToken_Simple(&data, false))
+                       if (!COM_ParseToken_Simple(&data, false, false))
                                break; // error
                        strlcpy(value, com_token, sizeof(value));
                        if (!strcmp("gridsize", key))
index 7710cf7..f2e1720 100644 (file)
@@ -2214,7 +2214,7 @@ void VM_parseentitydata(void)
        data = PRVM_G_STRING(OFS_PARM1);
 
        // parse the opening brace
-       if (!COM_ParseToken_Simple(&data, false) || com_token[0] != '{' )
+       if (!COM_ParseToken_Simple(&data, false, false) || com_token[0] != '{' )
                PRVM_ERROR ("VM_parseentitydata: %s: Couldn't parse entity data:\n%s", PRVM_NAME, data );
 
        PRVM_ED_ParseEdict (data, ent);
index 4d4be14..fd6b1d0 100644 (file)
@@ -872,7 +872,7 @@ void PRVM_ED_ParseGlobals (const char *data)
        while (1)
        {
                // parse key
-               if (!COM_ParseToken_Simple(&data, false))
+               if (!COM_ParseToken_Simple(&data, false, false))
                        PRVM_ERROR ("PRVM_ED_ParseGlobals: EOF without closing brace");
                if (com_token[0] == '}')
                        break;
@@ -880,7 +880,7 @@ void PRVM_ED_ParseGlobals (const char *data)
                strlcpy (keyname, com_token, sizeof(keyname));
 
                // parse value
-               if (!COM_ParseToken_Simple(&data, false))
+               if (!COM_ParseToken_Simple(&data, false, true))
                        PRVM_ERROR ("PRVM_ED_ParseGlobals: EOF without closing brace");
 
                if (com_token[0] == '}')
@@ -1129,7 +1129,7 @@ const char *PRVM_ED_ParseEdict (const char *data, prvm_edict_t *ent)
        while (1)
        {
        // parse key
-               if (!COM_ParseToken_Simple(&data, false))
+               if (!COM_ParseToken_Simple(&data, false, false))
                        PRVM_ERROR ("PRVM_ED_ParseEdict: EOF without closing brace");
                if (developer_entityparsing.integer)
                        Con_Printf("Key: \"%s\"", com_token);
@@ -1161,7 +1161,7 @@ const char *PRVM_ED_ParseEdict (const char *data, prvm_edict_t *ent)
                }
 
        // parse value
-               if (!COM_ParseToken_Simple(&data, false))
+               if (!COM_ParseToken_Simple(&data, false, true))
                        PRVM_ERROR ("PRVM_ED_ParseEdict: EOF without closing brace");
                if (developer_entityparsing.integer)
                        Con_Printf(" \"%s\"\n", com_token);
@@ -1236,7 +1236,7 @@ void PRVM_ED_LoadFromFile (const char *data)
        while (1)
        {
 // parse the opening brace
-               if (!COM_ParseToken_Simple(&data, false))
+               if (!COM_ParseToken_Simple(&data, false, false))
                        break;
                if (com_token[0] != '{')
                        PRVM_ERROR ("PRVM_ED_LoadFromFile: %s: found %s when expecting {", PRVM_NAME, com_token);
index 1ea3a7c..f5df7b4 100644 (file)
@@ -3614,7 +3614,7 @@ void R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(void)
                data = r_refdef.worldmodel->brush.entities;
        if (!data)
                return;
-       for (entnum = 0;COM_ParseToken_Simple(&data, false) && com_token[0] == '{';entnum++)
+       for (entnum = 0;COM_ParseToken_Simple(&data, false, false) && com_token[0] == '{';entnum++)
        {
                type = LIGHTTYPE_MINUSX;
                origin[0] = origin[1] = origin[2] = 0;
@@ -3632,7 +3632,7 @@ void R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(void)
                islight = false;
                while (1)
                {
-                       if (!COM_ParseToken_Simple(&data, false))
+                       if (!COM_ParseToken_Simple(&data, false, false))
                                break; // error
                        if (com_token[0] == '}')
                                break; // end of entity
@@ -3642,7 +3642,7 @@ void R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(void)
                                strlcpy(key, com_token, sizeof(key));
                        while (key[strlen(key)-1] == ' ') // remove trailing spaces
                                key[strlen(key)-1] = 0;
-                       if (!COM_ParseToken_Simple(&data, false))
+                       if (!COM_ParseToken_Simple(&data, false, false))
                                break; // error
                        strlcpy(value, com_token, sizeof(value));
 
index 753c96e..7b56c8f 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -2203,7 +2203,7 @@ int SV_ParticleEffectIndex(const char *name)
                                argc = 0;
                                for (;;)
                                {
-                                       if (!COM_ParseToken_Simple(&text, true) || !strcmp(com_token, "\n"))
+                                       if (!COM_ParseToken_Simple(&text, true, false) || !strcmp(com_token, "\n"))
                                                break;
                                        if (argc < 16)
                                        {