Skip to content

Commit

Permalink
fix: add migration for scene weather configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost91- committed May 28, 2023
1 parent 6dae340 commit 3df17a3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/fxmaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Hooks.once("init", function () {
]),
);

CONFIG.originalWeatherEffects = CONFIG.weatherEffects;
CONFIG.weatherEffects = { ...CONFIG.weatherEffects, ...weatherEffects };
});

Expand Down
21 changes: 21 additions & 0 deletions src/migration/world/4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { migrate } from "../helpers";

export async function migrate4() {
return migrate(migrationConfiguration4);
}

/** @type {import('../helpers').MigrationConfiguration} */
export const migrationConfiguration4 = {
Scene: migrateScene,
};

async function migrateScene(scene) {
const originalWeatherEffectKeys = Object.keys(CONFIG.originalWeatherEffects);
const weatherEffectsToMigrate = Object.keys(CONFIG.fxmaster.particleEffects).filter(
(effect) => !originalWeatherEffectKeys.includes(effect), // only migrate effects where we are certain they are ours
);

if (weatherEffectsToMigrate.includes(scene.weather)) {
await scene.update({ weather: `fxmaster.${scene.weather}` });
}
}
9 changes: 8 additions & 1 deletion src/migration/world/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import { packageId } from "../../constants.js";
import { migrate2, migrationConfiguration2 } from "./2.js";
import { migrate3, migrationConfiguration3 } from "./3.js";
import { migrate4, migrationConfiguration4 } from "./4.js";

export const targetServerMigration = 3;
export const targetServerMigration = 4;

export async function migrateWorld() {
const migration = game.settings.get(packageId, "migration");
Expand All @@ -21,6 +22,8 @@ export async function migrateWorld() {
isError |= await migrate2();
case 2:
isError |= await migrate3();
case 3:
isError |= await migrate4();
}

if (isError) {
Expand All @@ -46,4 +49,8 @@ export const worldMigrations = {
migrate: migrate3,
config: migrationConfiguration3,
},
4: {
migrate: migrate4,
config: migrationConfiguration4,
},
};

0 comments on commit 3df17a3

Please sign in to comment.