这篇教程C++ COM_ParseExt函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中COM_ParseExt函数的典型用法代码示例。如果您正苦于以下问题:C++ COM_ParseExt函数的具体用法?C++ COM_ParseExt怎么用?C++ COM_ParseExt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了COM_ParseExt函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: SCR_DrawSpectators/** SCR_DrawSpectators*/static int SCR_DrawSpectators( const char **ptrptr, int x, int y, int panelWidth, struct qfontface_s *font, int pass ){ char *token; const char *oldptr; char string[MAX_STRING_CHARS]; int yoffset = 0, xoffset = 0; int playerNum, ping; int aligns[3], offsets[3]; int colwidth, fullwidth, count = 0, height; bool titleDrawn = false; fullwidth = panelWidth * 1.5; if( fullwidth > cgs.vidWidth * 0.7 ) fullwidth = cgs.vidWidth * 0.7; colwidth = fullwidth / 3; aligns[0] = ALIGN_CENTER_TOP; aligns[1] = ALIGN_LEFT_TOP; aligns[2] = ALIGN_RIGHT_TOP; offsets[0] = 0; offsets[1] = -fullwidth * 0.5; offsets[2] = fullwidth * 0.5; assert( ptrptr && *ptrptr ); height = trap_SCR_FontHeight( font ); yoffset = height; // draw spectators while( *ptrptr ) { oldptr = *ptrptr; token = COM_ParseExt( ptrptr, true ); if( !token[0] ) break; if( token[0] == '&' ) // it's a different command than 'spectators', so step back and return { *ptrptr = oldptr; break; } // first token is played id playerNum = atoi( token ); if( playerNum < 0 || playerNum >= gs.maxclients ) break; // get a second token oldptr = *ptrptr; token = COM_ParseExt( ptrptr, true ); if( !token[0] ) break; if( token[0] == '&' ) // it's a different command than 'spectators', so step back and return { *ptrptr = oldptr; break; } // draw title if there are any spectators if( !titleDrawn ) { titleDrawn = true; if( pass ) { trap_SCR_DrawString( x, y + yoffset, ALIGN_CENTER_TOP, CG_TranslateString( "Spectators" ), font, colorYellow ); } yoffset += height; } // second token is ping ping = atoi( token ); // draw the spectator if( ping < 0 ) Q_snprintfz( string, sizeof( string ), "%s%s ...", cgs.clientInfo[playerNum].name, S_COLOR_WHITE ); else Q_snprintfz( string, sizeof( string ), "%s%s %i", cgs.clientInfo[playerNum].name, S_COLOR_WHITE, ping ); xoffset = offsets[count] + CG_HorizontalAlignForWidth( 0, aligns[count], trap_SCR_strWidth( string, font, 0 ) ); if ( pass ) { // fixme: the boxes aren't actually correctly aligned trap_SCR_DrawClampString( x + xoffset, y + yoffset, string, x + xoffset, y + yoffset, x + xoffset + colwidth, y + yoffset + height, font, colorWhite ); } count++; if( count > 2 ) { count = 0; yoffset += height; } } if( count ) yoffset += height;//.........这里部分代码省略.........
开发者ID:futurepneu,项目名称:racemod,代码行数:101,
示例2: Bot_ScriptParseAllCharacters/*==============Bot_ScriptParseAllCharacters==============*/void Bot_ScriptParseAllCharacters(){ char *pScript; char *token; bot_script_global_data_t *bsd; char params[MAX_TOKEN_CHARS]; if(!level.scriptEntity) { return; } pScript = level.scriptEntity; COM_BeginParseSession("Bot_ScriptParse"); numScriptCharacters = 0; memset(botCharacterScriptData, 0, sizeof(botCharacterScriptData)); while(1) { token = COM_Parse(&pScript); // we are expecting a name here if(!token[0]) { // end of script break; } if(token[0] == '{' || token[0] == '}') { G_Error("Bot_ScriptParse(), Error (line %d): entry identifier expected, '%s' found./n", 1 + COM_GetCurrentParseLine(), token); } // is this a bot? if(Q_stricmp(token, "BOT") != 0) { // not a bot, skip this whole entry SkipRestOfLine(&pScript); // skip this section SkipBracedSection(&pScript); // continue; } // this is the name if(numScriptCharacters == MAX_BOT_SCRIPT_CHARACTERS) { G_Error ("Bot_ScriptParse(), Error (line %d): MAX_BOT_SCRIPT_CHARACTERS exceeded (%i), too many bot script characters/n", 1 + COM_GetCurrentParseLine(), MAX_BOT_SCRIPT_CHARACTERS); break; } bsd = &botCharacterScriptData[numScriptCharacters++]; bsd->lineNum = 1 + COM_GetCurrentParseLine(); // read the name token = COM_Parse(&pScript); // we are expecting a name here if(!token[0]) { G_Error("Bot_ScriptParse(), Error (line %d): name expected, end of line found./n", 1 + COM_GetCurrentParseLine()); } if(token[0] == '{' || token[0] == '}') { G_Error("Bot_ScriptParse(), Error (line %d): name expected, '%s' found./n", 1 + COM_GetCurrentParseLine(), token); } // allocate the name bsd->name = G_Alloc(strlen(token) + 1); Q_strncpyz(bsd->name, token, strlen(token) + 1); // read the params memset(params, 0, sizeof(params)); while((token = COM_ParseExt(&pScript, qfalse)) && token[0]) { if(strlen(params) + strlen(token) >= sizeof(params)) { G_Error("Bot_ScriptParse(), Error (line %d): parameters exceed maximum size/n", 1 + COM_GetCurrentParseLine()); } if(strlen(params) > 0) { Q_strcat(params, sizeof(params), " "); } Q_strcat(params, sizeof(params), token); } // allocate the params bsd->params = G_Alloc(strlen(params) + 1); Q_strncpyz(bsd->params, params, strlen(params) + 1); // allocate memory for this character script bsd->data = G_Alloc(sizeof(bot_script_data_t)); memset(bsd->data, 0, sizeof(bot_script_data_t)); // now parse the script data for this character Bot_ScriptParse(bsd->data, &pScript); }}
开发者ID:ethr,项目名称:ETXreaLPro_etmain,代码行数:94,
示例3: Bot_ScriptInitBot/*================Bot_ScriptInitBot================*/qboolean Bot_ScriptInitBot(int entnum){ gentity_t *ent, *trav; bot_state_t *bs; char userinfo[MAX_INFO_STRING]; bot_script_global_data_t *bsgd; char *token, *p, *pBackup; int i, val = 0; int weapons[2]; gitem_t *item = NULL; char *name; // bs = &botstates[entnum]; if(!bs->inuse) { return qfalse; } if(bs->script.data) { return qtrue; } // set starting defaults bs->script.status.eventIndex = -1; bs->script.data = NULL; // ent = BotGetEntity(bs->entitynum); trap_GetUserinfo(bs->entitynum, userinfo, sizeof(userinfo)); name = Info_ValueForKey(userinfo, "scriptName"); if(!name || !name[0]) { return qfalse; } // find the script data for this bot bsgd = botCharacterScriptData; for(i = 0; i < numScriptCharacters; i++, bsgd++) { if(Q_stricmp(name, bsgd->name) != 0) { continue; } // check params p = bsgd->params; // // eliminate them with each condition not met while(qtrue) { token = COM_ParseExt(&p, qfalse); if(!token || !token[0]) { // we're done, we found a match break; } // if(token[0] != '/') { G_Error("BotScript, line %i: condition identifier expected, '%s' found/n", bsgd->lineNum, token); } // if(!Q_stricmp(token, "/team")) { token = COM_ParseExt(&p, qfalse); if(!token || !token[0] || token[0] == '/') { G_Error("BotScript, line %i: unexpected end of /team parameter", bsgd->lineNum); } // if(!Q_stricmp(token, "axis")) { val = TEAM_AXIS; } else if(!Q_stricmp(token, "allies")) { val = TEAM_ALLIES; } else { G_Error("BotScript, line %i: unknown team /"%s/"", bsgd->lineNum, token); } // eliminate player if(bs->mpTeam != val) { break; } } else // if(!Q_stricmp(token, "/class")) { token = COM_ParseExt(&p, qfalse); if(!token || !token[0] || token[0] == '/') { G_Error("BotScript, line %i: unexpected end of /class parameter", bsgd->lineNum); }//.........这里部分代码省略.........
开发者ID:ethr,项目名称:ETXreaLPro_etmain,代码行数:101,
示例4: __delete__void GameAjaxDataSource::StreamDone( int status, const char *contentType, void *privatep ){ SourceFetcherPair *fp = static_cast< SourceFetcherPair *>( privatep ); DynTableFetcher *fetcher = fp->second; GameAjaxDataSource *ds = fp->first; DynTable *table = fetcher->table; std::string tableName = table->GetName(); String rocketTableName = tableName.c_str(); DynTableList::iterator t_it = ds->tableList.find( tableName ); bool hasOldTable = t_it != ds->tableList.end(); DynTableFetcher *oldFetcher = hasOldTable ? t_it->second : NULL; DynTable *oldTable = hasOldTable ? oldFetcher->table : NULL; const char *data = fetcher->buf.c_str(); // simply exit on error or if nothing has changed in table data if( status < 0 || status >= 300 || ( hasOldTable && ( oldFetcher->buf == data ) ) ) { __delete__( table ); __delete__( fetcher ); __delete__( fp ); return; } // parse server response: // { // "key1" = "value1" // "key2" = "value2" // } char *token; std::string key, value; for(; ( token = COM_Parse( &data ) ) && token[0] == '{'; ) { Row row; while( 1 ) { token = COM_ParseExt( &data, true ); if( !token[0] ) break; // error if( token[0] == '}' ) break; // end of callvote key = Q_trim( token ); value = COM_ParseExt( &data, true ); row[key] = value; } table->AddRow( row ); } if( oldTable != NULL ) { ds->tableList[tableName] = fetcher; ds->NotifyRowChange( rocketTableName ); __delete__( oldTable ); __delete__( oldFetcher ); } else { ds->tableList[tableName] = fetcher; ds->NotifyRowAdd( rocketTableName, 0, table->GetNumRows() ); } __delete__( fp );}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:64,
示例5: WP_SaberParseParmsqboolean WP_SaberParseParms( const char *SaberName, saberInfo_t *saber, qboolean setColors ) { const char *token; const char *value; const char *p; float f; int n; if ( !saber ) { return qfalse; } //Set defaults so that, if it fails, there's at least something there WP_SaberSetDefaults( saber, setColors ); if ( !SaberName || !SaberName[0] ) { return qfalse; } saber->name = G_NewString( SaberName ); //try to parse it out p = SaberParms; COM_BeginParseSession(); // look for the right saber while ( p ) { token = COM_ParseExt( &p, qtrue ); if ( token[0] == 0 ) { return qfalse; } if ( !Q_stricmp( token, SaberName ) ) { break; } SkipBracedSection( &p ); } if ( !p ) { return qfalse; } if ( G_ParseLiteral( &p, "{" ) ) { return qfalse; } // parse the saber info block while ( 1 ) { token = COM_ParseExt( &p, qtrue ); if ( !token[0] ) { gi.Printf( S_COLOR_RED"ERROR: unexpected EOF while parsing '%s'/n", SaberName ); return qfalse; } if ( !Q_stricmp( token, "}" ) ) { break; } //saber fullName if ( !Q_stricmp( token, "name" ) ) { if ( COM_ParseString( &p, &value ) ) { continue; } saber->fullName = G_NewString( value ); continue; } //saber type if ( !Q_stricmp( token, "saberType" ) ) { if ( COM_ParseString( &p, &value ) ) { continue; } int saberType = GetIDForString( SaberTable, value ); if ( saberType >= SABER_SINGLE && saberType <= NUM_SABERS ) { saber->type = (saberType_t)saberType; } continue; } //saber hilt if ( !Q_stricmp( token, "saberModel" ) ) { if ( COM_ParseString( &p, &value ) ) { continue; }//.........这里部分代码省略.........
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:101,
示例6: SV_AutoUpdateFromWeb/** SV_AutoUpdateFromWeb*/void SV_AutoUpdateFromWeb( qboolean checkOnly ){ static const char *autoUpdateBaseUrl = APP_UPDATE_URL APP_SERVER_UPDATE_DIRECTORY; char checksumString1[32], checksumString2[32]; unsigned int checksum; qboolean success; int length, filenum; qbyte *data; const char *token, *ptr; char path[MAX_QPATH]; int downloadCount = 0, downloadFailed = 0; char newVersionTag[MAX_QPATH]; qboolean newVersion = qfalse; if( !dedicated->integer ) return; assert( svs.mapcmd[0] ); if( !checkOnly ) SV_UpdateActivity(); Com_Printf( "/n" ); Com_Printf( "========== Starting Auto Update ===========/n" ); Com_Printf( "Checking for updates/n" ); // download the update file list success = SV_WebDownload( autoUpdateBaseUrl, APP_SERVER_UPDATE_FILE, qtrue, qtrue ); // set as last updated today if( !checkOnly ) Cvar_ForceSet( "sv_lastAutoUpdate", va( "%i", (int)Com_DaysSince1900() ) ); if( !success ) // no update to do goto done; // read the file list if( ( length = FS_FOpenBaseFile( APP_SERVER_UPDATE_FILE, &filenum, FS_READ ) ) == -1 ) { Com_Printf( "WARNING: Couldn't find %s/n", path ); goto done; } if( !length ) { FS_FCloseFile( filenum ); goto done; } data = Mem_TempMalloc( length + 1 ); FS_Read( data, length, filenum ); FS_FCloseFile( filenum ); FS_RemoveBaseFile( APP_SERVER_UPDATE_FILE ); ptr = (const char *)data; // first token is always the current release version token = COM_ParseExt( &ptr, qtrue ); if( !token[0] ) goto cancel; // compare versions Q_strncpyz( newVersionTag, token, sizeof( newVersionTag ) ); if( atof( newVersionTag ) > atof( va( "%4.3f", APP_VERSION ) ) ) newVersion = qtrue; while( ptr ) { // we got what should be a checksum token = COM_ParseExt( &ptr, qtrue ); if( !token[0] ) goto cancel; // copy checksum reported by server Q_strncpyz( checksumString1, token, sizeof( checksumString1 ) ); // get filename token = COM_ParseExt( &ptr, qtrue ); if( !token[0] ) goto cancel; // filename should never begin with a slash if( token[0] == '/' ) token++; Q_strncpyz( path, token, sizeof( path ) ); // we got what should be a file path if( !COM_ValidateRelativeFilename( path ) ) { Com_Printf( "WARNING: Invalid filename %s/n", path ); continue; } checksum = FS_ChecksumBaseFile( path ); Q_snprintfz( checksumString2, sizeof( checksumString2 ), "%u", checksum );//.........这里部分代码省略.........
开发者ID:j0ki,项目名称:racesow,代码行数:101,
示例7: getCustomVote/*==================getCustomVote *Returns a custom vote. This will go beyond MAX_CUSTOM_VOTES.================== */t_customvote getCustomVote(char* votecommand) { t_customvote result; fileHandle_t file; char buffer[4*1024]; char *token,*pointer; char key[MAX_TOKEN_CHARS]; trap_FS_FOpenFile(g_votecustom.string,&file,FS_READ); if(!file) { memset(&result,0,sizeof(result)); return result; } memset(&buffer,0,sizeof(buffer)); trap_FS_Read(&buffer,sizeof(buffer),file); pointer = buffer; while ( qtrue ) { token = COM_Parse( &pointer ); if ( !token[0] ) { break; } if ( strcmp( token, "{" ) ) { Com_Printf( "Missing { in votecustom.cfg/n" ); break; } memset(&result,0,sizeof(result)); while ( 1 ) { token = COM_ParseExt( &pointer, qtrue ); if ( !token[0] ) { Com_Printf( "Unexpected end of customvote.cfg/n" ); break; } if ( !strcmp( token, "}" ) ) { break; } Q_strncpyz( key, token, sizeof( key ) ); token = COM_ParseExt( &pointer, qfalse ); if ( !token[0] ) { Com_Printf("Invalid/missing argument to %s in customvote.cfg/n",key); } if(!Q_stricmp(key,"votecommand")) { Q_strncpyz(result.votename,token,sizeof(result.votename)); } else if(!Q_stricmp(key,"displayname")) { Q_strncpyz(result.displayname,token,sizeof(result.displayname)); } else if(!Q_stricmp(key,"command")) { Q_strncpyz(result.command,token,sizeof(result.command)); } else { Com_Printf("Unknown key in customvote.cfg: %s/n",key); } } if(!Q_stricmp(result.votename,votecommand)) { return result; } } //Nothing was found memset(&result,0,sizeof(result)); return result;}
开发者ID:sookee,项目名称:oa-mod,代码行数:75,
示例8: NPC_PrecacheAnimationCFGvoid NPC_PrecacheAnimationCFG( const char *NPC_type ){ char filename[MAX_QPATH]; const char *token; const char *value; const char *p; int junk; if ( !Q_stricmp( "random", NPC_type ) ) {//sorry, can't precache a random just yet return; } p = NPCParms; COM_BeginParseSession(); // look for the right NPC while ( p ) { token = COM_ParseExt( &p, qtrue ); if ( token[0] == 0 ) return; if ( !Q_stricmp( token, NPC_type ) ) { break; } SkipBracedSection( &p ); } if ( !p ) { return; } if ( G_ParseLiteral( &p, "{" ) ) { return; } // parse the NPC info block while ( 1 ) { token = COM_ParseExt( &p, qtrue ); if ( !token[0] ) { gi.Printf( S_COLOR_RED"ERROR: unexpected EOF while parsing '%s'/n", NPC_type ); return; } if ( !Q_stricmp( token, "}" ) ) { break; } // legsmodel if ( !Q_stricmp( token, "legsmodel" ) ) { if ( COM_ParseString( &p, &value ) ) { continue; } //must copy data out of this pointer into a different part of memory because the funcs we're about to call will call COM_ParseExt Q_strncpyz( filename, value, sizeof( filename ), qtrue ); G_ParseAnimFileSet( filename, filename, &junk ); return; } // playerModel if ( !Q_stricmp( token, "playerModel" ) ) { if ( COM_ParseString( &p, &value ) ) { continue; } char animName[MAX_QPATH]; char *GLAName; char *slash = NULL; char *strippedName; int handle = gi.G2API_PrecacheGhoul2Model( va( "models/players/%s/model.glm", value ) ); if ( handle > 0 )//FIXME: isn't 0 a valid handle? { GLAName = gi.G2API_GetAnimFileNameIndex( handle ); if ( GLAName ) { Q_strncpyz( animName, GLAName, sizeof( animName ), qtrue ); slash = strrchr( animName, '/' ); if ( slash ) { *slash = 0; } strippedName = COM_SkipPath( animName ); //must copy data out of this pointer into a different part of memory because the funcs we're about to call will call COM_ParseExt Q_strncpyz( filename, value, sizeof( filename ), qtrue ); G_ParseAnimFileSet( value, strippedName, &junk );//qfalse ); //FIXME: still not precaching the animsounds.cfg? return;//.........这里部分代码省略.........
开发者ID:Hasimir,项目名称:jedi-outcast-1,代码行数:101,
示例9: NPC_Precache/*void NPC_Precache ( char *NPCName )Precaches NPC skins, tgas and md3s.*/void NPC_Precache ( gentity_t *spawner ){ clientInfo_t ci={0}; renderInfo_t ri={0}; team_t playerTeam = TEAM_FREE; const char *token; const char *value; const char *p; char *patch; char sound[MAX_QPATH]; qboolean md3Model = qfalse; char playerModel[MAX_QPATH]; char customSkin[MAX_QPATH]; if ( !Q_stricmp( "random", spawner->NPC_type ) ) {//sorry, can't precache a random just yet return; } strcpy(customSkin,"default"); p = NPCParms; COM_BeginParseSession(); // look for the right NPC while ( p ) { token = COM_ParseExt( &p, qtrue ); if ( token[0] == 0 ) return; if ( !Q_stricmp( token, spawner->NPC_type ) ) { break; } SkipBracedSection( &p ); } if ( !p ) { return; } if ( G_ParseLiteral( &p, "{" ) ) { return; } // parse the NPC info block while ( 1 ) { token = COM_ParseExt( &p, qtrue ); if ( !token[0] ) { gi.Printf( S_COLOR_RED"ERROR: unexpected EOF while parsing '%s'/n", spawner->NPC_type ); return; } if ( !Q_stricmp( token, "}" ) ) { break; } // headmodel if ( !Q_stricmp( token, "headmodel" ) ) { if ( COM_ParseString( &p, &value ) ) { continue; } if(!Q_stricmp("none", value)) { } else { Q_strncpyz( ri.headModelName, value, sizeof(ri.headModelName), qtrue); } md3Model = qtrue; continue; } // torsomodel if ( !Q_stricmp( token, "torsomodel" ) ) { if ( COM_ParseString( &p, &value ) ) { continue; } if(!Q_stricmp("none", value)) { } else//.........这里部分代码省略.........
开发者ID:Hasimir,项目名称:jedi-outcast-1,代码行数:101,
示例10: CM_ParseShader/*=================CM_ParseShaderThe current text pointer is at the explicit text definition of theshader. Parse it into the global shader variable.This extracts all the info from the shader required for physics and collisionIt is designed to *NOT* load any image files and not require any of the renderer to be initialised.=================*/static void CM_ParseShader( CCMShader *shader, const char **text ){ char *token; token = COM_ParseExt( text, qtrue ); if ( token[0] != '{' ) { Com_Printf( S_COLOR_YELLOW "WARNING: expecting '{', found '%s' instead in shader '%s'/n", token, shader->shader ); return; } while ( true ) { token = COM_ParseExt( text, qtrue ); if ( !token[0] ) { Com_Printf( S_COLOR_YELLOW "WARNING: no concluding '}' in shader %s/n", shader->shader ); return; } // end of shader definition if ( token[0] == '}' ) { break; } // stage definition else if ( token[0] == '{' ) { SkipBracedSection( text ); continue; } // material deprecated as of 11 Jan 01 // material undeprecated as of 7 May 01 - q3map_material deprecated else if ( !Q_stricmp( token, "material" ) || !Q_stricmp( token, "q3map_material" ) ) { SV_ParseMaterial( shader, text ); } // sun parms // q3map_sun deprecated as of 11 Jan 01 else if ( !Q_stricmp( token, "sun" ) || !Q_stricmp( token, "q3map_sun" ) ) {// float a, b; token = COM_ParseExt( text, qfalse );// shader->sunLight[0] = atof( token ); token = COM_ParseExt( text, qfalse );// shader->sunLight[1] = atof( token ); token = COM_ParseExt( text, qfalse );// shader->sunLight[2] = atof( token ); // VectorNormalize( shader->sunLight ); token = COM_ParseExt( text, qfalse );// a = atof( token );// VectorScale( shader->sunLight, a, shader->sunLight); token = COM_ParseExt( text, qfalse );// a = DEG2RAD(atof( token )); token = COM_ParseExt( text, qfalse );// b = DEG2RAD(atof( token ));// shader->sunDirection[0] = cos( a ) * cos( b );// shader->sunDirection[1] = sin( a ) * cos( b );// shader->sunDirection[2] = sin( b ); } else if ( !Q_stricmp( token, "surfaceParm" ) ) { SV_ParseSurfaceParm( shader, text ); continue; } else if ( !Q_stricmp( token, "fogParms" ) ) { vec3_t fogColor; if ( !CM_ParseVector( shader, text, 3, fogColor ) ) { return; } token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { Com_Printf( S_COLOR_YELLOW "WARNING: missing parm for 'fogParms' keyword in shader '%s'/n", shader->shader ); continue; }// shader->depthForOpaque = atof( token ); // skip any old gradient directions//.........这里部分代码省略.........
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:101,
示例11: NPC_ParseParms//.........这里部分代码省略......... ri->headYawRangeLeft = 80; ri->headYawRangeRight = 80; ri->headPitchRangeUp = 45; ri->headPitchRangeDown = 45; ri->torsoYawRangeLeft = 60; ri->torsoYawRangeRight = 60; ri->torsoPitchRangeUp = 30; ri->torsoPitchRangeDown = 50; VectorCopy(playerMins, NPC->mins); VectorCopy(playerMaxs, NPC->maxs); NPC->client->crouchheight = CROUCH_MAXS_2; NPC->client->standheight = DEFAULT_MAXS_2; NPC->client->dismemberProbHead = 100; NPC->client->dismemberProbArms = 100; NPC->client->dismemberProbHands = 100; NPC->client->dismemberProbWaist = 100; NPC->client->dismemberProbLegs = 100; if ( !Q_stricmp( "random", NPCName ) ) {//Randomly assemble a starfleet guy NPC_BuildRandom( NPC ); } else { p = NPCParms; COM_BeginParseSession(); // look for the right NPC while ( p ) { token = COM_ParseExt( &p, qtrue ); if ( token[0] == 0 ) { return qfalse; } if ( !Q_stricmp( token, NPCName ) ) { break; } SkipBracedSection( &p ); } if ( !p ) { return qfalse; } if ( G_ParseLiteral( &p, "{" ) ) { return qfalse; } // parse the NPC info block while ( 1 ) { token = COM_ParseExt( &p, qtrue ); if ( !token[0] ) { gi.Printf( S_COLOR_RED"ERROR: unexpected EOF while parsing '%s'/n", NPCName ); return qfalse; }
开发者ID:Hasimir,项目名称:jedi-outcast-1,代码行数:66,
示例12: G_Script_ScriptParse//.........这里部分代码省略......... { COM_ParseError("'{' expected, found: %s./n", token); } while ((token = COM_Parse(&pScript)) && (token[0] != '}')) { if (strlen(params)) // add a space between each param { Q_strcat(params, sizeof(params), " "); } if (strrchr(token, ' ')) // need to wrap this param in quotes since it has more than one word { Q_strcat(params, sizeof(params), "/""); } Q_strcat(params, sizeof(params), token); if (strrchr(token, ' ')) // need to wrap this param in quotes since it has mor { Q_strcat(params, sizeof(params), "/""); } } } else // hackly precaching of custom characters if (!Q_stricmp(token, "spawnbot")) { // this is fairly indepth, so I'll move it to a separate function for readability G_Script_ParseSpawnbot(&pScript, params, MAX_INFO_STRING); } else { token = COM_ParseExt(&pScript, qfalse); for (i = 0; token[0]; i++) { if (strlen(params)) // add a space between each param { Q_strcat(params, sizeof(params), " "); } if (i == 0) { // Special case: playsound's need to be cached on startup to prevent in-game pauses if (!Q_stricmp(action->actionString, "playsound")) { G_SoundIndex(token); } else if (!Q_stricmp(action->actionString, "changemodel")) { G_ModelIndex(token); } else if (buildScript && ( !Q_stricmp(action->actionString, "mu_start") || !Q_stricmp(action->actionString, "mu_play") || !Q_stricmp(action->actionString, "mu_queue") || !Q_stricmp(action->actionString, "startcam")) ) { if (strlen(token)) // we know there's a [0], but don't know if it's '0' { trap_SendServerCommand(-1, va("addToBuild %s/n", token)); } } }
开发者ID:morsik,项目名称:war-territory,代码行数:66,
示例13: CG_DrawScoreboard/** CG_DrawScoreboard*/void CG_DrawScoreboard( void ){ int pass; char *ptr, *token, *layout, title[MAX_STRING_CHARS], type; int team = TEAM_PLAYERS; int xpos; int ypos, yoffset, maxyoffset; struct qfontface_s *font; struct qfontface_s *monofont; struct qfontface_s *titlefont; int width, panelWidth; vec4_t whiteTransparent = { 1.0f, 1.0f, 1.0f, 0.5f }; // no layout defined if( !cgs.configStrings[CS_SCB_PLAYERTAB_LAYOUT][0] ) return; if( scoreboardString[0] != '&' ) // nothing to draw return; font = CG_ScoreboardFont( cg_scoreboardFontFamily, cg_scoreboardFontSize ); monofont = CG_ScoreboardFont( cg_scoreboardMonoFontFamily, cg_scoreboardFontSize ); titlefont = CG_ScoreboardFont( cg_scoreboardTitleFontFamily, cg_scoreboardTitleFontSize ); xpos = (int)( cgs.vidWidth * 0.5 ); ypos = (int)( cgs.vidHeight * 0.2 ) - 24 * cgs.vidHeight / 600; // draw title Q_snprintfz( title, sizeof( title ), va( "%s %s", trap_Cvar_String( "gamename" ), gs.gametypeName ) ); Q_strupr( title ); trap_SCR_DrawString( xpos, ypos, ALIGN_CENTER_TOP, title, titlefont, whiteTransparent ); ypos += trap_SCR_FontHeight( titlefont ); trap_SCR_DrawStringWidth( xpos, ypos, ALIGN_CENTER_TOP, cgs.configStrings[CS_HOSTNAME], cgs.vidWidth*0.75, font, whiteTransparent ); ypos += trap_SCR_FontHeight( font ); // calculate the panel width from the layout panelWidth = 0; layout = cgs.configStrings[CS_SCB_PLAYERTAB_LAYOUT]; while( SCR_GetNextColumnLayout( (const char **)&layout, NULL, &type, &width, font ) != NULL ) { if( !SCR_SkipColumn( type ) ) panelWidth += width; } // parse and draw the scoreboard message for ( pass = 0; pass < 2; pass++ ) { yoffset = 0; maxyoffset = 0; scr_numplayericons = 0; ptr = scoreboardString; while ( ptr ) { token = COM_ParseExt( &ptr, true ); if ( token[0] != '&' ) break; if ( !Q_stricmp( token, "&t" ) ) // team tab { yoffset = 0; yoffset += SCR_DrawTeamTab( (const char **)&ptr, &team, xpos, ypos + yoffset, panelWidth, font, titlefont, pass ); } else if ( !Q_stricmp( token, "&p" ) ) // player tab { yoffset += SCR_DrawPlayerTab( (const char **)&ptr, team, xpos, ypos + yoffset, panelWidth, font, pass ); } else if ( !Q_stricmp( token, "&w" ) ) // list of challengers { if ( yoffset < maxyoffset ) yoffset = maxyoffset; maxyoffset += SCR_DrawChallengers( (const char **)&ptr, xpos, ypos + yoffset, panelWidth, font, pass ); } else if ( !Q_stricmp( token, "&s" ) ) // list of spectators { if ( yoffset < maxyoffset ) yoffset = maxyoffset; maxyoffset += SCR_DrawSpectators( (const char **)&ptr, xpos, ypos + yoffset, panelWidth, font, pass ); } if ( yoffset > maxyoffset ) maxyoffset = yoffset; } if( !pass ) SCR_DrawPlayerIcons( font ); } // add the player stats yoffset = maxyoffset + trap_SCR_FontHeight( font ); yoffset += SCB_DrawPlayerStats( xpos, ypos + yoffset, monofont );}
开发者ID:futurepneu,项目名称:racemod,代码行数:96,
示例14: SCR_DrawPlayerTab/** SCR_DrawPlayerTab*/static int SCR_DrawPlayerTab( const char **ptrptr, int team, int x, int y, int panelWidth, struct qfontface_s *font, int pass ){ int dir, align, i, columncount; char type, string[MAX_STRING_CHARS]; const char *oldptr; char *token, *layout; int height, width, xoffset, yoffset; vec4_t teamcolor = { 0.0f, 0.0f, 0.0f, 1.0f }, color; int iconnum; struct shader_s *icon; bool highlight = false, trans = false; if( GS_TeamBasedGametype() ) { dir = ( team == TEAM_ALPHA ) ? -1 : 1; align = ( team == TEAM_ALPHA ) ? ALIGN_RIGHT_TOP : ALIGN_LEFT_TOP; } else { dir = 0; align = ALIGN_CENTER_TOP; } xoffset = 0; yoffset = 0; height = trap_SCR_FontHeight( font ); // start from the center again xoffset = CG_HorizontalAlignForWidth( 0, align, panelWidth ); xoffset += ( SCB_CENTERMARGIN * dir ); // draw the background columncount = 0; if( ( team == TEAM_ALPHA ) || ( team == TEAM_BETA ) ) CG_TeamColor( team, teamcolor ); // draw the player tab column titles layout = cgs.configStrings[CS_SCB_PLAYERTAB_LAYOUT]; while( SCR_GetNextColumnLayout( (const char **)&layout, NULL, &type, &width, font ) != NULL ) { // grab the actual scoreboard data oldptr = *ptrptr; // in case we need to revert token = COM_ParseExt( ptrptr, true ); if( token[0] == '&' ) { *ptrptr = oldptr; // failed, but revert so it can continue with the next player break; } if( !token[0] ) break; if( SCR_SkipColumn( type ) ) continue; Vector4Copy( colorWhite, color ); // reset to white after each column icon = NULL; string[0] = 0; // interpret the data based on the type defined in the layout switch( type ) { default: CG_Error( "SCR_DrawPlayerTab: Invalid player tab layout/n" ); break; case 's': // is a string Q_strncpyz( string, token, sizeof( string ) ); break; case 'n': // is a player name indicated by player number i = atoi( token ); if( i < 0 ) // negative numbers toggle transparency on { trans = true; i = -1 - i; } if( i < 0 || i >= gs.maxclients ) Q_strncpyz( string, "invalid", sizeof( string ) ); else Q_strncpyz( string, cgs.clientInfo[i].name, sizeof( string ) ); if( ISVIEWERENTITY( i + 1 ) ) // highlight if it's our own player highlight = true; break; case 'i': // is a integer (negatives are colored in red) i = atoi( token ); Q_snprintfz( string, sizeof( string ), "%i", i ); VectorCopy( i >= 0 ? colorWhite : colorRed, color ); break;//.........这里部分代码省略.........
开发者ID:futurepneu,项目名称:racemod,代码行数:101,
示例15: G_SpawnBot//.........这里部分代码省略......... return; } // Q_strncpyz( last_cmd, cmd, sizeof(last_cmd) ); Q_strncpyz( cmd, cmd_var, sizeof(cmd) ); } // if (strlen( pClass )) { pClassInt = 1 + G_ClassForString( pClass ); } else { pClassInt = 0; } if ( !Q_stricmp( team, "red" ) || !Q_stricmp( team, "r" ) || !Q_stricmp( team, "axis" ) ) { teamNum = TEAM_AXIS; } else if ( !Q_stricmp( team, "blue" ) || !Q_stricmp( team, "b" ) || !Q_stricmp( team, "allies" ) ) { teamNum = TEAM_ALLIES; } else { // pick the team with the least number of players teamNum = PickTeam( -1 ); } G_BotParseCharacterParms( characterFile, &characterInt ); // Gordon: 27/11/02 if( *pow && !Q_stricmp(pow, "yes") ) { prisonerOfWar = qtrue; } else { prisonerOfWar = qfalse; } // START Mad Doc - TDF // special case: if "NONE" is specified, treat this differently if (!Q_stricmp(pWeapon, "NONE")) { weaponSpawnNumber = -1; } // END Mad Doc - TDF // START Mad Doctor I changes, 8/17/2002. // If we have a weapon specified, and we have a class specified else if (isdigit(pWeapon[0])) { // Just convert the string to a number weaponSpawnNumber = atoi(pWeapon); } // if (isdigit(pWeapon[0]))... // If we have a weapon specified as a string, and we have a class specified else if (pClassInt > 0) { // Translate the weapon name into a proper weapon index // Get the index for the weapon weaponSpawnNumber = Bot_GetWeaponForClassAndTeam( pClassInt - 1, teamNum, pWeapon ); // Get default weapon if (weaponSpawnNumber == -1) weaponSpawnNumber = BG_GetPlayerClassInfo( teamNum, pClassInt - 1 )->classWeapons[0]; } // if (Q_stricmp(pWeapon[MAX_TOKEN_CHARS], "0")... // Otherwise, no weapon is selected else { // Just use the default weaponSpawnNumber = BG_GetPlayerClassInfo( teamNum, pClassInt - 1 )->classWeapons[0]; } // else... // START Mad Doc - TDF rankNum = atoi(rank); if( rankNum ) { rankNum--; // people like to start with 1 // Gordon: coders are people too :( } if (botSkills[0]) { // parse the skills out int i; char *pString, *token; pString = botSkills; for (i = 0; i < SK_NUM_SKILLS; i++) { token = COM_ParseExt( &pString, qfalse ); skills[i] = atoi(token); } } // {"/botskills", botSkills, qfalse, "[botskills]"}, // not really to be exposed to script// END Mad Doc - TDF G_AddBot( name, atoi(skill), team, spawnPoint, pClassInt, weaponSpawnNumber, characterInt, respawn, scriptName, rankNum, skills, prisonerOfWar );// END Mad Doctor I changes, 8/17/2002. }
开发者ID:GenaSG,项目名称:ET,代码行数:101,
示例16: G_ScriptAction_PlayAnim/*=================G_ScriptAction_PlayAnim syntax: playanim <startframe> <endframe> [looping <FOREVER/duration>] [rate <FPS>] NOTE: all source animations must be at 20fps=================*/qboolean G_ScriptAction_PlayAnim( gentity_t *ent, char *params ) { char *pString, *token, tokens[2][MAX_QPATH]; int i, endtime = 0; // TTimo: init qboolean looping = qfalse, forever = qfalse; int startframe, endframe, idealframe; int rate = 20; if ( ( ent->scriptStatus.scriptFlags & SCFL_ANIMATING ) && ( ent->scriptStatus.scriptStackChangeTime == level.time ) ) { // this is a new call, so cancel the previous animation ent->scriptStatus.scriptFlags &= ~SCFL_ANIMATING; } pString = params; for ( i = 0; i < 2; i++ ) { token = COM_ParseExt( &pString, qfalse ); if ( !token || !token[0] ) { G_Printf( "G_Scripting: syntax error/n/nplayanim <startframe> <endframe> [LOOPING <duration>]/n" ); return qtrue; } else { Q_strncpyz( tokens[i], token, sizeof( tokens[i] ) ); } } startframe = atoi( tokens[0] ); endframe = atoi( tokens[1] ); // check for optional parameters token = COM_ParseExt( &pString, qfalse ); if ( token[0] ) { if ( !Q_strcasecmp( token, "looping" ) ) { looping = qtrue; token = COM_ParseExt( &pString, qfalse ); if ( !token || !token[0] ) { G_Printf( "G_Scripting: syntax error/n/nplayanim <startframe> <endframe> [LOOPING <duration>]/n" ); return qtrue; } if ( !Q_strcasecmp( token, "untilreachmarker" ) ) { if ( level.time < ent->s.pos.trTime + ent->s.pos.trDuration ) { endtime = level.time + 100; } else { endtime = 0; } } else if ( !Q_strcasecmp( token, "forever" ) ) { ent->scriptStatus.animatingParams = params; ent->scriptStatus.scriptFlags |= SCFL_ANIMATING; endtime = level.time + 100; // we don't care when it ends, since we are going forever! forever = qtrue; } else { endtime = ent->scriptStatus.scriptStackChangeTime + atoi( token ); } token = COM_ParseExt( &pString, qfalse ); } if ( token[0] && !Q_strcasecmp( token, "rate" ) ) { token = COM_ParseExt( &pString, qfalse ); if ( !token[0] ) { G_Error( "G_Scripting: playanim has RATE parameter without an actual rate specified" ); } rate = atoi( token ); } if ( !looping ) { endtime = ent->scriptStatus.scriptStackChangeTime + ( ( endframe - startframe ) * ( 1000 / 20 ) ); } } idealframe = startframe + (int)floor( (float)( level.time - ent->scriptStatus.scriptStackChangeTime ) / ( 1000.0 / (float)rate ) ); if ( looping ) { ent->s.frame = startframe + ( idealframe - startframe ) % ( endframe - startframe ); ent->s.eFlags |= EF_MOVER_ANIMATE; } else { if ( idealframe > endframe ) { ent->s.frame = endframe; ent->s.eFlags &= ~EF_MOVER_ANIMATE; // stop interpolation, since we have gone passed the endframe } else { ent->s.frame = idealframe; ent->s.eFlags |= EF_MOVER_ANIMATE; } } if ( forever ) { ent->s.eFlags |= EF_MOVER_ANIMATE; return qtrue; // continue to the next command } if ( endtime <= level.time ) { ent->s.eFlags &= ~EF_MOVER_ANIMATE; // stop animating return qtrue;//.........这里部分代码省略.........
开发者ID:aleksandr-pushkarev,项目名称:RTCW-SP,代码行数:101,
示例17: G_ScriptAction_GotoMarker/*===============G_ScriptAction_GotoMarker syntax: gotomarker <targetname> <speed> [accel/deccel] [turntotarget] [wait] NOTE: speed may be modified to round the duration to the next 50ms for smooth transitions===============*/qboolean G_ScriptAction_GotoMarker( gentity_t *ent, char *params ) { char *pString, *token; gentity_t *target; vec3_t vec; float speed, dist; qboolean wait = qfalse, turntotarget = qfalse; int trType; int duration, i; vec3_t diff; vec3_t angles; if ( params && ( ent->scriptStatus.scriptFlags & SCFL_GOING_TO_MARKER ) ) { // we can't process a new movement until the last one has finished return qfalse; } if ( !params || ent->scriptStatus.scriptStackChangeTime < level.time ) { // we are waiting for it to reach destination if ( ent->s.pos.trTime + ent->s.pos.trDuration <= level.time ) { // we made it ent->scriptStatus.scriptFlags &= ~SCFL_GOING_TO_MARKER; // set the angles at the destination BG_EvaluateTrajectory( &ent->s.apos, ent->s.apos.trTime + ent->s.apos.trDuration, ent->s.angles ); VectorCopy( ent->s.angles, ent->s.apos.trBase ); VectorCopy( ent->s.angles, ent->r.currentAngles ); ent->s.apos.trTime = level.time; ent->s.apos.trDuration = 0; ent->s.apos.trType = TR_STATIONARY; VectorClear( ent->s.apos.trDelta ); // stop moving BG_EvaluateTrajectory( &ent->s.pos, level.time, ent->s.origin ); VectorCopy( ent->s.origin, ent->s.pos.trBase ); VectorCopy( ent->s.origin, ent->r.currentOrigin ); ent->s.pos.trTime = level.time; ent->s.pos.trDuration = 0; ent->s.pos.trType = TR_STATIONARY; VectorClear( ent->s.pos.trDelta ); script_linkentity( ent ); return qtrue; } } else { // we have just started this command pString = params; token = COM_ParseExt( &pString, qfalse ); if ( !token[0] ) { G_Error( "G_Scripting: gotomarker must have an targetname/n" ); } // find the entity with the given "targetname" target = G_Find( NULL, FOFS( targetname ), token ); if ( !target ) { G_Error( "G_Scripting: can't find entity with /"targetname/" = /"%s/"/n", token ); } VectorSubtract( target->r.currentOrigin, ent->r.currentOrigin, vec ); token = COM_ParseExt( &pString, qfalse ); if ( !token[0] ) { G_Error( "G_Scripting: gotomarker must have a speed/n" ); } speed = atof( token ); trType = TR_LINEAR_STOP; while ( token[0] ) { token = COM_ParseExt( &pString, qfalse ); if ( token[0] ) { if ( !Q_stricmp( token, "accel" ) ) { trType = TR_ACCELERATE; } else if ( !Q_stricmp( token, "deccel" ) ) { trType = TR_DECCELERATE; } else if ( !Q_stricmp( token, "wait" ) ) { wait = qtrue; } else if ( !Q_stricmp( token, "turntotarget" ) ) { turntotarget = qtrue; } } } // start the movement if ( ent->s.eType == ET_MOVER ) { VectorCopy( vec, ent->movedir ); VectorCopy( ent->r.currentOrigin, ent->pos1 ); VectorCopy( target->r.currentOrigin, ent->pos2 ); ent->speed = speed; dist = VectorDistance( ent->pos1, ent->pos2 );//.........这里部分代码省略.........
开发者ID:aleksandr-pushkarev,项目名称:RTCW-SP,代码行数:101,
示例18: G_ParseArmourScript/*===============G_ParseArmourScript===============*/void G_ParseArmourScript( char *buf, int upgrade ){ char *token; int count; count = 0; while( 1 ) { token = COM_Parse( &buf ); if( !token[0] ) break; if( strcmp( token, "{" ) ) { G_Printf( "Missing { in armour file/n" ); break; } if( count == MAX_ARMOUR_REGIONS ) { G_Printf( "Max armour regions exceeded in locdamage file/n" ); break; } //default g_armourRegions[ upgrade ][ count ].minHeight = 0.0; g_armourRegions[ upgrade ][ count ].maxHeight = 1.0; g_armourRegions[ upgrade ][ count ].minAngle = 0; g_armourRegions[ upgrade ][ count ].maxAngle = 360; g_armourRegions[ upgrade ][ count ].modifier = 1.0; g_armourRegions[ upgrade ][ count ].crouch = qfalse; while( 1 ) { token = COM_ParseExt( &buf, qtrue ); if( !token[0] ) { G_Printf( "Unexpected end of armour file/n" ); break; } if( !Q_stricmp( token, "}" ) ) { break; } else if( !strcmp( token, "minHeight" ) ) { token = COM_ParseExt( &buf, qfalse ); if ( !token[0] ) strcpy( token, "0" ); g_armourRegions[ upgrade ][ count ].minHeight = atof( token ); } else if( !strcmp( token, "maxHeight" ) ) { token = COM_ParseExt( &buf, qfalse ); if ( !token[0] ) strcpy( token, "100" ); g_armourRegions[ upgrade ][ count ].maxHeight = atof( token ); } else if( !strcmp( token, "minAngle" ) ) { token = COM_ParseExt( &buf, qfalse ); if ( !token[0] ) strcpy( token, "0" ); g_armourRegions[ upgrade ][ count ].minAngle = atoi( token ); } else if( !strcmp( token, "maxAngle" ) ) { token = COM_ParseExt( &buf, qfalse ); if ( !token[0] ) strcpy( token, "360" ); g_armourRegions[ upgrade ][ count ].maxAngle = atoi( token ); } else if( !strcmp( token, "modifier" ) ) { token = COM_ParseExt( &buf, qfalse ); if ( !token[0] ) strcpy( token, "1.0" ); g_armourRegions[ upgrade ][ count ].modifier = atof( token ); } else if( !strcmp( token, "crouch" ) ) {//.........这里部分代码省略.........
开发者ID:aminehaddad,项目名称:tremulous-tremball,代码行数:101,
示例19: G_ScriptAction_Accum/*=================G_ScriptAction_Accum syntax: accum <buffer_index> <command> <paramater> Commands: accum <n> inc <m> accum <n> abort_if_less_than <m> accum <n> abort_if_greater_than <m> accum <n> abort_if_not_equal <m> accum <n> abort_if_equal <m> accum <n> set <m> accum <n> random <m> accum <n> bitset <m> accum <n> bitreset <m> accum <n> abort_if_bitset <m> accum <n> abort_if_not_bitset <m>=================*/qboolean G_ScriptAction_Accum( gentity_t *ent, char *params ) { char *pString, *token, lastToken[MAX_QPATH]; int bufferIndex; pString = params; token = COM_ParseExt( &pString, qfalse ); if ( !token[0] ) { G_Error( "G_Scripting: accum without a buffer index/n" ); } bufferIndex = atoi( token ); if ( bufferIndex >= G_MAX_SCRIPT_ACCUM_BUFFERS ) { G_Error( "G_Scripting: accum buffer is outside range (0 - %i)/n", G_MAX_SCRIPT_ACCUM_BUFFERS ); } token = COM_ParseExt( &pString, qfalse ); if ( !token[0] ) { G_Error( "G_Scripting: accum without a command/n" ); } Q_strncpyz( lastToken, token, sizeof( lastToken ) ); token = COM_ParseExt( &pString, qfalse ); if ( !Q_stricmp( lastToken, "inc" ) ) { if ( !token[0] ) { G_Error( "Scripting: accum %s requires a parameter/n", lastToken ); } ent->scriptAccumBuffer[bufferIndex] += atoi( token ); } else if ( !Q_stricmp( lastToken, "abort_if_less_than" ) ) { if ( !token[0] ) { G_Error( "Scripting: accum %s requires a parameter/n", lastToken ); } if ( ent->scriptAccumBuffer[bufferIndex] < atoi( token ) ) { // abort the current script ent->scriptStatus.scriptStackHead = ent->scriptEvents[ent->scriptStatus.scriptEventIndex].stack.numItems; } } else if ( !Q_stricmp( lastToken, "abort_if_greater_than" ) ) { if ( !token[0] ) { G_Error( "Scripting: accum %s requires a parameter/n", lastToken ); } if ( ent->scriptAccumBuffer[bufferIndex] > atoi( token ) ) { // abort the current script ent->scriptStatus.scriptStackHead = ent->scriptEvents[ent->scriptStatus.scriptEventIndex].stack.numItems; } } else if ( !Q_stricmp( lastToken, "abort_if_not_equal" ) ) { if ( !token[0] ) { G_Error( "Scripting: accum %s requires a parameter/n", lastToken ); } if ( ent->scriptAccumBuffer[bufferIndex] != atoi( token ) ) { // abort the current script ent->scriptStatus.scriptStackHead = ent->scriptEvents[ent->scriptStatus.scriptEventIndex].stack.numItems; } } else if ( !Q_stricmp( lastToken, "abort_if_equal" ) ) { if ( !token[0] ) { G_Error( "Scripting: accum %s requires a parameter/n", lastToken ); } if ( ent->scriptAccumBuffer[bufferIndex] == atoi( token ) ) { // abort the current script ent->scriptStatus.scriptStackHead = ent->scriptEvents[ent->scriptStatus.scriptEventIndex].stack.numItems; } } else if ( !Q_stricmp( lastToken, "bitset" ) ) { if ( !token[0] ) { G_Error( "Scripting: accum %s requires a parameter/n", lastToken ); } ent->scriptAccumBuffer[bufferIndex] |= ( 1 << atoi( token ) ); } else if ( !Q_stricmp( lastToken, "bitreset" ) ) { if ( !token[0] ) { G_Error( "Scripting: accum %s requires a parameter/n", lastToken ); } ent->scriptAccumBuffer[bufferIndex] &= ~( 1 << atoi( token ) ); } else if ( !Q_stricmp( lastToken, "abort_if_bitset" ) ) { if ( !token[0] ) { G_Error( "Scripting: accum %s requires a parameter/n", lastToken ); } if ( ent->scriptAccumBuffer[bufferIndex] & ( 1 << atoi( token ) ) ) { // abort the current script ent->scriptStatus.scriptStackHead = ent->scriptEvents[ent->scriptStatus.scriptEventIndex].stack.numItems; }//.........这里部分代码省略.........
开发者ID:aleksandr-pushkarev,项目名称:RTCW-SP,代码行数:101,
示例20: ParseDmgScriptstatic int ParseDmgScript( damageRegion_t *regions, const char *buf ){ char *token; float angleSpan, heightSpan; int count; for ( count = 0;; count++ ) { token = COM_Parse( &buf ); if ( !token[ 0 ] ) { break; } if ( strcmp( token, "{" ) ) { COM_ParseError( "Missing {" ); break; } if ( count >= MAX_DAMAGE_REGIONS ) { COM_ParseError( "Max damage regions exceeded" ); break; } // defaults regions[ count ].name[ 0 ] = '/0'; regions[ count ].minHeight = 0.0f; regions[ count ].maxHeight = 1.0f; regions[ count ].minAngle = 0.0f; regions[ count ].maxAngle = 360.0f; regions[ count ].modifier = 1.0f; regions[ count ].crouch = false; regions[ count ].nonlocational = false; while ( 1 ) { token = COM_ParseExt( &buf, true ); if ( !token[ 0 ] ) { COM_ParseError( "Unexpected end of file" ); break; } if ( !Q_stricmp( token, "}" ) ) { break; } else if ( !strcmp( token, "name" ) ) { token = COM_ParseExt( &buf, false ); if ( token[ 0 ] ) { Q_strncpyz( regions[ count ].name, token, sizeof( regions[ count ].name ) ); } } else if ( !strcmp( token, "minHeight" ) ) { token = COM_ParseExt( &buf, false ); if ( !token[ 0 ] ) { strcpy( token, "0" ); } regions[ count ].minHeight = atof( token ); } else if ( !strcmp( token, "maxHeight" ) ) { token = COM_ParseExt( &buf, false ); if ( !token[ 0 ] ) { strcpy( token, "100" ); } regions[ count ].maxHeight = atof( token ); } else if ( !strcmp( token, "minAngle" ) ) { token = COM_ParseExt( &buf, false ); if ( !token[ 0 ] ) { strcpy( token, "0" ); } regions[ count ].minAngle = atoi( token ); } else if ( !strcmp( token, "maxAngle" ) ) { token = COM_ParseExt( &buf, false ); if ( !token[ 0 ] ) {//.........这里部分代码省略.........
开发者ID:matthiaskrgr,项目名称:Unvanquished,代码行数:101,
示例21: UI_ParseInfos/*===============UI_ParseInfos===============*/int UI_ParseInfos( char *buf, int max, char *infos[] ){ char *token; int count; char key[ MAX_TOKEN_CHARS ]; char info[ MAX_INFO_STRING ]; count = 0; while ( 1 ) { token = COM_Parse( &buf ); if ( !token[ 0 ] ) { break; } if ( strcmp( token, "{" ) ) { Com_Printf( "Missing { in info file/n" ); break; } if ( count == max ) { Com_Printf( "Max infos exceeded/n" ); break; } info[ 0 ] = '/0'; while ( 1 ) { token = COM_ParseExt( &buf, qtrue ); if ( !token[ 0 ] ) { Com_Printf( "Unexpected end of info file/n" ); break; } if ( !strcmp( token, "}" ) ) { break; } Q_strncpyz( key, token, sizeof( key ) ); token = COM_ParseExt( &buf, qfalse ); if ( !token[ 0 ] ) { strcpy( token, "<NULL>" ); } Info_SetValueForKey( info, key, token ); } //NOTE: extra space for arena number infos[ count ] = UI_Alloc( strlen( info ) + strlen( "//num//" ) + strlen( va( "%d", MAX_ARENAS ) ) + 1 ); if ( infos[ count ] ) { strcpy( infos[ count ], info ); count++; } } return count;}
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:76,
示例22: R_LoadEntities/*================R_LoadEntities================*/void R_LoadEntities( lump_t *l, world_t &worldData ) { const char *p, *token; char keyname[MAX_TOKEN_CHARS]; char value[MAX_TOKEN_CHARS]; world_t *w; float ambient = 1; COM_BeginParseSession(); w = &worldData; w->lightGridSize[0] = 64; w->lightGridSize[1] = 64; w->lightGridSize[2] = 128; VectorSet(tr.sunAmbient, 1, 1, 1); tr.distanceCull = 12000;//DEFAULT_DISTANCE_CULL; p = (char *)(fileBase + l->fileofs); token = COM_ParseExt( &p, qtrue ); if (!*token || *token != '{') { COM_EndParseSession(); return; } // only parse the world spawn while ( 1 ) { // parse key token = COM_ParseExt( &p, qtrue ); if ( !*token || *token == '}' ) { break; } Q_strncpyz(keyname, token, sizeof(keyname)); // parse value token = COM_ParseExt( &p, qtrue ); if ( !*token || *token == '}' ) { break; } Q_strncpyz(value, token, sizeof(value)); // check for remapping of shaders for vertex lighting/* s = "vertexremapshader"; if (!Q_strncmp(keyname, s, strlen(s)) ) { s = strchr(value, ';'); if (!s) { ri.Printf( S_COLOR_YELLOW "WARNING: no semi colon in vertexshaderremap '%s'/n", value ); break; } *s++ = 0; if (r_vertexLight->integer) { R_RemapShader(value, s, "0"); } continue; } // check for remapping of shaders s = "remapshader"; if (!Q_strncmp(keyname, s, strlen(s)) ) { s = strchr(value, ';'); if (!s) { ri.Printf( S_COLOR_YELLOW "WARNING: no semi colon in shaderremap '%s'/n", value ); break; } *s++ = 0; R_RemapShader(value, s, "0"); continue; }*/ if (!Q_stricmp(keyname, "distanceCull")) { sscanf(value, "%f", &tr.distanceCull ); continue; } //check for linear fog -rww if (!Q_stricmp(keyname, "linFogStart")) { sscanf(value, "%f", &tr.rangedFog ); tr.rangedFog = -tr.rangedFog; continue; } // check for a different grid size if (!Q_stricmp(keyname, "gridsize")) { sscanf(value, "%f %f %f", &w->lightGridSize[0], &w->lightGridSize[1], &w->lightGridSize[2] ); continue; } // find the optional world ambient for arioche if (!Q_stricmp(keyname, "_color")) { sscanf(value, "%f %f %f", &tr.sunAmbient[0], &tr.sunAmbient[1], &tr.sunAmbient[2] ); continue; } if (!Q_stricmp(keyname, "ambient")) { sscanf(value, "%f", &ambient); continue; } } //both default to 1 so no harm if not present.//.........这里部分代码省略.........
开发者ID:DavidZeise,项目名称:OpenJK,代码行数:101,
示例23: UI_SaberParseParmqboolean UI_SaberParseParm( const char *saberName, const char *parmname, char *saberData ) { const char *token; const char *value; const char *p; if ( !saberName || !saberName[0] ) { return qfalse; } //try to parse it out p = SaberParms; // A bogus name is passed in COM_BeginParseSession("saberinfo"); // look for the right saber while ( p ) { token = COM_ParseExt( &p, qtrue ); if ( token[0] == 0 ) { return qfalse; } if ( !Q_stricmp( token, saberName ) ) { break; } SkipBracedSection( &p, 0 ); } if ( !p ) { return qfalse; } if ( UI_ParseLiteral( &p, "{" ) ) { return qfalse; } // parse the saber info block while ( 1 ) { token = COM_ParseExt( &p, qtrue ); if ( !token[0] ) { Com_Printf( S_COLOR_RED"ERROR: unexpected EOF while parsing '%s'/n", saberName ); return qfalse; } if ( !Q_stricmp( token, "}" ) ) { break; } if ( !Q_stricmp( token, parmname ) ) { if ( COM_ParseString( &p, &value ) ) { continue; } strcpy( saberData, value ); return qtrue; } SkipRestOfLine( &p ); continue; } return qfalse;}
开发者ID:DarthFutuza,项目名称:JediKnightGalaxies,代码行数:73,
示例24: Bot_ScriptLog_Entry/*=================Bot_ScriptLog_Entry=================*/void Bot_ScriptLog_Entry(bot_state_t * bs, qboolean showDetails, char *preText, char *fmt, ...){ va_list ap; char text[1024], *pStr, *token; fileHandle_t f; int i; // if(!(f = bs->script.logFile)) { return; } // // timestamp // get the time/date Q_strncpyz(text, va("(%i) ", level.time), sizeof(text)); trap_FS_Write(text, strlen(text), f); // i = 40; // padding for indentation // pretext if(preText) { trap_FS_Write(preText, strlen(preText), f); i -= strlen(preText); if(i < 0) { i = 0; } } // indentation while(i--) trap_FS_Write(" ", 1, f); // if(showDetails && (Bot_Script_GetCurrentLine(bs) > -1)) { // show the current script line and text Q_strncpyz(text, va("(line %i:", Bot_Script_GetCurrentLine(bs)), sizeof(text)); trap_FS_Write(text, strlen(text), f); // text pStr = bs->script.status.currentItem->text; while((token = COM_ParseExt(&pStr, qfalse)) && token[0]) { trap_FS_Write(" ", 1, f); trap_FS_Write(token, strlen(token), f); } trap_FS_Write(") ", 2, f); } // if(fmt) { va_start(ap, fmt); Q_vsnprintf(text, sizeof(text), fmt, ap); if(strlen(text) >= sizeof(text)) { //G_Error( "Bot_ScriptLog_Entry: text exceeded buffer size" ); // just cut it short text[sizeof(text) - 1] = '/0'; } va_end(ap); // trap_FS_Write(text, strlen(text), f); } trap_FS_Write("/r/n", 2, f);}
开发者ID:ethr,项目名称:ETXreaLPro_etmain,代码行数:69,
示例25: UI_SaberGetHiltInfovoid UI_SaberGetHiltInfo( const char *singleHilts[MAX_SABER_HILTS], const char *staffHilts[MAX_SABER_HILTS] ){ int numSingleHilts = 0, numStaffHilts = 0; const char *saberName; const char *token; const char *p; //go through all the loaded sabers and put the valid ones in the proper list p = SaberParms; COM_BeginParseSession("saberlist"); // look for a saber while ( p ) { token = COM_ParseExt( &p, qtrue ); if ( token[0] == 0 ) {//invalid name continue; } saberName = String_Alloc( token ); //see if there's a "{" on the next line SkipRestOfLine( &p ); if ( UI_ParseLiteralSilent( &p, "{" ) ) {//nope, not a name, keep looking continue; } //this is a saber name if ( !UI_SaberValidForPlayerInMP( saberName ) ) { SkipBracedSection( &p, 0 ); continue; } if ( UI_IsSaberTwoHanded( saberName ) ) { if ( numStaffHilts < MAX_SABER_HILTS-1 )//-1 because we have to NULL terminate the list { staffHilts[numStaffHilts++] = saberName; } else { Com_Printf( "WARNING: too many two-handed sabers, ignoring saber '%s'/n", saberName ); } } else { if ( numSingleHilts < MAX_SABER_HILTS-1 )//-1 because we have to NULL terminate the list { singleHilts[numSingleHilts++] = saberName; } else { Com_Printf( "WARNING: too many one-handed sabers, ignoring saber '%s'/n", saberName ); } } //skip the whole braced section and move on to the next entry SkipBracedSection( &p, 0 ); } //null terminate the list so the UI code knows where to stop listing them singleHilts[numSingleHilts] = NULL; staffHilts[numStaffHilts] = NULL;}
开发者ID:DarthFutuza,项目名称:JediKnightGalaxies,代码行数:64,
示例26: Bot_ScriptParse//.........这里部分代码省略......... } if(strlen(params)) { // copy the params into the event curEvent->params = &bsd->stringPool[strPoolCount]; Q_strncpyz(curEvent->params, params, BOT_SIZE_STRING_POOL - strPoolCount); if((strPoolCount += strlen(params) + 1) >= BOT_SIZE_STRING_POOL) { G_Error("Bot_ScriptParse(), Error (line %d): string pool size exceeded (MAX = %i)/n", 1 + COM_GetCurrentParseLine(), BOT_SIZE_STRING_POOL); } } // parse the actions for this event while((token = COM_Parse(text)) && (token[0] != '}')) { if(!token[0]) { G_Error("Bot_ScriptParse(), Error (line %d): '}' expected, end of script found./n", 1 + COM_GetCurrentParseLine()); } action = Bot_ActionForString(token); if(!action) { G_Error("Bot_ScriptParse(), Error (line %d): unknown action: %s./n", 1 + COM_GetCurrentParseLine(), token); } items[numItems].action = action; items[numItems].lineNum = 1 + COM_GetCurrentParseLine(); items[numItems].text = *text - strlen(token); memset(params, 0, sizeof(params)); token = COM_ParseExt(text, qfalse); for(i = 0; token[0]; i++) { if(strlen(params)) { // add a space between each param Q_strcat(params, sizeof(params), " "); } // Special case: playsound's need to be cached on startup to prevent in-game pauses if(i == 0) { if(!Q_stricmp(action->actionString, "playsound")) { G_SoundIndex(token); } } if(strrchr(token, ' ')) { // need to wrap this param in quotes since it has more than one word Q_strcat(params, sizeof(params), "/""); } Q_strcat(params, sizeof(params), token); if(strrchr(token, ' ')) { // need to wrap this param in quotes since it has more than one word Q_strcat(params, sizeof(params), "/""); } token = COM_ParseExt(text, qfalse); } if(strlen(params))
开发者ID:ethr,项目名称:ETXreaLPro_etmain,代码行数:67,
示例27: AICast_ScriptParse//.........这里部分代码省略......... if (BG_IndexForString( token, animStateStr, qtrue ) < 0) { G_Error( "AICast_ScriptParse(), Error (line %d): unknown state type '%s'./n", COM_GetCurrentParseLine(), token ); } } } if (strlen( params )) // add a space between each param Q_strcat( params, sizeof(params), " " ); Q_strcat( params, sizeof(params), token ); } if (strlen( params )) { // copy the params into the event curEvent->params = G_Alloc( strlen( params ) + 1 ); Q_strncpyz( curEvent->params, params, strlen(params)+1 ); } // parse the actions for this event while ((token = COM_Parse( &pScript )) && (token[0] != '}')) { if (!token[0]) { G_Error( "AICast_ScriptParse(), Error (line %d): '}' expected, end of script found./n", COM_GetCurrentParseLine() ); } action = AICast_ActionForString( token ); if (!action) { G_Error( "AICast_ScriptParse(), Error (line %d): unknown action: %s./n", COM_GetCurrentParseLine(), token ); } curEvent->stack.items[curEvent->stack.numItems].action = action; memset( params, 0, sizeof(params) ); token = COM_ParseExt( &pScript, qfalse ); for (i=0; token[0]; i++) { if (strlen( params )) { // add a space between each param Q_strcat( params, sizeof(params), " " ); } // Special case: playsound's need to be cached on startup to prevent in-game pauses if ((i==0) && !Q_stricmp(action->actionString, "playsound")) { G_SoundIndex(token); } if (strrchr(token,' ')) // need to wrap this param in quotes since it has more than one word Q_strcat( params, sizeof(params), "/"" ); Q_strcat( params, sizeof(params), token ); if (strrchr(token,' ')) // need to wrap this param in quotes since it has more than one word Q_strcat( params, sizeof(params), "/"" ); token = COM_ParseExt( &pScript, qfalse ); } if (strlen( params )) { // copy the params into the event curEvent->stack.items[curEvent->stack.numItems].params = G_Alloc( strlen( params ) + 1 ); Q_strncpyz( curEvent->stack.items[curEvent->stack.numItems].params, params, strlen(params)+1 ); } curEvent->stack.numItems++; if (curEvent->stack.numItems >= AICAST_MAX_SCRIPT_STACK_ITEMS) { G_Error( "AICast_ScriptParse(): script exceeded MAX_SCRIPT_ITEMS (%d), line %d/n", AICAST_MAX_SCRIPT_STACK_ITEMS, COM_GetCurrentParseLine() ); } } numEventItems++; } else // skip this character completely { // TTimo gcc: suggest parentheses around assignment used as truth value while ( ( token = COM_Parse( &pScript ) ) ) { if (!token[0]) { G_Error( "AICast_ScriptParse(), Error (line %d): '}' expected, end of script found./n", COM_GetCurrentParseLine() ); } else if (token[0] == '{') { bracketLevel++; } else if (token[0] == '}') { if (!--bracketLevel) break; } } } } // alloc and copy the events into the cast_state_t for this cast if (numEventItems > 0) { cs->castScriptEvents = G_Alloc( sizeof(cast_script_event_t) * numEventItems ); memcpy( cs->castScriptEvents, events, sizeof(cast_script_event_t) * numEventItems ); cs->numCastScriptEvents = numEventItems; cs->castScriptStatus.castScriptEventIndex = -1; }}
开发者ID:natelo,项目名称:rtcwPub,代码行数:101,
示例28: CG_ParseVoiceChats/*=================CG_ParseVoiceChats=================*/int CG_ParseVoiceChats( const char *filename, voiceChatList_t *voiceChatList, int maxVoiceChats ) { int len, i; fileHandle_t f; char buf[MAX_VOICEFILESIZE]; char **p, *ptr; char *token; voiceChat_t *voiceChats; qboolean compress; sfxHandle_t sound; compress = qtrue; if (cg_buildScript.integer) { compress = qfalse; } len = trap_FS_FOpenFile( filename, &f, FS_READ ); if ( !f ) { trap_Print( va( S_COLOR_RED "voice chat file not found: %s/n", filename ) ); return qfalse; } if ( len >= MAX_VOICEFILESIZE ) { trap_Print( va( S_COLOR_RED "voice chat file too large: %s is %i, max allowed is %i/n", filename, len, MAX_VOICEFILESIZE ) ); trap_FS_FCloseFile( f ); return qfalse; } trap_FS_Read( buf, len, f ); buf[len] = 0; trap_FS_FCloseFile( f ); ptr = buf; p = &ptr; Com_sprintf(voiceChatList->name, sizeof(voiceChatList->name), "%s", filename); voiceChats = voiceChatList->voiceChats; for ( i = 0; i < maxVoiceChats; i++ ) { voiceChats[i].id[0] = 0; } token = COM_ParseExt(p, qtrue); if (!token || token[0] == 0) { return qtrue; } if (!Q_stricmp(token, "female")) { voiceChatList->gender = GENDER_FEMALE; } else if (!Q_stricmp(token, "male")) { voiceChatList->gender = GENDER_MALE; } else if (!Q_stricmp(token, "neuter")) { voiceChatList->gender = GENDER_NEUTER; } else { trap_Print( va( S_COLOR_RED "expected gender not found in voice chat file: %s/n", filename ) ); return qfalse; } voiceChatList->numVoiceChats = 0; while ( 1 ) { token = COM_ParseExt(p, qtrue); if (!token || token[0] == 0) { return qtrue; } Com_sprintf(voiceChats[voiceChatList->numVoiceChats].id, sizeof( voiceChats[voiceChatList->numVoiceChats].id ), "%s", token); token = COM_ParseExt(p, qtrue); if (Q_stricmp(token, "{")) { trap_Print( va( S_COLOR_RED "expected { found %s in voice chat file: %s/n", token, filename ) ); return qfalse; } voiceChats[voiceChatList->numVoiceChats].numSounds = 0; while(1) { token = COM_ParseExt(p, qtrue); if (!token || token[0] == 0) { return qtrue; } if (!Q_stricmp(token, "}")) break; //sound = trap_S_RegisterSound( token, compress ); // leilei - speed voiceChats[voiceChatList->numVoiceChats].sounds[voiceChats[voiceChatList->numVoiceChats].numSounds] = sound; token = COM_ParseExt(p, qtrue); if (!token || token[0] == 0) { return qtrue; } Com_sprintf(voiceChats[voiceChatList->numVoiceChats].chats[ voiceChats[voiceChatList->numVoiceChats].numSounds], MAX_CHATSIZE, "%s", token); // if (sound) // leilei - speed voiceChats[voiceChatList->numVoiceChats].numSounds++; if (voiceChats[voiceChatList->numVoiceChats].numSounds >= MAX_VOICESOUNDS) break; } voiceChatList->numVoiceChats++; if (voiceChatList->numVoiceChats >= maxVoiceChats) return qtrue; } return qtrue;}
开发者ID:OpenArena,项目名称:leixperimental,代码行数:100,
示例29: SCR_DrawChallengers/** SCR_DrawChallengers*/static int SCR_DrawChallengers( const char **ptrptr, int x, int y, int panelWidth, struct qfontface_s *font, int pass ){ char *token; const char *oldptr; char string[MAX_STRING_CHARS]; int yoffset = 0, xoffset = 0; int playerNum, ping; int height; assert( ptrptr && *ptrptr ); height = trap_SCR_FontHeight( font ); // draw title yoffset = height; if( pass ) { trap_SCR_DrawString( x + xoffset, y + yoffset, ALIGN_CENTER_TOP, CG_TranslateString( "Spectating you" ), font, colorCyan ); // racesow } yoffset += height; // draw challengers while( *ptrptr ) { oldptr = *ptrptr; token = COM_ParseExt( ptrptr, true ); if( !token[0] ) break; if( token[0] == '&' ) // it's a different command than 'challengers', so step back and return { *ptrptr = oldptr; break; } // first token is played id playerNum = atoi( token ); if( playerNum < 0 || playerNum >= gs.maxclients ) break; // get a second token oldptr = *ptrptr; token = COM_ParseExt( ptrptr, true ); if( !token[0] ) break; if( token[0] == '&' ) // it's a different command than 'challengers', so step back and return { *ptrptr = oldptr; break; } // second token is ping ping = atoi( token ); // draw the challenger if( ping < 0 ) Q_snprintfz( string, sizeof( string ), "%s%s ...", cgs.clientInfo[playerNum].name, S_COLOR_WHITE ); else Q_snprintfz( string, sizeof( string ), "%s%s %i", cgs.clientInfo[playerNum].name, S_COLOR_WHITE, ping ); if( pass ) { trap_SCR_DrawString( x + xoffset, y + yoffset, ALIGN_CENTER_TOP, string, font, colorWhite ); } yoffset += height; } yoffset += height; return yoffset;}
开发者ID:futurepneu,项目名称:racemod,代码行数:73,
注:本文中的COM_ParseExt函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ COM_ParseString函数代码示例 C++ COM_Parse函数代码示例 |