void CAntiCheatManager::OnClientDisconnect(INetChannel& rNetChannel, IActor * pActor) { uint16 channelId = rNetChannel.GetLocalChannelID(); TPlayerSessionDataMap::iterator existingData = m_PlayerSessionData.find(channelId); if(existingData != m_PlayerSessionData.end()) { existingData->second.disconnectTime = gEnv->pTimer->GetFrameStartTime(ITimer::ETIMER_UI); CGameRules *pGameRules = g_pGame->GetGameRules(); IGameRulesPlayerStatsModule *pPlayerStatsModule = pGameRules->GetPlayerStatsModule(); pGameRules->GetActorByChannelId(channelId); GetPlayerStats(pPlayerStatsModule, pActor->GetEntityId(), existingData->second); } }
void CAntiCheatManager::DumpPlayerRecords() { XmlNodeRef playerRecords = GetISystem()->CreateXmlNode("PlayerSessionRecords"); CGameRules *pGameRules = g_pGame->GetGameRules(); IGameRulesPlayerStatsModule *pPlayerStatsModule = pGameRules->GetPlayerStatsModule(); for (TPlayerSessionDataMap::iterator itPlayerRecord = m_PlayerSessionData.begin(); itPlayerRecord != m_PlayerSessionData.end(); ++itPlayerRecord) { XmlNodeRef playerSession = playerRecords->newChild("PlayerSession"); playerSession->setAttr("local_session_id", itPlayerRecord->first); SPlayerSessionData& rPlayerSessionData = itPlayerRecord->second; playerSession->setAttr("player_nickname", rPlayerSessionData.playerName); playerSession->setAttr("connect_game_time", rPlayerSessionData.connectTime.GetMilliSecondsAsInt64()); int64 nDisconnectTime = itPlayerRecord->second.disconnectTime.GetMilliSecondsAsInt64(); //nDisconnectTime == 0 means that it has not been set, and so the player did not disconnect and was present at round end if(nDisconnectTime != 0) { playerSession->setAttr("disconnect_game_time", nDisconnectTime); } else { if(IActor * pActor = pGameRules->GetActorByChannelId(itPlayerRecord->first)) { GetPlayerStats(pPlayerStatsModule, pActor->GetEntityId(), rPlayerSessionData); } } playerSession->setAttr("kills", rPlayerSessionData.kills); playerSession->setAttr("deaths", rPlayerSessionData.deaths); playerSession->setAttr("points", rPlayerSessionData.points); } CheatLogInternalXml(playerRecords); m_PlayerSessionData.clear(); }
void CUIObjectives::OnRequestMissionObjectives( const SUIEvent& event ) { CGameRules* pGameRules = GetGameRules(); if ( pGameRules && g_pGame->GetIGameFramework()->GetClientActor() ) { CActor* pActor = pGameRules->GetActorByChannelId( g_pGame->GetIGameFramework()->GetClientActor()->GetChannelId() ); if ( pActor ) { std::map< string, int > tmpList; int teamID = pGameRules->GetTeam( pActor->GetEntityId() ); for ( TObjectiveMap::iterator it = m_ObjectiveMap.begin(); it != m_ObjectiveMap.end(); ++it ) { CGameRules::TObjective* pObjective = pGameRules->GetObjective( teamID, it->first.c_str() ); if ( pObjective ) tmpList[ it->first ] = pObjective->status; } for ( std::map< string, int >::iterator it = tmpList.begin(); it != tmpList.end(); ++it ) MissionObjectiveAdded( it->first, it->second ); } } }
//------------------------------------------------------------------------ void CGameRulesMPDamageHandling::Update(float frameTime) { FUNCTION_PROFILER(gEnv->pSystem, PROFILE_GAME); float currentTime = gEnv->pTimer->GetCurrTime(); m_entityLastDamageUpdateTimer += frameTime; if (m_entityLastDamageUpdateTimer > EntityCollisionLatentUpdateTimer) { m_entityLastDamageUpdateTimer = 0.0f; if (!m_entityCollisionRecords.empty()) { EntityCollisionRecords::iterator it = m_entityCollisionRecords.begin(); while (it != m_entityCollisionRecords.end()) { const EntityCollisionRecord& record = it->second; if ((record.time + EntityCollisionIgnoreTimeBetweenCollisions) < currentTime) { m_entityCollisionRecords.erase(it++); } else { ++it; } } } } UpdateKickableCarRecords(frameTime, currentTime); if (gEnv->IsClient()) { #ifndef _RELEASE if (g_pGameCVars->pl_melee.mp_victim_screenfx_dbg_force_test_duration > 0.f) { m_localMeleeScreenFxTimer = (g_pGameCVars->pl_melee.mp_victim_screenfx_dbg_force_test_duration + g_pGameCVars->pl_melee.mp_victim_screenfx_blendout_duration); g_pGameCVars->pl_melee.mp_victim_screenfx_dbg_force_test_duration = 0.f; } #endif if (m_localMeleeScreenFxTimer > 0.f) { UpdateLocalMeleeScreenFx(frameTime); } } #ifdef SERVER_CHECKS //Iterate over unverified hits and see if there are any that haven't been assigned shots for X seconds const float fCurrentTime = gEnv->pTimer->GetCurrTime(); int nNumUnverifiedHits = m_unverifiedList.size(); static const float kMaxTimeUnverified = 5.0f; const float kDeleteUnverifiedBeforeThis = fCurrentTime - kMaxTimeUnverified; for(int i = 0; i < nNumUnverifiedHits; i++) { const SUnverifiedFireData &rUnverifiedData = m_unverifiedList[i]; if(kDeleteUnverifiedBeforeThis > rUnverifiedData.fTime) { CGameRules * pGameRules = g_pGame->GetGameRules(); if(pGameRules) { IActor * pActor = pGameRules->GetActorByChannelId(rUnverifiedData.uChannelId); if(pActor) { g_pGame->GetAntiCheatManager()->FlagActivity(eCT_HitShotIdMismatch, pActor->GetChannelId()); m_unverifiedList[i] = m_unverifiedList[nNumUnverifiedHits-1]; m_unverifiedList.pop_back(); nNumUnverifiedHits--; i--; } } } } static const float kMaxTimeVerifiedKept = 7.5f; const float kDeleteVerifiedBeforeThis = fCurrentTime - kMaxTimeVerifiedKept; //Iterate over shots and remove any that are too old TShotHitVerificationMap::iterator iter = m_shotHitVerificationMap.begin(); while(iter != m_shotHitVerificationMap.end()) { if(iter->second.fTime < kDeleteVerifiedBeforeThis) { TShotHitVerificationMap::iterator eraseIter = iter++; m_shotHitVerificationMap.erase(eraseIter); } else { iter++; } } #endif }