mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 21:53:50 +01:00
Fixed bug and added compatibility for converting RunningScript offline dataMap to version v0.43.1
This commit is contained in:
parent
1d0515a957
commit
08417f250e
2
dist/engine.bundle.js
vendored
2
dist/engine.bundle.js
vendored
File diff suppressed because one or more lines are too long
@ -22,6 +22,7 @@ import {gameOptionsBoxClose} from "../utils/GameOptions";
|
||||
import {clearEventListeners} from "../utils/uiHelpers/clearEventListeners";
|
||||
import {Reviver, Generic_toJSON,
|
||||
Generic_fromJSON} from "../utils/JSONReviver";
|
||||
import { convertTimeMsToTimeElapsedString } from "../utils/StringHelperFunctions";
|
||||
import {createElement} from "../utils/uiHelpers/createElement";
|
||||
import {createPopup} from "../utils/uiHelpers/createPopup";
|
||||
import {createStatusText} from "./ui/createStatusText";
|
||||
@ -509,9 +510,11 @@ function loadImportedGame(saveObj, saveString) {
|
||||
|
||||
Player.lastUpdate = Engine._lastUpdate;
|
||||
Engine.start(); //Run main game loop and Scripts loop
|
||||
dialogBoxCreate("While you were offline, your scripts generated <span class='money-gold'>$" +
|
||||
numeralWrapper.format(offlineProductionFromScripts, '0,0.00') + "</span> and your Hacknet Nodes generated <span class='money-gold'>$" +
|
||||
numeralWrapper.format(offlineProductionFromHacknetNodes, '0,0.00') + "</span>");
|
||||
const timeOfflineString = convertTimeMsToTimeElapsedString(time);
|
||||
dialogBoxCreate(`Offline for ${timeOfflineString}. While you were offline, your scripts ` +
|
||||
"generated <span class='money-gold'>" +
|
||||
numeralWrapper.formatMoney(offlineProductionFromScripts) + "</span> and your Hacknet Nodes generated <span class='money-gold'>" +
|
||||
numeralWrapper.formatMoney(offlineProductionFromHacknetNodes) + "</span>");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -812,6 +812,9 @@ function loadAllRunningScripts() {
|
||||
}
|
||||
|
||||
function scriptCalculateOfflineProduction(runningScriptObj) {
|
||||
console.log("Calculating offline production for: ");
|
||||
console.log(runningScriptObj);
|
||||
|
||||
//The Player object stores the last update time from when we were online
|
||||
var thisUpdate = new Date().getTime();
|
||||
var lastUpdate = Player.lastUpdate;
|
||||
|
@ -1905,7 +1905,7 @@ let Terminal = {
|
||||
}
|
||||
const scriptname = commandArray[1];
|
||||
if (!scriptname.endsWith(".lit") && !isScriptFilename(scriptname) && !scriptname.endsWith(".txt")) {
|
||||
postError("scp only works for .script, .txt, and .lit files");
|
||||
postError("scp only works for scripts, text files (.txt), and literature files (.lit)");
|
||||
return;
|
||||
}
|
||||
const destServer = getServer(commandArray[2]);
|
||||
|
@ -1365,9 +1365,11 @@ const Engine = {
|
||||
Player.lastUpdate = Engine._lastUpdate;
|
||||
Engine.start(); //Run main game loop and Scripts loop
|
||||
removeLoadingScreen();
|
||||
dialogBoxCreate("While you were offline, your scripts generated <span class='money-gold'>$" +
|
||||
formatNumber(offlineProductionFromScripts, 2) + "</span> and your Hacknet Nodes generated <span class='money-gold'>$" +
|
||||
formatNumber(offlineProductionFromHacknetNodes, 2) + "</span>");
|
||||
const timeOfflineString = convertTimeMsToTimeElapsedString(time);
|
||||
dialogBoxCreate(`Offline for ${timeOfflineString}. While you were offline, your scripts ` +
|
||||
"generated <span class='money-gold'>" +
|
||||
numeralWrapper.formatMoney(offlineProductionFromScripts) + "</span> and your Hacknet Nodes generated <span class='money-gold'>" +
|
||||
numeralWrapper.formatMoney(offlineProductionFromHacknetNodes) + "</span>");
|
||||
//Close main menu accordions for loaded game
|
||||
var visibleMenuTabs = [terminal, createScript, activeScripts, stats,
|
||||
hacknetnodes, city, tutorial, options, dev];
|
||||
|
@ -15,7 +15,15 @@ function Reviver(key, value) {
|
||||
if (typeof value === "object" &&
|
||||
typeof value.ctor === "string" &&
|
||||
typeof value.data !== "undefined") {
|
||||
// Compatibility for version v0.43.1
|
||||
// TODO Remove this eventually
|
||||
if (value.ctor === "AllServersMap") {
|
||||
console.log('Converting AllServersMap for v0.43.1');
|
||||
return value.data;
|
||||
}
|
||||
|
||||
ctor = Reviver.constructors[value.ctor] || window[value.ctor];
|
||||
|
||||
if (typeof ctor === "function" &&
|
||||
typeof ctor.fromJSON === "function") {
|
||||
|
||||
@ -45,7 +53,7 @@ function Generic_toJSON(ctorName, obj, keys) {
|
||||
}
|
||||
|
||||
data = {};
|
||||
for (index = 0; index < keys.length; ++index) {
|
||||
for (let index = 0; index < keys.length; ++index) {
|
||||
key = keys[index];
|
||||
data[key] = obj[key];
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ function convertTimeMsToTimeElapsedString(time: number): string {
|
||||
if (days > 0) {res += `${days} days `; }
|
||||
if (hours > 0) {res += `${hours} hours `; }
|
||||
if (minutes > 0) {res += `${minutes} minutes `; }
|
||||
res += `${seconds} seconds `;
|
||||
res += `${seconds} seconds`;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user