コード例 #1
0
void GenerateUniquePlayerId(CSteamAPIContext *pSteamAPIContext)
{
	CSHA1 sha1;

	// Add the steam name
	char szSteamId[256] = "\0";
	CSteamID steamid = pSteamAPIContext->SteamUser()->GetSteamID();
	V_sprintf_safe(szSteamId, "%u%u%u%u", steamid.GetEUniverse(), steamid.GetEAccountType(), steamid.GetAccountID(), steamid.GetUnAccountInstance());
	sha1.Update((unsigned char *)szSteamId, strlen(szSteamId));
	
	// Add some random numbers
	char randomNumbers[256] = "\0";
	Q_snprintf(randomNumbers, sizeof(randomNumbers), "%i%i%i%i%i%i",
		RandomInt(0, 1000), RandomInt(0, 1000), RandomInt(0, 1000), RandomInt(0, 1000), RandomInt(0, 1000), RandomInt(0, 1000));
	sha1.Update((unsigned char *)randomNumbers, strlen(randomNumbers));

	// Generate the hash
	sha1.Final();

	// Compile SHA1 Report
	char szReport[1024] = "\0";
	sha1.ReportHash(szReport);

	// Remove the spaces and make it lowercase
	char playerId[1024] = "\0";
	Q_StrSubst(szReport, " ", "", playerId, sizeof(playerId));
	Q_strlower(playerId);

	DevMsg("Generated unique player ID: %s\n", playerId);
	ae_uniqueplayerid.SetValue(playerId);
}
コード例 #2
0
ファイル: MapLayout.cpp プロジェクト: Au-heppa/swarm-sdk
void CInstanceSpawn::FixupValues( const char *pFindValue, const char *pReplaceValue )
{
	for ( int i = 0; i < m_AdditionalKeyValues.Count(); ++ i )
	{
		if ( Q_stristr( m_AdditionalKeyValues[i].m_Value, pFindValue ) != NULL )
		{
			char outputString[MAX_TILEGEN_IDENTIFIER_LENGTH];
			Q_StrSubst( m_AdditionalKeyValues[i].m_Value, pFindValue, pReplaceValue, outputString, MAX_TILEGEN_IDENTIFIER_LENGTH );
			Q_strncpy( m_AdditionalKeyValues[i].m_Value, outputString, MAX_TILEGEN_IDENTIFIER_LENGTH );
		}
	}
}
コード例 #3
0
ファイル: bot_util.cpp プロジェクト: BSVino/Arcon
//--------------------------------------------------------------------------------------------------------------
// Takes the bot pointer and constructs the net name using the current bot name prefix.
void UTIL_ConstructBotNetName( char *name, int nameLength, const BotProfile *profile )
{
	if (profile == NULL)
	{
		name[0] = 0;
		return;
	}

	// if there is no bot prefix just use the profile name.
	if ((cv_bot_prefix.GetString() == NULL) || (strlen(cv_bot_prefix.GetString()) == 0))
	{
		Q_strncpy( name, profile->GetName(), nameLength );
		return;
	}

	// find the highest difficulty
	const char *diffStr = BotDifficultyName[0];
	for ( int i=BOT_EXPERT; i>0; --i )
	{
		if ( profile->IsDifficulty( (BotDifficultyType)i ) )
		{
			diffStr = BotDifficultyName[i];
			break;
		}
	}

	const char *weaponStr = NULL;
	if ( profile->GetWeaponPreferenceCount() )
	{
		weaponStr = profile->GetWeaponPreferenceAsString( 0 );

		const char *translatedAlias = GetTranslatedWeaponAlias( weaponStr );

		char wpnName[128];
		Q_snprintf( wpnName, sizeof( wpnName ), "weapon_%s", translatedAlias );
		WEAPON_FILE_INFO_HANDLE	hWpnInfo = LookupWeaponInfoSlot( wpnName );
		if ( hWpnInfo != GetInvalidWeaponInfoHandle() )
		{
			CCFWeaponInfo *pWeaponInfo = dynamic_cast< CCFWeaponInfo* >( GetFileWeaponInfoFromHandle( hWpnInfo ) );
			if ( pWeaponInfo )
			{
				weapontype_t weaponType = pWeaponInfo->m_eWeaponType;
				weaponStr = CCFWeaponInfo::WeaponTypeToString( weaponType );
			}
		}
	}
	if ( !weaponStr )
	{
		weaponStr = "";
	}

	char skillStr[16];
	Q_snprintf( skillStr, sizeof( skillStr ), "%.0f", profile->GetSkill()*100 );

	char temp[MAX_PLAYER_NAME_LENGTH*2];
	char prefix[MAX_PLAYER_NAME_LENGTH*2];
	Q_strncpy( temp, cv_bot_prefix.GetString(), sizeof( temp ) );
	Q_StrSubst( temp, "<difficulty>", diffStr, prefix, sizeof( prefix ) );
	Q_StrSubst( prefix, "<weaponclass>", weaponStr, temp, sizeof( temp ) );
	Q_StrSubst( temp, "<skill>", skillStr, prefix, sizeof( prefix ) );
	Q_snprintf( name, nameLength, "%s %s", prefix, profile->GetName() );
}
コード例 #4
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pszName - 
//			piIndex - 
//			bDummy - 
// Output : 
//-----------------------------------------------------------------------------
IEditorTexture *CTextureSystem::FindActiveTexture(LPCSTR pszInputName, int *piIndex, BOOL bDummy)
{

	// The .vmf file format gets confused if there are backslashes in material names,
	// so make sure they're all using forward slashes here.
	char szName[MAX_PATH];
	Q_StrSubst( pszInputName, "\\", "/", szName, sizeof( szName ) );
	const char *pszName = szName;
	IEditorTexture *pTex = NULL;
	//
	// Check the cache first.
	//
	if (m_pLastTex && !stricmp(pszName, m_pLastTex->GetName()))
	{
		if (piIndex)
		{
			*piIndex = m_nLastIndex;
		}

		return m_pLastTex;
	}

	int iIndex = 0;

	// We're finding by name, so we don't care what the format is as long as the name matches.
	if ( m_pActiveGroup )
	{
		pTex = m_pActiveGroup->FindTextureByName( pszName, &iIndex, tfNone );
		if ( pTex )
		{
			if ( piIndex )
				*piIndex = iIndex;
			
			m_pLastTex = pTex;
			m_nLastIndex = iIndex;
			
			return pTex;
		}
	}

	//
	// Let's try again, this time with \textures\ decoration
	// TODO: remove this?
	//
	{
		iIndex = 0;
		char szBuf[512];

		sprintf(szBuf, "textures\\%s", pszName);

		for (int i = strlen(szBuf) -1; i >= 0; i--)
		{
			if (szBuf[i] == '/')
				szBuf[i] = '\\';
		}

		strlwr(szBuf);

		if ( m_pActiveGroup )
		{
			pTex = m_pActiveGroup->FindTextureByName( szBuf, &iIndex, tfNone );
			if ( pTex )
			{
				if ( piIndex )
					*piIndex = iIndex;
				
				m_pLastTex = pTex;
				m_nLastIndex = iIndex;
				
				return pTex;
			}
		}
	}
	//
	// Caller doesn't want dummies.
	//
	if (!bDummy)
	{
		return(NULL);
	}

	Assert(!piIndex);

	//
	// Check the list of dummies for a texture with the same name and texture format.
	//
	if (m_pActiveContext)
	{
		int nDummyCount = m_pActiveContext->Dummies.Count();
		for (int nDummy = 0; nDummy < nDummyCount; nDummy++)
		{
			IEditorTexture *pTex = m_pActiveContext->Dummies.Element(nDummy);
			if (!strcmpi(pszName, pTex->GetName()))
			{
				m_pLastTex = pTex;
				m_nLastIndex = -1;
				return(pTex);
			}
		}

		//
		// Not found; add a dummy as a placeholder for the missing texture.
		//
		pTex = AddDummy(pszName, g_pGameConfig->GetTextureFormat());
	}

	if (pTex != NULL)
	{
		m_pLastTex = pTex;
		m_nLastIndex = -1;
	}

	return(pTex);
}