本文整理汇总了C++中PS_ReadToken函数的典型用法代码示例。如果您正苦于以下问题:C++ PS_ReadToken函数的具体用法?C++ PS_ReadToken怎么用?C++ PS_ReadToken使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PS_ReadToken函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ParseEntity
/*
================
ParseEntity
================
*/
qboolean ParseEntity(script_t *script)
{
epair_t *e;
entity_t *mapent;
token_t token;
if (!PS_ReadToken(script, &token))
return false;
if (strcmp(token.string, "{"))
Error ("ParseEntity: { not found");
if (num_entities == MAX_MAP_ENTITIES)
Error ("num_entities == MAX_MAP_ENTITIES");
mapent = &entities[num_entities];
num_entities++;
do
{
if (!PS_ReadToken(script, &token))
Error ("ParseEntity: EOF without closing brace");
if (!strcmp(token.string, "}") )
break;
PS_UnreadLastToken(script);
e = ParseEpair(script);
e->next = mapent->epairs;
mapent->epairs = e;
} while (1);
return true;
} //end of the function ParseEntity
开发者ID:SilverlineDev,项目名称:spearmint,代码行数:37,代码来源:l_bsp_ent.c
示例2: PS_ExpectTokenType
//============================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//============================================================================
int PS_ExpectTokenType(script_t *script, int type, int subtype, token_t *token)
{
char str[MAX_TOKEN];
if (!PS_ReadToken(script, token))
{
ScriptError(script, "couldn't read expected token");
return 0;
} //end if
if (token->type != type)
{
strcpy(str, "");
if (type == TT_STRING) strcpy(str, "string");
if (type == TT_LITERAL) strcpy(str, "literal");
if (type == TT_NUMBER) strcpy(str, "number");
if (type == TT_NAME) strcpy(str, "name");
if (type == TT_PUNCTUATION) strcpy(str, "punctuation");
ScriptError(script, "expected a %s, found %s", str, token->string);
return 0;
} //end if
if (token->type == TT_NUMBER)
{
if ((token->subtype & subtype) != subtype)
{
strcpy(str, "");
if (subtype & TT_DECIMAL) strcpy(str, "decimal");
if (subtype & TT_HEX) strcpy(str, "hex");
if (subtype & TT_OCTAL) strcpy(str, "octal");
if (subtype & TT_BINARY) strcpy(str, "binary");
if (subtype & TT_LONG) strcat(str, " long");
if (subtype & TT_UNSIGNED) strcat(str, " unsigned");
if (subtype & TT_FLOAT) strcat(str, " float");
if (subtype & TT_INTEGER) strcat(str, " integer");
ScriptError(script, "expected %s, found %s", str, token->string);
return 0;
} //end if
} //end if
else if (token->type == TT_PUNCTUATION)
{
if (subtype < 0)
{
ScriptError(script, "BUG: wrong punctuation subtype");
return 0;
} //end if
if (token->subtype != subtype)
{
ScriptError(script, "expected %s, found %s",
script->punctuations[subtype].p, token->string);
return 0;
} //end if
} //end else if
return 1;
} //end of the function PS_ExpectTokenType
开发者ID:0culus,项目名称:ioq3,代码行数:60,代码来源:l_script.c
示例3: PS_ExpectAnyToken
int PS_ExpectAnyToken(script_t *script, token_t *token)
{
if (!PS_ReadToken(script, token))
{
ScriptError(script, "couldn't read expected token");
return 0;
}
else
{
return 1;
}
}
开发者ID:belstgut,项目名称:etlegacy,代码行数:12,代码来源:l_script.c
示例4: PS_SkipUntilString
int PS_SkipUntilString(script_t *script, char *string)
{
token_t token;
while (PS_ReadToken(script, &token))
{
if (!strcmp(token.string, string))
{
return 1;
}
}
return 0;
}
开发者ID:belstgut,项目名称:etlegacy,代码行数:13,代码来源:l_script.c
示例5: PS_ExpectTokenString
//============================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//============================================================================
int PS_ExpectTokenString( script_t *script, char *string ) {
token_t token;
if ( !PS_ReadToken( script, &token ) ) {
ScriptError( script, "couldn't find expected %s", string );
return 0;
} //end if
if ( strcmp( token.string, string ) ) {
ScriptError( script, "expected %s, found %s", string, token.string );
return 0;
} //end if
return 1;
} //end of the function PS_ExpectToken
开发者ID:chegestar,项目名称:omni-bot,代码行数:20,代码来源:l_script.c
示例6: ScrewUpFile
/*
=================
ScrewUpFile
=================
*/
void ScrewUpFile (char *oldfile, char *newfile)
{
FILE *fp;
script_t *script;
token_t token;
replacefunc_t *f;
char *ptr;
printf( "screwing up file %s\n", oldfile );
script = LoadScriptFile( oldfile );
if ( !script ) {
Error( "error opening %s\n", oldfile );
}
fp = fopen( newfile, "wb" );
if ( !fp ) {
Error( "error opening %s\n", newfile );
}
//
while ( PS_ReadToken( script, &token ) )
{
WriteWhiteSpace( fp, script );
if ( token.type == TT_NAME )
{
f = FindFunctionName( token.string );
if ( f ) {
ptr = f->newname;
} else { ptr = token.string;}
while ( *ptr )
{
fputc( *ptr, fp );
ptr++;
} //end while
} //end if
else
{
WriteString( fp, script );
} //end else
} //end while
WriteWhiteSpace( fp, script );
FreeMemory( script );
fclose( fp );
} //end of the function ScrewUpFile
开发者ID:basecq,项目名称:q2dos,代码行数:47,代码来源:extractfuncs.c
示例7: AAS_ParseBSPEntities
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
void AAS_ParseBSPEntities( void ) {
script_t *script;
token_t token;
bsp_entity_t *ent;
bsp_epair_t *epair;
byte *buffer, *buftrav;
int bufsize;
// RF, modified this, so that it first gathers up memory requirements, then allocates a single chunk,
// and places the strings all in there
bspworld.ebuffer = NULL;
script = LoadScriptMemory( bspworld.dentdata, bspworld.entdatasize, "entdata" );
SetScriptFlags( script, SCFL_NOSTRINGWHITESPACES | SCFL_NOSTRINGESCAPECHARS ); //SCFL_PRIMITIVE);
bufsize = 0;
while ( PS_ReadToken( script, &token ) )
{
if ( strcmp( token.string, "{" ) ) {
ScriptError( script, "invalid %s\n", token.string );
AAS_FreeBSPEntities();
FreeScript( script );
return;
} //end if
if ( bspworld.numentities >= MAX_BSPENTITIES ) {
botimport.Print( PRT_MESSAGE, "too many entities in BSP file\n" );
break;
} //end if
while ( PS_ReadToken( script, &token ) )
{
if ( !strcmp( token.string, "}" ) ) {
break;
}
bufsize += sizeof( bsp_epair_t );
if ( token.type != TT_STRING ) {
ScriptError( script, "invalid %s\n", token.string );
AAS_FreeBSPEntities();
FreeScript( script );
return;
} //end if
StripDoubleQuotes( token.string );
bufsize += strlen( token.string ) + 1;
if ( !PS_ExpectTokenType( script, TT_STRING, 0, &token ) ) {
AAS_FreeBSPEntities();
FreeScript( script );
return;
} //end if
StripDoubleQuotes( token.string );
bufsize += strlen( token.string ) + 1;
} //end while
if ( strcmp( token.string, "}" ) ) {
ScriptError( script, "missing }\n" );
AAS_FreeBSPEntities();
FreeScript( script );
return;
} //end if
} //end while
FreeScript( script );
buffer = (byte *)GetClearedHunkMemory( bufsize );
buftrav = buffer;
bspworld.ebuffer = buffer;
// RF, now parse the entities into memory
// RF, NOTE: removed error checks for speed, no need to do them twice
script = LoadScriptMemory( bspworld.dentdata, bspworld.entdatasize, "entdata" );
SetScriptFlags( script, SCFL_NOSTRINGWHITESPACES | SCFL_NOSTRINGESCAPECHARS ); //SCFL_PRIMITIVE);
bspworld.numentities = 1;
while ( PS_ReadToken( script, &token ) )
{
ent = &bspworld.entities[bspworld.numentities];
bspworld.numentities++;
ent->epairs = NULL;
while ( PS_ReadToken( script, &token ) )
{
if ( !strcmp( token.string, "}" ) ) {
break;
}
epair = (bsp_epair_t *) buftrav; buftrav += sizeof( bsp_epair_t );
epair->next = ent->epairs;
ent->epairs = epair;
StripDoubleQuotes( token.string );
epair->key = (char *) buftrav; buftrav += ( strlen( token.string ) + 1 );
strcpy( epair->key, token.string );
if ( !PS_ExpectTokenType( script, TT_STRING, 0, &token ) ) {
AAS_FreeBSPEntities();
FreeScript( script );
return;
} //end if
//.........这里部分代码省略.........
开发者ID:JackalFrost,项目名称:RTCW-WSGF,代码行数:101,代码来源:be_aas_bspq3.c
示例8: AAS_ParseBSPEntities
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
void AAS_ParseBSPEntities(void)
{
script_t *script;
token_t token;
bsp_entity_t *ent;
bsp_epair_t *epair;
script = LoadScriptMemory(bspworld.dentdata, bspworld.entdatasize, "entdata");
SetScriptFlags(script, SCFL_NOSTRINGWHITESPACES|SCFL_NOSTRINGESCAPECHARS);//SCFL_PRIMITIVE);
bspworld.numentities = 1;
while(PS_ReadToken(script, &token))
{
if (strcmp(token.string, "{"))
{
ScriptError(script, "invalid %s", token.string);
AAS_FreeBSPEntities();
FreeScript(script);
return;
} //end if
if (bspworld.numentities >= MAX_BSPENTITIES)
{
botimport.Print(PRT_MESSAGE, "too many entities in BSP file\n");
break;
} //end if
ent = &bspworld.entities[bspworld.numentities];
bspworld.numentities++;
ent->epairs = NULL;
while(PS_ReadToken(script, &token))
{
if (!strcmp(token.string, "}")) break;
epair = (bsp_epair_t *) GetClearedHunkMemory(sizeof(bsp_epair_t));
epair->next = ent->epairs;
ent->epairs = epair;
if (token.type != TT_STRING)
{
ScriptError(script, "invalid %s", token.string);
AAS_FreeBSPEntities();
FreeScript(script);
return;
} //end if
StripDoubleQuotes(token.string);
epair->key = (char *) GetHunkMemory(strlen(token.string) + 1);
strcpy(epair->key, token.string);
if (!PS_ExpectTokenType(script, TT_STRING, 0, &token))
{
AAS_FreeBSPEntities();
FreeScript(script);
return;
} //end if
StripDoubleQuotes(token.string);
epair->value = (char *) GetHunkMemory(strlen(token.string) + 1);
strcpy(epair->value, token.string);
} //end while
if (strcmp(token.string, "}"))
{
ScriptError(script, "missing }");
AAS_FreeBSPEntities();
FreeScript(script);
return;
} //end if
} //end while
FreeScript(script);
} //end of the function AAS_ParseBSPEntities
开发者ID:pelya,项目名称:spearmint,代码行数:71,代码来源:be_aas_bspq3.c
示例9: Q2_ParseMapEntity
/*
================
Q2_ParseMapEntity
================
*/
qboolean Q2_ParseMapEntity(script_t *script)
{
entity_t *mapent;
epair_t *e;
side_t *s;
int i, j;
int startbrush, startsides;
vec_t newdist;
mapbrush_t *b;
token_t token;
if (!PS_ReadToken(script, &token))
{
return false;
}
if (strcmp(token.string, "{"))
{
Error("ParseEntity: { not found");
}
if (num_entities == MAX_MAP_ENTITIES)
{
Error("num_entities == MAX_MAP_ENTITIES");
}
startbrush = nummapbrushes;
startsides = nummapbrushsides;
mapent = &entities[num_entities];
num_entities++;
memset(mapent, 0, sizeof(*mapent));
mapent->firstbrush = nummapbrushes;
mapent->numbrushes = 0;
// mapent->portalareas[0] = -1;
// mapent->portalareas[1] = -1;
do
{
if (!PS_ReadToken(script, &token))
{
Error("ParseEntity: EOF without closing brace");
} //end if
if (!strcmp(token.string, "}"))
{
break;
}
if (!strcmp(token.string, "{"))
{
Q2_ParseBrush(script, mapent);
} //end if
else
{
PS_UnreadLastToken(script);
e = ParseEpair(script);
e->next = mapent->epairs;
mapent->epairs = e;
} //end else
}
while (1);
GetVectorForKey(mapent, "origin", mapent->origin);
//
// if there was an origin brush, offset all of the planes and texinfo
//
if (mapent->origin[0] || mapent->origin[1] || mapent->origin[2])
{
for (i = 0 ; i < mapent->numbrushes ; i++)
{
b = &mapbrushes[mapent->firstbrush + i];
for (j = 0 ; j < b->numsides ; j++)
{
s = &b->original_sides[j];
newdist = mapplanes[s->planenum].dist -
DotProduct(mapplanes[s->planenum].normal, mapent->origin);
s->planenum = FindFloatPlane(mapplanes[s->planenum].normal, newdist, 0, NULL);
s->texinfo = TexinfoForBrushTexture(&mapplanes[s->planenum],
&side_brushtextures[s - brushsides], mapent->origin);
}
MakeBrushWindings(b);
}
}
// group entities are just for editor convenience
// toss all brushes into the world entity
if (!strcmp("func_group", ValueForKey(mapent, "classname")))
{
Q2_MoveBrushesToWorld(mapent);
mapent->numbrushes = 0;
return true;
}
// areaportal entities move their brushes, but don't eliminate
// the entity
//.........这里部分代码省略.........
开发者ID:morsik,项目名称:war-territory,代码行数:101,代码来源:map_q2.c
示例10: Q2_ParseBrush
/*
=================
Q2_ParseBrush
=================
*/
void Q2_ParseBrush(script_t *script, entity_t *mapent)
{
mapbrush_t *b;
int i, j, k;
int mt;
side_t *side, *s2;
int planenum;
brush_texture_t td;
int planepts[3][3];
token_t token;
if (nummapbrushes >= MAX_MAPFILE_BRUSHES)
{
Error("nummapbrushes == MAX_MAPFILE_BRUSHES");
}
b = &mapbrushes[nummapbrushes];
b->original_sides = &brushsides[nummapbrushsides];
b->entitynum = num_entities - 1;
b->brushnum = nummapbrushes - mapent->firstbrush;
b->leafnum = -1;
do
{
if (!PS_ReadToken(script, &token))
{
break;
}
if (!strcmp(token.string, "}"))
{
break;
}
//IDBUG: mixed use of MAX_MAPFILE_? and MAX_MAP_? this could
// lead to out of bound indexing of the arrays
if (nummapbrushsides >= MAX_MAPFILE_BRUSHSIDES)
{
Error("MAX_MAPFILE_BRUSHSIDES");
}
side = &brushsides[nummapbrushsides];
//read the three point plane definition
for (i = 0; i < 3; i++)
{
if (i != 0)
{
PS_ExpectTokenString(script, "(");
}
for (j = 0; j < 3; j++)
{
PS_ExpectAnyToken(script, &token);
planepts[i][j] = atof(token.string);
} //end for
PS_ExpectTokenString(script, ")");
} //end for
//
//read the texturedef
//
PS_ExpectAnyToken(script, &token);
strcpy(td.name, token.string);
PS_ExpectAnyToken(script, &token);
td.shift[0] = atol(token.string);
PS_ExpectAnyToken(script, &token);
td.shift[1] = atol(token.string);
PS_ExpectAnyToken(script, &token);
td.rotate = atol(token.string);
PS_ExpectAnyToken(script, &token);
td.scale[0] = atof(token.string);
PS_ExpectAnyToken(script, &token);
td.scale[1] = atof(token.string);
//find default flags and values
mt = FindMiptex(td.name);
td.flags = textureref[mt].flags;
td.value = textureref[mt].value;
side->contents = textureref[mt].contents;
side->surf = td.flags = textureref[mt].flags;
//check if there's a number available
if (PS_CheckTokenType(script, TT_NUMBER, 0, &token))
{
side->contents = token.intvalue;
PS_ExpectTokenType(script, TT_NUMBER, 0, &token);
side->surf = td.flags = token.intvalue;
PS_ExpectTokenType(script, TT_NUMBER, 0, &token);
td.value = token.intvalue;
}
// translucent objects are automatically classified as detail
// if (side->surf & (SURF_TRANS33|SURF_TRANS66) )
// side->contents |= CONTENTS_DETAIL;
if (side->contents & (CONTENTS_PLAYERCLIP | CONTENTS_MONSTERCLIP))
{
//.........这里部分代码省略.........
开发者ID:morsik,项目名称:war-territory,代码行数:101,代码来源:map_q2.c
示例11: PS_ExpectTokenType
bool PS_ExpectTokenType( script_t* script, int type, int subtype, token_t* token ) {
if ( !PS_ReadToken( script, token ) ) {
ScriptError( script, "couldn't read expected token" );
return false;
}
if ( token->type != type ) {
char str[ MAX_TOKEN ];
if ( type == TT_STRING ) {
String::Cpy( str, "string" );
}
if ( type == TT_LITERAL ) {
String::Cpy( str, "literal" );
}
if ( type == TT_NUMBER ) {
String::Cpy( str, "number" );
}
if ( type == TT_NAME ) {
String::Cpy( str, "name" );
}
if ( type == TT_PUNCTUATION ) {
String::Cpy( str, "punctuation" );
}
ScriptError( script, "expected a %s, found %s", str, token->string );
return false;
}
if ( token->type == TT_NUMBER ) {
if ( ( token->subtype & subtype ) != subtype ) {
char str[ MAX_TOKEN ];
if ( subtype & TT_DECIMAL ) {
String::Cpy( str, "decimal" );
}
if ( subtype & TT_HEX ) {
String::Cpy( str, "hex" );
}
if ( subtype & TT_OCTAL ) {
String::Cpy( str, "octal" );
}
if ( subtype & TT_BINARY ) {
String::Cpy( str, "binary" );
}
if ( subtype & TT_LONG ) {
String::Cat( str, sizeof ( str ), " long" );
}
if ( subtype & TT_UNSIGNED ) {
String::Cat( str, sizeof ( str ), " unsigned" );
}
if ( subtype & TT_FLOAT ) {
String::Cat( str, sizeof ( str ), " float" );
}
if ( subtype & TT_INTEGER ) {
String::Cat( str, sizeof ( str ), " integer" );
}
ScriptError( script, "expected %s, found %s", str, token->string );
return false;
}
} else if ( token->type == TT_PUNCTUATION ) {
if ( subtype < 0 ) {
ScriptError( script, "BUG: wrong punctuation subtype" );
return false;
}
if ( token->subtype != subtype ) {
ScriptError( script, "expected %s, found %s",
script->punctuations[ subtype ].p, token->string );
return false;
}
}
return true;
}
开发者ID:janisl,项目名称:jlquake,代码行数:69,代码来源:script.cpp
注:本文中的PS_ReadToken函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论