From 40a9038baf65f593ddbf4117c618242953dedefa Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 24 Sep 2007 18:45:51 +0000 Subject: [PATCH] changed COM_ParseToken_Simple to have a parsebackslash option, usually 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 --- cl_parse.c | 6 +++--- cl_particles.c | 2 +- common.c | 8 ++++---- common.h | 6 +++--- console.c | 4 ++-- host_cmd.c | 22 +++++++++++----------- libcurl.c | 2 +- menu.c | 4 ++-- model_brush.c | 38 +++++++++++++++++++------------------- prvm_cmds.c | 2 +- prvm_edict.c | 10 +++++----- r_shadow.c | 6 +++--- sv_main.c | 2 +- 13 files changed, 56 insertions(+), 56 deletions(-) diff --git a/cl_parse.c b/cl_parse.c index e0c102e5..cb933480 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -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)) diff --git a/cl_particles.c b/cl_particles.c index ad30b92e..0a24cf75 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -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; diff --git a/common.c b/common.c index e0154eec..6c59c33c 100644 --- 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; diff --git a/common.h b/common.h index 47f62bb9..0eaa2e25 100644 --- 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; diff --git a/console.c b/console.c index d7e614a1..4c992962 100644 --- 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); diff --git a/host_cmd.c b/host_cmd.c index dbd917dc..21c8690a 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -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 # diff --git a/libcurl.c b/libcurl.c index 301a81b7..843fb74a 100644 --- 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 1b0a0b2b..aa2d6e34 100644 --- 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 diff --git a/model_brush.c b/model_brush.c index 6c776b30..ffefe938 100644 --- a/model_brush.c +++ b/model_brush.c @@ -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)) diff --git a/prvm_cmds.c b/prvm_cmds.c index 7710cf78..f2e1720d 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -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); diff --git a/prvm_edict.c b/prvm_edict.c index 4d4be14b..fd6b1d03 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -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); diff --git a/r_shadow.c b/r_shadow.c index 1ea3a7c3..f5df7b45 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -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)); diff --git a/sv_main.c b/sv_main.c index 753c96ee..7b56c8fc 100644 --- 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) { -- 2.39.2