fishfolk / bones

An easy-to-use game engine for making real games.
https://fishfolk.org/development/bones/introduction/
Other
210 stars 20 forks source link

feat(networking): Support restarting network session #384

Closed MaxCWhitehead closed 4 months ago

MaxCWhitehead commented 4 months ago

These are changes in prep for map transition. Session runner now has a restart function. When game session is reset, network session runner can be restarted by re-initializing it and using existing socket with increment match id.

Sockets now wrap ggrs messages with a match_id that allows filtering in flight messages from previous matches out to avoid issues when re-creating ggrs session.

Note that GGRS takes a boxed socket - incrementing match id on our NetworkMatchSocket or other cloned socket will not impact current ggrs socket, which is fine as we are re-creating ggrs session anyway. It may only be effectively updated by cloning socket, incrementing, and re-creating ggrs session. This also avoids issues with interior mutability of NetworkMatchSocket (arc wrapping socket), so we operate by cloning / saving boxed socket + updating this.

Additionally added resource NetworkInfo which is updated by net session runner before each step. Contains current + last confirmed frame, which gameplay code may use to confirm events (such as map transition) have been synchronized + confirmed by all players.

These changes + session commands PR should be everything we need on the bones side to get map transitions in.