-
Notifications
You must be signed in to change notification settings - Fork 112
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
ArraySchema incorrect removed index (onRemove on client receives incorrect index) #78
Comments
Hi @giuliano-marinelli, this is a known issue and has been fixed already on the latest alpha version of Colyseus (colyseus/colyseus#357, colyseus/schema#82) If you can I recommend upgrading to the latest alpha version, which seems to be stable so far (I'm using in 2 web projects), here is the preview of the migration guide for it: https://deploy-preview-45--colyseus-docs.netlify.app/migrating/0.14/ |
Thanks! I upgrade my project then 👍 |
Version 0.14 is out! 🎉 https://github.com/colyseus/colyseus/releases/tag/0.14.0 |
This still seems to be a problem in the current version (0.14.0 server / 0.14.1 js client): The client-side |
Hi @Steditor, thanks for reporting, could you please provide more info about which operations you've done, and how is your structure represented so I can reproduce over here? If you can provide a test scenario like this would be ideal: https://github.com/colyseus/schema/blob/master/test/ArraySchemaTest.ts#L9-L48 Cheers! |
I think I now understand, where the problem came from: I assumed that the calls to Something else is fishy with the indices when removing and adding elements. Maybe it's me using the framework in a wrong way, but: As soon as you mix |
When removes an item from a ArraySchema that's not the last one (for example: array.shift(), that removes first one), The onRemove(instance, key) defined in the Client receives as key and instance always the last one element of the array.
Example
We have a Schema called World that contains an array of Points (schema too) called test, and an action that add elements when data is "a: 1", or removes the first one element if data is "a: 2"
Then on Client:
I'm using the Client in Angular 10 imported in this way:
import * as BABYLON from '@babylonjs/core/Legacy/legacy';
Thanks, Cheers :)
The text was updated successfully, but these errors were encountered: