diff --git a/src/SaveObject.tsx b/src/SaveObject.tsx index 70ab08b9a..4a4dfaae4 100755 --- a/src/SaveObject.tsx +++ b/src/SaveObject.tsx @@ -43,10 +43,10 @@ class BitburnerSaveObject { StaneksGiftSave = ""; SaveTimestamp = ""; - getSaveString(): string { + getSaveString(excludeRunningScripts = false): string { this.PlayerSave = JSON.stringify(Player); - this.AllServersSave = saveAllServers(); + this.AllServersSave = saveAllServers(excludeRunningScripts); this.CompaniesSave = JSON.stringify(Companies); this.FactionsSave = JSON.stringify(Factions); this.AliasesSave = JSON.stringify(Aliases); @@ -68,7 +68,7 @@ class BitburnerSaveObject { } saveGame(emitToastEvent = true): void { - const saveString = this.getSaveString(); + const saveString = this.getSaveString(Settings.ExcludeRunningScriptsFromSave); save(saveString) .then(() => { @@ -80,7 +80,7 @@ class BitburnerSaveObject { } exportGame(): void { - const saveString = this.getSaveString(); + const saveString = this.getSaveString(Settings.ExcludeRunningScriptsFromSave); // Save file name is based on current timestamp and BitNode const epochTime = Math.round(Date.now() / 1000); diff --git a/src/Server/AllServers.ts b/src/Server/AllServers.ts index 5e425487f..edea136b7 100644 --- a/src/Server/AllServers.ts +++ b/src/Server/AllServers.ts @@ -204,10 +204,14 @@ export function loadAllServers(saveString: string): void { AllServers = JSON.parse(saveString, Reviver); } -export function saveAllServers(): string { +export function saveAllServers(excludeRunningScripts = false): string { const TempAllServers = JSON.parse(JSON.stringify(AllServers), Reviver); for (const key in TempAllServers) { const server = TempAllServers[key]; + if (excludeRunningScripts) { + server.runningScripts = []; + continue; + } for (let i = 0; i < server.runningScripts.length; ++i) { const runningScriptObj = server.runningScripts[i]; runningScriptObj.logs.length = 0; diff --git a/src/Settings/Settings.ts b/src/Settings/Settings.ts index 153ab43e5..fe27b0def 100644 --- a/src/Settings/Settings.ts +++ b/src/Settings/Settings.ts @@ -117,6 +117,11 @@ interface IDefaultSettings { */ SuppressSavedGameToast: boolean; + /* + * Whether the game should skip saving the running scripts for late game + */ + ExcludeRunningScriptsFromSave: boolean; + /* * Theme colors */ @@ -187,6 +192,7 @@ export const defaultSettings: IDefaultSettings = { SuppressTIXPopup: false, SuppressSavedGameToast: false, UseIEC60027_2: false, + ExcludeRunningScriptsFromSave: false, theme: defaultTheme, styles: defaultStyles, @@ -223,6 +229,7 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = { SuppressTIXPopup: defaultSettings.SuppressTIXPopup, SuppressSavedGameToast: defaultSettings.SuppressSavedGameToast, UseIEC60027_2: defaultSettings.UseIEC60027_2, + ExcludeRunningScriptsFromSave: defaultSettings.ExcludeRunningScriptsFromSave, MonacoTheme: "monokai", MonacoInsertSpaces: false, MonacoFontSize: 20, diff --git a/src/ui/React/GameOptionsRoot.tsx b/src/ui/React/GameOptionsRoot.tsx index 263a87661..c93b8cadb 100644 --- a/src/ui/React/GameOptionsRoot.tsx +++ b/src/ui/React/GameOptionsRoot.tsx @@ -426,6 +426,14 @@ export function GameOptionsRoot(props: IProps): React.ReactElement { If this is set all references to memory will use GiB instead of GB, in accordance with IEC 60027-2. } /> + + Settings.ExcludeRunningScriptsFromSave = newValue} + text="Exclude Running Scripts from Save" + tooltip={<> + If this is set, the save file will exclude all running scripts. This is only useful if your save is lagging a lot. You'll have to restart your script every time you launch the game. + } /> +