AnneKitsune / entity_component

Apache License 2.0
8 stars 2 forks source link

fix bug where interleaved kill and create lead to duplicate ids #1

Closed tgolsson closed 3 years ago

tgolsson commented 3 years ago

Noticed this due to a "upgrade" system transforming entities into new ones, so it'd delete X entities and create X entities, but only X - 1 would be remembered.

For the test case, what would happen is that you'd observe the sequence:

Create 0
Create 1
Kill 0
Kill 1
Create 2
Create 2

This is due to return i == max_id in the first post-kill create, and then returning max_id in the second call. It also seems to me like max_id is more clearly next_id -- if you disagree I can drop that commit, but that realization helped diagnose this bug.

AnneKitsune commented 3 years ago

Thanks! <3

AnneKitsune commented 3 years ago

published in planck_ecs = "1.1.0" and entity_component = "1.1.0" ! :hearts: