当前位置: 首页>>代码示例>>C++>>正文


C++ Q_strlen函数代码示例

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


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

示例1: Netchan_UpdateProgress

NOXREF void Netchan_UpdateProgress(netchan_t *chan)
{
	NOXREFCHECK;
	fragbuf_t *p;
	int c = 0;
	int total = 0;
	int i;
	float bestpercent = 0.0f;
	float percent;
	char sz[1024];
	char *in;
	char *out;
	int len = 0;

	scr_downloading.value = -1.0f;
	gDownloadFile[0] = 0;

	if (net_drawslider.value != 1.0f)
	{
		if (!chan->incomingbufs[FRAG_FILE_STREAM])
			return;
	}
	for (i = MAX_STREAMS - 1; i >= 0; i--)
	{
		if (chan->incomingbufs[i])
		{
			p = chan->incomingbufs[i];
			total = FRAG_GETCOUNT(p->bufferid);

			while (p)
			{
				c++;
				p = p->next;
			}

			if (total)
			{
				percent = (float)c * 100.0f / (float)total;
				if (percent > bestpercent)
					bestpercent = percent;
			}
			p = chan->incomingbufs[i];
			if (i == FRAG_FILE_STREAM)
			{
				in = (char *)p->frag_message.data;
				out = sz;

				while (*in)
				{
					*out++ = *in++;
					len++;

					if (len > 128)
						break;
				}

				*out = '\0';
				if (Q_strlen(sz) > 0 && (*sz != '!' || !Q_strncmp(sz, "!ModuleC.dll", 11)))
				{
					Q_strncpy(gDownloadFile, sz, 255);
					gDownloadFile[255] = 0;
				}
			}
		}
		else if (chan->fragbufs[i])
		{
			if (chan->fragbufcount[i])
			{
				percent = (float)chan->fragbufs[i]->bufferid * 100.0f / (float)chan->fragbufcount[i];
				if (percent > bestpercent)
					bestpercent = percent;
			}
		}
	}

	scr_downloading.value = bestpercent;
}
开发者ID:Chuvi-w,项目名称:rehlds,代码行数:77,代码来源:net_chan.cpp

示例2: Cmd_StuffCmds_f

/*
===============
Cmd_StuffCmds_f

Adds command line parameters as script statements
Commands lead with a +, and continue until a - or another +
quake +prog jctest.qp +cmd amlev1
quake -nosound +cmd amlev1
===============
*/
void Cmd_StuffCmds_f (void)
{
	int		i, j;
	int		s;
	char	*text, *build, c;
		
	if (Cmd_Argc () != 1)
	{
		Con_Printf ("stuffcmds : execute command line parameters\n");
		return;
	}

// build the combined string to parse from
	s = 0;
	for (i=1 ; i<com_argc ; i++)
	{
		if (!com_argv[i])
			continue;		// NEXTSTEP nulls out -NXHost
		s += Q_strlen (com_argv[i]) + 1;
	}
	if (!s)
		return;
		
	text = Z_Malloc (s+1);
	text[0] = 0;
	for (i=1 ; i<com_argc ; i++)
	{
		if (!com_argv[i])
			continue;		// NEXTSTEP nulls out -NXHost
		Q_strcat (text,com_argv[i]);
		if (i != com_argc-1)
			Q_strcat (text, " ");
	}
	
// pull out the commands
	build = Z_Malloc (s+1);
	build[0] = 0;
	
	for (i=0 ; i<s-1 ; i++)
	{
		if (text[i] == '+')
		{
			i++;

			for (j=i ; (text[j] != '+') && (text[j] != '-') && (text[j] != 0) ; j++)
				;

			c = text[j];
			text[j] = 0;
			
			Q_strcat (build, text+i);
			Q_strcat (build, "\n");
			text[j] = c;
			i = j-1;
		}
	}
	
	if (build[0])
		Cbuf_InsertText (build);
	
	Z_Free (text);
	Z_Free (build);
}
开发者ID:Azarien,项目名称:SoftQuake,代码行数:73,代码来源:cmd.c

示例3: Cmd_StuffCmds_f

/* <4e74> ../engine/cmd.c:271 */
void Cmd_StuffCmds_f(void)
{
	int i;
	int s;
	char *build;

	if (Cmd_Argc() != 1)
	{
		Con_Printf("stuffcmds : execute command line parameters\n");
		return;
	}

	if (com_argc <= 1)
	{
		return;
	}

	// Get total length for the command line parameters
	s = 0;
	for (i = 1; i < com_argc; i++)
	{
		if (com_argv[i])
		{
			s += Q_strlen(com_argv[i]) + 1;
		}
	}

	if (s == 0)
	{
		return;
	}

	// Create buffer able to get all arguments
	build = (char *)Z_Malloc(s + com_argc * 2);
	build[0] = 0;

	//  Iterate thru arguments searching for ones starting with +
	for (i = 1; i < com_argc; i++)
	{
		if (com_argv[i] && com_argv[i][0] == '+')
		{
			// Add command or cvar
			Q_strcat(build, &com_argv[i][1]);
			// Then add all following parameters till we meet argument with + or -, which means next command/cvar/parameter
			i++;
			while (com_argv[i] && com_argv[i][0] != '+' && com_argv[i][0] != '-')
			{
				Q_strcat(build, " ");
				Q_strcat(build, com_argv[i]);
				i++;
			}
			// End up with new line which split commands for command processor
			Q_strcat(build, "\n");
			i--;
		}
	}

	if (build[0] != 0)
	{
		Cbuf_InsertText(build);
	}

	// Free buffers
	Z_Free(build);
}
开发者ID:LeninChan,项目名称:rehlds,代码行数:66,代码来源:cmd.cpp

示例4: RandomFloat

void CTFHLTVDirector::CreateShotFromEvent( CHLTVGameEvent *event )
{
    // show event at least for 2 more seconds after it occured
    const char *name = event->m_Event->GetName();

    int thera = RandomFloat()>0.5?20:-20;

    if ( !Q_strcmp( "teamplay_point_startcapture", name ) ||
            !Q_strcmp( "teamplay_point_captured", name ) ||
            !Q_strcmp( "teamplay_capture_blocked", name ) )
    {
        CBaseEntity *pCapturePoint = GetCapturePointByIndex( event->m_Event->GetInt( "cp" ) );

        int iCameraIndex = -1;
        float flClosest = 99999.9f;

        if ( pCapturePoint )
        {
            // Does it have an associated viewpoint?
            for ( int i = 0; i<m_nNumFixedCameras; i++ )
            {
                CBaseEntity *pCamera = m_pFixedCameras[ i ];

                if ( pCamera )
                {
                    byte pvs[MAX_MAP_CLUSTERS/8];
                    int clusterIndex = engine->GetClusterForOrigin( pCamera->GetAbsOrigin() );
                    engine->GetPVSForCluster( clusterIndex, sizeof(pvs), pvs );
                    bool bCameraInPVS = engine->CheckOriginInPVS( pCapturePoint->GetAbsOrigin(), pvs, sizeof( pvs ) );

                    if ( bCameraInPVS == true )
                    {
                        float flDistance = (pCapturePoint->GetAbsOrigin() - pCamera->GetAbsOrigin()).Length();
                        if ( flDistance <= flClosest )
                        {
                            iCameraIndex = i;
                            flClosest = flDistance;
                        }
                    }
                }
            }
        }

        CBasePlayer *pPlayer = NULL;

        if ( !Q_strcmp( "teamplay_point_captured", name ) )
        {
            const char *pszCappers = event->m_Event->GetString("cappers");
            int nLength = Q_strlen(pszCappers);

            if ( nLength > 0 )
            {
                int iRandomCapper = pszCappers[ RandomInt(0,nLength-1) ];
                pPlayer = UTIL_PlayerByIndex( iRandomCapper );
            }
        }
        else if ( !Q_strcmp( "teamplay_capture_blocked", name ) )
        {
            int iBlocker = event->m_Event->GetInt("blocker");
            pPlayer = UTIL_PlayerByIndex( iBlocker );
        }

        if ( pPlayer )
        {
            if ( iCameraIndex >= 0 && RandomFloat() > 0.66f )
            {
                StartFixedCameraShot( iCameraIndex, pPlayer->entindex() );
            }
            else if ( pCapturePoint )
            {
                StartChaseCameraShot( pPlayer->entindex(), pCapturePoint->entindex(), 96, 20, thera, false );
            }
            else
            {
                StartChaseCameraShot( pPlayer->entindex(), 0, 96, 20, 0, false );
            }
        }
        else if ( iCameraIndex >= 0 && pCapturePoint )
        {
            // no player known for this event
            StartFixedCameraShot( iCameraIndex, pCapturePoint->entindex() );
        }

        // shot 2 seconds after event
        m_nNextShotTick = min( m_nNextShotTick, (event->m_Tick+TIME_TO_TICKS(1.0)) );
    }
    else if ( !Q_strcmp( "object_destroyed", name ) )
    {
        CBasePlayer *attacker = UTIL_PlayerByUserId( event->m_Event->GetInt("attacker") );
        if ( attacker )
        {
            int iObjectIndex = event->m_Event->GetInt("index");
            StartChaseCameraShot( attacker->entindex(), iObjectIndex, 96, 20, thera, false );
        }
    }
    else if ( !Q_strcmp( "ctf_flag_captured", name ) )
    {
        CBasePlayer *capper = UTIL_PlayerByUserId( event->m_Event->GetInt("capper") );
        if ( capper )
        {
//.........这里部分代码省略.........
开发者ID:zxz41,项目名称:TF2Classic,代码行数:101,代码来源:tf_hltvdirector.cpp

示例5: CONSOLE_ECHO


//.........这里部分代码省略.........
				CONSOLE_ECHO("Error parsing %s - expected '='\n", filename);
				FREE_FILE(dataPointer);
				return;
			}

			token = SharedGetToken();
			if (Q_strcmp(token, "=") != 0)
			{
				CONSOLE_ECHO("Error parsing %s - expected '='\n", filename);
				FREE_FILE(dataPointer);
				return;
			}

			// get attribute value
			dataFile = SharedParse(dataFile);
			if (!dataFile)
			{
				CONSOLE_ECHO("Error parsing %s - expected attribute value\n", filename);
				FREE_FILE(dataPointer);
				return;
			}

			token = SharedGetToken();

			const char *decoratedName = GetDecoratedSkinName(skinName, filename);
			bool skinExists = GetCustomSkinIndex(decoratedName) > 0;
			if (m_nextSkin < NumCustomSkins && !skinExists)
			{
				// decorate the name
				m_skins[m_nextSkin] = CloneString(decoratedName);

				// construct the model filename
				m_skinModelnames[m_nextSkin] = CloneString(token);
				m_skinFilenames[m_nextSkin] = new char[Q_strlen(token) * 2 + Q_strlen("models/player//.mdl") + 1];
				Q_sprintf(m_skinFilenames[m_nextSkin], "models/player/%s/%s.mdl", token, token);
				m_nextSkin++;
			}

			// eat 'End'
			dataFile = SharedParse(dataFile);
			if (!dataFile)
			{
				CONSOLE_ECHO("Error parsing %s - expected 'End'\n", filename);
				FREE_FILE(dataPointer);
				return;
			}

			token = SharedGetToken();
			if (Q_strcmp(token, "End") != 0)
			{
				CONSOLE_ECHO("Error parsing %s - expected 'End'\n", filename);
				FREE_FILE(dataPointer);
				return;
			}

			// it's just a custom skin - no need to do inheritance on a bot profile, etc.
			continue;
		}

		// encountered a new profile
		BotProfile *profile;
		if (isDefault)
		{
			profile = &defaultProfile;
		}
		else
开发者ID:s1lentq,项目名称:ReGameDLL_CS,代码行数:67,代码来源:bot_profile.cpp

示例6: if

void CSDKPlayerClassInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName )
{
	BaseClass::Parse( pKeyValuesData, szWeaponName );

	m_iTeam= pKeyValuesData->GetInt( "team", TEAM_UNASSIGNED );

	// Figure out what team can have this player class
	m_iTeam = TEAM_UNASSIGNED;

//Tony; don't check for teams unless we're using teams. You could do a free for all, but class / character based game if you wanted.
#ifdef SDK_USE_TEAMS
	const char *pTeam = pKeyValuesData->GetString( "team", NULL );
	if ( pTeam )
	{
		if ( Q_stricmp( pTeam, "BLUE" ) == 0 )
		{
			m_iTeam = SDK_TEAM_BLUE;
		}
		else if ( Q_stricmp( pTeam, "RED" ) == 0 )
		{
			m_iTeam = SDK_TEAM_RED;
		}
		else
		{
			Assert( false );
		}
	}
	else
	{
		Assert( false );
	}
#endif

	const char *pszPrimaryWeapon = pKeyValuesData->GetString( "primaryweapon", NULL );
	m_iPrimaryWeapon = AliasToWeaponID( pszPrimaryWeapon );
	Assert( m_iPrimaryWeapon != WEAPON_NONE );	// require player to have a primary weapon

	const char *pszSecondaryWeapon = pKeyValuesData->GetString( "secondaryweapon", NULL );

	if ( pszSecondaryWeapon )
	{
        m_iSecondaryWeapon = AliasToWeaponID( pszSecondaryWeapon );
//		Assert( m_iSecondaryWeapon != WEAPON_NONE );
	}
	else 
		m_iSecondaryWeapon = WEAPON_NONE;

	const char *pszMeleeWeapon = pKeyValuesData->GetString( "meleeweapon", NULL );
	if ( pszMeleeWeapon )
	{
		m_iMeleeWeapon = AliasToWeaponID( pszMeleeWeapon );
//        Assert( m_iMeleeWeapon != WEAPON_NONE );
	}
	else
		m_iMeleeWeapon = WEAPON_NONE;

	m_iNumGrensType1 = pKeyValuesData->GetInt( "numgrens", 0 );
	if ( m_iNumGrensType1 > 0 )
	{
		const char *pszGrenType1 = pKeyValuesData->GetString( "grenadetype", NULL );
		m_iGrenType1 = AliasToWeaponID( pszGrenType1 );
//		Assert( m_iGrenType1 != WEAPON_NONE );
	}

	m_iNumGrensType2 = pKeyValuesData->GetInt( "numgrens2", 0 );
	if ( m_iNumGrensType2 > 0 )
	{
		const char *pszGrenType2 = pKeyValuesData->GetString( "grenadetype2", NULL );
		m_iGrenType2 = AliasToWeaponID( pszGrenType2 );
//		Assert( m_iGrenType2 != WEAPON_NONE );
	}

	Q_strncpy( m_szLimitCvar, pKeyValuesData->GetString( "limitcvar", "!! Missing limit cvar on Player Class" ), sizeof(m_szLimitCvar) );

	Assert( Q_strlen( m_szLimitCvar ) > 0 && "Every class must specify a limitcvar" );

	// HUD player status health images (when the player is hurt)
	Q_strncpy( m_szClassImage, pKeyValuesData->GetString( "classimage", "white" ), sizeof( m_szClassImage ) );
	Q_strncpy( m_szClassImageBG, pKeyValuesData->GetString( "classimagebg", "white" ), sizeof( m_szClassImageBG ) );

	m_flRunSpeed		= pKeyValuesData->GetFloat( "RunSpeed", SDK_DEFAULT_PLAYER_RUNSPEED );
	m_flSprintSpeed		= pKeyValuesData->GetFloat( "SprintSpeed", SDK_DEFAULT_PLAYER_RUNSPEED );
	m_flProneSpeed		= pKeyValuesData->GetFloat( "ProneSpeed", SDK_DEFAULT_PLAYER_RUNSPEED );

	m_iArmor			= pKeyValuesData->GetInt( "armor", 0 );

}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:87,代码来源:sdk_playerclass_info_parse.cpp

示例7: Con_SetInputText

void Con_SetInputText( const char *inputText )
{
	if( host.type != HOST_DEDICATED ) return;
	SetWindowText( s_wcd.hwndInputLine, inputText );
	SendMessage( s_wcd.hwndInputLine, EM_SETSEL, Q_strlen( inputText ), -1 );
}
开发者ID:Rhoin,项目名称:Xash3D-CrossPlatform-Port,代码行数:6,代码来源:sys_con.c

示例8: main

/*
================
main
================
*/
int main (int c, char **v)
{
	double			time, oldtime, newtime;
	extern void (*dos_error_func)(char *, ...);
	static	char	cwd[1024];

	printf ("Quake v%4.2f\n", VERSION);
	
// make sure there's an FPU
	signal(SIGNOFP, Sys_NoFPUExceptionHandler);
	signal(SIGABRT, Sys_DefaultExceptionHandler);
	signal(SIGALRM, Sys_DefaultExceptionHandler);
	signal(SIGKILL, Sys_DefaultExceptionHandler);
	signal(SIGQUIT, Sys_DefaultExceptionHandler);
	signal(SIGINT, Sys_DefaultExceptionHandler);

	if (fptest_temp >= 0.0)
		fptest_temp += 0.1;

	COM_InitArgv (c, v);

	quakeparms.argc = com_argc;
	quakeparms.argv = com_argv;

	dos_error_func = Sys_Error;

	Sys_DetectWin95 ();
	Sys_PageInProgram ();
	Sys_GetMemory ();

	atexit (Sys_AtExit);	// in case we crash

	getwd (cwd);
	if (cwd[Q_strlen(cwd)-1] == '/') cwd[Q_strlen(cwd)-1] = 0;
	quakeparms.basedir = cwd; //"f:/quake";

	isDedicated = (COM_CheckParm ("-dedicated") != 0);

	Sys_Init ();

	if (!isDedicated)
		dos_registerintr(9, TrapKey);

//Sys_InitStackCheck ();
	
	Host_Init(&quakeparms);

//Sys_StackCheck ();

//Con_Printf ("Top of stack: 0x%x\n", &time);
	oldtime = Sys_FloatTime ();
	while (1)
	{
		newtime = Sys_FloatTime ();
		time = newtime - oldtime;

		if (cls.state == ca_dedicated && (time<sys_ticrate.value))
			continue;

		Host_Frame (time);

//Sys_StackCheck ();

		oldtime = newtime;
	}
}
开发者ID:ACIIL,项目名称:Quake,代码行数:71,代码来源:sys_dos.c

示例9: R_ShowTextures

/*
===============
R_ShowTextures

Draw all the images to the screen, on top of whatever
was there.  This is used to test for texture thrashing.
===============
*/
void R_ShowTextures( void )
{
	gltexture_t	*image;
	float		x, y, w, h;
	int		i, j, k, base_w, base_h;
	int		total, start, end;
	rgba_t		color = { 192, 192, 192, 255 };
	int		charHeight, numTries = 0;
	static qboolean	showHelp = true;
	string		shortname;

	if( !gl_showtextures->integer )
		return;

	if( showHelp )
	{
		CL_CenterPrint( "use '<-' and '->' keys to view all the textures", 0.25f );
		showHelp = false;
	}

	pglClear( GL_COLOR_BUFFER_BIT );
	pglFinish();

	base_w = 8;
	base_h = 6;

rebuild_page:
	total = base_w * base_h;
	start = total * (gl_showtextures->integer - 1);
	end = total * gl_showtextures->integer;
	if( end > MAX_TEXTURES ) end = MAX_TEXTURES;

	w = glState.width / (float)base_w;
	h = glState.height / (float)base_h;

	Con_DrawStringLen( NULL, NULL, &charHeight );

	for( i = j = 0; i < MAX_TEXTURES; i++ )
	{
		image = R_GetTexture( i );
		if( j == start ) break; // found start
		if( pglIsTexture( image->texnum )) j++;
	}

	if( i == MAX_TEXTURES && gl_showtextures->integer != 1 )
	{
		// bad case, rewind to one and try again
		Cvar_SetFloat( "r_showtextures", max( 1, gl_showtextures->integer - 1 ));
		if( ++numTries < 2 ) goto rebuild_page;	// to prevent infinite loop
	}

	for( k = 0; i < MAX_TEXTURES; i++ )
	{
		if( j == end ) break; // page is full

		image = R_GetTexture( i );
		if( !pglIsTexture( image->texnum ))
			continue;

		x = k % base_w * w;
		y = k / base_w * h;

		pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
		GL_Bind( XASH_TEXTURE0, i ); // NOTE: don't use image->texnum here, because skybox has a 'wrong' indexes

		if(( image->flags & TF_DEPTHMAP ) && !( image->flags & TF_NOCOMPARE ))
			pglTexParameteri( image->target, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE );

		pglBegin( GL_QUADS );
		pglTexCoord2f( 0, 0 );
		pglVertex2f( x, y );
		if( image->flags & TF_TEXTURE_RECTANGLE )
			pglTexCoord2f( image->width, 0 );
		else pglTexCoord2f( 1, 0 );
		pglVertex2f( x + w, y );
		if( image->flags & TF_TEXTURE_RECTANGLE )
			pglTexCoord2f( image->width, image->height );
		else pglTexCoord2f( 1, 1 );
		pglVertex2f( x + w, y + h );
		if( image->flags & TF_TEXTURE_RECTANGLE )
			pglTexCoord2f( 0, image->height );
		else pglTexCoord2f( 0, 1 );
		pglVertex2f( x, y + h );
		pglEnd();

		if(( image->flags & TF_DEPTHMAP ) && !( image->flags & TF_NOCOMPARE ))
			pglTexParameteri( image->target, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB );

		FS_FileBase( image->name, shortname );
		if( Q_strlen( shortname ) > 18 )
		{
			// cutoff too long names, it looks ugly
//.........这里部分代码省略.........
开发者ID:jeefo,项目名称:xash3d,代码行数:101,代码来源:gl_backend.c

示例10: Sys_Print

/*
================
Sys_Print

print into window console
================
*/
void Sys_Print( const char *pMsg )
{
	const char	*msg;
	char		buffer[32768];
	char		logbuf[32768];
	char		*b = buffer;
	char		*c = logbuf;	
	int		i = 0;

	if( host.type == HOST_NORMAL )
		Con_Print( pMsg );
#ifdef _WIN32
	// if the message is REALLY long, use just the last portion of it
	if( Q_strlen( pMsg ) > sizeof( buffer ) - 1 )
		msg = pMsg + Q_strlen( pMsg ) - sizeof( buffer ) + 1;
	else msg = pMsg;

	// copy into an intermediate buffer
	while( msg[i] && (( b - buffer ) < sizeof( buffer ) - 1 ))
	{
		if( msg[i] == '\n' && msg[i+1] == '\r' )
		{
			b[0] = '\r';
			b[1] = '\n';
			c[0] = '\n';
			b += 2, c++;
			i++;
		}
		else if( msg[i] == '\r' )
		{
			b[0] = '\r';
			b[1] = '\n';
			b += 2;
		}
		else if( msg[i] == '\n' )
		{
			b[0] = '\r';
			b[1] = '\n';
			c[0] = '\n';
			b += 2, c++;
		}
		else if( msg[i] == '\35' || msg[i] == '\36' || msg[i] == '\37' )
		{
			i++; // skip console pseudo graph
		}
		else if( IsColorString( &msg[i] ))
		{
			i++; // skip color prefix
		}
		else
		{
			*b = *c = msg[i];
			b++, c++;
		}
		i++;
	}

	*b = *c = 0; // cutoff garbage

	Sys_PrintLog( logbuf );
	Con_WinPrint( buffer );
#else
	Sys_PrintLog( pMsg );
#endif
	if( host.rd.target )
	{
		if(( Q_strlen( pMsg ) + Q_strlen( host.rd.buffer )) > ( host.rd.buffersize - 1 ))
		{
			if( host.rd.flush )
			{
				host.rd.flush( host.rd.address, host.rd.target, host.rd.buffer );
				*host.rd.buffer = 0;
			}
		}
		Q_strcat( host.rd.buffer, pMsg );
		return;
	}
}
开发者ID:Tox86,项目名称:xash3d,代码行数:85,代码来源:sys_win.c

示例11: ScaleFOVByWidthRatio


//.........这里部分代码省略.........

	if ( tr.DidHitWorld() )
	{
		if ( tr.hitbox == 0 )
		{
			Vector dummy;
			IMaterial *pMat = engine->TraceLineMaterialAndLighting( start, end, dummy, dummy );
			if ( pMat )
			{
				numMaterials = 1;
				MatList = new IMaterial*[1];
				MatList[0] = pMat;
			}
		}
		else
		{
			ICollideable *prop = staticpropmgr->GetStaticPropByIndex( tr.hitbox - 1 );
			if ( prop )
			{
				IClientRenderable *pRenderProp = prop->GetIClientUnknown()->GetClientRenderable();
				if ( pRenderProp )
				{
					const model_t *pModel = pRenderProp->GetModel();
					if ( pModel )
						pSHdr = modelinfo->GetStudiomodel( pModel );
				}
			}
		}
	}
	else if ( tr.m_pEnt )
	{
		const model_t *pModel = tr.m_pEnt->GetModel();
		if ( pModel )
			pSHdr = modelinfo->GetStudiomodel( pModel );
	}

	if ( pSHdr )
	{
		Assert( !numMaterials && !MatList );
		numMaterials = pSHdr->numtextures;
		const int numPaths = pSHdr->numcdtextures;

		if ( numMaterials )
		{
			CUtlVector< IMaterial* >hValidMaterials;
			for ( int i = 0; i < numMaterials; i++ )
			{
				mstudiotexture_t *pStudioTex = pSHdr->pTexture( i );
				const char *matName = pStudioTex->pszName();

				for ( int p = 0; p < numPaths; p++ )
				{
					char tmpPath[MAX_PATH];
					Q_snprintf( tmpPath, MAX_PATH, "%s%s\0", pSHdr->pCdtexture( p ), matName );
					Q_FixSlashes( tmpPath );
					IMaterial *pTempMat = materials->FindMaterial( tmpPath, TEXTURE_GROUP_MODEL );
					if ( !IsErrorMaterial( pTempMat ) )
					{
						hValidMaterials.AddToTail( pTempMat );
						break;
					}
				}
			}

			numMaterials = hValidMaterials.Count();
			if ( numMaterials )
			{
				MatList = new IMaterial*[ numMaterials ];
				for ( int i = 0; i < numMaterials; i++ )
					MatList[i] = hValidMaterials[i];
			}

			hValidMaterials.Purge();
		}
	}

	*szMat = new char*[ numMaterials ];

	int iTotalLength = 0;
	for ( int i = 0; i < numMaterials; i++ )
		iTotalLength += Q_strlen( MatList[i]->GetName() ) + 1;

	**szMat = new char[ iTotalLength ];

	int curpos = 0;
	for ( int i = 0; i < numMaterials; i++ )
	{
		const char *pszName = MatList[i]->GetName();

		int curLength = Q_strlen( pszName ) + 1;
		(*szMat)[ i ] = **szMat + curpos;
		Q_strcpy( (*szMat)[ i ], pszName );
		curpos += curLength;
	}

	if ( MatList )
		delete [] MatList;

	return numMaterials;
}
开发者ID:InfoSmart,项目名称:InSource,代码行数:101,代码来源:SEdit_ModelRender.cpp

示例12: CMD_ARGV


//.........这里部分代码省略.........
		IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_DISCONNECT;
	}
	else if (FStrEq(pcmd, "bot_nav_splice"))
	{
		IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_SPLICE;
	}
	else if (FStrEq(pcmd, "bot_nav_crouch"))
	{
		IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_ATTRIB_CROUCH;
	}
	else if (FStrEq(pcmd, "bot_nav_jump"))
	{
		IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_ATTRIB_JUMP;
	}
	else if (FStrEq(pcmd, "bot_nav_precise"))
	{
		IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_ATTRIB_PRECISE;
	}
	else if (FStrEq(pcmd, "bot_nav_no_jump"))
	{
		IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_editCmd) = EDIT_ATTRIB_NO_JUMP;
	}
	else if (FStrEq(pcmd, "bot_nav_analyze"))
	{
		IMPLEMENT_ARRAY_CLASS(CCSBotManager, m_isAnalysisRequested) = true;
	}
	else if (FStrEq(pcmd, "bot_nav_strip"))
	{
		StripNavigationAreas();// TODO: reverse me
	}
	else if (FStrEq(pcmd, "bot_nav_save"))
	{
		GET_GAME_DIR(buffer);
		buffer[ Q_strlen(buffer) ] = '\\';

		Q_strcat(buffer, CBotManager::GetNavMapFilename());

		if (SaveNavigationMap(buffer))// TODO: reverse me
			CONSOLE_ECHO("Navigation map '%s' saved.\n", buffer);
		else
			CONSOLE_ECHO("ERROR: Cannot save navigation map '%s'.\n", buffer);
	}
	else if (FStrEq(pcmd, "bot_nav_load"))
	{
		ValidateMapData();
	}
	else if (FStrEq(pcmd, "bot_nav_use_place"))
	{
		if (CMD_ARGC() == 1)
		{
			int i = 0;
			const BotPhraseList *placeList = TheBotPhrases->GetPlaceList();

			for (BotPhraseList::const_iterator iter = placeList->begin(); iter != placeList->end(); ++iter, i++)
			{
				if ((*iter)->GetID() == GetNavPlace())
					CONSOLE_ECHO("--> %-26s", (*iter)->GetName());
				else
					CONSOLE_ECHO("%-30s", (*iter)->GetName());

				if (!(i % 3))
					CONSOLE_ECHO("\n");
			}
			CONSOLE_ECHO("\n");
		}
		else
开发者ID:coolmans,项目名称:ReGameDLL_CS,代码行数:67,代码来源:cs_bot_manager.cpp

示例13: SetDefaultChannels

void TokenChannels_t::Tokenize( const char *string )
{
	SetDefaultChannels();
	if ( !string || !*string )
		return;

	if ( Q_strlen( string ) > 128 )
	{
		iActiveChannels = 1;
		bHasAnyValues = true;
		bReady = true;
		bChannelAsValue[0] = true;
	}

	while ( *string == ' ' )
		string++;
	const bool bNormalize = string && (*string == 'n' || *string == 'N' );
	if ( bNormalize )
		string++;
	while ( *string == ' ' )
		string++;

	char localString[ MAX_OPERATION_C ];
	Q_snprintf( localString, sizeof(localString), "%s\0", string );

	char *MakeUpper = localString;
	while( MakeUpper && *MakeUpper )
	{
		if ( *MakeUpper == 'e' )
			*MakeUpper = 'E';
		else if ( *MakeUpper == 'p' )
			*MakeUpper = 'P';
		else if ( *MakeUpper == 'i' )
			*MakeUpper = 'I';
		MakeUpper++;
	}

	const char *stringtest = localString;
	while (stringtest && *stringtest)
	{
		if ( ISSTRING_LITERAL( localString, stringtest ) || ISSTRING_VALUE( localString, stringtest ) )
			bHasAnyValues = true;
		stringtest++;
	}

	char *cleanupReader = localString;
	while ( *cleanupReader )
	{
		if ( !ISSTRING_VALUE( localString, cleanupReader ) &&
				*cleanupReader != ' ' &&
				!ISSTRING_OPERATOR( cleanupReader ) &&
				GetChannelNumFromChar( cleanupReader ) < 0 &&
				!ISSTRING_LITERAL( localString, cleanupReader ) &&
				!ISCHAR_BRACKET( *cleanupReader ) &&
				*cleanupReader != '$'
				)
		{
			SnipCharFromString( cleanupReader );
			//cleanupReader--;
		}
		cleanupReader++;
	}

	char cleanupString[MAX_OPERATION_C];
	cleanupReader = cleanupString;
	Q_strcpy( cleanupString, localString );
	Q_memset( localString, 0, sizeof( localString ) );

#define STEST_VALUE 0
#define STEST_OPERATOR 1
#define STEST_BRACKET_OPEN 2
#define STEST_BRACKET_CLOSE 3
#define STEST_BRACKET( x ) ( x == STEST_BRACKET_OPEN || x == STEST_BRACKET_CLOSE )

	while( *cleanupReader )
	{
		if ( *cleanupReader == ' ' )
		{
			const char *searchfront = cleanupReader;
			const char *searchback = cleanupReader;

			int priorToSpace = -1;
			int afterSpace = -1;
			while ( searchfront >= cleanupString )
			{
				if ( ISSTRING_VALUE( cleanupString, searchfront ) ||
					ISSTRING_LITERAL( cleanupString, searchfront ) || *searchfront == '$' )
					priorToSpace = STEST_VALUE;
				else if ( ISSTRING_OPERATOR( searchfront ) )
					priorToSpace = STEST_OPERATOR;
				else if ( ISCHAR_BOPEN( *searchfront ) )
					priorToSpace = STEST_BRACKET_OPEN;
				else if ( ISCHAR_BCLOSE( *searchfront ) )
					priorToSpace = STEST_BRACKET_CLOSE;
				else if ( GetChannelNumFromChar( searchfront ) >= 0 )
					break;
				if ( priorToSpace >= 0 )
					break;
				searchfront--;
			}
//.........这里部分代码省略.........
开发者ID:BSVino,项目名称:source-shader-editor,代码行数:101,代码来源:tokenchannels.cpp

示例14: Assert

void CUtlString::Set( const char *pValue )
{
	Assert( !m_Storage.IsReadOnly() );
	int nLen = pValue ? Q_strlen(pValue) + 1 : 0;
	m_Storage.Set( pValue, nLen );
}
开发者ID:Baer42,项目名称:source-sdk-2013,代码行数:6,代码来源:utlstring.cpp

示例15: sscanf

bool CSmokeStack::KeyValue( const char *szKeyName, const char *szValue )
{
	if( stricmp( szKeyName, "Wind" ) == 0 )
	{
		sscanf( szValue, "%f %f %f", &m_vWind.GetForModify().x, &m_vWind.GetForModify().y, &m_vWind.GetForModify().z );
		return true;
	}
	else if( stricmp( szKeyName, "WindAngle" ) == 0 )
	{
		m_WindAngle = atoi( szValue );
		RecalcWindVector();
		return true;
	}
	else if( stricmp( szKeyName, "WindSpeed" ) == 0 )
	{
		m_WindSpeed = atoi( szValue );
		RecalcWindVector();
		return true;
	}
	else if ( stricmp( szKeyName, "SmokeMaterial" ) == 0 )
	{
		// Make sure we have a vmt extension.
		if ( Q_stristr( szValue, ".vmt" ) )
		{
			m_strMaterialModel = AllocPooledString( szValue );
		}
		else
		{
			char str[512];
			Q_snprintf( str, sizeof( str ), "%s.vmt", szValue );
			m_strMaterialModel = AllocPooledString( str );
		}
		
		const char *pName = STRING( m_strMaterialModel );
		char szStrippedName[512];

		m_iMaterialModel = PrecacheModel( pName );
		Q_StripExtension( pName, szStrippedName, Q_strlen(pName)+1 );

		int iLength = Q_strlen( szStrippedName );
		szStrippedName[iLength-1] = '\0';

		int iCount = 1;
		char str[512];
		Q_snprintf( str, sizeof( str ), "%s%d.vmt", szStrippedName, iCount );
		
		while ( filesystem->FileExists( UTIL_VarArgs( "materials/%s", str ) ) )
		{
			PrecacheModel( str );
			iCount++;
			
			Q_snprintf( str, sizeof( str ), "%s%d.vmt", szStrippedName, iCount );
		}

		return true;
	}
	else
	{
		return BaseClass::KeyValue( szKeyName, szValue );
	}
}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:61,代码来源:smokestack.cpp


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