Skip to content

Preserve map entity order - #357

Merged
Vegita2 merged 8 commits into
masterfrom
fix/entity-order
Sep 13, 2026
Merged

Vegita2 merged 8 commits into
masterfrom
fix/entity-order

Conversation

@2767mr

@2767mr 2767mr commented Sep 13, 2026

Copy link
Copy Markdown
Member

Since entities are generated concurrently, the order at which they are added was indeterminstic. Instead, this waits for all entities to load and then adds all successfully generated entities in the correct order.

This has the downside of not adding any entities if any entity never finishes loading.

I also included a fix for a race condition while I was at it.

@2767mr 2767mr linked an issue Sep 13, 2026 that may be closed by this pull request

@Vegita2 Vegita2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. I remembered having a test case fail because of entity orders and found this line

// TODO: fix map loading, order of entities doesn't matter

Now it probably should say it DOES matter. Tests currently don't work anyway so it's something for the future when we update angular and use vitest.

I also noticed there is a race condition when quickly loading multiple maps which already existed before. Because of the async entity loading the second map can load entities from the first map. Probably out of scope for this pull request but should be kept in mind

Comment thread webapp/src/app/services/phaser/entities/entity-manager.ts Outdated
@Vegita2
Vegita2 enabled auto-merge (squash) September 13, 2026 14:02
@Vegita2
Vegita2 merged commit 70e762b into master Sep 13, 2026
4 checks passed
@Vegita2
Vegita2 deleted the fix/entity-order branch September 13, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Save data in the same order as loaded

2 participants