Skip to content

Commit

Permalink
Fix data prep for self cyclical containers (#15112)
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosFdez authored Jun 16, 2024
1 parent 8a6155e commit 01aa557
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/module/item/container/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,19 @@ class ContainerPF2e<TParent extends ActorPF2e | null = ActorPF2e | null> extends
return super.bulk.plus(this.capacity.value.minus(this.bulkIgnored));
}

override prepareBaseData(): void {
super.prepareBaseData();

// Simple measure to avoid self-recursive containers
if (this.system.containerId === this.id) {
this.system.containerId = null;
}
}

/** Reload this container's contents following Actor embedded-document preparation */
override prepareSiblingData(this: ContainerPF2e<ActorPF2e>): void {
super.prepareSiblingData();

if (this.system.containerId === this.id) this.system.containerId = null;
this.contents = new Collection(
this.actor.inventory.filter((i) => i.container?.id === this.id).map((item) => [item.id, item]),
);
Expand Down

0 comments on commit 01aa557

Please sign in to comment.