Fix Foundry v14 actor ownership updates

This commit is contained in:
Jason committed 2026-12-02 21:38:56 -05:00
1 parent 17b06810c8
commit b70f10dd38
5 files changed
+64 -16

No files matched your search

+2 -4
View File
@@ -123,10 +123,8 @@ export async function applyPlan(game,constants,api,plan,log) {
const folder=lookup(game,'Actor',path);
const current=actor.toObject().ownership ?? {};
if(actor.folder?.id===folder.id && equal(current,ownership))continue;
const patch={folder:folder.id};
for(const key of Object.keys(current))if(!(key in ownership))patch[`ownership.-=${key}`]=null;
for(const [key,level] of Object.entries(ownership))patch[`ownership.${key}`]=level;
await actor.update(patch);
// Replace the ownership map as a field so former owners are removed in the same update.
await actor.update({folder: folder.id, ownership: globalThis._replace(ownership)});
if(actor.folder?.id!==folder.id || !equal(actor.toObject().ownership,ownership))throw Error(`Actor ownership/folder verification failed: ${actor.name}`);
log.push(`Organized ${actor.name}`);
}