colyseus / schema

An incremental binary state serializer with delta encoding for games.
https://docs.colyseus.io/state/schema/
MIT License
134 stars 41 forks source link

(For repro) Adds a failing test case to the StateView #178

Closed LukeWood closed 3 months ago

LukeWood commented 3 months ago

Tentatively, I think this should pass - but it fails with:

  1) StateView
       MapSchema
         should sync single item:
     AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

undefined !== 3

Maybe I misunderstand, but I would expect this to remain unchanged in the output - whether or not you call encodeMultiple once, or many times. I think this might be related to my issues - as I'm forcing calls to broadcastStatePatch() manually. If this is in fact expected, let me know and feel free to close. Still trying to learn about how this all fits together.


Happy to offer a fix, but not entirely sure what is going on here 😓

endel commented 3 months ago

Thanks for the failing test, this does look like a bug!

endel commented 3 months ago

Hi @LukeWood, thank you so much for the test case! I've just refactored StateView.add() and made some changes in the encoding order for StateView's. Released version 3.0.0-alpha.26 with the changes.

Please let me know if "refId" not found issues still persist in your project 🙏 Cheers!