NewCreature / JoyNet

A base networking engine which synchronize input over a network to produce duplicate games.
3 stars 2 forks source link

Lag compensation #1

Open flipcoder opened 12 years ago

flipcoder commented 12 years ago

I'm looking into adding lag compensation, but the way joynet works (with sending controls, instead of updating object positions), it might require some changes to what data is being sent. The easy solution is to add a new type of struct (joynet_object_state) whose position could be sent much like a control. Then have another struct (joynet_object) that contains a circular buffer of object states, which we could use to roll back object history based on some time value (interpolating all the linear state changes, like position and transformation changes). I'm rusty at C, but I'll try my hand at a proof of concept at some point if this sounds like its worth it.

flipcoder commented 12 years ago

Probably should mention that if we're sending object positions we'll need to add some server-side validity checking of positions/transforms. Also, joynet_object_state packets should be sent as sequenced unreliable for interpolatable positions and sequenced reliable for absolute state changes (this includes stopping motion).

NewCreature commented 12 years ago

You should be able to build an object state synchronization system without touching the input aggregation system. No reason there can't be two systems in JoyNet.

I have been thinking about separating player management from input aggregation. If I did this, you could use the player management code I already have and just add the necessary object state update messages.

The main obstacle is coming up with a way to link the objects into JoyNet so not as much game-specific code has to be written. If we aren't going to let JoyNet handle object updates then we may as well just not add object state functionality to JoyNet. We can already use custom messages to build a game-specific set of messages.