Skip to content

Commit

Permalink
Source Engine: Crash fix for parenting
Browse files Browse the repository at this point in the history
Objects can spawn after map load. Whoops.

This needs a better fix overall to fix our spawn ordering, but my attempts kept running into issues.
  • Loading branch information
magcius committed Dec 21, 2024
1 parent 28842a7 commit 3330230
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/SourceEngine/EntitySystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4473,12 +4473,15 @@ export class EntitySystem {
// before calling the spawn method on anything.
for (let i = 0; i < this.entities.length; i++) {
const entity = this.entities[i];
assert(entity.spawnState === SpawnState.ReadyForSpawn);
entity.setupParent(this);
if (entity.spawnState === SpawnState.ReadyForSpawn)
entity.setupParent(this);
}

for (let i = 0; i < this.entities.length; i++)
this.entities[i].spawn(this);
for (let i = 0; i < this.entities.length; i++) {
const entity = this.entities[i];
if (entity.spawnState === SpawnState.ReadyForSpawn)
entity.spawn(this);
}
}

this.processOutputQueue();
Expand Down

0 comments on commit 3330230

Please sign in to comment.