• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ COM_ParseExt函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中COM_ParseExt函数的典型用法代码示例。如果您正苦于以下问题:C++ COM_ParseExt函数的具体用法?C++ COM_ParseExt怎么用?C++ COM_ParseExt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了COM_ParseExt函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:cg_scoreboard.cpp


示例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,代码来源:ai_script.c


示例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,代码来源:ai_script.c


示例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,代码来源:ui_gameajax_datasource.cpp


示例5: WP_SaberParseParms

qboolean 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,代码来源:wp_saberLoad.cpp


示例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,代码来源:sv_ccmds.c


示例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,代码来源:g_vote.c


示例8: NPC_PrecacheAnimationCFG

void 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,代码来源:NPC_stats.cpp


示例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,代码来源:NPC_stats.cpp


示例10: CM_ParseShader

/*
=================
CM_ParseShader

The current text pointer is at the explicit text definition of the
shader.  Parse it into the global shader variable.

This extracts all the info from the shader required for physics and collision
It 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,代码来源:cm_shader.cpp


示例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,代码来源:NPC_stats.cpp


示例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,代码来源:g_script.c


示例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,代码来源:cg_scoreboard.cpp


示例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,代码来源:cg_scoreboard.cpp


示例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,代码来源:g_bot.c


示例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,代码来源:g_script_actions.c


示例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( & 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ COM_ParseString函数代码示例发布时间:2022-05-30
下一篇:
C++ COM_Parse函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap