Bug 2913 - ucmd->serverTime not accurate
Status: RESOLVED INVALID
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Misc
Version: 1.33 SVN
Hardware: All All
: P2 normal
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks: 2903
 
Reported: 2006-11-08 12:40 EST by Tony J. White
Modified: 2007-05-21 11:27:04 EDT
0 users

See Also:


Attachments
svn963 more accurate serverTime for ucmd (538 bytes, patch)
2006-11-08 12:41 EST, Tony J. White
svn965 serverTime (509 bytes, patch)
2006-11-09 15:58 EST, Tony J. White
svn973 serverTime (996 bytes, patch)
2006-11-13 19:31 EST, Tony J. White

Description Tony J. White 2006-11-08 12:40:46 EST
The serverTime a client attaches to a usercmd appears to be slightly lagged depending on client fps.  This is because cl.serverTime is calculated by CL_SetCGameTime() AFTER the call to CL_SendCmd() but BEFORE the call to SCR_UpdateScreen().  Simply moving up the call to CL_SetCGameTime() a few lines seems to correct this.

The amount of lag depends on the rendering FPS on the client: the less frames rendered between cmds the smaller the lag.  e.g. a client rendering only 20fps may have serverTime lagged by up to 50ms, but one rendering 100fps may only have serverTime lagged by 10ms.

To the existing game code this doesn't make a difference since it only uses the delta in serverTime between two commands, but it does make a difference to Unlagged since the exact value of serverTime is used for backward reconciliation of client position.  I think is why cg_cmdTimeNudge exists in Neil's Unlagged code.
Comment 1 Tony J. White 2006-11-08 12:41:36 EST
Created attachment 1140 [details]
svn963 more accurate serverTime for ucmd
Comment 2 Tony J. White 2006-11-09 15:58:28 EST
Created attachment 1142 [details]
svn965 serverTime

Last patch may have put the serverTime too far ahead.  This patch moves the CL_SendCmd() call to immediately after the SCR_UpdateScreen() call instead of moving the CL_SetCGameTime() call.  This should ensure that the cmd is sent with the rendered serverTime as closely as possible to when that frame was rendered (in the same CL_Frame() call).
Comment 3 Tony J. White 2006-11-13 19:31:51 EST
Created attachment 1150 [details]
svn973 serverTime

After more testing it appears just calling CL_SetCGameTime() prior to CL_SendCmd() is not _enough_.  Adding the cls.frametime too seems like the most accurate time so far.  This is through trial and error more than understanding the timing problem, so I'll try come up with a better explaination eventually.
Comment 4 Tony J. White 2006-11-17 10:00:24 EST
OK, this bug appears to be invalid.  The ucmd->serverTime does appear to be lagging the real serverTime, but it is by the time of one server frame (usually 50ms).  I think this is normal/expected.  See "built-in 50ms lag" at:

http://axon.cs.byu.edu/~josh/unlagged/docs/README.html

ucmd->serverTime just needs to be adjusted in the game code.
Comment 5 Ryan C. Gordon 2007-05-21 11:27:04 EDT
Setting a QA contact on all ioquake3 bugs, even resolved ones. Sorry if you get a flood of email from this, it should only happen once. Apologies for the incovenience.

--ryan.