您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ COM_BeginParseSession函数代码示例

51自学网 2021-06-01 20:03:43
  C++
这篇教程C++ COM_BeginParseSession函数代码示例写得很实用,希望能帮到您。

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

在下文中一共展示了COM_BeginParseSession函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: IT_ParseParms

static void IT_ParseParms(const char *buffer){	const char	*holdBuf;	const char	*token;//	bg_numItems = 0;	holdBuf = buffer;	COM_BeginParseSession();	while ( holdBuf ) 	{		token = COM_ParseExt( &holdBuf, qtrue );		if ( !Q_stricmp( token, "{" ) ) 		{			token =token;			IT_ParseWeaponParms(&holdBuf);		}		 	}	COM_EndParseSession(  );//	--bg_numItems;}
开发者ID:JamesKhoury,项目名称:OpenJK,代码行数:26,


示例2: G_ParseInfos

/*===============G_ParseInfos===============*/int G_ParseInfos( char *buf, int max, char *infos[] ) {	char	*token;	int		count;	char	key[MAX_TOKEN_CHARS];	char	info[MAX_INFO_STRING];	count = 0;	COM_BeginParseSession ("G_ParseInfos");	while ( 1 ) {		token = COM_Parse( (const char **)(&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( (const char **)(&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( (const char **)(&buf), qfalse );			if ( !token[0] ) {				strcpy( token, "<NULL>" );			}			Info_SetValueForKey( info, key, token );		}		//NOTE: extra space for arena number		infos[count] = (char *) G_Alloc(strlen(info) + strlen("//num//") + strlen(va("%d", MAX_ARENAS)) + 1);		if (infos[count]) {			strcpy(infos[count], info);			count++;		}	}	return count;}
开发者ID:Rhamill7,项目名称:OpenJK,代码行数:56,


示例3: loadTIKI

void loadTIKI(const char *fname) {	int len;	char *txt;	char *p;	const char *fixedPath;	const char *token;	char path[MAX_TOOLPATH];	float scale;	len = F_LoadBuf(fname,(byte**)&txt);	if(len == -1) {		T_Error("loadTIKI: Cannot open %s/n",fname);		return;	}	path[0] = 0;	scale = 1.f;	// NOTE: this will not open the "fname" file!	COM_BeginParseSession(fname);	p = txt;	token = COM_ParseExt(&p, qtrue);	while(token[0]) {		if (!Q_stricmp(token, "path") || !Q_stricmp(token, "$path")) {			token = COM_ParseExt(&p, qtrue);			strcpy(path,token);		} else if (!Q_stricmp(token, "scale")) {			token = COM_ParseExt(&p, qtrue);			scale = atof(token);		} else if (!Q_stricmp(token, "skelmodel")) {			token = COM_ParseExt(&p, qtrue);			mainModel = readSKD(fixPath(token,path,fname),scale);		} else if(strstr(token,".skc")) {			tAnim_t *a;			fixedPath = fixPath(token,path,fname);			a = appendSKC(mainModel,fixedPath,scale);			if(a) {				strcpy(inAnimFNames[numAnims],fixedPath);				anims[numAnims] = a;				numAnims++;			}		}		token = COM_ParseExt(&p, qtrue);	}	F_FreeBuf(txt);}
开发者ID:kingtiger01,项目名称:OpenMOHAA,代码行数:49,


示例4: G_LoadIPBans

void G_LoadIPBans( void ){//load in all the banned IPs	int		i, len;	char	*p, *token;	fileHandle_t fh;	char	banIPBuffer[MAX_IPFILTERS*32];			//	The list of file names read in	char	banIPFile[MAX_QPATH];	len = trap_FS_FOpenFile("banip.txt", &fh, FS_READ);	if ( !fh )	{		G_Printf ( "G_LoadBanIP - ERROR: can't open banip.txt/n" );		return;	}		trap_FS_Read(banIPBuffer, len, fh);	banIPBuffer[len] = 0;	trap_FS_FCloseFile(fh);	p = banIPBuffer;	COM_BeginParseSession(banIPFile);	//had to change this to compile linux	token = COM_ParseExt( (const char **) &p, qtrue );	if ( token )	{		numIPFilters = atoi(token);		for ( i = 0 ; i < numIPFilters ; i++ ) 		{			//had to change this to compile linux			token = COM_ParseExt( (const char **) &p, qtrue );			if ( token )			{//have an ip				if ( !Q_stricmp("unused",token) )				{					ipFilters[i].compare = 0xffffffffu;				}				else				{					StringToFilter(token,&ipFilters[i]);				}			}			else			{				break;			}		}	}}
开发者ID:mehmehsomeone,项目名称:OpenRP,代码行数:49,


示例5: CL_SetExpectedHunkUsage

/** * @brief Sets com_expectedhunkusage, so the client knows how to draw the percentage bar * * @param[in] mapname * * @see SV_SetExpectedHunkUsage (Copied from server to here) */void CL_SetExpectedHunkUsage(const char *mapname){	int        handle;	const char *memlistfile = "hunkusage.dat";	int        len;	len = FS_FOpenFileByMode(memlistfile, &handle, FS_READ);	if (len >= 0)     // the file exists, so read it in, strip out the current entry for this map, and save it out, so we can append the new value	{		char *token;		char *buftrav;		char *buf = (char *)Z_Malloc(len + 1);		Com_Memset(buf, 0, len + 1);		FS_Read((void *)buf, len, handle);		FS_FCloseFile(handle);		// now parse the file, filtering out the current map		buftrav = buf;		COM_BeginParseSession("CL_SetExpectedHunkUsage");		while ((token = COM_Parse(&buftrav)) != NULL && token[0])		{			if (!Q_stricmp(token, mapname))			{				// found a match				token = COM_Parse(&buftrav);    // read the size				if (token && token[0])				{					// this is the usage					com_expectedhunkusage = atoi(token);					Z_Free(buf);					return;				}			}		}		Z_Free(buf);	}	// just set it to a negative number,so the cgame knows not to draw the percent bar	com_expectedhunkusage = -1;}
开发者ID:zturtleman,项目名称:etlegacy,代码行数:50,


示例6: WP_ParseParms

//--------------------------------------------static void WP_ParseParms(const char *buffer){	const char	*holdBuf;	const char	*token;	holdBuf = buffer;	COM_BeginParseSession();	while ( holdBuf ) 	{		token = COM_ParseExt( &holdBuf, qtrue );		if ( !Q_stricmp( token, "{" ) ) 		{			token =token;			WP_ParseWeaponParms(&holdBuf);		}		 	}}
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:22,


示例7: G_InitDamageLocations

void G_InitDamageLocations( void ){	const char   *modelName;	char         filename[ MAX_QPATH ];	int          i;	int          len;	fileHandle_t fileHandle;	char         buffer[ MAX_DAMAGE_REGION_TEXT ];	for ( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ )	{		modelName = BG_ClassModelConfig( i )->modelName;		Com_sprintf( filename, sizeof( filename ), "configs/classes/%s.locdamage.cfg", modelName );		len = trap_FS_FOpenFile( filename, &fileHandle, FS_READ );		if ( !fileHandle )		{			G_Printf( S_COLOR_RED "file not found: %s/n", filename );			continue;		}		if ( len >= MAX_DAMAGE_REGION_TEXT )		{			G_Printf( S_COLOR_RED "file too large: %s is %i, max allowed is %i/n",			          filename, len, MAX_DAMAGE_REGION_TEXT );			trap_FS_FCloseFile( fileHandle );			continue;		}		COM_BeginParseSession( filename );		trap_FS_Read( buffer, len, fileHandle );		buffer[ len ] = 0;		trap_FS_FCloseFile( fileHandle );		g_numDamageRegions[ i ] = ParseDmgScript( g_damageRegions[ i ], buffer );	}}
开发者ID:Gireen,项目名称:Unvanquished,代码行数:39,


示例8: CM_CreateShaderTextHash

/*====================CM_CreateShaderTextHash=====================*/void CM_CreateShaderTextHash(void){	const char			*p;	qboolean			hasNewLines;	char				*token;	CCMShaderText		*shader;	p = shaderText;	COM_BeginParseSession ("CM_CreateShaderTextHash");	// look for label	while (p)	{		p = SkipWhitespace(p, &hasNewLines);		token = COM_ParseExt( &p, qtrue );		if ( !token[0] )		{			break;		}		shader = new CCMShaderText(token, p);		shaderTextTable.insert(shader);		SkipBracedSection(&p);	}}
开发者ID:Sepulman,项目名称:OpenJK,代码行数:29,


示例9: BG_ParseItemsText

/*=================BG_ParseItemsText=================*/void BG_ParseItemsText(char *buff){	char	*token;	char *buffer;	int i,len;	COM_BeginParseSession();	buffer = buff;	while ( buffer ) 	{		token = COM_ParseExt( &buffer, qtrue );		i=0;		while (itemnames[i])		{			if (Q_stricmp(token, itemnames[i])==0)			{				token = COM_ParseExt( &buffer, qtrue );				if (token[0])				{						len = strlen(token);					if (len)					{						bg_itemlist[i].pickup_name = (buffer - (len + 1));	// The +1 is to get rid of the " at the beginning of the sting.						*(buffer - 1) = '/0';		//	Place an string end where is belongs.					}				}				break;			}			i++;		}	}}
开发者ID:gitter-badger,项目名称:rpgxEF,代码行数:41,


示例10: AnimParseAnimConfig

/*============AnimParseAnimConfig  returns qfalse if error, qtrue otherwise============*/static qboolean AnimParseAnimConfig( playerInfo_t *animModelInfo, const char *filename, const char *input ) {	char    *text_p, *token;	animation_t *animations;//	headAnimation_t *headAnims;	int i, fps, skip = -1;//	if (!weaponStringsInited) {//		BG_InitWeaponStrings();//	}//	globalFilename = (char *)filename;	animations = animModelInfo->animations;	animModelInfo->numAnimations = 0;//	headAnims = animModelInfo->headAnims;	text_p = (char *)input;	COM_BeginParseSession( "AnimParseAnimConfig" );	animModelInfo->footsteps = FOOTSTEP_NORMAL;	VectorClear( animModelInfo->headOffset );	animModelInfo->gender = GENDER_MALE;	animModelInfo->isSkeletal = qfalse;	animModelInfo->version = 0;	// read optional parameters	while ( 1 ) {		token = COM_Parse( &text_p );		if ( !token ) {			break;		}		if ( !Q_stricmp( token, "footsteps" ) ) {			token = COM_Parse( &text_p );			if ( !token ) {				break;			}			if ( !Q_stricmp( token, "default" ) || !Q_stricmp( token, "normal" ) ) {				animModelInfo->footsteps = FOOTSTEP_NORMAL;			} else if ( !Q_stricmp( token, "boot" ) ) {				animModelInfo->footsteps = FOOTSTEP_BOOT;			} else if ( !Q_stricmp( token, "flesh" ) ) {				animModelInfo->footsteps = FOOTSTEP_FLESH;			} else if ( !Q_stricmp( token, "mech" ) ) {				animModelInfo->footsteps = FOOTSTEP_MECH;			} else if ( !Q_stricmp( token, "energy" ) ) {				animModelInfo->footsteps = FOOTSTEP_ENERGY;			} else {//				BG_AnimParseError( "Bad footsteps parm '%s'/n", token );			}			continue;		} else if ( !Q_stricmp( token, "headoffset" ) ) {			for ( i = 0 ; i < 3 ; i++ ) {				token = COM_Parse( &text_p );				if ( !token ) {					break;				}				animModelInfo->headOffset[i] = atof( token );			}			continue;		} else if ( !Q_stricmp( token, "sex" ) ) {			token = COM_Parse( &text_p );			if ( !token ) {				break;			}			if ( token[0] == 'f' || token[0] == 'F' ) {				animModelInfo->gender = GENDER_FEMALE;			} else if ( token[0] == 'n' || token[0] == 'N' ) {				animModelInfo->gender = GENDER_NEUTER;			} else {				animModelInfo->gender = GENDER_MALE;			}			continue;		} else if ( !Q_stricmp( token, "version" ) ) {			token = COM_Parse( &text_p );			if ( !token ) {				break;			}			animModelInfo->version = atoi( token );			continue;		} else if ( !Q_stricmp( token, "skeletal" ) ) {			animModelInfo->isSkeletal = qtrue;			continue;		}		if ( animModelInfo->version < 2 ) {			// if it is a number, start parsing animations			if ( Q_isnumeric( token[0] ) ) {				text_p -= strlen( token );    // unget the token				break;			}		}		// STARTANIMS marks the start of the animations//.........这里部分代码省略.........
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:101,


示例11: UI_SaberParseParm

qboolean 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;	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 ( UI_ParseLiteral( &p, "{" ) ) 	{		return qfalse;	}			// parse the saber info block	while ( 1 ) 	{		token = COM_ParseExt( &p, qtrue );		if ( !token[0] ) 		{			ui.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:3ddy,项目名称:Jedi-Outcast,代码行数:72,


示例12: AICast_ScriptParse

void AICast_ScriptParse( cast_state_t *cs ) {	#define MAX_SCRIPT_EVENTS   64	gentity_t   *ent;	char        *pScript;	char        *token;	qboolean wantName;	qboolean inScript;	int eventNum;	cast_script_event_t events[MAX_SCRIPT_EVENTS];	int numEventItems;	cast_script_event_t *curEvent;	char params[MAX_QPATH];	cast_script_stack_action_t  *action;	int i;	int bracketLevel;	qboolean buildScript;       //----(SA)	added	if ( !level.scriptAI ) {		return;	}	ent = &g_entities[cs->entityNum];	if ( !ent->aiName ) {		return;	}	buildScript = trap_Cvar_VariableIntegerValue( "com_buildScript" );	buildScript = qtrue;	pScript = level.scriptAI;	wantName = qtrue;	inScript = qfalse;	COM_BeginParseSession( "AICast_ScriptParse" );	bracketLevel = 0;	numEventItems = 0;	memset( events, 0, sizeof( events ) );	while ( 1 )	{		token = COM_Parse( &pScript );		if ( !token[0] ) {			if ( !wantName ) {				G_Error( "AICast_ScriptParse(), Error (line %d): '}' expected, end of script found./n", COM_GetCurrentParseLine() );			}			break;		}		// end of script		if ( token[0] == '}' ) {			if ( inScript ) {				break;			}			if ( wantName ) {				G_Error( "AICast_ScriptParse(), Error (line %d): '}' found, but not expected./n", COM_GetCurrentParseLine() );			}			wantName = qtrue;		} else if ( token[0] == '{' )    {			if ( wantName ) {				G_Error( "AICast_ScriptParse(), Error (line %d): '{' found, NAME expected./n", COM_GetCurrentParseLine() );			}		} else if ( wantName )   {			if ( !Q_strcasecmp( ent->aiName, token ) ) {				inScript = qtrue;				numEventItems = 0;			}			wantName = qfalse;		} else if ( inScript )   {			if ( !Q_strcasecmp( token, "attributes" ) ) {				// read in all the attributes				AICast_CheckLevelAttributes( cs, ent, &pScript );				continue;			}			eventNum = AICast_EventForString( token );			if ( eventNum < 0 ) {				G_Error( "AICast_ScriptParse(), Error (line %d): unknown event: %s./n", COM_GetCurrentParseLine(), token );			}			if ( numEventItems >= MAX_SCRIPT_EVENTS ) {				G_Error( "AICast_ScriptParse(), Error (line %d): MAX_SCRIPT_EVENTS reached (%d)/n", COM_GetCurrentParseLine(), MAX_SCRIPT_EVENTS );			}			// if this is a "friendlysightcorpse" event, then disable corpse vis sharing			if ( !Q_stricmp( token, "friendlysightcorpse" ) ) {				cs->aiFlags &= ~AIFL_CORPSESIGHTING;			}			curEvent = &events[numEventItems];			curEvent->eventNum = eventNum;			memset( params, 0, sizeof( params ) );			// parse any event params before the start of this event's actions			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() );				}				if ( eventNum == 13 ) {   // statechange event, check params					if ( strlen( token ) > 1 ) {//.........这里部分代码省略.........
开发者ID:JackalFrost,项目名称:RTCW-WSGF,代码行数:101,


示例13: UI_ManageDeckLoading

static void UI_ManageDeckLoading( void ){	char			fileRoute[MAX_QPATH];	char			mapRoute[MAX_QPATH];	char			info[MAX_TOKEN_CHARS];	fileHandle_t	f;	int				file_len;	char			*textPtr;	char			buffer[20000];	char			*token;	//get the map name	trap_GetConfigString( CS_SERVERINFO, info, sizeof( info ) );	Com_sprintf( mapRoute, sizeof( fileRoute ), "maps/%s", Info_ValueForKey( info, "mapname" ) );	//check for language	UI_LanguageFilename( mapRoute, "turbolift", fileRoute );	file_len = trap_FS_FOpenFile( fileRoute, &f, FS_READ );	if ( file_len <= 1 )	{		//Com_Printf( S_COLOR_YELLOW "WARNING: Attempted to load %s, but wasn't found./n", fileRoute );		UI_TurboliftMenu_LoadDecks();		return;	}	trap_FS_Read( buffer, file_len, f );	trap_FS_FCloseFile( f );	if ( !buffer[0] )	{		Com_Printf( S_COLOR_RED "ERROR: Attempted to load %s, but no data was read./n", fileRoute );		UI_TurboliftMenu_LoadDecks();		return;	}	s_turbolift.numDecks = 0;	memset( &s_turbolift.deckData, 0, sizeof( s_turbolift.deckData ) );	buffer[file_len] = '/0';	COM_BeginParseSession();	textPtr = buffer;	//Com_Printf( S_COLOR_RED "Beginning Parse/n" );	//expected format is 'decknum' <space> 'deck Desc'	while( 1 )	{		token = COM_Parse( &textPtr );		if ( !token[0] )			break;		//Com_Printf( S_COLOR_RED "First Token: %s/n", token );		//in case of Scooter's EF SP style DAT files, which require 'DECK' in front of the number		if ( !Q_strncmp( token, "DECK", 4 ) )			token += 4;		//grab the deck number		s_turbolift.deckData[s_turbolift.numDecks].deckNum = atoi( token );		token = COM_ParseExt( &textPtr, qfalse );		if (!token[0])			continue;		//Com_Printf( S_COLOR_RED "Second Token: %s/n", token );		Q_strncpyz( s_turbolift.deckData[s_turbolift.numDecks].deckDesc, 					token,					sizeof( s_turbolift.deckData[s_turbolift.numDecks].deckDesc ) );		s_turbolift.numDecks++;		//if this is an EF SP style script, there may be more data after these two. ignore them		if ( COM_ParseExt( &textPtr, qfalse ) == NULL )			SkipRestOfLine( &textPtr );	}	qsort( s_turbolift.deckData, s_turbolift.numDecks, sizeof( deckData_t ), SortDecks );}
开发者ID:gitter-badger,项目名称:rpgxEF,代码行数:81,


示例14: 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,


示例15: AICast_ScriptParse

/*==============AICast_ScriptParse  Parses the script for the given character==============*/void AICast_ScriptParse( cast_state_t *cs ){	#define MAX_SCRIPT_EVENTS	64	gentity_t	*ent;	char		*pScript;	char		*token;	qboolean	wantName;	qboolean	inScript;	int			eventNum;	cast_script_event_t	events[MAX_SCRIPT_EVENTS];	int			numEventItems;	cast_script_event_t *curEvent;	char		params[MAX_QPATH];	cast_script_stack_action_t	*action;	int			i;	int			bracketLevel;	if (!level.scriptAI)		return;	ent = &g_entities[cs->entityNum];	if (!ent->aiName)		return;	pScript = level.scriptAI;	wantName = qtrue;	inScript = qfalse;	COM_BeginParseSession("AICast_ScriptParse");	bracketLevel = 0;	numEventItems = 0;	memset( events, 0, sizeof(events) );	while (1)	{		token = COM_Parse( &pScript );		if ( !token[0] )		{			if ( !wantName )			{				G_Error( "AICast_ScriptParse(), Error (line %d): '}' expected, end of script found./n", COM_GetCurrentParseLine() );			}			break;		}		// end of script		if ( token[0] == '}' )		{			if ( inScript )			{				break;			}			if ( wantName )			{				G_Error( "AICast_ScriptParse(), Error (line %d): '}' found, but not expected./n", COM_GetCurrentParseLine() );			}			wantName = qtrue;		}		else if ( token[0] == '{' )		{			if ( wantName )			{				G_Error( "AICast_ScriptParse(), Error (line %d): '{' found, NAME expected./n", COM_GetCurrentParseLine() );			}		}		else if ( wantName )		{			if ( !Q_strcasecmp( ent->aiName, token ) )			{				inScript = qtrue;				numEventItems = 0;			}			wantName = qfalse;		}		else if ( inScript )		{			if ( !Q_strcasecmp( token, "attributes" ) ) {				// read in all the attributes				AICast_CheckLevelAttributes( cs, ent, &pScript );				continue;			}			eventNum = AICast_EventForString( token );			if (eventNum < 0)			{				G_Error( "AICast_ScriptParse(), Error (line %d): unknown event: %s./n", COM_GetCurrentParseLine(), token );			}			if (numEventItems >= MAX_SCRIPT_EVENTS)			{				G_Error( "AICast_ScriptParse(), Error (line %d): MAX_SCRIPT_EVENTS reached (%d)/n", COM_GetCurrentParseLine(), MAX_SCRIPT_EVENTS );			}			// if this is a "friendlysightcorpse" event, then disable corpse vis sharing//.........这里部分代码省略.........
开发者ID:natelo,项目名称:rtcwPub,代码行数:101,


示例16: UI_SaberGetHiltInfo

//void UI_SaberGetHiltInfo( const char *singleHilts[MAX_SABER_HILTS], const char *staffHilts[MAX_SABER_HILTS] )void UI_SaberGetHiltInfo(void){	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 );			continue;		}		if ( UI_IsSaberTwoHanded( saberName ) )		{#ifndef DYNAMICMEMORY_SABERS			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			UI_ReaAllocMem((void *)&saberStaffHiltInfo, sizeof(char *), numStaffHilts+1);			saberStaffHiltInfo[numStaffHilts++] = (char *) saberName;#endif		}		else		{#ifndef DYNAMICMEMORY_SABERS			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 );			}#else			UI_ReaAllocMem((void *)&saberSingleHiltInfo, sizeof(char *), numSingleHilts+1);			saberSingleHiltInfo[numSingleHilts++] = (char *) saberName;#endif		}		//skip the whole braced section and move on to the next entry		SkipBracedSection( &p );	}	//null terminate the list so the UI code knows where to stop listing them#ifndef DYNAMICMEMORY_SABERS	singleHilts[numSingleHilts] = NULL;	staffHilts[numStaffHilts] = NULL;#else	saberSingleHiltCount = numSingleHilts;	saberStaffHiltCount = numStaffHilts;#endif}
开发者ID:ForcePush,项目名称:OJPRPFZ,代码行数:79,


示例17: NPC_ParseParms

//.........这里部分代码省略.........	ri->torsoYawRangeRight = 60;	ri->torsoPitchRangeUp = 30;	ri->torsoPitchRangeDown = 70;	*/	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] ) 
开发者ID:CairnTrenor,项目名称:OpenJK,代码行数:67,


示例18: 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))			{//.........这里部分代码省略.........
开发者ID:CairnTrenor,项目名称:OpenJK,代码行数:101,


示例19: ScanAndLoadShaderFilesR1

/** * @brief Finds and loads all .shader files, combining them into * a single large text block that can be scanned for shader names */int ScanAndLoadShaderFilesR1(){	char         **shaderFiles;	char         *buffers[MAX_SHADER_FILES];	char         *p;	int          numShaderFiles, i;	char         *oldp, *token, *textEnd;	char         **hashMem;	int          shaderTextHashTableSizes[MAX_SHADERTEXT_HASH], hash;	unsigned int size;	char         filename[MAX_QPATH];	long         sum = 0, summand;	Com_Memset(buffers, 0, MAX_SHADER_FILES);	Com_Memset(shaderTextHashTableSizes, 0, MAX_SHADER_FILES);	// scan for shader files	shaderFiles = ri.FS_ListFiles("scripts", ".shader", &numShaderFiles);	if (!shaderFiles || !numShaderFiles)	{		Ren_Print("----- ScanAndLoadShaderFilesR1 (no files)-----/n");		return 0;	}	Ren_Print("----- ScanAndLoadShaderFilesR1 (%i files)-----/n", numShaderFiles);	if (numShaderFiles >= MAX_SHADER_FILES)	{		Ren_Drop("MAX_SHADER_FILES limit is reached!");	}	// load and parse shader files	for (i = 0; i < numShaderFiles; i++)	{		Com_sprintf(filename, sizeof(filename), "scripts/%s", shaderFiles[i]);		COM_BeginParseSession(filename);		Ren_Developer("...loading '%s'/n", filename);		summand = ri.FS_ReadFile(filename, (void **)&buffers[i]);		if (!buffers[i])		{			Ren_Drop("Couldn't load %s", filename); // in this case shader file is cought/listed but the file can't be read - drop!		}		p = buffers[i];		while (1)		{			token = COM_ParseExt(&p, qtrue);			if (!*token)			{				break;			}			// Step over the "table"/"guide" and the name			if (!Q_stricmp(token, "table") || !Q_stricmp(token, "guide"))			{				token = COM_ParseExt2(&p, qtrue);				if (!*token)				{					break;				}			}			oldp = p;			token = COM_ParseExt2(&p, qtrue);			if (token[0] != '{' && token[1] != '/0')			{				Ren_Warning("WARNING: Bad shader file %s has incorrect syntax near token '%s' line %i/n", filename, token, COM_GetCurrentParseLine());				ri.FS_FreeFile(buffers[i]);				buffers[i] = NULL;				break;			}			SkipBracedSection(&oldp);			p = oldp;		}		if (buffers[i])		{			sum += summand;		}	}	// build single large buffer	s_shaderTextR1    = (char *)ri.Hunk_Alloc(sum + numShaderFiles * 2, h_low);	s_shaderTextR1[0] = '/0';	textEnd           = s_shaderTextR1;	// free in reverse order, so the temp files are all dumped	for (i = numShaderFiles - 1; i >= 0 ; i--)	{//.........这里部分代码省略.........
开发者ID:zturtleman,项目名称:etlegacy,代码行数:101,


示例20: 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;	COM_BeginParseSession ("UI_ParseInfos");	while ( 1 ) {		token = COM_Parse( (const char **)&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( (const char **)&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( (const char **)&buf, qfalse );			if ( !token[0] ) {				strcpy( token, "<NULL>" );			}			Info_SetValueForKey( info, key, token );		}		//NOTE: extra space for arena number		infos[count] = (char *) UI_Alloc(strlen(info) + strlen("//num//") + strlen(va("%d", MAX_ARENAS)) + 1);		if (infos[count]) {			strcpy(infos[count], info);#ifndef FINAL_BUILD			if (trap->Cvar_VariableValue("com_buildScript"))			{				char *botFile = Info_ValueForKey(info, "personality");				if (botFile && botFile[0])				{					int fh = 0;					trap->FS_Open(botFile, &fh, FS_READ);					if (fh)					{						trap->FS_Close(fh);					}				}			}#endif			count++;		}	}	return count;}
开发者ID:BSzili,项目名称:OpenJK,代码行数:71,


示例21: IN_IsConsoleKey

/*===============IN_IsConsoleKeyTODO: If the SDL_Scancode situation improves, use it instead of      both of these methods===============*/static qboolean IN_IsConsoleKey( fakeAscii_t key, int character ){	typedef struct consoleKey_s	{		enum		{			QUAKE_KEY,			CHARACTER		} type;		union		{			fakeAscii_t key;			int character;		} u;	} consoleKey_t;	static consoleKey_t consoleKeys[ MAX_CONSOLE_KEYS ];	static int numConsoleKeys = 0;	int i;	// Only parse the variable when it changes	if( cl_consoleKeys->modified )	{		const char *text_p;        char *token;		cl_consoleKeys->modified = qfalse;		text_p = cl_consoleKeys->string;		numConsoleKeys = 0;		COM_BeginParseSession();		while( numConsoleKeys < MAX_CONSOLE_KEYS )		{			consoleKey_t *c = &consoleKeys[ numConsoleKeys ];			int charCode = 0;			token = COM_Parse( &text_p );			if( !token[ 0 ] )				break;			if( strlen( token ) == 4 )				charCode = Com_HexStrToInt( token );			if( charCode > 0 )			{				c->type = consoleKey_t::CHARACTER;				c->u.character = charCode;			}			else			{				c->type = consoleKey_t::QUAKE_KEY;				c->u.key = (fakeAscii_t)Key_StringToKeynum( token );				// 0 isn't a key				if( c->u.key <= 0 )					continue;			}			numConsoleKeys++;		}		COM_EndParseSession();	}	// If the character is the same as the key, prefer the character	if( key == character )		key = A_NULL;	for( i = 0; i < numConsoleKeys; i++ )	{		consoleKey_t *c = &consoleKeys[ i ];		switch( c->type )		{			case consoleKey_t::QUAKE_KEY:				if( key && c->u.key == key )					return qtrue;				break;			case consoleKey_t::CHARACTER:				if( c->u.character == character )					return qtrue;				break;		}	}	return qfalse;}
开发者ID:Delfin1,项目名称:OpenJK,代码行数:96,


示例22: G_Script_ScriptParse

/*==============G_Script_ScriptParse  Parses the script for the given entity==============*/void G_Script_ScriptParse( gentity_t *ent ) {	#define MAX_SCRIPT_EVENTS   64	char        *pScript;	char        *token;	qboolean wantName;	qboolean inScript;	int eventNum;	g_script_event_t events[MAX_SCRIPT_EVENTS];	int numEventItems;	g_script_event_t *curEvent;	// DHM - Nerve :: Some of our multiplayer script commands have longer parameters	//char		params[MAX_QPATH];	char params[MAX_INFO_STRING];	// dhm - end	g_script_stack_action_t *action;	int i;	int bracketLevel;	qboolean buildScript;       //----(SA)	added	if ( !ent->scriptName ) {		return;	}	if ( !level.scriptEntity ) {		return;	}	buildScript = trap_Cvar_VariableIntegerValue( "com_buildScript" );	buildScript = qtrue;	pScript = level.scriptEntity;	wantName = qtrue;	inScript = qfalse;	COM_BeginParseSession( "G_Script_ScriptParse" );	bracketLevel = 0;	numEventItems = 0;	memset( events, 0, sizeof( events ) );	while ( 1 )	{		token = COM_Parse( &pScript );		if ( !token[0] ) {			if ( !wantName ) {				G_Error( "G_Script_ScriptParse(), Error (line %d): '}' expected, end of script found./n", COM_GetCurrentParseLine() );			}			break;		}		// end of script		if ( token[0] == '}' ) {			if ( inScript ) {				break;			}			if ( wantName ) {				G_Error( "G_Script_ScriptParse(), Error (line %d): '}' found, but not expected./n", COM_GetCurrentParseLine() );			}			wantName = qtrue;		} else if ( token[0] == '{' )    {			if ( wantName ) {				G_Error( "G_Script_ScriptParse(), Error (line %d): '{' found, NAME expected./n", COM_GetCurrentParseLine() );			}		} else if ( wantName )   {			if ( !Q_strcasecmp( ent->scriptName, token ) ) {				inScript = qtrue;				numEventItems = 0;			}			wantName = qfalse;		} else if ( inScript )   {			//if ( !Q_strcasecmp( token, "attributes" ) ) {			//	// read in all the attributes			//	G_Script_CheckLevelAttributes( cs, ent, &pScript );			//	continue;			//}			eventNum = G_Script_EventForString( token );			if ( eventNum < 0 ) {				G_Error( "G_Script_ScriptParse(), Error (line %d): unknown event: %s./n", COM_GetCurrentParseLine(), token );			}			if ( numEventItems >= MAX_SCRIPT_EVENTS ) {				G_Error( "G_Script_ScriptParse(), Error (line %d): MAX_SCRIPT_EVENTS reached (%d)/n", COM_GetCurrentParseLine(), MAX_SCRIPT_EVENTS );			}			curEvent = &events[numEventItems];			curEvent->eventNum = eventNum;			memset( params, 0, sizeof( params ) );			// parse any event params before the start of this event's actions			while ( ( token = COM_Parse( &pScript ) ) && ( token[0] != '{' ) )			{				if ( !token[0] ) {					G_Error( "G_Script_ScriptParse(), Error (line %d): '}' expected, end of script found./n", COM_GetCurrentParseLine() );				}//.........这里部分代码省略.........
开发者ID:JackalFrost,项目名称:RTCW-WSGF,代码行数:101,


示例23: 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,


示例24: 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 );//.........这里部分代码省略.........
开发者ID:CairnTrenor,项目名称:OpenJK,代码行数:101,


示例25: BG_ParseRankNames

qboolean BG_ParseRankNames( char* fileName, rankNames_t rankNames[] ) {	fileHandle_t	f;	int				file_len;	char			charText[20000];	char*			textPtr;	char*			token;	int				i = 0;	file_len = trap_FS_FOpenFile( fileName, &f, FS_READ );	if ( file_len<= 0 ) {		return qfalse;	}	if ( file_len >= ( sizeof(charText) - 1) ) {		Com_Printf( S_COLOR_RED "File length of %s is too long./n", fileName );	}	memset( &charText, 0, sizeof( charText ) );	memset( rankNames, 0, sizeof( rankNames ) );	trap_FS_Read( charText, file_len, f );	charText[file_len] = 0;	trap_FS_FCloseFile( f );	COM_BeginParseSession();	textPtr = charText;	token = COM_Parse( &textPtr );	if ( !token[0] ) {		Com_Printf( S_COLOR_RED "No data found in buffer: %s/n", fileName );		return qfalse;	}	if ( Q_stricmpn( token, "{", 1 ) ) {		Com_Printf( S_COLOR_RED "No beginning { found in %s/n", fileName );		return qfalse;	}	//Parse out the default cell.  Default has no names anyway,	//but in case a n00bie modder put names in anyway.	SkipBracedSection( &textPtr );	while( 1 ) {		//lastPtr = textPtr;		token = COM_Parse( &textPtr );		if( !token[0] ) {			break;		}		if ( i >= MAX_RANKS ) {			break;		}		//If we hit an open brace (ie, assuming we hit the start of a new rank cell)		if ( !Q_stricmpn( token, "{", 1 ) ) {			while ( 1 ) {				token = COM_Parse( &textPtr );				if( !token[0] ) {					break;				}				//We hit a MenuTexture entry, since this uses { symbols, we'll skip these to stop errors.				if ( !Q_stricmpn( token, "MenuTexture", 11 ) ) {					SkipRestOfLine( &textPtr );					continue;				}				if ( !Q_stricmpn( token, "ConsoleName", 11) ) {					if ( COM_ParseString( &textPtr, &token ) ) {						continue;					}					Q_strncpyz( rankNames[i].consoleName, token, sizeof( rankNames[i].consoleName ) );					continue;				}				else if ( !Q_stricmpn( token, "FormalName", 10) ) {					if ( COM_ParseString( &textPtr, &token ) ) {						continue;					}					Q_strncpyz( rankNames[i].formalName, token, sizeof( rankNames[i].formalName ) );					continue;				}				//We hit the end of the cell.				else if ( !Q_stricmpn( token, "}", 1 ) ) {					break;				}			}			//Error check.  If we didn't get both a formal and console name, pwn the caller. ;P			if ( !rankNames[i].consoleName[0] || !rankNames[i].formalName[0] ) {				Com_Printf( S_COLOR_RED "One or more rank names were not found in rank#: %i/n", i );				return qfalse;//.........这里部分代码省略.........
开发者ID:gitter-badger,项目名称:rpgxEF,代码行数:101,


示例26: 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:Avygeil,项目名称:NewJK,代码行数:101,


示例27: CL_UpdateLevelHunkUsage

/** * @brief This updates the "hunkusage.dat" file with the current map and it's hunk usage count * * This is used for level loading, so we can show a percentage bar dependant on the amount * of hunk memory allocated so far * * This will be slightly inaccurate if some settings like sound quality are changed, but these * things should only account for a small variation (hopefully) */void CL_UpdateLevelHunkUsage(void){	int        handle;	const char *memlistfile = "hunkusage.dat";	char       outstr[256];	int        len, memusage;	memusage = Cvar_VariableIntegerValue("com_hunkused");	len = FS_FOpenFileByMode(memlistfile, &handle, FS_READ);	if (len >= 0)     // the file exists, so read it in, strip out the current entry for this map, and save it out, so we can append the new value	{		char *buftrav, *outbuftrav;		char *outbuf;		char *token;		char *buf;		buf = (char *)Z_Malloc(len + 1);		Com_Memset(buf, 0, len + 1);		outbuf = (char *)Z_Malloc(len + 1);		Com_Memset(outbuf, 0, len + 1);		(void) FS_Read((void *)buf, len, handle);		FS_FCloseFile(handle);		// now parse the file, filtering out the current map		buftrav       = buf;		outbuftrav    = outbuf;		outbuftrav[0] = '/0';		COM_BeginParseSession("CL_UpdateLevelHunkUsage");		while ((token = COM_Parse(&buftrav)) != NULL && token[0])		{			if (!Q_stricmp(token, cl.mapname))			{				// found a match				token = COM_Parse(&buftrav); // read the size				if (token && token[0])				{					if (atoi(token) == memusage) // if it is the same, abort this process					{						Z_Free(buf);						Z_Free(outbuf);						return;					}				}			}			else // send it to the outbuf			{				Q_strcat(outbuftrav, len + 1, token);				Q_strcat(outbuftrav, len + 1, " ");				token = COM_Parse(&buftrav);    // read the size				if (token && token[0])				{					Q_strcat(outbuftrav, len + 1, token);					Q_strcat(outbuftrav, len + 1, "/n");				}				else				{					//Com_Error does memory clean up					//Z_Free(buf);					//Z_Free(outbuf);					Com_Error(ERR_DROP, "hunkusage.dat file is corrupt");				}			}		}		handle = FS_FOpenFileWrite(memlistfile);		if (handle < 0)		{			Com_Error(ERR_DROP, "cannot create %s", memlistfile);		}		// input file is parsed, now output to the new file		len = strlen(outbuf);		if (FS_Write((void *)outbuf, len, handle) != len)		{			Com_Error(ERR_DROP, "cannot write to %s", memlistfile);		}		FS_FCloseFile(handle);		Z_Free(buf);		Z_Free(outbuf);	}	// now append the current map to the current file	(void) FS_FOpenFileByMode(memlistfile, &handle, FS_APPEND);	if (handle < 0)	{		Com_Error(ERR_DROP, "cannot write to hunkusage.dat, check disk full");	}	Com_sprintf(outstr, sizeof(outstr), "%s %i/n", cl.mapname, memusage);	(void) FS_Write(outstr, strlen(outstr), handle);//.........这里部分代码省略.........
开发者ID:zturtleman,项目名称:etlegacy,代码行数:101,


示例28: G_Script_ScriptParse

/*==============G_Script_ScriptParse  Parses the script for the given entity==============*/void G_Script_ScriptParse(gentity_t *ent) {	char                    *pScript;	qboolean                wantName;	qboolean                inScript;	int                     eventNum;	g_script_event_t        events[G_MAX_SCRIPT_STACK_ITEMS];	int                     numEventItems;	g_script_event_t        *curEvent;	char                    params[MAX_INFO_STRING];	g_script_stack_action_t *action;	int                     i;	int                     bracketLevel;	qboolean                buildScript;	if (!ent->scriptName) {		return;	}	if (!level.scriptEntity) {		return;	}	buildScript = trap_Cvar_VariableIntegerValue("com_buildScript");	pScript  = level.scriptEntity;	wantName = qtrue;	inScript = qfalse;	COM_BeginParseSession("G_Script_ScriptParse");	bracketLevel  = 0;	numEventItems = 0;	memset(events, 0, sizeof (events));	for (;;) {		char *token;		token = COM_Parse(&pScript);		if (!token[0]) {			if (!wantName) {				G_Error("G_Script_ScriptParse(), Error (line %d): '}' expected, end of script found./n", COM_GetCurrentParseLine());			}			break;		}		// end of script		if (token[0] == '}') {			if (inScript) {				break;			}			if (wantName) {				G_Error("G_Script_ScriptParse(), Error (line %d): '}' found, but not expected./n", COM_GetCurrentParseLine());			}			wantName = qtrue;		} else if (token[0] == '{') {			if (wantName) {				G_Error("G_Script_ScriptParse(), Error (line %d): '{' found, NAME expected./n", COM_GetCurrentParseLine());			}		} else if (wantName) {			if (!Q_stricmp(token, "bot")) {				// a bot, skip this whole entry				SkipRestOfLine(&pScript);				// skip this section				SkipBracedSection(&pScript);				//				continue;			}			if (!Q_stricmp(token, "entity")) {				// this is an entity, so go back to look for a name				continue;			}			if (!Q_stricmp(ent->scriptName, token)) {				inScript      = qtrue;				numEventItems = 0;			}			wantName = qfalse;		} else if (inScript) {			Q_strlwr(token);			eventNum = G_Script_EventForString(token);			if (eventNum < 0) {				G_Error("G_Script_ScriptParse(), Error (line %d): unknown event: %s./n", COM_GetCurrentParseLine(), token);			}			if (numEventItems >= G_MAX_SCRIPT_STACK_ITEMS) {				G_Error("G_Script_ScriptParse(), Error (line %d): G_MAX_SCRIPT_STACK_ITEMS reached (%d)/n", COM_GetCurrentParseLine(), G_MAX_SCRIPT_STACK_ITEMS);			}			curEvent           = &events[numEventItems];			curEvent->eventNum = eventNum;			memset(params, 0, sizeof (params));			// parse any event params before the start of this event's actions			while ((token = COM_Parse(&pScript)) != NULL && (token[0] != '{')) {				if (!token[0]) {//.........这里部分代码省略.........
开发者ID:ETrun,项目名称:ETrun,代码行数:101,


示例29: G_ParseAnimationFile

/*======================CG_ParseAnimationFileRead a configuration file containing animation coutns and ratesmodels/players/visor/animation.cfg, etc======================*/qboolean G_ParseAnimationFile( const char *af_filename ) {	const char		*text_p;	int			len;	int			i;	const char		*token;	float		fps;	int			skip;	char		text[40000];	int			animNum;	animation_t	*animations = level.knownAnimFileSets[level.numKnownAnimFileSets].animations;	len = gi.RE_GetAnimationCFG(af_filename, NULL, 0);	if (len <= 0)	{		return qfalse;	}	if ( len <= 0 ) 	{		return qfalse;	}	if ( len >= sizeof( text ) - 1 ) 	{		G_Error( "G_ParseAnimationFile: File %s too long/n (%d > %d)", af_filename, len, sizeof( text ) - 1);		return qfalse;	}	len = gi.RE_GetAnimationCFG(af_filename, text, sizeof(text));	// parse the text	text_p = text;	skip = 0;	// quiet the compiler warning	//FIXME: have some way of playing anims backwards... negative numFrames?	//initialize anim array so that from 0 to MAX_ANIMATIONS, set default values of 0 1 0 100	for(i = 0; i < MAX_ANIMATIONS; i++)	{		animations[i].firstFrame = 0;		animations[i].numFrames = 0;		animations[i].loopFrames = -1;		animations[i].frameLerp = 100;		animations[i].initialLerp = 100;	}	// read information for each frame	COM_BeginParseSession();	while(1) 	{		token = COM_Parse( &text_p );		if ( !token || !token[0]) 		{			break;		}		animNum = GetIDForString(animTable, token);		if(animNum == -1)		{//#ifndef FINAL_BUILD#ifdef _DEBUG			Com_Printf(S_COLOR_RED"WARNING: Unknown token %s in %s/n", token, af_filename);#endif			continue;		}		token = COM_Parse( &text_p );		if ( !token ) 		{			break;		}		animations[animNum].firstFrame = atoi( token );		token = COM_Parse( &text_p );		if ( !token ) 		{			break;		}		animations[animNum].numFrames = atoi( token );		token = COM_Parse( &text_p );		if ( !token ) 		{			break;		}		animations[animNum].loopFrames = atoi( token );		token = COM_Parse( &text_p );		if ( !token ) 		{			break;		}//.........这里部分代码省略.........
开发者ID:DavidZeise,项目名称:OpenJK,代码行数:101,



注:本文中的COM_BeginParseSession函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ COM_CheckParm函数代码示例
C++ COM_Argv函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。