I have a game that communicates with server from time to time via ajax.
I need the game to know all in every tick, what is the server time.
What I tried:
1) I tried sending server time to game, set a global variable "now" to this value, and in every tick add dt to "now" with no luck, because when game goes out of focus, this will break (c2 pauses)
2) I tried messing with wallclocktime, sent server time to game, set a global variable "server_time" to this value minus current wallclocktime on receive and every tick set a "now" global variable to "server_time" + wallclocktime. My logic tells me this _should_ work, but it doesnt, every time I get new current time from server, "now" goes back around 10 - 20 seconds. why?
any ideas would be greatly appreciated.