evolve icon indicating copy to clipboard operation
evolve copied to clipboard

Time played randomly turns negative

Open ghost opened this issue 12 years ago • 2 comments

Every now and then, someone's "time played" on my server will turn negative, and then it will count back up into the positives. Any way to fix this?

ghost avatar May 17 '13 20:05 ghost

I can confirm this issue with my own port of Evolve (Linux x86_64 server here), I will be investigating this issue further and try to come up with a solution.

Bucky21659 avatar Apr 11 '14 18:04 Bucky21659

My friend and I have come up with a fix, we think the issue is due to the fact that srcds is 32-bit and os.clock() returns a 64 bit value on 64 bit systems. Around os.clock() time of 2140.xx, the decimal precsion increases and the negative bit gets set. So the values start counting at -2140.xxxxxx back toward 0. In order to solve this problem, we take the absolute differences in time values of the clock rather than just subtracting new - old. We ran a debuger overnight, which would log the clock time, last time, calculated play time, and final time (what gets logged to file) on a per-player basis and got this. At line 789, the clock time went negative but the actual playtime was preserved. Yeah there were a few seconds lost but I don't think it's significant enough for it to cause any issues.

Here's our patch, just save as sv_playerinfo.lua and put it in your ev_plugins folder (overwrite the existing). I also forked this Evolve port and committed the patch, here.

Bucky21659 avatar Apr 16 '14 15:04 Bucky21659