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

C++ Q_snprintf函数代码示例

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

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



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

示例1: Q_strncpy

//-----------------------------------------------------------------------------
// Purpose: Starts the effect
// Input  : *pParticleMgr - 
//			*pArgs - 
//-----------------------------------------------------------------------------
void C_SmokeStack::Start(CParticleMgr *pParticleMgr, IPrototypeArgAccess *pArgs)
{
	pParticleMgr->AddEffect( &m_ParticleEffect, this );
	
	// Figure out the material name.
	char str[512] = "unset_material";
	const model_t *pModel = modelinfo->GetModel( m_iMaterialModel );
	if ( pModel )
	{
		Q_strncpy( str, modelinfo->GetModelName( pModel ), sizeof( str ) );

		// Get rid of the extension because the material system doesn't want it.
		char *pExt = Q_stristr( str, ".vmt" );
		if ( pExt )
			pExt[0] = 0;
	}

	m_MaterialHandle[0] = m_ParticleEffect.FindOrAddMaterial( str );

#ifdef HL2_EPISODIC
	int iCount = 1;
	char szNames[512];

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

	Q_snprintf( szNames, sizeof( szNames ), "%s%d.vmt", str, iCount );

	while ( filesystem->FileExists( VarArgs( "materials/%s", szNames ) ) && iCount < SMOKESTACK_MAX_MATERIALS )
	{
		char *pExt = Q_stristr( szNames, ".vmt" );
		if ( pExt )
			pExt[0] = 0;

		m_MaterialHandle[iCount] = m_ParticleEffect.FindOrAddMaterial( szNames );
		iCount++;
	}

	m_iMaxFrames = iCount-1;

	m_ParticleSpawn.Init( mat_reduceparticles.GetBool() ? m_Rate / 4 : m_Rate ); // Obey mat_reduceparticles in episodic
#else
	m_ParticleSpawn.Init( m_Rate );
#endif

	m_InvLifetime = m_Speed / m_JetLength;

	m_pParticleMgr = pParticleMgr;

	// Figure out how we need to draw.
	IMaterial *pMaterial = pParticleMgr->PMaterialToIMaterial( m_MaterialHandle[0] );
	if( pMaterial )
	{
		m_Renderer.Init( pParticleMgr, pMaterial );
	}
	
	QueueLightParametersInRenderer();

	// For the first N seconds, always simulate so it can build up the smokestack.
	// Afterwards, we set it to freeze when it's not being rendered.
	m_ParticleEffect.SetAlwaysSimulate( true );
	SetNextClientThink( gpGlobals->curtime + 5 );
}
开发者ID:1n73rf4c3,项目名称:source-sdk-2013,代码行数:68,代码来源:c_smokestack.cpp


示例2: VidInit

void CHud :: VidInit( void )
{
	m_scrinfo.iSize = sizeof( m_scrinfo );
	GetScreenInfo( &m_scrinfo );

	// ----------
	// Load Sprites
	// ---------
	m_hHudError = 0;
	
	if( ScreenWidth < 640 )
		m_iRes = 320;
	else m_iRes = 640;
	
	// Only load this once
	if( !m_pSpriteList )
	{
		// we need to load the hud.txt, and all sprites within
		m_pSpriteList = SPR_GetList( "sprites/hud.txt", &m_iSpriteCountAllRes );

		if( m_pSpriteList )
		{
			// count the number of sprites of the appropriate res
			client_sprite_t *p = m_pSpriteList;
			m_iSpriteCount = 0;

			for( int j = 0; j < m_iSpriteCountAllRes; j++ )
			{
				if( p->iRes == m_iRes )
					m_iSpriteCount++;
				p++;
			}

			// allocated memory for sprite handle arrays
 			m_rghSprites = new HSPRITE[m_iSpriteCount];
			m_rgrcRects = new wrect_t[m_iSpriteCount];
			m_rgszSpriteNames = new char[m_iSpriteCount * MAX_SPRITE_NAME_LENGTH];

			p = m_pSpriteList;
			int index = 0;

			for( j = 0; j < m_iSpriteCountAllRes; j++ )
			{
				if( p->iRes == m_iRes )
				{
					char sz[256];
					Q_snprintf( sz, sizeof( sz ), "sprites/%s.spr", p->szSprite );
					m_rghSprites[index] = SPR_Load( sz );
					m_rgrcRects[index] = p->rc;
					Q_strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH );

					index++;
				}
				p++;
			}
		}
		else
		{
			ALERT( at_warning, "hud.txt couldn't load\n");
			m_pCvarDraw->value = 0;
			return;
		}
	}
	else
	{
		// we have already have loaded the sprite reference from hud.txt, but
		// we need to make sure all the sprites have been loaded (we've gone through a transition, or loaded a save game)
		client_sprite_t *p = m_pSpriteList;

		for( int j = 0, index = 0; j < m_iSpriteCountAllRes; j++ )
		{
			if( p->iRes == m_iRes )
			{
				char sz[256];
				Q_snprintf( sz, sizeof( sz ), "sprites/%s.spr", p->szSprite );
				m_rghSprites[index] = SPR_Load( sz );
				index++;
			}
			p++;
		}
	}

	// assumption: number_1, number_2, etc, are all listed and loaded sequentially
	m_HUD_number_0 = GetSpriteIndex( "number_0" );
	m_iFontHeight = m_rgrcRects[m_HUD_number_0].bottom - m_rgrcRects[m_HUD_number_0].top;
	
	// loading error sprite
	m_HUD_error = GetSpriteIndex( "error" );
	m_hHudError = GetSprite( m_HUD_error );
	
	m_Ammo.VidInit();
	m_Health.VidInit();
	m_Geiger.VidInit();
	m_Train.VidInit();
	m_Battery.VidInit();
	m_Flash.VidInit();
	m_MOTD.VidInit();
	m_Message.VidInit();
	m_Scoreboard.VidInit();
	m_StatusBar.VidInit();
//.........这里部分代码省略.........
开发者ID:XashDev,项目名称:XashXT,代码行数:101,代码来源:hud.cpp


示例3: LoadWeaponSprites

void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon )
{
	int i, iRes;
	
	if( ScreenWidth < 640 )
		iRes = 320;
	else iRes = 640;

	char sz[128];

	if ( !pWeapon ) return;

	memset( &pWeapon->rcActive, 0, sizeof( wrect_t ));
	memset( &pWeapon->rcInactive, 0, sizeof( wrect_t ));
	memset( &pWeapon->rcAmmo, 0, sizeof( wrect_t ));
	memset( &pWeapon->rcAmmo2, 0, sizeof( wrect_t ));
	pWeapon->hInactive = 0;
	pWeapon->hActive = 0;
	pWeapon->hAmmo = 0;
	pWeapon->hAmmo2 = 0;
	
	Q_snprintf( sz, sizeof( sz ), "sprites/%s.txt", pWeapon->szName );
	client_sprite_t *pList = SPR_GetList( sz, &i );

	if( !pList ) return;

	client_sprite_t *p;
	
	p = GetSpriteList( pList, "crosshair", iRes, i );
	if( p )
	{
		Q_snprintf( sz, sizeof( sz ), "sprites/%s.spr", p->szSprite );
		pWeapon->hCrosshair = SPR_Load( sz );
		pWeapon->rcCrosshair = p->rc;
	}
	else pWeapon->hCrosshair = 0;

	p = GetSpriteList( pList, "autoaim", iRes, i );
	if( p )
	{
		Q_snprintf( sz, sizeof( sz ), "sprites/%s.spr", p->szSprite );
		pWeapon->hAutoaim = SPR_Load( sz );
		pWeapon->rcAutoaim = p->rc;
	}
	else pWeapon->hAutoaim = 0;

	p = GetSpriteList( pList, "zoom", iRes, i );
	if( p )
	{
		Q_snprintf( sz, sizeof( sz ), "sprites/%s.spr", p->szSprite );
		pWeapon->hZoomedCrosshair = SPR_Load( sz );
		pWeapon->rcZoomedCrosshair = p->rc;
	}
	else
	{
		pWeapon->hZoomedCrosshair = pWeapon->hCrosshair; // default to non-zoomed crosshair
		pWeapon->rcZoomedCrosshair = pWeapon->rcCrosshair;
	}

	p = GetSpriteList( pList, "zoom_autoaim", iRes, i );
	if( p )
	{
		Q_snprintf( sz, sizeof( sz ), "sprites/%s.spr", p->szSprite );
		pWeapon->hZoomedAutoaim = SPR_Load( sz );
		pWeapon->rcZoomedAutoaim = p->rc;
	}
	else
	{
		pWeapon->hZoomedAutoaim = pWeapon->hZoomedCrosshair;  // default to zoomed crosshair
		pWeapon->rcZoomedAutoaim = pWeapon->rcZoomedCrosshair;
	}

	p = GetSpriteList( pList, "weapon", iRes, i );
	if( p )
	{
		Q_snprintf( sz, sizeof( sz ), "sprites/%s.spr", p->szSprite );
		pWeapon->hInactive = SPR_Load( sz );
		pWeapon->rcInactive = p->rc;
		gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top );
	}
	else
	{
		pWeapon->hInactive = gHUD.m_hHudError;
		pWeapon->rcInactive = gHUD.GetSpriteRect( gHUD.m_HUD_error );
		gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top );
	}

	p = GetSpriteList( pList, "weapon_s", iRes, i );
	if( p )
	{
		Q_snprintf( sz, sizeof( sz ), "sprites/%s.spr", p->szSprite );
		pWeapon->hActive = SPR_Load( sz );
		pWeapon->rcActive = p->rc;
	}
	else
	{
		pWeapon->hActive = gHUD.m_hHudError;
		pWeapon->rcActive = gHUD.GetSpriteRect( gHUD.m_HUD_error );
	}

//.........这里部分代码省略.........
开发者ID:ptitSeb,项目名称:XashXT,代码行数:101,代码来源:ammo.cpp


示例4: AppendPlayerInformation

void AppendPlayerInformation(ISteamHTTP *pSteamHttp, HTTPRequestHandle httpRequest, CSteamAPIContext *pSteamAPIContext, CBasePlayer *pPlayer, bool bAnonymous)
{
	// Local DS
	time_t rawtime;
	struct tm* timeinfo;

	time(&rawtime);
	timeinfo = localtime(&rawtime);
	char* local_ds = asctime(timeinfo);

	char* newLine = strstr(local_ds, "\n");
	if (newLine)
	{
		*newLine = 0;
	}

	pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "localdatetime", local_ds);

	// Build DS
	char build_ds[64];
	Q_snprintf(build_ds, sizeof(build_ds), "%s,%s", __DATE__, __TIME__);
	pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "builddatetime", build_ds);

	// DxLevel
	pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "dxlevel", ConVarRef("mat_dxlevel").GetString());

	if (pPlayer)
	{
		// Position
		char player_position[32];
		Vector player_pos = pPlayer->GetLocalOrigin();
		Q_snprintf(player_position, sizeof(player_position), "%.2f,%.2f,%.2f", player_pos.x, player_pos.y, player_pos.z);
		pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "position", player_position);

		// Angles
		char player_angles[32];
		QAngle player_ang = pPlayer->GetLocalAngles();
		Q_snprintf(player_angles, sizeof(player_angles), "%.2f,%.2f,%.2f", player_ang.x, player_ang.y, player_ang.z);
		pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "angles", player_angles);

		// Health
		char player_health[16];
		Q_snprintf(player_health, sizeof(player_health), "%i", pPlayer->GetHealth());
		pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "health", player_health);

		// Weapon
		CBaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon();
		if (pWeapon)
		{
			pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "weapon", pWeapon->GetClassname());
		}
	}

	// Cheats
	char cheats_enabled[8];
	Q_snprintf(cheats_enabled, sizeof(cheats_enabled), "%i", (ConVarRef("sv_cheats").GetBool() || ConVarRef("developer").GetBool()));
	pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "cheats", cheats_enabled);

	// Map
#ifdef CLIENT_DLL
	char mapname[256];
	V_FileBase(engine->GetLevelName(), mapname, sizeof(mapname));
	pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "level", mapname);
#else
	pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "level", gpGlobals->mapname.ToCStr());
#endif

	if (pSteamAPIContext)
	{
		// Language
		pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "language", pSteamAPIContext->SteamUtils()->GetSteamUILanguage());
	}

	// Platform
	char *			platform = "unknown";
	if (IsPC())		platform = "pc";
	if (IsOSX())	platform = "osx";
	if (IsLinux())	platform = "linux";
	if (IsX360())	platform = "360";
	if (IsPS3())	platform = "ps3";
	pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "platform", platform);

	// Player ID
	if (bAnonymous == false)
	{
		if (ae_uniqueplayerid.GetInt() == 0)
			GenerateUniquePlayerId(pSteamAPIContext);
		pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "playerid", ae_uniqueplayerid.GetString());
	}
}
开发者ID:P1x3lF3v3r,项目名称:Estranged-Act-1,代码行数:90,代码来源:estrangedplayerinformation.cpp


示例5: Assert

//-----------------------------------------------------------------------------
// Purpose: Static method
// Input  : *hdr - 
//			sounds - 
//-----------------------------------------------------------------------------
void CModelSoundsCache::BuildAnimationEventSoundList( CStudioHdr *hdr, CUtlVector< unsigned short >& sounds )
{
	Assert( hdr );
	
	// force animation event resolution!!!
	VerifySequenceIndex( hdr );

	// Find all animation events which fire off sound script entries...
	for ( int iSeq=0; iSeq < hdr->GetNumSeq(); iSeq++ )
	{
		mstudioseqdesc_t *pSeq = &hdr->pSeqdesc( iSeq );
		
		// Now read out all the sound events with their timing
		for ( int iEvent=0; iEvent < (int)pSeq->numevents; iEvent++ )
		{
			mstudioevent_t *pEvent = pSeq->pEvent( iEvent );
			
			switch ( pEvent->event )
			{
			default:
				{
					if ( pEvent->type & AE_TYPE_NEWEVENTSYSTEM )
					{
						if ( pEvent->event == AE_SV_PLAYSOUND )
						{
							FindOrAddScriptSound( sounds, pEvent->pszOptions() );
						}
					}
				}
				break;
			// Old-style client .dll animation event
			case CL_EVENT_SOUND:
				{
					FindOrAddScriptSound( sounds, pEvent->pszOptions() );
				}
				break;
			case CL_EVENT_FOOTSTEP_LEFT:
			case CL_EVENT_FOOTSTEP_RIGHT:
				{
					char soundname[256];
					char const *options = pEvent->pszOptions();
					if ( !options || !options[0] )
					{
						options = "NPC_CombineS";
					}

					Q_snprintf( soundname, 256, "%s.RunFootstepLeft", options );
					FindOrAddScriptSound( sounds, soundname );
					Q_snprintf( soundname, 256, "%s.RunFootstepRight", options );
					FindOrAddScriptSound( sounds, soundname );
					Q_snprintf( soundname, 256, "%s.FootstepLeft", options );
					FindOrAddScriptSound( sounds, soundname );
					Q_snprintf( soundname, 256, "%s.FootstepRight", options );
					FindOrAddScriptSound( sounds, soundname );
				}
				break;
			case AE_CL_PLAYSOUND:
				{
					if ( !( pEvent->type & AE_TYPE_CLIENT ) )
						break;

					if ( pEvent->pszOptions()[0] )
					{
						FindOrAddScriptSound( sounds, pEvent->pszOptions() );
					}
					else
					{
						Warning( "-- Error --:  empty soundname, .qc error on AE_CL_PLAYSOUND in model %s, sequence %s, animevent # %i\n", 
							hdr->pszName(), pSeq->pszLabel(), iEvent+1 );
					}
				}
				break;
			case SCRIPT_EVENT_SOUND:
				{
					FindOrAddScriptSound( sounds, pEvent->pszOptions() );
				}
				break;

			case SCRIPT_EVENT_SOUND_VOICE:
				{
					FindOrAddScriptSound( sounds, pEvent->pszOptions() );
				}
				break;
			}
		}
	}
}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:92,代码来源:ModelSoundsCache.cpp


示例6: Host_Say

//// HOST_SAY
// String comes in as
// say blah blah blah
// or as
// blah blah blah
//
void Host_Say( edict_t *pEdict, const CCommand &args, bool teamonly )
{
	CBasePlayer *client;
	int		j;
	char	*p;
	char	text[256];
	char    szTemp[256];
	const char *cpSay = "say";
	const char *cpSayTeam = "say_team";
	const char *pcmd = args[0];
	bool bSenderDead = false;

	// We can get a raw string now, without the "say " prepended
	if ( args.ArgC() == 0 )
		return;

	if ( !stricmp( pcmd, cpSay) || !stricmp( pcmd, cpSayTeam ) )
	{
		if ( args.ArgC() >= 2 )
		{
			p = (char *)args.ArgS();
		}
		else
		{
			// say with a blank message, nothing to do
			return;
		}
	}
	else  // Raw text, need to prepend argv[0]
	{
		if ( args.ArgC() >= 2 )
		{
			Q_snprintf( szTemp,sizeof(szTemp), "%s %s", ( char * )pcmd, (char *)args.ArgS() );
		}
		else
		{
			// Just a one word command, use the first word...sigh
			Q_snprintf( szTemp,sizeof(szTemp), "%s", ( char * )pcmd );
		}
		p = szTemp;
	}

	CBasePlayer *pPlayer = NULL;
	if ( pEdict )
	{
		pPlayer = ((CBasePlayer *)CBaseEntity::Instance( pEdict ));
		Assert( pPlayer );

		// make sure the text has valid content
		p = CheckChatText( pPlayer, p );
	}

	if ( !p )
		return;

	if ( pEdict )
	{
		if ( !pPlayer->CanSpeak() )
			return;

		// See if the player wants to modify of check the text
		pPlayer->CheckChatText( p, 127 );	// though the buffer szTemp that p points to is 256, 
											// chat text is capped to 127 in CheckChatText above

		Assert( strlen( pPlayer->GetPlayerName() ) > 0 );

		bSenderDead = ( pPlayer->m_lifeState != LIFE_ALIVE );
	}
	else
	{
		bSenderDead = false;
	}

	const char *pszFormat = NULL;
	const char *pszPrefix = NULL;
	const char *pszLocation = NULL;
	if ( g_pGameRules )
	{
		pszFormat = g_pGameRules->GetChatFormat( teamonly, pPlayer );
		pszPrefix = g_pGameRules->GetChatPrefix( teamonly, pPlayer );	
		pszLocation = g_pGameRules->GetChatLocation( teamonly, pPlayer );
	}

	const char *pszPlayerName = pPlayer ? pPlayer->GetPlayerName():"Console";

	//DHL Chat Macros
	char *s_pHealthMacro = Q_strstr( p, "%h" );
	if ( s_pHealthMacro && pPlayer )
	{
		char sHealthMacro[20];
		Q_snprintf( sHealthMacro, sizeof( sHealthMacro ), "HP: %i", pPlayer->GetHealth() >= 0 ? pPlayer->GetHealth() : 0 );
		Q_strcpy( s_pHealthMacro, sHealthMacro );
	}

//.........这里部分代码省略.........
开发者ID:dreckard,项目名称:dhl2,代码行数:101,代码来源:client.cpp


示例7: AddSnapshotToDatabase

//=================================
// Add the current snapshot to the db
//=================================
void AddSnapshotToDatabase( void )
{
	char szSnapshot[1024];

	//Only update the prices and close.
	if ( g_bWeeklyUpdate == true )
	{
		weeklyprice_t prices;
		CUtlBuffer buf;

		prices.iVersion = PRICE_BLOB_VERSION;

		for ( int i = 1; i < WEAPON_MAX; i ++ )
		{
			Q_snprintf( szSnapshot, sizeof( szSnapshot ), "update weapon_info set current_price=%d, purchases_thisweek=0 where WeaponID=%d", g_iNewWeaponPrices[i], i  );

			int retcode = mysql->Execute( szSnapshot );
			if ( retcode != 0 )
			{
				Msg( "Query:\n %s\n failed - Retcode: %d\n", szSnapshot, retcode );
			}

			prices.iPreviousPrice[i] = g_Weapons[i].iCurrentPrice;
			prices.iCurrentPrice[i] = g_iNewWeaponPrices[i];
		}
	

		buf.Put( &prices, sizeof( weeklyprice_t ) );

		if ( g_pFullFileSystem )
		{
			g_pFullFileSystem->WriteFile( PRICE_BLOB_NAME, NULL, buf );
		}

		Q_snprintf( szSnapshot, sizeof( szSnapshot ), "update reset_counter set counter=counter+1"  );

		int retcode = mysql->Execute( szSnapshot );
		if ( retcode != 0 )
		{
			Msg( "Query:\n %s\n failed - Retcode: %d\n", szSnapshot, retcode );
		}

		return;
	}

	g_iCounter++;
		
	for ( int i = 1; i < WEAPON_MAX; i ++ )
	{
		Q_snprintf( szSnapshot, sizeof( szSnapshot ), "Insert into purchases_pricing ( snapshot, dt2, weapon_id, purchases, current_price, projected_price, reset_counter ) values ( \"%d_%d\", NOW(), %d, %d, %d, %d, %d );",
					g_iCounter, i,
				   	i,
					g_iPurchaseDelta[i],
					g_Weapons[i].iCurrentPrice,
					g_iNewWeaponPrices[i], 
					g_iResetCounter );

		int retcode = mysql->Execute( szSnapshot );
		if ( retcode != 0 )
		{
			Msg( "Query:\n %s\n failed - Retcode: %d\n", szSnapshot, retcode );
		}
	}


	Q_snprintf( szSnapshot, sizeof( szSnapshot ), "update snapshot_counter set counter=%d", g_iCounter  );

	int retcode = mysql->Execute( szSnapshot );
	if ( retcode != 0 )
	{
		Msg( "Query:\n %s\n failed - Retcode: %d\n", szSnapshot, retcode );
	}

	for ( int i = 1; i < WEAPON_MAX; i ++ )
	{
		Q_snprintf( szSnapshot, sizeof( szSnapshot ), "update weapon_info set purchases=%d, purchases_thisweek=purchases_thisweek+%d where WeaponID=%d", g_iCurrentWeaponPurchases[i], g_iPurchaseDelta[i], i  );

		int retcode = mysql->Execute( szSnapshot );
		if ( retcode != 0 )
		{
			Msg( "Query:\n %s\n failed - Retcode: %d\n", szSnapshot, retcode );
		}
	}

	Msg( "Added new snapshot to database\n", szSnapshot, retcode );
	
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:90,代码来源:blackmarket.cpp


示例8: Q_snprintf

void CASW_Mission_Chooser_Source_Local::AddToSavedCampaignList(const char *szSaveName)
{
	// find out what campaign this save is for
	char szFullFileName[256];
	Q_snprintf(szFullFileName, sizeof(szFullFileName), "save/%s", szSaveName);
	KeyValues *pSaveKeyValues = new KeyValues( szSaveName );
	if (pSaveKeyValues->LoadFromFile(g_pFullFileSystem, szFullFileName))
	{
		const char *pCampaignName = pSaveKeyValues->GetString("CampaignName");
		// check the campaign exists
		char tempfile[MAX_PATH];
		Q_snprintf( tempfile, sizeof( tempfile ), "resource/campaigns/%s.txt", pCampaignName );
		if (g_pFullFileSystem->FileExists(tempfile))
		{
			ASW_Mission_Chooser_Saved_Campaign item;
			Q_snprintf(item.m_szSaveName, sizeof(item.m_szSaveName), "%s", szSaveName);
			Q_snprintf(item.m_szCampaignName, sizeof(item.m_szCampaignName), "%s", pCampaignName);
			Q_snprintf(item.m_szDateTime, sizeof(item.m_szDateTime), "%s", pSaveKeyValues->GetString("DateTime"));
			//Msg("save %s multiplayer %d\n", szSaveName, pSaveKeyValues->GetInt("Multiplayer"));
			item.m_bMultiplayer = (pSaveKeyValues->GetInt("Multiplayer") > 0);
			//Msg("item multiplayer = %d\n", item.m_bMultiplayer);

			// check subsections for player names and player IDs, concat them into two strings
			char namebuffer[256];
			char idbuffer[512];
			namebuffer[0] = '\0';
			idbuffer[0] = '\0';
			int namepos = 0;
			int idpos = 0;
			KeyValues *pkvSubSection = pSaveKeyValues->GetFirstSubKey();
			while ( pkvSubSection )
			{
				if ((Q_stricmp(pkvSubSection->GetName(), "PLAYER")==0) && namepos < 253)
				{
					const char *pName = pkvSubSection->GetString("PlayerName");
					if (pName && pName[0] != '\0')
					{
						int namelength = Q_strlen(pName);
						for (int charcopy=0; charcopy<namelength && namepos<253; charcopy++)
						{
							namebuffer[namepos] = pName[charcopy];
							namepos++;
						}
						namebuffer[namepos] = ' '; namepos++;
						namebuffer[namepos] = '\0';
					}
				}
				if ((Q_stricmp(pkvSubSection->GetName(), "DATA")==0) && idpos < 253)
				{
					const char *pID = pkvSubSection->GetString("DataBlock");
					if (pID && pID[0] != '\0')
					{
						int idlength = Q_strlen(pID);
						for (int charcopy=0; charcopy<idlength && idpos<253; charcopy++)
						{
							idbuffer[idpos] = pID[charcopy];
							idpos++;
						}
						idbuffer[idpos] = ' '; idpos++;
						idbuffer[idpos] = '\0';
					}
				}
				pkvSubSection = pkvSubSection->GetNextKey();
			}
			Q_snprintf(item.m_szPlayerNames, sizeof(item.m_szPlayerNames), "%s", namebuffer);
			Q_snprintf(item.m_szPlayerIDs, sizeof(item.m_szPlayerIDs), "%s", idbuffer);
			item.m_iMissionsComplete = pSaveKeyValues->GetInt("NumMissionsComplete");
			m_SavedCampaignList.Insert( item );
		}
	}
	pSaveKeyValues->deleteThis();

	// check if there's now too many save games
	int iNumMultiplayer = GetNumSavedCampaigns(true, NULL);
	if (iNumMultiplayer > asw_max_saves.GetInt())
	{
		// find the oldest one
		ASW_Mission_Chooser_Saved_Campaign* pChosen = false;
		int iChosen = -1;
		for (int i=m_SavedCampaignList.Count()-1; i>=0; i--)
		{
			if (m_SavedCampaignList[i].m_bMultiplayer)
			{
				pChosen = &m_SavedCampaignList[i];
				iChosen = i;
				break;
			}			
		}
		// delete if found
		if (iChosen != -1 && pChosen)
		{
			char buffer[MAX_PATH];
			Q_snprintf(buffer, sizeof(buffer), "save/%s", pChosen->m_szSaveName);
			Msg("Deleting save %s as we have too many\n", buffer);
			g_pFullFileSystem->RemoveFile( buffer, "GAME" );
			m_SavedCampaignList.Remove(iChosen);
		}
	}
}
开发者ID:jtanx,项目名称:ch1ckenscoop,代码行数:99,代码来源:asw_mission_chooser_source_local.cpp


示例9: V_StripExtension

bool CASW_Mission_Chooser_Source_Local::ASW_Campaign_CreateNewSaveGame(char *szFileName, int iFileNameMaxLen, const char *szCampaignName, bool bMultiplayerGame, const char *szStartingMission)	// szFileName arg is the desired filename or NULL for an autogenerated one.  Function sets szFileName with the filename used.
{
	if (!szFileName)
		return false;

	char stripped[MAX_PATH];
	V_StripExtension( szCampaignName, stripped, MAX_PATH );

	char szStartingMissionStripped[64];
	if ( szStartingMission )
	{
		V_StripExtension( szStartingMission, szStartingMissionStripped, sizeof( szStartingMissionStripped ) );
	}
	else
	{
		szStartingMissionStripped[0] = 0;
	}

	// check the campaign file exists
	char campbuffer[MAX_PATH];
	Q_snprintf(campbuffer, sizeof(campbuffer), "resource/campaigns/%s.txt", stripped);
	if (!g_pFullFileSystem->FileExists(campbuffer))
	{
		Msg("No such campaign: %s\n", campbuffer);
		return false;
	}

	// Get the current time and date as a string
	char szDateTime[256];
	int year, month, dayOfWeek, day, hour, minute, second;
	ASW_System_GetCurrentTimeAndDate(&year, &month, &dayOfWeek, &day, &hour, &minute, &second);
	Q_snprintf(szDateTime, sizeof(szDateTime), "%02d/%02d/%02d %02d:%02d", month, day, year, hour, minute);

	if (szFileName[0] == '\0')
	{
		// autogenerate a filename based on the current time and date
		Q_snprintf(szFileName, iFileNameMaxLen, "%s_save_%02d_%02d_%02d_%02d_%02d_%02d", stripped, year, month, day, hour, minute, second);
	}

	// make sure the path and extension are correct
	Q_SetExtension( szFileName, ".campaignsave", iFileNameMaxLen );
	char tempbuffer[256];
	Q_snprintf(tempbuffer, sizeof(tempbuffer), "%s", szFileName);
	const char *pszNoPathName = Q_UnqualifiedFileName(tempbuffer);
	//Msg("Unqualified = %s\n", pszNoPathName);		//softcopy:
	char szFullFileName[256];
	Q_snprintf(szFullFileName, sizeof(szFullFileName), "save/%s", pszNoPathName);
	//Msg("Creating new save with filename: %s\n", szFullFileName);		//softcopy:

	KeyValues *pSaveKeyValues = new KeyValues( pszNoPathName );

	int nMissionsComplete = 0;
	if ( szStartingMission && szStartingMission[0] )
	{
		KeyValues *pCampaignDetails = GetCampaignDetails( stripped );
		if ( pCampaignDetails )
		{
			int nMissionSections = 0;
			for ( KeyValues *pMission = pCampaignDetails->GetFirstSubKey(); pMission; pMission = pMission->GetNextKey() )
			{
				if ( !Q_stricmp( pMission->GetName(), "MISSION" ) )
				{
					if ( !Q_stricmp( pMission->GetString( "MapName", "" ), szStartingMissionStripped ) )
					{
						nMissionsComplete = nMissionSections - 1;		// skip first dummy mission
						break;
					}
					nMissionSections++;
				}
			}
		}
	}
	
	pSaveKeyValues->SetInt("Version", ASW_CURRENT_SAVE_VERSION);
	pSaveKeyValues->SetString("CampaignName", stripped);
	pSaveKeyValues->SetInt("CurrentPosition", nMissionsComplete + 1);		// position squad on the first uncompleted mission
	pSaveKeyValues->SetInt("NumMissionsComplete", nMissionsComplete);
	pSaveKeyValues->SetInt("InitialNumMissionsComplete", nMissionsComplete);
	pSaveKeyValues->SetInt("Multiplayer", bMultiplayerGame ? 1 : 0);
	pSaveKeyValues->SetString("DateTime", szDateTime);
	pSaveKeyValues->SetInt("NumPlayers", 0);	
	
	// write out each mission's status
	KeyValues *pSubSection;
	for (int i=0; i<ASW_MAX_MISSIONS_PER_CAMPAIGN; i++)
	{
		pSubSection = new KeyValues("MISSION");
		pSubSection->SetInt("MissionID", i);
		bool bComplete = ( i != 0 ) && ( i <= nMissionsComplete );
		pSubSection->SetInt("MissionComplete", bComplete ? 1 : 0 );
		pSaveKeyValues->AddSubKey(pSubSection);
	}

	const int nInitialSkillPoints = 0;

	// write out each marine's stats
	for (int i=0; i<ASW_NUM_MARINE_PROFILES; i++)
	{
		pSubSection = new KeyValues("MARINE");
		pSubSection->SetInt("MarineID", i);
//.........这里部分代码省略.........
开发者ID:jtanx,项目名称:ch1ckenscoop,代码行数:101,代码来源:asw_mission_chooser_source_local.cpp


示例10: ReadEncryptedKVFile

KeyValues* ReadEncryptedKVFile( IFileSystem *filesystem, const char *szFilenameWithoutExtension, const unsigned char *pICEKey )
{
	Assert( strchr( szFilenameWithoutExtension, '.' ) == NULL );
	char szFullName[512];

	const char *pSearchPath = "GAME";

	// Open the weapon data file, and abort if we can't
	KeyValues *pKV = new KeyValues( "WeaponDatafile" );
	pKV->UsesEscapeSequences( true );

	Q_snprintf(szFullName,sizeof(szFullName), "%s.txt", szFilenameWithoutExtension);

	if ( !pKV->LoadFromFile( filesystem, szFullName, pSearchPath ) ) // try to load the normal .txt file first
	{
#ifndef _XBOX
		if ( pICEKey )
		{
			Q_snprintf(szFullName,sizeof(szFullName), "%s.ctx", szFilenameWithoutExtension); // fall back to the .ctx file

			FileHandle_t f = filesystem->Open( szFullName, "rb", pSearchPath );

			if (!f)
			{
				pKV->deleteThis();
				return NULL;
			}
			// load file into a null-terminated buffer
			int fileSize = filesystem->Size(f);
			char *buffer = (char*)MemAllocScratch(fileSize + 1);
		
			Assert(buffer);
		
			filesystem->Read(buffer, fileSize, f); // read into local buffer
			buffer[fileSize] = 0; // null terminate file as EOF
			filesystem->Close( f );	// close file after reading

			UTIL_DecodeICE( (unsigned char*)buffer, fileSize, pICEKey );

			bool retOK = pKV->LoadFromBuffer( szFullName, buffer, filesystem );

			MemFreeScratch();

			if ( !retOK )
			{
				pKV->deleteThis();
				return NULL;
			}
		}
		else
		{
			pKV->deleteThis();
			return NULL;
		}
#else
		pKV->deleteThis();
		return NULL;
#endif
	}

	return pKV;
}
开发者ID:DeadFuze,项目名称:swarm-sdk,代码行数:62,代码来源:weapon_parse.cpp


示例11: SetMayaScriptSettings

//-----------------------------------------------------------------------------
// Points the maya script to the appropriate place
//-----------------------------------------------------------------------------
void SetMayaScriptSettings( )
{
	char pMayaScriptPath[ MAX_PATH ];
	Q_snprintf( pMayaScriptPath, sizeof(pMayaScriptPath), "%%VPROJECT%%\\..\\sdktools\\maya\\7.0\\modules\\utilities\\scripts" );
	SetVConfigRegistrySetting( "MAYA_SCRIPT_PATH", pMayaScriptPath, false );
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:9,代码来源:main.cpp


示例12: ToHL2MPPlayer

void CHL2MPRules::ClientSettingsChanged( CBasePlayer *pPlayer )
{
#ifndef CLIENT_DLL
	
	CHL2MP_Player *pHL2Player = ToHL2MPPlayer( pPlayer );

	if ( pHL2Player == NULL )
		return;

	const char *pCurrentModel = modelinfo->GetModelName( pPlayer->GetModel() );
	const char *szModelName = engine->GetClientConVarValue( engine->IndexOfEdict( pPlayer->edict() ), "cl_playermodel" );

	//If we're different.
	if ( stricmp( szModelName, pCurrentModel ) )
	{
		//Too soon, set the cvar back to what it was.
		//Note: this will make this function be called again
		//but since our models will match it'll just skip this whole dealio.
		if ( pHL2Player->GetNextModelChangeTime() >= gpGlobals->curtime )
		{
			char szReturnString[512];

			Q_snprintf( szReturnString, sizeof (szReturnString ), "cl_playermodel %s\n", pCurrentModel );
			engine->ClientCommand ( pHL2Player->edict(), szReturnString );

			Q_snprintf( szReturnString, sizeof( szReturnString ), "Please wait %d more seconds before trying to switch.\n", (int)(pHL2Player->GetNextModelChangeTime() - gpGlobals->curtime) );
			ClientPrint( pHL2Player, HUD_PRINTTALK, szReturnString );
			return;
		}

		if ( HL2MPRules()->IsTeamplay() == false )
		{
			pHL2Player->SetPlayerModel();

			const char *pszCurrentModelName = modelinfo->GetModelName( pHL2Player->GetModel() );

			char szReturnString[128];
			Q_snprintf( szReturnString, sizeof( szReturnString ), "Your player model is: %s\n", pszCurrentModelName );

			ClientPrint( pHL2Player, HUD_PRINTTALK, szReturnString );
		}
		else
		{
			if ( Q_stristr( szModelName, "models/human") )
			{
				pHL2Player->ChangeTeam( TEAM_REBELS );
			}
			else
			{
				pHL2Player->ChangeTeam( TEAM_COMBINE );
			}
		}
	}
	if ( sv_report_client_settings.GetInt() == 1 )
	{
		UTIL_LogPrintf( "\"%s\" cl_cmdrate = \"%s\"\n", pHL2Player->GetPlayerName(), engine->GetClientConVarValue( pHL2Player->entindex(), "cl_cmdrate" ));
	}

	BaseClass::ClientSettingsChanged( pPlayer );
#endif
	
}
开发者ID:Asunaya,项目名称:game,代码行数:62,代码来源:hl2mp_gamerules.cpp


示例13: Info_SetValueForStarKey

/* <41063> ../engine/info.c:275 */
void Info_SetValueForStarKey(char *s, const char *key, const char *value, int maxsize)
{
	char newArray[MAX_INFO_STRING];
	char *v;
	int c;

	if (!key || !value)
	{
		Con_Printf("Keys and values can't be null\n");
		return;
	}

	if (key[0] == 0)
	{
		Con_Printf("Keys can't be an empty string\n");
		return;
	}

	if (Q_strstr(key, "\\") || Q_strstr(value, "\\"))
	{
		Con_Printf("Can't use keys or values with a \\\n");
		return;
	}

	if (Q_strstr(key, "..") || Q_strstr(value, ".."))
	{
		// TODO: Why silently return?
		//Con_Printf("Can't use keys or values with a ..\n");
		return;
	}

	if (Q_strstr(key, "\"") || Q_strstr(value, "\""))
	{
		Con_Printf("Can't use keys or values with a \"\n");
		return;
	}

	int keyLen = Q_strlen(key);
	int valueLan = Q_strlen(value);

	if (keyLen >= MAX_KV_LEN || valueLan >= MAX_KV_LEN)
	{
		Con_Printf("Keys and values must be < %i characters\n", MAX_KV_LEN);
		return;
	}

	if (!Q_UnicodeValidate(key) || !Q_UnicodeValidate(value))
	{
		Con_Printf("Keys and values must be valid utf8 text\n");
		return;
	}

	// Remove current key/value and return if we doesn't specified to set a value
	Info_RemoveKey(s, key);
	if (value[0] == 0)
	{
		return;
	}

	// Create key/value pair
	Q_snprintf(newArray, MAX_INFO_STRING - 1, "\\%s\\%s", key, value);
	newArray[MAX_INFO_STRING - 1] = 0;

	int neededLength = Q_strlen(newArray);
	if ((int)Q_strlen(s) + neededLength >= maxsize)
	{
		// no more room in the buffer to add key/value
		if (!Info_IsKeyImportant(key))
		{
			// no room to add setting
			Con_Printf("Info string length exceeded\n");
			return;
		}

		// keep removing the largest key/values until we have a room
		char *largekey;
		do
		{
			largekey = Info_FindLargestKey(s, maxsize);
			if (largekey[0] == 0)
			{
				// no room to add setting
				Con_Printf("Info string length exceeded\n");
				return;
			}
			Info_RemoveKey(s, largekey);
		} while ((int)Q_strlen(s) + neededLength >= maxsize);
	}

	// auto lowercase team
	bool lowerCaseValue = Q_stricmp(key, "team") == 0;
	s += Q_strlen(s);
	v = newArray;
	while (*v)
	{
		c = (unsigned char)*v++;
		if (lowerCaseValue)
		{
			c = tolower(c);
//.........这里部分代码省略.........
开发者ID:ChunHungLiu,项目名称:rehlds,代码行数:101,代码来源:info.cpp


示例14: Q_snprintf

void EntityOutputManager::FireEventDetour(void *pOutput, CBaseEntity *pActivator, CBaseEntity *pCaller, float fDelay)
{
	if (!pCaller)
	{
		return;
	}

	char sOutput[20];
	Q_snprintf(sOutput, sizeof(sOutput), "%p", pOutput);

	// attempt to directly lookup a hook using the pOutput pointer
	OutputNameStruct *pOutputName = NULL;

	bool fastLookup = false;
	
	// Fast lookup failed - check the slow way for hooks that haven't fired yet
	if ((fastLookup = EntityOutputs->Retrieve(sOutput, (void **)&pOutputName)) == false)
	{
		const char *classname = GetEntityClassname(pCaller);
		const char *outputname = FindOutputName(pOutput, pCaller);
		
		if (!outputname)
		{
			return;
		}

		pOutputName = FindOutputPointer(classname, outputname, false);

		if (!pOutputName)
		{
			return;
		}
	}

	if (!pOutputName->hooks.empty())
	{
		if (!fastLookup)
		{
			// hook exists on this classname and output - map it into our quick find trie
			EntityOutputs->Insert(sOutput, pOutputName);
		}

		SourceHook::List<omg_hooks *>::iterator _iter;

		omg_hooks *hook;

		_iter = pOutputName->hooks.begin();

		while (_iter != pOutputName->hooks.end())
		{
			hook = (omg_hooks *)*_iter;

			hook->in_use = true;

			cell_t ref = gamehelpers->EntityToReference(pCaller);
			
			if (hook->entity_ref != -1 
					&& gamehelpers->ReferenceToIndex(hook->entity_ref) == gamehelpers->ReferenceToIndex(ref)
					&& ref != hook->entity_ref)
			{
				// same entity index but different reference. Entity has changed, kill the hook.
				_iter = pOutputName->hooks.erase(_iter);
				CleanUpHook(hook);

				continue;
			}

			if (hook->entity_ref == -1 || hook->entity_ref == ref) // Global classname hook
			{
				//fire the forward to hook->pf
				hook->pf->PushString(pOutputName->Name);
				hook->pf->PushCell(gamehelpers->ReferenceToBCompatRef(ref));
				hook->pf->PushCell(gamehelpers->EntityToBCompatRef(pActivator));

				//hook->pf->PushCell(handle);
				hook->pf->PushFloat(fDelay);
				hook->pf->Execute(NULL);

				if ((hook->entity_ref != -1) && hook->only_once)
				{
					_iter = pOutputName->hooks.erase(_iter);
					CleanUpHook(hook);

					continue;
				}

				if (hook->delete_me)
				{
					_iter = pOutputName->hooks.erase(_iter);
					CleanUpHook(hook);
					continue;
				}
			}

			hook->in_use = false;
			_iter++;
		}
	}
}
开发者ID:dvarnai,项目名称:simillimum,代码行数:99,代码来源:output.cpp


示例15: R_ParseDetailTextures

void R_ParseDetailTextures( const char *filename )
{
	char	*afile, *pfile;
	string	token, texname;
	string	detail_texname;
	string	detail_path;
	float	xScale, yScale;
	texture_t	*tex;
	int	i;

	if( r_detailtextures->integer >= 2 && !FS_FileExists( filename, false ))
	{
		// use built-in generator for detail textures
		R_CreateDetailTexturesList( filename );
	}

	afile = (char *)FS_LoadFile( filename, NULL, false );
	if( !afile ) return;

	pfile = afile;

	// format: 'texturename' 'detailtexture' 'xScale' 'yScale'
	while(( pfile = COM_ParseFile( pfile, token )) != NULL )
	{
		texname[0] = '\0';
		detail_texname[0] = '\0';

		// read texname
		if( token[0] == '{' )
		{
			// NOTE: COM_ParseFile handled some symbols seperately
			// this code will be fix it
			pfile = COM_ParseFile( pfile, token );
			Q_strncat( texname, "{", sizeof( texname ));
			Q_strncat( texname, token, sizeof( texname ));
		}
		else Q_strncpy( texname, token, sizeof( texname ));

		// read detailtexture name
		pfile = COM_ParseFile( pfile, token );
		Q_strncat( detail_texname, token, sizeof( detail_texname ));

		// trying the scales or '{'
		pfile = COM_ParseFile( pfile, token );

		// read second part of detailtexture name
		if( token[0] == '{' )
		{
			Q_strncat( detail_texname, token, sizeof( detail_texname ));
			pfile = COM_ParseFile( pfile, token ); // read scales
			Q_strncat( detail_texname, token, sizeof( detail_texname ));
			pfile = COM_ParseFile( pfile, token ); // parse scales
		}

		Q_snprintf( detail_path, sizeof( detail_path ), "gfx/%s", detail_texname );

		// read scales
		xScale = Q_atof( token );		

		pfile = COM_ParseFile( pfile, token );
		yScale = Q_atof( token );

		if( xScale <= 0.0f || yScale <= 0.0f )
			continue;

		// search for existing texture and uploading detail texture
		for( i = 0; i < cl.worldmodel->numtextures; i++ )
		{
			tex = cl.worldmodel->textures[i];

			if( Q_stricmp( tex->name, texname ))
				continue;

			tex->dt_texturenum = GL_LoadTexture( detail_path, NULL, 0, TF_FORCE_COLOR, NULL );

			// texture is loaded
			if( tex->dt_texturenum )
			{
				gltexture_t	*glt;

				GL_SetTextureType( tex->dt_texturenum, TEX_DETAIL );
				glt = R_GetTexture( tex->gl_texturenum );
				glt->xscale = xScale;
				glt->yscale = yScale;
			}
			break;
		}
	}

	Mem_Free( afile );
}
开发者ID:THE-Swank,项目名称:xash3d,代码行数:91,代码来源:gl_rmisc.c


示例16: LoadSrcVTFFiles

//-----------------------------------------------------------------------------
// Loads VTF files
//-----------------------------------------------------------------------------
static bool LoadSrcVTFFiles( IVTFTexture *pSrcVTFTextures[6], const char *pSkyboxMaterialBaseName,
							int *pUnionTextureFlags, bool bHDR )
{
	const char *facingName[6] = { "rt", "lf", "bk", "ft", "up", "dn" };
	int i;
	for( i = 0; i < 6; i++ )
	{
		char srcMaterialName[1024];
		sprintf( srcMaterialName, "%s%s", pSkyboxMaterialBaseName, facingName[i] );

		IMaterial *pSkyboxMaterial = g_pMaterialSystem->FindMaterial( srcMaterialName, "skybox" );
		//IMaterialVar *pSkyTextureVar = pSkyboxMaterial->FindVar( bHDR ? "$hdrbasetexture" : "$basetexture", NULL ); //, bHDR ? false : true );
		IMaterialVar *pSkyTextureVar = pSkyboxMaterial->FindVar( "$basetexture", NULL ); // Since we're setting it to black anyway, just use $basetexture for HDR
		const char *vtfName = pSkyTextureVar->GetStringValue();
		char srcVTFFileName[MAX_PATH];
		Q_snprintf( srcVTFFileName, MAX_PATH, "materials/%s.vtf", vtfName );

		CUtlBuffer buf;
		if ( !g_pFullFileSystem->ReadFile( srcVTFFileName, NULL, buf ) )
		{
			// Try looking for a compressed HDR texture
			if ( bHDR )
			{
				/* // FIXME: We need a way to uncompress this format!
				bool bHDRCompressed = true;

				pSkyTextureVar = pSkyboxMaterial->FindVar( "$hdrcompressedTexture", NULL );
				vtfName = pSkyTextureVar->GetStringValue();
				Q_snprintf( srcVTFFileName, MAX_PATH, "materials/%s.vtf", vtfName );

				if ( !g_pFullFileSystem->ReadFile( srcVTFFileName, NULL, buf ) )
				*/
				{
					return false;
				}
			}
			else
			{
				return false;
			}
		}

		pSrcVTFTextures[i] = CreateVTFTexture();
		if (!pSrcVTFTextures[i]->Unserialize(buf))
		{
			Warning("*** Error unserializing skybox texture: %s\n", pSkyboxMaterialBaseName );
			return false;
		}

		*pUnionTextureFlags |= pSrcVTFTextures[i]->Flags();
		int flagsNoAlpha = pSrcVTFTextures[i]->Flags() & ~( TEXTUREFLAGS_EIGHTBITALPHA | TEXTUREFLAGS_ONEBITALPHA );
		int flagsFirstNoAlpha = pSrcVTFTextures[0]->Flags() & ~( TEXTUREFLAGS_EIGHTBITALPHA | TEXTUREFLAGS_ONEBITALPHA );
		
		// NOTE: texture[0] is a side texture that could be 1/2 height, so allow this and also allow 4x4 faces
		if ( ( ( pSrcVTFTextures[i]->Width() != pSrcVTFTextures[0]->Width() ) && ( pSrcVTFTextures[i]->Width() != 4 ) ) ||
			 ( ( pSrcVTFTextures[i]->Height() != pSrcVTFTextures[0]->Height() ) && ( pSrcVTFTextures[i]->Height() != pSrcVTFTextures[0]->Height()*2 )  && ( pSrcVTFTextures[i]->Height() != 4 ) ) ||
			 ( flagsNoAlpha != flagsFirstNoAlpha ) )
		{
			Warning("*** Error: Skybox vtf files for %s weren't compiled with the same size texture and/or same flags!\n", pSkyboxMaterialBaseName );
			return false;
		}

		if ( bHDR )
		{
			pSrcVTFTextures[i]->ConvertImageFormat( IMAGE_FORMAT_RGB323232F, false );
			pSrcVTFTextures[i]->GenerateMipmaps();
			pSrcVTFTextures[i]->ConvertImageFormat( IMAGE_FORMAT_RGBA16161616F, false );
		}
	}

	return true;
}
开发者ID:Baer42,项目名称:source-sdk-2013,代码行数:75,代码来源:cubemap.cpp

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ Q_snprintfz函数代码示例发布时间:2022-05-30
下一篇:
C++ Q_rint函数代码示例发布时间: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