Beispiel #1
0
void CAntiCheatManager::DataDownloaded(CDownloadableResourcePtr inResource)
{
	const int bufferSize = 1024*1024;
	char* pBuffer = new char[bufferSize];
	int dataLength = bufferSize;

	inResource->GetDecryptedData(pBuffer,&dataLength,DECRYPTION_KEY,int(sizeof(DECRYPTION_KEY)-1),SIGNING_SALT,int(sizeof(SIGNING_SALT)-1));

	if (dataLength > 0)
	{
		XmlNodeRef xmlData = gEnv->pSystem->LoadXmlFromBuffer(pBuffer, dataLength);
		if (xmlData)
		{
			CryLog("Parsing downloaded Anti-Cheat Configuration...");
			ParseAntiCheatConfig(xmlData);
		}
		else
		{
			CryLog("Unable to parse downloaded Anti-Cheat Configuration");
		}
	}
	else
	{
		CryLog("Error decrypting Anti-Cheat Configuration");
	}
}
void CDataPatchDownloader::DataDownloaded(
	CDownloadableResourcePtr		inResource)
{
	const int bufferSize = 1024*1024;
	char* pBuffer = new char[bufferSize];
	if (pBuffer)
	{
		int dataLength = bufferSize;

		inResource->GetDecryptedData(pBuffer,&dataLength,DECRYPTION_KEY,int(sizeof(DECRYPTION_KEY)-1),SIGNING_SALT,int(sizeof(SIGNING_SALT)-1));

		if (dataLength > 0)
		{
			IXmlParser		*pParser=GetISystem()->GetXmlUtils()->CreateXmlParser();

			m_patchCRC=CCrc32::Compute(pBuffer,dataLength);
			m_patchXML=pParser->ParseBuffer(pBuffer,dataLength,false);
			if (!m_patchXML)
			{
				m_patchCRC = 0;
				CryLog("Failed to parse game data patch xml");
			}
			else
			{
				m_patchXML->getAttr("patchid",m_patchId);
				int matchmakingVersion = 0;
				if (m_patchXML->getAttr("matchmakingversion",matchmakingVersion))
				{
					if (matchmakingVersion != g_pGameCVars->g_MatchmakingVersion)
					{
						// Unload the patch XML, because it doesn't match the matchmaking version
						CryLog("Game data patch matchmaking version (%d) does not match this build's matchmaking version (%d)", matchmakingVersion, g_pGameCVars->g_MatchmakingVersion);
						m_patchCRC = 0;
						m_patchId = 0;
						m_patchXML = NULL;
					}
				}
			}

			pParser->Release();
		}

		delete [] pBuffer;
	}

	// if it downloads the patch is marked as available, regardless of whether it parsed / passed checks
	// if it fails parsing or checks, it will end up with a CRC of 0 and so cause the game to follow paths
	// of not having a patch
	if (m_pListener)
	{
		m_pListener->DataPatchAvailable();
	}
}