Jump to content
  • Advertisement
Sign in to follow this  

Processing inputs right away

This topic is 2075 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



I was reading some Carmack updates about the QuakeWorld development here : http://fabiensanglard.net/quakeSource/johnc-log.aug.htm


And that part made me think about how to process inputs :


Instead of expecting everyone's messages to be dealt with at once, I now
deal with each packet as it comes in. That player alone is moved forward
in time, and a custom response is sent out in very short order. The rest
of the objects in the world are spread out between the incoming packets.
There are a lot of issues that that brings up. Time is no longer advancing
uniformly for all objects in the world, which can cause a lot of problems.

It works, though! The average time from a packet ariving at the system to
the time a response is sent back is down to under 4ms, as opposed to over
50 with the old dedicated servers. 


In my projects I usually have a big server loop, processing all the received messages and sending back "independently" the server updates to all the players.


It works but indeed, as he said, it adds some latency if you process the messages at 30 or 60fps but I always just dealed with it; now i'm wondering how you handle cheat with this kind of architecture.


The issue being cheaters trying to speedhack by just sending packets at a different expected rate. Do you average the number of packets received from the client and try to consume them at an arbitrary rate ?


Is it a good route to take ? Any drawback ?

Share this post

Link to post
Share on other sites
Personally, I don't like the "everyone moves when their packets come in" mechanism. It may move for certain fast-paced games with little physical interaction between entities, but it is inherently nondeterministic and doesn't work well at all for multi-entity interactions (e g two rolling balls colliding or whatever.)

Share this post

Link to post
Share on other sites
I'm with hplus.

This is a technique that can be useful for certain types of simulation, but for anything with nontrivial physics, it's a bloody nightmare.

Share this post

Link to post
Share on other sites

Thanks for the help.


I thought more about how to process MY inputs and i need a few enlightments :


The client is sending ~2 frames per packet.


What i used to do in my other projects is checking on the server if there are datas to dispatch, if so, call movePlayer() or throwArrow() and since i'm having 2 frames i was sometimes calling throwArrow() twice in a row.


But right now i'm using an entity/component architecture, the same as T=Machine where an entity can only have one component type. So when i'm receiving a client packet about throwing arrows the networkSystem would attach a CThrowArrowEvent component to my client entity and then the event would propagate through all my systems.


That's my server loop :






So if i'm having two events in the same packet about throwing arrows, i can't just attach 2 events to my player entity as soon as i'm processing the packet since my entityManager structure doesn't allow it.


I would like to avoid changing my entityManager but i'm not sure what method would fit the best my architecture.


I could make one server loop per packet frame for all the players which mean that i would make two loops in a row independently of my server fps. I would still send back datas at regular interval. How does that sound ?



Share this post

Link to post
Share on other sites
Typically, events are time stamped, which means that you will only dispatch/attach events for a particular time stamp during a particular loop through your simulation loop. The other event would wait in a queue until its time stamp comes up, and be handled at that time.

Share this post

Link to post
Share on other sites

I have no idea why i thought it would be different from what i was doing, i actually had a bug when spamming an action key would cumulate latency, so i started from that and made wrong premises. Thanks putting me on the right track :3


(I actually have more questions but i'll make another thread);

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!