• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code Compare time stamps from server and client

Pharrahnox

Grizzled Veteran
Feb 3, 2016
268
71
Cranny mate
I've added stamina to players, and am trying to get it working nicely over a network. The server is authoritative with respect to stamina, so when stamina is changed on the server, it is replicated to the client. The client predicts what its value for stamina should be at any point in time, and when it gets overriden by the server's replicated value, the client attempts to reproduce all changes to stamina that occurred after the time of replication. The changes are stored in a pooled doubly-linked list, and each node has a timestamp.

The changes to stamina stored in the linked list have their timestamps determined by the client, and the replicated stamina struct has a timestamp determined by the server. These timestamps are compared so that any stored changes to stamina that occurred before the replication event can be discarded. The issue is that the server and client don't agree on the timestamps. Using WorldInfo.TimeSeconds is way off, since it seems that the server starts ticking that when it loads the map, and even using ActorTimeSeconds is about 0.5 seconds off, which is too much to be useful. I've even tried making my own ElapsedTime variable that is simply the sum of all DeltaTimes from Tick(), but it's also 0.5 seconds off.

How can I correctly sync the timestamps from the client and the server?