data = entdata;
if (!data)
return;
- if (!COM_ParseToken_Simple(&data, false, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
return; // error
if (com_token[0] != '{')
return; // error
while (1)
{
- if (!COM_ParseToken_Simple(&data, false, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
return; // error
if (com_token[0] == '}')
break; // end of worldspawn
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, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
return; // error
strlcpy (value, com_token, sizeof (value));
if (!strcmp("sky", key))
argv[arrayindex][0] = 0;
for (;;)
{
- if (!COM_ParseToken_Simple(&text, true, false))
+ if (!COM_ParseToken_Simple(&text, true, false, true))
return;
if (!strcmp(com_token, "\n"))
break;
bufptr = buf;
for(;;)
{
- if(!COM_ParseToken_Simple(&bufptr, true, false))
+ if(!COM_ParseToken_Simple(&bufptr, true, false, true))
break;
if(!strcmp(com_token, "\n"))
continue; // empty line
s2 = 1;
t2 = 1;
- if (COM_ParseToken_Simple(&bufptr, true, false) && strcmp(com_token, "\n"))
+ if (COM_ParseToken_Simple(&bufptr, true, false, true) && strcmp(com_token, "\n"))
{
strlcpy(texturename, com_token, sizeof(texturename));
s1 = atof(com_token);
- if (COM_ParseToken_Simple(&bufptr, true, false) && strcmp(com_token, "\n"))
+ if (COM_ParseToken_Simple(&bufptr, true, false, true) && strcmp(com_token, "\n"))
{
texturename[0] = 0;
t1 = atof(com_token);
- if (COM_ParseToken_Simple(&bufptr, true, false) && strcmp(com_token, "\n"))
+ if (COM_ParseToken_Simple(&bufptr, true, false, true) && strcmp(com_token, "\n"))
{
s2 = atof(com_token);
- if (COM_ParseToken_Simple(&bufptr, true, false) && strcmp(com_token, "\n"))
+ if (COM_ParseToken_Simple(&bufptr, true, false, true) && strcmp(com_token, "\n"))
{
t2 = atof(com_token);
strlcpy(texturename, "particles/particlefont.tga", sizeof(texturename));
- if (COM_ParseToken_Simple(&bufptr, true, false) && strcmp(com_token, "\n"))
+ if (COM_ParseToken_Simple(&bufptr, true, false, true) && strcmp(com_token, "\n"))
strlcpy(texturename, com_token, sizeof(texturename));
}
}
Parse a token out of a string
==============
*/
-int COM_ParseToken_Simple(const char **datapointer, qboolean returnnewline, qboolean parsebackslash)
+int COM_ParseToken_Simple(const char **datapointer, qboolean returnnewline, qboolean parsebackslash, qboolean parsecomments)
{
int len;
int c;
if (data[0] == '\r' && data[1] == '\n')
data++;
- if (data[0] == '/' && data[1] == '/')
+ if (parsecomments && data[0] == '/' && data[1] == '/')
{
// comment
while (*data && *data != '\n' && *data != '\r')
data++;
goto skipwhite;
}
- else if (data[0] == '/' && data[1] == '*')
+ else if (parsecomments && data[0] == '/' && data[1] == '*')
{
// comment
data++;
extern char com_token[MAX_INPUTLINE];
-int COM_ParseToken_Simple(const char **datapointer, qboolean returnnewline, qboolean parsebackslash);
+int COM_ParseToken_Simple(const char **datapointer, qboolean returnnewline, qboolean parsebackslash, qboolean parsecomments);
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);
for (;;)
{
int l;
- if (!COM_ParseToken_Simple(&data, false, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
break;
if (com_token[0] == '{')
continue;
for (l = 0;l < (int)sizeof(keyname) - 1 && com_token[k+l] && !ISWHITESPACE(com_token[k+l]);l++)
keyname[l] = com_token[k+l];
keyname[l] = 0;
- if (!COM_ParseToken_Simple(&data, false, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
break;
if (developer_extra.integer)
Con_DPrintf("key: %s %s\n", keyname, com_token);
stringlistinit(&resultbuf);
stringlistinit(&dirbuf);
- while(COM_ParseToken_Simple(&patterns, false, false))
+ while(COM_ParseToken_Simple(&patterns, false, false, true))
{
fssearch_t *search;
if(strchr(com_token, '/'))
ch = 0;
while(ch < 256)
{
- if(!COM_ParseToken_Simple(&p, false, false))
+ if(!COM_ParseToken_Simple(&p, false, false, true))
return;
switch(*com_token)
default:
if(!strcmp(com_token, "extraspacing"))
{
- if(!COM_ParseToken_Simple(&p, false, false))
+ if(!COM_ParseToken_Simple(&p, false, false, true))
return;
extraspacing = atof(com_token);
}
else if(!strcmp(com_token, "scale"))
{
- if(!COM_ParseToken_Simple(&p, false, false))
+ if(!COM_ParseToken_Simple(&p, false, false, true))
return;
fnt->settings.scale = atof(com_token);
}
else
{
Con_Printf("Warning: skipped unknown font property %s\n", com_token);
- if(!COM_ParseToken_Simple(&p, false, false))
+ if(!COM_ParseToken_Simple(&p, false, false, true))
return;
}
break;
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)
{
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);
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;
{
// 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] == '{')
for (;;)
{
start = t;
- if (!COM_ParseToken_Simple(&t, false, false))
+ if (!COM_ParseToken_Simple(&t, false, false, true))
break;
if (com_token[0] == '{')
{
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;
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
}
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]));
}
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
}
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
}
}
// 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"))
;
}
}
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 #
foundone = Curl_SendRequirement(req->filename, foundone, sendbuffer, sizeof(sendbuffer)) || foundone;
p = sv_curl_serverpackages.string;
- while(COM_ParseToken_Simple(&p, false, false))
+ while(COM_ParseToken_Simple(&p, false, false, true))
foundone = Curl_SendRequirement(com_token, foundone, sendbuffer, sizeof(sendbuffer)) || foundone;
if(foundone)
buf[len] = 0;
t = buf;
// version
- COM_ParseToken_Simple(&t, false, false);
+ COM_ParseToken_Simple(&t, false, false, true);
//version = atoi(com_token);
// description
- COM_ParseToken_Simple(&t, false, false);
+ COM_ParseToken_Simple(&t, false, false, true);
strlcpy (m_filenames[i], com_token, sizeof (m_filenames[i]));
// change _ back to space
int i, j, k;
if (!data)
return;
- if (!COM_ParseToken_Simple(&data, false, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
return; // error
if (com_token[0] != '{')
return; // error
while (1)
{
- if (!COM_ParseToken_Simple(&data, false, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
return; // error
if (com_token[0] == '}')
break; // end of worldspawn
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, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
return; // error
dpsnprintf(value, sizeof(value), "%s", com_token);
if (!strcmp("wad", key)) // for HalfLife maps
if (!maptext)
return;
text = maptext;
- if (!COM_ParseToken_Simple(&data, false, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
return; // error
submodel = 0;
for (;;)
{
- if (!COM_ParseToken_Simple(&data, false, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
break;
if (com_token[0] != '{')
return; // error
brushes = Mem_Alloc(loadmodel->mempool, maxbrushes * sizeof(mbrush_t));
for (;;)
{
- if (!COM_ParseToken_Simple(&data, false, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
return; // error
if (com_token[0] == '}')
break; // end of entity
}
for (;;)
{
- if (!COM_ParseToken_Simple(&data, false, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
return; // error
if (com_token[0] == '}')
break; // end of brush
// FIXME: support hl .map format
for (pointnum = 0;pointnum < 3;pointnum++)
{
- COM_ParseToken_Simple(&data, false, false);
+ COM_ParseToken_Simple(&data, false, false, true);
for (componentnum = 0;componentnum < 3;componentnum++)
{
- COM_ParseToken_Simple(&data, false, false);
+ COM_ParseToken_Simple(&data, false, false, true);
point[pointnum][componentnum] = atof(com_token);
}
- COM_ParseToken_Simple(&data, false, false);
+ COM_ParseToken_Simple(&data, false, false, true);
}
- COM_ParseToken_Simple(&data, false, false);
+ COM_ParseToken_Simple(&data, false, false, true);
strlcpy(facetexture, com_token, sizeof(facetexture));
- COM_ParseToken_Simple(&data, false, false);
+ COM_ParseToken_Simple(&data, false, false, true);
//scroll_s = atof(com_token);
- COM_ParseToken_Simple(&data, false, false);
+ COM_ParseToken_Simple(&data, false, false, true);
//scroll_t = atof(com_token);
- COM_ParseToken_Simple(&data, false, false);
+ COM_ParseToken_Simple(&data, false, false, true);
//rotate = atof(com_token);
- COM_ParseToken_Simple(&data, false, false);
+ COM_ParseToken_Simple(&data, false, false, true);
//scale_s = atof(com_token);
- COM_ParseToken_Simple(&data, false, false);
+ COM_ParseToken_Simple(&data, false, false, true);
//scale_t = atof(com_token);
TriangleNormal(point[0], point[1], point[2], planenormal);
VectorNormalizeDouble(planenormal);
// some Q3 maps override the lightgrid_cellsize with a worldspawn key
// VorteX: q3map2 FS-R generates tangentspace deluxemaps for q3bsp and sets 'deluxeMaps' key
loadmodel->brushq3.deluxemapping = false;
- if (data && COM_ParseToken_Simple(&data, false, false) && com_token[0] == '{')
+ if (data && COM_ParseToken_Simple(&data, false, false, true) && com_token[0] == '{')
{
while (1)
{
- if (!COM_ParseToken_Simple(&data, false, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
break; // error
if (com_token[0] == '}')
break; // end of worldspawn
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, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
break; // error
strlcpy(value, com_token, sizeof(value));
if (!strcasecmp("gridsize", key)) // this one is case insensitive to 100% match q3map2
}
-typedef void (*mod_framegroupify_parsegroups_t) (unsigned int i, int start, int len, float fps, qboolean loop, void *pass);
+typedef void (*mod_framegroupify_parsegroups_t) (unsigned int i, int start, int len, float fps, qboolean loop, const char *name, void *pass);
static int Mod_FrameGroupify_ParseGroups(const char *buf, mod_framegroupify_parsegroups_t cb, void *pass)
{
const char *bufptr;
+ const char *name;
int start, len;
float fps;
unsigned int i;
for(;;)
{
// an anim scene!
- if (!COM_ParseToken_Simple(&bufptr, true, false))
+ if (!COM_ParseToken_Simple(&bufptr, true, false, false))
break;
if (!strcmp(com_token, "\n"))
continue; // empty line
start = atoi(com_token);
- if (!COM_ParseToken_Simple(&bufptr, true, false))
+ if (!COM_ParseToken_Simple(&bufptr, true, false, false))
break;
if (!strcmp(com_token, "\n"))
{
continue;
}
len = atoi(com_token);
- if (!COM_ParseToken_Simple(&bufptr, true, false))
+ if (!COM_ParseToken_Simple(&bufptr, true, false, false))
break;
// we default to looping as it's usually wanted, so to NOT loop you append a 0
- if (strcmp(com_token, "\n"))
+ if (strcmp(com_token, "\n") && strcmp(com_token, "//"))
{
fps = atof(com_token);
- if (!COM_ParseToken_Simple(&bufptr, true, false))
+ if (!COM_ParseToken_Simple(&bufptr, true, false, false))
break;
- if (strcmp(com_token, "\n"))
+ if (strcmp(com_token, "\n") && strcmp(com_token, "//"))
loop = atoi(com_token) != 0;
else
loop = true;
loop = true;
}
+ name = NULL;
+ if(!strcmp(com_token, "//"))
+ {
+ if (COM_ParseToken_Simple(&bufptr, true, false, false))
+ {
+ if(strcmp(com_token, "\n"))
+ {
+ name = com_token;
+ // skip to EOL
+ while (*bufptr && *bufptr != '\n' && *bufptr != '\r')
+ bufptr++;
+ }
+ }
+ }
+
if(cb)
- cb(i, start, len, fps, loop, pass);
+ cb(i, start, len, fps, loop, name, pass);
++i;
}
return i;
}
-static void Mod_FrameGroupify_ParseGroups_Store (unsigned int i, int start, int len, float fps, qboolean loop, void *pass)
+static void Mod_FrameGroupify_ParseGroups_Store (unsigned int i, int start, int len, float fps, qboolean loop, const char *name, void *pass)
{
dp_model_t *mod = (dp_model_t *) pass;
animscene_t *anim = &mod->animscenes[i];
- dpsnprintf(anim->name, sizeof(anim[i].name), "groupified_%d_anim", i);
+ if(name)
+ strlcpy(anim->name, name, sizeof(anim[i].name));
+ else
+ dpsnprintf(anim->name, sizeof(anim[i].name), "groupified_%d_anim", i);
anim->firstframe = bound(0, start, mod->num_poses - 1);
anim->framecount = bound(1, len, mod->num_poses - anim->firstframe);
anim->framerate = max(1, fps);
data = PRVM_G_STRING(OFS_PARM1);
// parse the opening brace
- if (!COM_ParseToken_Simple(&data, false, false) || com_token[0] != '{' )
+ if (!COM_ParseToken_Simple(&data, false, false, true) || com_token[0] != '{' )
prog->error_cmd("VM_parseentitydata: %s: Couldn't parse entity data:\n%s", prog->name, data );
PRVM_ED_ParseEdict (prog, data, ent);
while (1)
{
// parse key
- if (!COM_ParseToken_Simple(&data, false, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
prog->error_cmd("PRVM_ED_ParseGlobals: EOF without closing brace");
if (com_token[0] == '}')
break;
strlcpy (keyname, com_token, sizeof(keyname));
// parse value
- if (!COM_ParseToken_Simple(&data, false, true))
+ if (!COM_ParseToken_Simple(&data, false, true, true))
prog->error_cmd("PRVM_ED_ParseGlobals: EOF without closing brace");
if (developer_entityparsing.integer)
while (1)
{
// parse key
- if (!COM_ParseToken_Simple(&data, false, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
prog->error_cmd("PRVM_ED_ParseEdict: EOF without closing brace");
if (developer_entityparsing.integer)
Con_Printf("Key: \"%s\"", com_token);
}
// parse value
- if (!COM_ParseToken_Simple(&data, false, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
prog->error_cmd("PRVM_ED_ParseEdict: EOF without closing brace");
if (developer_entityparsing.integer)
Con_Printf(" \"%s\"\n", com_token);
while (1)
{
// parse the opening brace
- if (!COM_ParseToken_Simple(&data, false, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
break;
if (com_token[0] != '{')
prog->error_cmd("PRVM_ED_LoadFromFile: %s: found %s when expecting {", prog->name, com_token);
data = cl.worldmodel->brush.entities;
if (!data)
return;
- for (entnum = 0;COM_ParseToken_Simple(&data, false, false) && com_token[0] == '{';entnum++)
+ for (entnum = 0;COM_ParseToken_Simple(&data, false, false, true) && com_token[0] == '{';entnum++)
{
type = LIGHTTYPE_MINUSX;
origin[0] = origin[1] = origin[2] = 0;
islight = false;
while (1)
{
- if (!COM_ParseToken_Simple(&data, false, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
break; // error
if (com_token[0] == '}')
break; // end of entity
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, false))
+ if (!COM_ParseToken_Simple(&data, false, false, true))
break; // error
strlcpy(value, com_token, sizeof(value));
argc = 0;
for (;;)
{
- if (!COM_ParseToken_Simple(&text, true, false) || !strcmp(com_token, "\n"))
+ if (!COM_ParseToken_Simple(&text, true, false, true) || !strcmp(com_token, "\n"))
break;
if (argc < 16)
{