Skip to content

Commit

Permalink
code format
Browse files Browse the repository at this point in the history
  • Loading branch information
sjrc6 committed Dec 19, 2024
1 parent 53cd576 commit 4fc9a49
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
1 change: 0 additions & 1 deletion src/engine/shared/tater_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ MACRO_CONFIG_COL(ClNotifyWhenLastColor, tc_last_notify_color, 256, CFGFLAG_CLIEN
MACRO_CONFIG_INT(ClRenderCursorSpec, tc_cursor_in_spec, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Render your gun cursor when spectating in freeview")
MACRO_CONFIG_INT(ClRenderCursorSpecAlpha, tc_cursor_in_spec_alpha, 100, 0, 100, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Alpha of cursor in freeview")


MACRO_CONFIG_INT(ClRenderNameplateSpec, tc_render_nameplate_spec, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Render nameplates when spectating")

MACRO_CONFIG_INT(ClApplyProfileSkin, tc_profile_skin, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Apply skin in profiles")
Expand Down
35 changes: 17 additions & 18 deletions src/game/client/gameclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2301,7 +2301,7 @@ void CGameClient::OnPredict()
int FinalTickSelf = FinalTickRegular + g_Config.m_ClFastInput; // the final tick for just our local tee
int FinalTickOthers = FinalTickSelf; // the final tick for all other tees
if(g_Config.m_ClFastInput && !g_Config.m_ClFastInputOthers)
FinalTickOthers = FinalTickSelf - g_Config.m_ClFastInput;
FinalTickOthers = FinalTickSelf - g_Config.m_ClFastInput;

for(int Tick = Client()->GameTick(g_Config.m_ClDummy) + 1; Tick <= FinalTickSelf; Tick++)
{
Expand Down Expand Up @@ -2443,8 +2443,8 @@ void CGameClient::OnPredict()
}

// detect mispredictions of other players and make corrections smoother when possible
if(g_Config.m_ClAntiPingSmooth &&
Predict() && AntiPingPlayers() &&
if(g_Config.m_ClAntiPingSmooth &&
Predict() && AntiPingPlayers() &&
m_NewTick && m_PredictedTick >= MIN_TICK &&
absolute(m_PredictedTick - Client()->PredGameTick(g_Config.m_ClDummy)) <= 1 &&
absolute(Client()->GameTick(g_Config.m_ClDummy) - Client()->PrevGameTick(g_Config.m_ClDummy)) <= 2)
Expand Down Expand Up @@ -2511,9 +2511,9 @@ void CGameClient::OnPredict()
pSmoothLocalChar &&
RealPredTick && m_PredictedTick >= MIN_TICK)
{
int PredTime = clamp(Client()->GetPredictionTime(), 0, 8000); //Milliseconds for some reason?? TODO: Use more precision
int PredTime = clamp(Client()->GetPredictionTime(), 0, 8000); // Milliseconds for some reason?? TODO: Use more precision

// Nightmare: in order to get 100% accurate comparison to detect mispredictions we must
// Nightmare: in order to get 100% accurate comparison to detect mispredictions we must
// tick the PREVIOUS predicted world with our CURRENT predicted inputs
CCharacter *pSmoothDummyChar = 0;
CCharacter *pPredDummyChar = 0;
Expand Down Expand Up @@ -2574,12 +2574,12 @@ void CGameClient::OnPredict()
if(m_aClients[i].m_aPredTick[Tick % 200] == 0)
continue;
vec2 Pos = m_aClients[i].m_aPredPos[Tick % 200];
if(Tick == GameTick - 1)
if(Tick == GameTick - 1)
{
MaxPos = Pos;
MinPos = Pos;
}
else
else
{
MaxPos.x = std::max(Pos.x, MaxPos.x);
MaxPos.y = std::max(Pos.y, MaxPos.y);
Expand Down Expand Up @@ -2634,7 +2634,7 @@ void CGameClient::OnPredict()
float Confidence = 1.0f;
if(PredDir == vec2(0, 0))
Confidence = 1.0f;
else
else
{
Confidence = std::max(0.0f, dot(LastDir, PredDir));
Confidence = std::pow(Confidence, 4.0f); // Can be adjusted
Expand All @@ -2645,7 +2645,7 @@ void CGameClient::OnPredict()
// Manage uncertainty value
float TickSize = TickDuration / ((float)PredTime * 1.5f); // 20ms / PredTime
float PrevConfidence = 1.0f - m_aClients[i].m_Uncertainty;
float NewConfidence = PrevConfidence - Uncertainty + TickSize;
float NewConfidence = PrevConfidence - Uncertainty + TickSize;
NewConfidence = std::clamp(NewConfidence, -1.25f, 1.0f); // A certain about of "negative buffer" is allowed
m_aClients[i].m_Uncertainty = 1.0f - NewConfidence;
NewConfidence = std::max(0.0f, NewConfidence);
Expand All @@ -2661,7 +2661,7 @@ void CGameClient::OnPredict()
vec2 ConfidenceVector = ConfidenceParallel * std::max(TrustFactor, NewConfidence) + ConfidencePerp * NewConfidence;

// Minor safe gaurd against insane predictions
if (length(ConfidenceVector) > HistoryDistance)
if(length(ConfidenceVector) > HistoryDistance)
ConfidenceVector = mix(normalize(ConfidenceVector) * HistoryDistance, ConfidenceVector, NewConfidence);

vec2 ConfidencePos = ServerPos + ConfidenceVector;
Expand All @@ -2670,18 +2670,17 @@ void CGameClient::OnPredict()
ConfidencePos.x = std::clamp(ConfidencePos.x, MinPos.x, MaxPos.x);
ConfidencePos.y = std::clamp(ConfidencePos.y, MinPos.y, MaxPos.y);

//m_aClients[i].m_DebugVector = ConfidenceParallel;
//m_aClients[i].m_DebugVector2 = ConfidencePerp;
//m_aClients[i].m_DebugVector3 = HistoryVector * 25.0f;
// m_aClients[i].m_DebugVector = ConfidenceParallel;
// m_aClients[i].m_DebugVector2 = ConfidencePerp;
// m_aClients[i].m_DebugVector3 = HistoryVector * 25.0f;

m_aClients[i].m_PrevImprovedPredPos = m_aClients[i].m_ImprovedPredPos;
m_aClients[i].m_ImprovedPredPos = ConfidencePos;


//char aBuf[256];
//str_format(aBuf, sizeof(aBuf), "Trust: %.2f, Confidence: %.2f", TrustFactor, NewConfidence);
//if(NewConfidence != 1.0f || TrustFactor != 1.0f)
//Echo(aBuf);
// char aBuf[256];
// str_format(aBuf, sizeof(aBuf), "Trust: %.2f, Confidence: %.2f", TrustFactor, NewConfidence);
// if(NewConfidence != 1.0f || TrustFactor != 1.0f)
// Echo(aBuf);
}
}
// Copy the current pred world so on the next tick we have the "previous" pred world to advance and test against
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/prediction/entities/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class CCharacter : public CEntity
int m_FreezeAccumulation;
int m_AliveAccumulation;
//TClient
CNetObj_PlayerInput* LatestInput() { return &m_LatestInput; };
CNetObj_PlayerInput *LatestInput() { return &m_LatestInput; };

private:
// weapon info
Expand Down

0 comments on commit 4fc9a49

Please sign in to comment.