Added some safety for missing things if someone was on a REALLY old system version and then updated all the way

This commit is contained in:
WBHarry 2026-06-27 21:12:12 +02:00
parent 453054c0e4
commit f47ec012ea

View file

@ -155,6 +155,7 @@ export async function runMigrations() {
/* Migrate old countdown structure */ /* Migrate old countdown structure */
const countdownSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns); const countdownSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
if (!countdownSettings.narrative || !countdownSettings.encounter) {
const getCountdowns = (data, type) => { const getCountdowns = (data, type) => {
return Object.keys(data.countdowns).reduce((acc, key) => { return Object.keys(data.countdowns).reduce((acc, key) => {
const countdown = data.countdowns[key]; const countdown = data.countdowns[key];
@ -189,11 +190,13 @@ export async function runMigrations() {
data: { refreshType: RefreshType.Countdown } data: { refreshType: RefreshType.Countdown }
}); });
Hooks.callAll(socketEvent.Refresh, { refreshType: RefreshType.Countdown }); Hooks.callAll(socketEvent.Refresh, { refreshType: RefreshType.Countdown });
}
lastMigrationVersion = '1.2.0'; lastMigrationVersion = '1.2.0';
} }
if (foundry.utils.isNewerVersion('1.2.7', lastMigrationVersion)) { if (foundry.utils.isNewerVersion('1.2.7', lastMigrationVersion)) {
try {
const tagTeam = game.settings.get(CONFIG.DH.id, 'TagTeamRoll'); const tagTeam = game.settings.get(CONFIG.DH.id, 'TagTeamRoll');
const initatorMissing = tagTeam.initiator && !game.actors.some(actor => actor.id === tagTeam.initiator); const initatorMissing = tagTeam.initiator && !game.actors.some(actor => actor.id === tagTeam.initiator);
const missingMembers = Object.keys(tagTeam.members).reduce((acc, id) => { const missingMembers = Object.keys(tagTeam.members).reduce((acc, id) => {
@ -208,9 +211,10 @@ export async function runMigrations() {
members: missingMembers members: missingMembers
}); });
await game.settings.set(CONFIG.DH.id, 'TagTeamRoll', tagTeam); await game.settings.set(CONFIG.DH.id, 'TagTeamRoll', tagTeam);
} finally {
lastMigrationVersion = '1.2.7'; lastMigrationVersion = '1.2.7';
} }
}
if (foundry.utils.isNewerVersion('1.5.5', lastMigrationVersion)) { if (foundry.utils.isNewerVersion('1.5.5', lastMigrationVersion)) {
/* Clear out Environments that were added directly from compendium */ /* Clear out Environments that were added directly from compendium */