void Resolver::Log() { for (int i = 1; i <= g_GlobalVars->maxClients; i++) { auto &record = arr_infos[i]; C_BasePlayer *player = C_BasePlayer::GetPlayerByIndex(i); if (!player || !player->IsAlive() || player->m_iTeamNum() == g_LocalPlayer->m_iTeamNum()) { record.m_bActive = false; continue; } if (player->IsDormant()) continue; if(record.m_flSimulationTime == player->m_flSimulationTime()) continue; record.SaveRecord(player); record.m_bActive = true; } }
void CSDKMapOverview::UpdatePlayers() { C_SDK_PlayerResource *pSDKPR = (C_SDK_PlayerResource*)GameResources(); if ( !pSDKPR ) return; CBasePlayer *localPlayer = C_BasePlayer::GetLocalPlayer(); if( localPlayer == NULL ) return; MapPlayer_t *localMapPlayer = GetPlayerByUserID(localPlayer->GetUserID()); if( localMapPlayer == NULL ) return; for ( int i = 1; i<= gpGlobals->maxClients; i++) { MapPlayer_t *player = &m_Players[i-1]; SDKMapPlayer_t *playerSDK = GetSDKInfoForPlayerIndex(i-1); if ( !playerSDK ) continue; // update from global player resources if ( pSDKPR->IsConnected(i) ) { player->health = pSDKPR->GetHealth( i ); if ( !pSDKPR->IsAlive( i ) ) { // Safety actually happens after a TKPunish. player->health = 0; playerSDK->isDead = true; } if ( player->team != pSDKPR->GetTeam( i ) ) { player->team = pSDKPR->GetTeam( i ); if( player == localMapPlayer ) player->icon = m_TeamIconsSelf[ GetIconNumberFromTeamNumber(player->team) ]; else player->icon = m_TeamIcons[ GetIconNumberFromTeamNumber(player->team) ]; player->color = m_TeamColors[ GetIconNumberFromTeamNumber(player->team) ]; } } Vector position = player->position; QAngle angles = player->angle; C_BasePlayer *pPlayer = UTIL_PlayerByIndex( i ); if ( pPlayer && !pPlayer->IsDormant() ) { // update position of active players in our PVS position = pPlayer->EyePosition(); angles = pPlayer->EyeAngles(); SetPlayerPositions( i-1, position, angles ); } } }
void Resolver::Resolve() { for (int i = 1; i <= g_GlobalVars->maxClients; i++) { auto &record = arr_infos[i]; if (!record.m_bActive) continue; C_BasePlayer *player = C_BasePlayer::GetPlayerByIndex(i); if (!player || !player->IsAlive() || player->IsDormant() || player == g_LocalPlayer) continue; if (record.m_flVelocity == 0.f && player->m_vecVelocity().Length2D() != 0.f) { Math::VectorAngles(player->m_vecVelocity(), record.m_angDirectionFirstMoving); record.m_nCorrectedFakewalkIdx = 0; } auto firedShots = g_LocalPlayer->m_iShotsFired(); if (g_Options.debug_fliponkey) { float_t new_yaw = player->m_flLowerBodyYawTarget(); if (g_InputSystem->IsButtonDown(g_Options.debug_flipkey)) new_yaw += 180.f; new_yaw = Math::ClampYaw(new_yaw); player->m_angEyeAngles().yaw = new_yaw; return; } if (g_Options.hvh_resolver_override && g_InputSystem->IsButtonDown(g_Options.hvh_resolver_override_key)) { Override(); //needs an improvement sometimes f****d up xD Global::resolverModes[player->EntIndex()] = "Overriding"; return; } AnimationLayer curBalanceLayer, prevBalanceLayer; ResolveInfo curtickrecord; curtickrecord.SaveRecord(player); if ((player->m_fFlags() & FL_ONGROUND) && (IsFakewalking(player, curtickrecord) || (player->m_vecVelocity().Length2D() > 0.1f && player->m_vecVelocity().Length2D() < 45.f && !(player->m_fFlags() & FL_DUCKING)))) //Fakewalk, shiftwalk check // We have to rework the fakewalk resolving, it sucks :D { float_t new_yaw = ResolveFakewalk(player, curtickrecord); new_yaw = Math::ClampYaw(new_yaw); player->m_angEyeAngles().yaw = new_yaw; Global::resolverModes[player->EntIndex()] = "Fakewalking"; continue; } if (IsEntityMoving(player)) { float_t new_yaw = player->m_flLowerBodyYawTarget(); new_yaw = Math::ClampYaw(new_yaw); player->m_angEyeAngles().yaw = new_yaw; record.m_flStandingTime = player->m_flSimulationTime(); record.m_flMovingLBY = player->m_flLowerBodyYawTarget(); record.m_bIsMoving = true; Global::resolverModes[player->EntIndex()] = "Moving"; continue; } if (IsAdjustingBalance(player, curtickrecord, &curBalanceLayer)) { if (fabsf(LBYDelta(curtickrecord)) > 35.f) { float_t new_yaw = player->m_flLowerBodyYawTarget() + record.m_flLbyDelta; new_yaw = Math::ClampYaw(new_yaw); player->m_angEyeAngles().yaw = new_yaw; Global::resolverModes[player->EntIndex()] = "Fakehead (delta > 35)"; } if (IsAdjustingBalance(player, record, &prevBalanceLayer)) { if ((prevBalanceLayer.m_flCycle != curBalanceLayer.m_flCycle) || curBalanceLayer.m_flWeight == 1.f) { float flAnimTime = curBalanceLayer.m_flCycle, flSimTime = player->m_flSimulationTime(); if (flAnimTime < 0.01f && prevBalanceLayer.m_flCycle > 0.01f && g_Options.rage_lagcompensation && CMBacktracking::Get().IsTickValid(TIME_TO_TICKS(flSimTime - flAnimTime))) { CMBacktracking::Get().SetOverwriteTick(player, QAngle(player->m_angEyeAngles().pitch, player->m_flLowerBodyYawTarget(), 0), (flSimTime - flAnimTime), 2); } float_t new_yaw = player->m_flLowerBodyYawTarget(); new_yaw = Math::ClampYaw(new_yaw); player->m_angEyeAngles().yaw = new_yaw; Global::resolverModes[player->EntIndex()] = "Breaking LBY"; continue; } else if (curBalanceLayer.m_flWeight == 0.f && (prevBalanceLayer.m_flCycle > 0.92f && curBalanceLayer.m_flCycle > 0.92f)) // breaking lby with delta < 120 { if (player->m_flSimulationTime() >= record.m_flStandingTime + 0.22f && record.m_bIsMoving) { record.m_flLbyDelta = record.m_flLowerBodyYawTarget - player->m_flLowerBodyYawTarget(); float_t new_yaw = player->m_flLowerBodyYawTarget() + record.m_flLbyDelta; new_yaw = Math::ClampYaw(new_yaw); player->m_angEyeAngles().yaw = new_yaw; record.m_bIsMoving = false; Global::resolverModes[player->EntIndex()] = "Breaking LBY (delta < 120)"; continue; } if (player->m_flSimulationTime() >= record.m_flStandingTime + 1.32f && std::fabsf(record.m_flLbyDelta) < 35.f) { record.m_flLbyDelta = record.m_flMovingLBY - player->m_flLowerBodyYawTarget(); float_t new_yaw = player->m_flLowerBodyYawTarget() + record.m_flLbyDelta; new_yaw = Math::ClampYaw(new_yaw); player->m_angEyeAngles().yaw = new_yaw; record.m_bIsMoving = false; Global::resolverModes[player->EntIndex()] = "LBY delta < 35"; continue; } } } else { float_t new_yaw = player->m_flLowerBodyYawTarget(); new_yaw = Math::ClampYaw(new_yaw); player->m_angEyeAngles().yaw = new_yaw; Global::resolverModes[player->EntIndex()] = "Other"; continue; } } if (player->m_flSimulationTime() >= record.m_flStandingTime + 0.22f && record.m_bIsMoving) { record.m_flLbyDelta = record.m_flLowerBodyYawTarget - player->m_flLowerBodyYawTarget(); float_t new_yaw = player->m_flLowerBodyYawTarget() + record.m_flLbyDelta; new_yaw = Math::ClampYaw(new_yaw); player->m_angEyeAngles().yaw = new_yaw; record.m_bIsMoving = false; Global::resolverModes[player->EntIndex()] = "Breaking LBY (delta < 120)"; continue; } if (player->m_flSimulationTime() >= record.m_flStandingTime + 1.32f && std::fabsf(record.m_flLbyDelta) < 35.f) { record.m_flLbyDelta = record.m_flMovingLBY - player->m_flLowerBodyYawTarget(); float_t new_yaw = player->m_flLowerBodyYawTarget() + record.m_flLbyDelta; new_yaw = Math::ClampYaw(new_yaw); player->m_angEyeAngles().yaw = new_yaw; record.m_bIsMoving = false; Global::resolverModes[player->EntIndex()] = "LBY delta < 35"; continue; } float_t new_yaw = player->m_flLowerBodyYawTarget() + record.m_flLbyDelta; new_yaw = Math::ClampYaw(new_yaw); player->m_angEyeAngles().yaw = new_yaw; } }