Please sign in to comment.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix linked list corruption bug when spawning a new entity
There is a rare linked list bug in that will drop an entity if an entity's `Process` routine does the following: 1) Spawns a new entity whose listId is the same as the current listId 2) The entity changes its list on the same frame it spawned the entity The problem is that the Entity GameLoop was holding the address of the previous entity, and the Entity Spawn routines add the newly spawned entity to the beginning of the entity list. When the new entity is spawned onto the currently looping list, `_previousEntity` has the potential to be invalidated, causing an entity to be dropped. We solve this dilemma by having a special list that temporarily stores the newly spawned entities and prevents `_previousEntity` from being invalidated. Then, at the start of each frame the entities will be moved into their appropriate list and the entity loop continues as normal. Luckily, this behaviour already exists in `Entity.ProcessGameLoop`, the `tryToActivateAgain` list. Some unit tests that relied on the old behaviour have also been updated to pass successfully.
- Loading branch information
Showing with 47 additions and 40 deletions.