Skip to content

Change int to float for flDeadtime calculation#1798

Open
xXxPROHvHeRxXx wants to merge 2 commits intoValveSoftware:masterfrom
xXxPROHvHeRxXx:master
Open

Change int to float for flDeadtime calculation#1798
xXxPROHvHeRxXx wants to merge 2 commits intoValveSoftware:masterfrom
xXxPROHvHeRxXx:master

Conversation

@xXxPROHvHeRxXx
Copy link

Description

This is my original work. I identified a bug in
CLagCompensationManager::FrameUpdatePostEntityThink() in
src/game/server/player_lagcompensation.cpp.

Bug

The variable flDeadtime is declared as int but stores the result
of a float subtraction:

int flDeadtime = gpGlobals->curtime - sv_maxunlag.GetFloat();

The fl prefix in the variable name suggests it was intended to be
a float. The implicit cast to int truncates the fractional part.

Impact

Lag compensation records are pruned too aggressively — up to 1 tick
earlier than intended.

Example:

  • curtime = 150.7, sv_maxunlag = 1.0
  • Expected (float): flDeadtime = 149.7
  • Actual (int): flDeadtime = 149

Records with m_flSimulationTime between 149.0 and 149.7 are
incorrectly removed. This can reduce hit registration accuracy
for players at higher latencies.

Fix

- int flDeadtime = gpGlobals->curtime - sv_maxunlag.GetFloat();

+ float flDeadtime = gpGlobals->curtime - sv_maxunlag.GetFloat();

Confirmation

This Contribution is my original work. I identified this issue
by reviewing the publicly available Source SDK 2013 source code
in this repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant