Netcode progress
May 11, 2024 • 3 min
Week of May 4 to May 11. Main work: multiplayer level joint creation and bullet timer synchronization
- Minor changes
- May have fixed a bug in deserialization which caused an assertion to fail. Fixed it by allowing the read to happen if not out of bounds.
- More consistently present checks for multiplayer debug mode toggling being on/off from Lua
- Less verbose printf output from multiplayer if certain preprocessor defines are set to 0 instead of 1
- Major changes
- Joint creation sending by implementing persistent event updates. These are sent to clients even if the client connects after the event is generated. Certain events are deemed persistent by the server by checking if it is of a certain type (CreateJoint or DestroyJoint are the only two for now).
- Wip fixing bullet timer not being synchronized properly between client and server. Bullets are either shot at too slow a rate sometimes (earlier this week), or every frame continuously (later this week), or (as of writing) at what appears to be a near-constant time shifted rate but when logged it will show it getting stuck at the fireRate's current value which is set to 25 but sometimes oscillating to negative values which might be when it shoots.
- This may be caused by the time shifting that the server tells the client to do, which somehow messes with event updates.
- Implementation of attempted fixes was done by having a cache of event updates which holds the old values of event updates' contents before the client applies the server changes during the event update rollback. This to ensure that the diffs between what the server said and what the client applied to the simulation in the future don't just overwrite the state the server set. We can now diff with the event update cache, not just with the current state of the shape.
- Fixed spurious continuous event updates for walls that have no relevant bullet timers.
- Implemented printf debugging to try to fix bullet timers by logging them per shape; pre- and post-simulation, and pre- and post-application of event updates on the client.
- Game Tech Notes (API/core game changes, unrelated to bug fixes; changes in what works / what doesn't)
- CreateJoint event works
- Multiplayer bullet timer syncing wip
- The DestroyJoint event is not fully implemented.
- What's going well
- Multiplayer overall is going well. It had come a long way.
- What needs more work
- Multiplayer needs more work.
- What I'll do in the future
- Implement multiplayer enough to where I can host a continuously-on server and join it when necessary in order to train the dark noform deep-reinforcement learning (DRL) system on each level that he appears in (in his more advanced form that is), starting with the school level since that's the only one almost finished being designed with his DRL in mind as of now.
- Later I will return to multiplayer to optimize it and test it from computers over wifi or the internet where lag conditions are unpredictable. I will be making it more bullet-proof as well.