Scripts now treat {}()': as single character tokens.

This commit is contained in:
Bill Currie 2010-09-05 15:35:22 +09:00
parent fe4bf28335
commit 827d0d0ad6
4 changed files with 14 additions and 5 deletions

View file

@ -157,9 +157,16 @@ Script_GetToken (script_t *script, qboolean crossline)
dstring_copysubstr (script->token, token_p, script->p - token_p);
script->p++;
} else {
const char *single = "{}()':";
token_p = script->p;
while (*script->p && !isspace ((unsigned char) *script->p))
if (strchr (single, *script->p)) {
script->p++;
} else {
while (*script->p && !isspace ((unsigned char) *script->p)
&& !strchr (single, *script->p))
script->p++;
}
dstring_copysubstr (script->token, token_p, script->p - token_p);
}

View file

@ -187,7 +187,8 @@ ParseVerts (int *n_verts)
if (map_script->token->str[0] != ':')
map_error ("parsing brush");
*n_verts = atoi (map_script->token->str + 1);
Script_GetToken (map_script, false);
*n_verts = atoi (map_script->token->str);
verts = malloc (sizeof (vec3_t) * *n_verts);
for (i = 0; i < *n_verts; i++) {

View file

@ -834,7 +834,8 @@ progs_src_compile (void)
else
dsprintf (qc_filename, "%s", script->token->str);
if (options.verbosity >= 2)
printf ("%s:%d: compiling %s\n", script->file, script->line, qc_filename->str);
printf ("%s:%d: compiling %s\n", script->file, script->line,
qc_filename->str);
if (single) {
fprintf (single, "$frame_reset\n");

View file

@ -186,7 +186,7 @@ LoadEntities (void)
// go through all the entities
while (Script_GetToken (script, 1)) {
// parse the opening brace
if (script->token->str[0] != '{')
if (!strcmp (script->token->str, "{"))
fprintf (stderr, "LoadEntities: found %s when expecting {",
script->token->str);
@ -220,7 +220,7 @@ LoadEntities (void)
// FIXME shouldn't cross line
if (!Script_GetToken (script, 1))
fprintf (stderr, "LoadEntities: EOF without closing brace");
if (script->token->str[0] == '}')
if (!strcmp (script->token->str, "}"))
fprintf (stderr, "LoadEntities: closing brace without data");
epair = calloc (1, sizeof (epair_t));