void CAntiCheatManager::CheatLogInternalXml(XmlNodeRef xmlNode) { char sTime[128]; time_t ltime; time( <ime ); struct tm *today = localtime( <ime ); strftime( sTime, 20, "%H:%M:%S", today ); xmlNode->setAttr("time", sTime); const int64 time = gEnv->pTimer->GetFrameStartTime(ITimer::ETIMER_UI).GetMilliSecondsAsInt64(); xmlNode->setAttr("game_time", time); // Print to the console and normal game log IXmlStringData * pXMLStringData = xmlNode->getXMLData(); CryLog("AntiCheatManager: %s", pXMLStringData->GetString()); // But also log to AntiCheatLog.xml which will be uploaded via telemetry if (m_pLogFile) { gEnv->pCryPak->FWrite(pXMLStringData->GetString(), 1, pXMLStringData->GetStringLength(), m_pLogFile); } pXMLStringData->Release(); }
void CGameTokenSystem::Serialize( TSerialize ser ) { // when writing game tokens we store the per-level tokens (Level.xxx) in a group // with the real level name TFlowInputData data; std::vector<CGameToken*> levelTokens; static const char* levelPrefix = "Level."; static const size_t prefixLength = 6; assert(strlen(levelPrefix) == prefixLength); const bool bSaving = ser.IsWriting(); if (bSaving) { // Saving. if (m_levelToLevelSave) { IXmlStringData* xmlData = m_levelToLevelSave->getXMLData(5000); string strXMLData( xmlData->GetString() ); ser.Value("LTLGameTokensData", strXMLData); xmlData->Release(); } int nTokens = 0; ser.BeginGroup("GlobalTokens"); if (!m_pGameTokensMap->empty()) { GameTokensMap::iterator iter = m_pGameTokensMap->begin(); GameTokensMap::iterator iterEnd = m_pGameTokensMap->end(); while (iter != iterEnd) { CGameToken *pToken = iter->second; if (0 == strncmp(levelPrefix, pToken->m_name.c_str(), prefixLength)) { levelTokens.push_back(pToken); } else { nTokens++; ser.BeginGroup("Token"); ser.Value( "name",pToken->m_name ); ser.Value( "flags", pToken->m_nFlags ); pToken->m_value.Serialize(ser); ser.EndGroup(); } ++iter; } } ser.Value( "count",nTokens ); ser.EndGroup(); nTokens = (int)levelTokens.size(); ser.BeginGroup( "LevelTokens" ); ser.Value( "count",nTokens ); if (!levelTokens.empty()) { std::vector<CGameToken*>::iterator iter = levelTokens.begin(); std::vector<CGameToken*>::iterator iterEnd = levelTokens.end(); while (iter != iterEnd) { CGameToken *pToken = *iter; { ser.BeginGroup("Token"); ser.Value( "name",pToken->m_name ); ser.Value( "flags", pToken->m_nFlags ); pToken->m_value.Serialize(ser); ser.EndGroup(); } ++iter; } } ser.EndGroup(); } else { #ifdef _GAMETOKENSDEBUGINFO ClearDebugHistory(); #endif // Loading. { string strXMLData; ser.Value("LTLGameTokensData", strXMLData); m_levelToLevelSave = gEnv->pSystem->LoadXmlFromBuffer(strXMLData.c_str(), strXMLData.length()); } for (int pass = 0; pass < 2; pass++) { if (pass == 0) ser.BeginGroup("GlobalTokens"); else ser.BeginGroup("LevelTokens"); string tokenName; int nTokens = 0; ser.Value( "count",nTokens ); uint32 flags = 0; for (int i = 0; i < nTokens; i++) { ser.BeginGroup("Token"); ser.Value( "name",tokenName ); ser.Value( "flags", flags ); data.Serialize(ser); CGameToken *pToken = (CGameToken*)FindToken(tokenName); if (pToken) { pToken->m_value = data; pToken->m_nFlags = flags; } else { // Create token. pToken = (CGameToken*)SetOrCreateToken( tokenName,data ); pToken->m_nFlags = flags; } ser.EndGroup(); } ser.EndGroup(); } } }