From fbadd8effcb14d7b09a501b5eea16c2babd6d90a Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Sun, 15 Mar 2020 12:50:04 -0700 Subject: [PATCH] Reset corp data for saves where it wasn't initialized properly. --- js/003-data/gameVariableData.js | 27 ++++++++++--------- .../backwardsCompatibility.js | 5 ++++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/js/003-data/gameVariableData.js b/js/003-data/gameVariableData.js index 6ef0ebd4b88..d63b39821ce 100644 --- a/js/003-data/gameVariableData.js +++ b/js/003-data/gameVariableData.js @@ -198,6 +198,20 @@ App.Data.defaultGameStateVariables = { secExpEnabled: 0, }; +// Corp data +App.Data.CorpInitData = { + Announced: 0, + Incorporated: 0, + Market: 0, + Econ: 0, + CashDividend: 0, + Div: 0, + ExpandToken: 0, + Spec: 0, + SpecToken: 0, + SpecRaces: [] +}; + // The other half of the above whitelist. However, entries in this array will be forced to the values set here upon starting NG+. App.Data.resetOnNGPlus = { targetArcology: {fs: "New"}, @@ -221,18 +235,7 @@ App.Data.resetOnNGPlus = { ServQiIDs: [], SpaiIDs: [], NurseryiIDs: [], - corp: { - Announced: 0, - Incorporated: 0, - Market: 0, - Econ: 0, - CashDividend: 0, - Div: 0, - ExpandToken: 0, - Spec: 0, - SpecToken: 0, - SpecRaces: [] - }, + corp: App.Data.CorpInitData, dividendTimer: 0, personalShares: 0, publicShares: 0, diff --git a/src/data/backwardsCompatibility/backwardsCompatibility.js b/src/data/backwardsCompatibility/backwardsCompatibility.js index b04dee29383..c33af649825 100644 --- a/src/data/backwardsCompatibility/backwardsCompatibility.js +++ b/src/data/backwardsCompatibility/backwardsCompatibility.js @@ -937,6 +937,11 @@ App.Update.globalVariables = function() { } } } + + /* if we managed to end up in a state where the corp isn't properly defined, forcefully reset it to starting conditions */ + if (typeof V.corp.Incorporated === "undefined") { + V.corp = clone(App.Data.CorpInitData); + } } // Organs -- GitLab