kandashi / Active-Token-Lighting

MIT License
24 stars 24 forks source link

Upgrading 0.2.17 to 0.3.04 Destroys Active Effects on Actors #76

Closed tjlanza closed 2 years ago

tjlanza commented 2 years ago

Describe the bug Upgrading from 0.2.17 to 0.3.04 destroys active effect properties on all actors.

To Reproduce Steps to reproduce the behavior:

  1. Have world using 0.2.17
  2. Upgrade to 0.3.04
  3. Say goodbye to your configured AEs.

Expected behavior AEs should remain as they were before the upgrade.

Screenshots image

image

Environment:

Additional context I initially encountered the issue on my live game server, but with all the modules active, I couldn't narrow down a cause. Tposney's comment on the Discord is what prompted me to look at ATL/ATE.

The server environment I tested on did not previously have ATL at all. The Foundry package installer initially offered 0.2.17 as the only available new install, rather than 0.3.04 (under the new name). It offered 0.3.04 as an upgrade.

tjlanza commented 2 years ago

Apparently this was a known issue, according to the package-releases channel on the Foundry Discord.

This snippet was provided by a fellow user to me. It's obviously specific to a particular actor, but it does successfully restore the active effects from items to the actor. AEs that exist purely on the actor can't be saved, but this does at least spare time from having to manually redo each actor's items.

I hope you can implement this (or a variation of it) as an upgrade/migration path.

for (const effect of game.actors.getName("Michael O'Hanlon").effects) {
    console.log('Checking effect', effect.data.label, effect);
    if (effect.data.changes.length > 0) continue;
    console.log('Effect has no changes', effect.data.label);
    const source = await effect.source;
    if (source instanceof getDocumentClass('Actor')) continue;
    const sourceEffect = source.effects.find(e => e.data.label === effect.data.label);
    if (!sourceEffect) continue;
    if (sourceEffect.data.changes.length === 0) {
        console.log('Source Effect also has none, ignoring');
        continue;
    }
    console.log('Updating effect with', sourceEffect.data.label, sourceEffect);
    await effect.update({'changes': duplicate(sourceEffect.data.changes)});
}
kandashi commented 2 years ago

Fixed in 0.3.05 thanks for the help