-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
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
1 parent
4847ea8
commit 2722765
Showing
4 changed files
with
47 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,8 @@ function _SetupCounterTest { | |
jsr Entity.Spawn | ||
bcc Fail | ||
|
||
jsr Entity.ProcessGameLoop | ||
|
||
sec | ||
rts | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters