Various fixes to our upgrade logic (#536)

Stuff broke over time, especially with the major changes we made leading
up to 2.3. We should test with older saves if/when we make large changes
in the future.

Fixes #532
This commit is contained in:
David Walker
2023-05-26 21:16:31 -07:00
committed by GitHub
parent ab207ce36c
commit db26d054fc
6 changed files with 58 additions and 54 deletions
+6 -2
View File
@@ -1,6 +1,7 @@
import { convertTimeMsToTimeElapsedString } from "./utils/StringHelperFunctions";
import { initAugmentations } from "./Augmentation/AugmentationHelpers";
import { AugmentationNames } from "./Augmentation/data/AugmentationNames";
import { initBitNodeMultipliers } from "./BitNode/BitNode";
import { initSourceFiles } from "./SourceFile/SourceFiles";
import { generateRandomContract } from "./CodingContractGenerator";
import { initCompanies } from "./Company/Companies";
@@ -229,11 +230,14 @@ const Engine: {
load: function (saveString) {
startExploits();
setupUncaughtPromiseHandler();
// Source files must be initialized early because save-game translation in
// loadGame() needs them sometimes.
initSourceFiles();
// Load game from save or create new game
if (loadGame(saveString)) {
FormatsNeedToChange.emit();
initSourceFiles();
initBitNodeMultipliers();
initAugmentations(); // Also calls Player.reapplyAllAugmentations()
Player.reapplyAllSourceFiles();
if (Player.hasWseAccount) {
@@ -374,7 +378,7 @@ const Engine: {
} else {
// No save found, start new game
FormatsNeedToChange.emit();
initSourceFiles();
initBitNodeMultipliers();
Engine.start(); // Run main game loop and Scripts loop
Player.init();
initForeignServers(Player.getHomeComputer());