mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 09:43:54 +01:00
Add option to exclude running scripts from save
This commit is contained in:
parent
ea2f53e3b4
commit
b22eb58aba
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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.
|
||||
</>} />
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<OptionSwitch checked={Settings.ExcludeRunningScriptsFromSave}
|
||||
onChange={(newValue) => 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.
|
||||
</>} />
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<Tooltip
|
||||
title={
|
||||
|
Loading…
Reference in New Issue
Block a user