-
Notifications
You must be signed in to change notification settings - Fork 42
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 push/splice/push, item added at wrong index. #94
Comments
Thanks for reporting and providing the example @Zielak, thanks also @Steditor for providing a similar scenario here colyseus/colyseus.js#78 (comment) (I believe the use cases are the same) This issue is going to be a bit difficult to solve. The " You can get items from the arraySchema.getByIndex(dynamicIndex) The It might be possible to work around this somehow and provide the actual local index for the schema callbacks, I just don't want to overly complicate things, as they're already quite complicated! 😰 |
So this Anyway, I chose to work around this by having an array of Schemas instead and not rely on the arrays' indexes: |
Glad you've worked it out @Zielak
Hm, well observed! Only if it surpasses |
Could this be possibly related? colyseus/colyseus#407 |
I've made this bug reproducible at State handling example of
colyseus-example
: https://github.com/Zielak/colyseus-examples - branch master.My use case
I want mark cards selected by the player in their hand. I'm using
cardsSelected:ArraySchema<number>
. Values are IDs of cards, and i wanted to use the array's index to know in which order the cards were selected.The issue appeared when I tried to select and deselect the same card many times. I've pinned it down to minimal, reproducible case: add/remove/add-again:
Note:
onAdd
comes with the item being added into index 1I've also inspected web socket messages on client, and it seems that the server-side Colyseus is sending this incorrect key.
The text was updated successfully, but these errors were encountered: