-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map decode will fail for some stored values #44
Comments
Wow, that's a nice catch, thanks for the detailed report, and diving deep into the problem. I'm going to check this as soon as possible! |
I made some changes to the tests that catch this problem. In order to do this, I created a helper function that will convert the encoded array to a "byte" array (where all values are in the [0,255] range), like the websocket would do in a normal client/server interaction. |
Nice, thanks @colombotapps, I've been experimenting with your proposal and made sure we use bytes from I've also added a failing test for the current issue here: https://github.com/colyseus/schema/blob/master/test/EdgeCasesTest.ts#L9-L39 Once this is fixed, I'm going to push a version Cheers! |
Hi @colombotapps, I've just created a PR to fix this (#45). Next step is to apply the patch on all decoders to use the new (Note that the decoder implementations for other languages hosted on this repository are outdated, the most up-to-date ones are on each Colyseus client repository) |
Hi @colombotapps, you mind checking if @Wenish has set-up a nice pipeline to auto-generate a ZIP file containing the Unity plugin files in the releases now: https://github.com/colyseus/colyseus-unity3d/releases/tag/0.11.2 There's a Cheers! |
The decode logic for a map will test for nil values (192) to determine if a map entry was removed. However, a map which has a int32 type, for example, can have the first byte with a value of 192. For example, the number 3520 will be encoded as 192, 13, 0, 0 but will be decoded as a nil value (i.e. the entry was removed). This will happen for any encoded value where 192 is a valid first byte (uint8, int8, uint16, etc.)
This logic tests for the nil values
schema/src/Schema.ts
Line 356 in 76a8cac
and calls the onRemove event. Removed values should be encoded in a different way, maybe we could add a byte to indicate the removal or not of the key before the new value, such that this byte can then have a magic value and the actual value of the field can be anything?
The text was updated successfully, but these errors were encountered: