mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 20:25:45 +01:00
Fix bad aug reinitialization point
This is just a quick fix. Also added some savegame fix code that will soon be removed once the better fix is in.
This commit is contained in:
parent
4b8a4d739b
commit
aecdbe8e8f
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user