예제 #1
0
void CAntiCheatManager::ParseAntiCheatConfig(const char * filename)
{
	CCryFile file;

	CryFixedStringT<128> realFileName;
	realFileName.Format("%s/%s", PathUtil::GetGameFolder().c_str(), filename);
	if (file.Open( realFileName.c_str(), "rb", ICryPak::FOPEN_HINT_QUIET | ICryPak::FOPEN_ONDISK ))
	{
		const size_t fileSize = file.GetLength();
		char* pBuffer = new char [fileSize];

		file.ReadRaw(pBuffer, fileSize);

		XmlNodeRef xmlData = gEnv->pSystem->LoadXmlFromBuffer(pBuffer, fileSize);

		SAFE_DELETE_ARRAY(pBuffer);

		if(xmlData)
		{
			CryLog("Parsing Anti-Cheat Configuration...");
			ParseAntiCheatConfig(xmlData);
		}
		else
		{
			CryLog("Unable to parse Anti-Cheat Configuration");
		}
	}
	else
	{
		CryLog("Unable to load '%s'", realFileName.c_str());
	}
}
예제 #2
0
string CLuaRemoteDebug::GetLineFromFile( const char *sFilename,int nLine )
{
	CCryFile file;

	if (!file.Open(sFilename,"rb"))
	{
		return "";
	}
	int nLen = file.GetLength();
	char *sScript = new char [nLen + 1];
	char *sString = new char [nLen + 1];
	file.ReadRaw( sScript,nLen );
	sScript[nLen] = '\0';

	int nCurLine = 1;
	string strLine;

	strcpy( sString,"" );

	const char *strLast = sScript+nLen;

	const char *str = sScript;
	while (str < strLast)
	{
		char *s = sString;
		while (str < strLast && *str != '\n' && *str != '\r')
		{
			*s++ = *str++;
		}
		*s = '\0';
		if (str + 2 <= strLast && str[0] == '\r' && str[1] == '\n')
		{
			// Skip \r\n (Windows style line endings)
			str += 2;
		}
		else
		{
			// Skip \n or \r (Unix/Mac style line endings)
			str += 1;
		}

		if (nCurLine == nLine)
		{
			strLine = sString;
			strLine.replace( '\t',' ' );
			strLine.Trim();
			break;
		}
		nCurLine++;
	}

	delete []sString;
	delete []sScript;

	return strLine;
}