diff --git a/src/Faction/Faction.ts b/src/Faction/Faction.ts index b303340a6..b4ea4e5ff 100644 --- a/src/Faction/Faction.ts +++ b/src/Faction/Faction.ts @@ -70,9 +70,12 @@ export class Faction { /** Initializes a Faction object from a JSON save state. */ static fromJSON(value: IReviverValue): Faction { const faction = Generic_fromJSON(Faction, value.data); + if (!Array.isArray(faction.augmentations)) faction.augmentations = []; // Remove invalid augs from faction. Augs are repopulated with correct augs during any reset. const augHelper = getEnumHelper("AugmentationName"); faction.augmentations = faction.augmentations.filter((augName) => augHelper.isMember(augName)); + // Fix broken saves, this will soon be removed when better fix is implemented + faction.augmentations = [...new Set(faction.augmentations)]; return faction; } } diff --git a/src/Faction/Factions.ts b/src/Faction/Factions.ts index 49660d904..d9ad0d931 100644 --- a/src/Faction/Factions.ts +++ b/src/Faction/Factions.ts @@ -37,18 +37,6 @@ export function initFactions(): void { for (const name of Object.keys(FactionInfos)) { resetFaction(new Faction(name)); } -} - -//Resets a faction during (re-)initialization. Saves the favor in the new -//Faction object and deletes the old Faction Object from "Factions". Then -//reinserts the new Faction object -function resetFaction(newFactionObject: Faction): void { - const factionName: string = newFactionObject.name; - if (factionExists(factionName)) { - newFactionObject.favor = Factions[factionName].favor; - delete Factions[factionName]; - } - AddToFactions(newFactionObject); // All factions are added, this is a good place to add augs back to factions. initCircadianModulator(); for (const aug of getRecordValues(Augmentations)) { @@ -62,3 +50,15 @@ function resetFaction(newFactionObject: Faction): void { } } } + +//Resets a faction during (re-)initialization. Saves the favor in the new +//Faction object and deletes the old Faction Object from "Factions". Then +//reinserts the new Faction object +function resetFaction(newFactionObject: Faction): void { + const factionName: string = newFactionObject.name; + if (factionExists(factionName)) { + newFactionObject.favor = Factions[factionName].favor; + delete Factions[factionName]; + } + AddToFactions(newFactionObject); +}