mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 17:43:48 +01:00
safeguards
This commit is contained in:
parent
3aacab504b
commit
3289f76cd0
@ -13,6 +13,15 @@ export let Factions: IMap<Faction> = {};
|
|||||||
|
|
||||||
export function loadFactions(saveString: string): void {
|
export function loadFactions(saveString: string): void {
|
||||||
Factions = JSON.parse(saveString, Reviver);
|
Factions = JSON.parse(saveString, Reviver);
|
||||||
|
// safety check for when we load older save file that don't have newer factions
|
||||||
|
for (const faction of Object.keys(Factions)) {
|
||||||
|
try {
|
||||||
|
Factions[faction].getInfo();
|
||||||
|
} catch (err) {
|
||||||
|
console.error("deleting " + faction);
|
||||||
|
delete Factions[faction];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AddToFactions(faction: Faction): void {
|
export function AddToFactions(faction: Faction): void {
|
||||||
|
Loading…
Reference in New Issue
Block a user