Page 1 of 1

My netcode is working, but I have a question

Posted: Wed May 06, 2015 6:12 am
by cohadar
Ok so I am making a mini multiplayer game
https://github.com/cohadar/tanks-of-harmony-and-love

Using lua-enet for networking.
Never made multiplayer game before, but I think I did netcode right, just not sure.

It works like this:
Love FPS is 60, I sample and send user commands to server at 30 FPS, server works at 60 FPS but updates clients at 10 FPS.
Clients and servers are in lockstep, they all have tick counter updated every 60 FPS.
When state on client and server gets different a resync is forced on client ( I display sync text on screen for debugging )

So far it is working fine, I just thought to ask nevertheless.
Am I doing something wrong? Could I be doing something better?

Re: My netcode is working, but I have a question

Posted: Thu May 07, 2015 8:32 pm
by I~=Spam
Fps isn't a good way to count because if fps is ever lower than 60 there will be a lot of mismatches. Unfortunately, I don't know how it should be done either... :crazy: What I would do it have a separate thread on the client that will try to ask server for an update and send updates every so many seconds using socket.sleep. This sub thread would communicate with the main thread via messages. The server would be written in pure lua + luasocket (so no love callbacks) and would be willing to get a message from its clients at any time.