diff --git a/css/styles.css b/css/styles.css
index c26064b68..d958405aa 100644
--- a/css/styles.css
+++ b/css/styles.css
@@ -237,6 +237,7 @@ tr:focus {
right: 0;
bottom: 0;
padding: 4px;
+ margin-right: 14px;
background-color: transparent;
z-index: 2;
}
@@ -250,7 +251,7 @@ tr:focus {
position: absolute; /* Stay in place */
right: 0;
top: 0;
- height: 175px; /* Full height */
+ height: 185px; /* Full height */
/*margin: 50% auto;*/
padding: 5px;
border: 2px solid var(--my-highlight-color);
@@ -262,12 +263,13 @@ tr:focus {
#character-overview-text {
padding: 4px;
- margin: 12px;
+ margin: 10px;
color: white;
background-color: #444;
}
-#character-overview-save-button {
+#character-overview-save-button,
+#character-overview-options-button {
color: #aaa;
font-size: 16px;
font-weight: bold;
@@ -280,8 +282,14 @@ tr:focus {
}
#character-overview-save-button:hover,
-#character-overview-save-button:focus {
+#character-overview-save-button:focus,
+#character-overview-options-button:hover,
+#character-overview-options-button:focus {
color: white;
text-decoration: none;
cursor: pointer;
}
+
+#character-overview-options-button {
+ display: inline-block;
+}
diff --git a/index.html b/index.html
index 7f66c8930..3f1f94613 100644
--- a/index.html
+++ b/index.html
@@ -732,6 +732,7 @@
diff --git a/src/NetscriptEvaluator.js b/src/NetscriptEvaluator.js
index 07162262a..464156d8b 100644
--- a/src/NetscriptEvaluator.js
+++ b/src/NetscriptEvaluator.js
@@ -974,6 +974,10 @@ function runScriptFromScript(server, scriptname, workerScript, threads=1) {
var script = server.scripts[i];
script.threads = threads;
server.runningScripts.push(script.filename); //Push onto runningScripts
+ script.moneyStolenMap = new AllServersMap();
+ script.numTimesHackMap = new AllServersMap();
+ script.numTimesGrowMap = new AllServersMap();
+ script.numTimesWeakenMap = new AllServersMap();
addWorkerScript(script, server);
resolve(true);
return;
diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js
index ef567287b..be368d979 100644
--- a/src/NetscriptFunctions.js
+++ b/src/NetscriptFunctions.js
@@ -181,10 +181,12 @@ function netscriptHack(exp, workerScript) {
var moneyGained = scriptCalculatePercentMoneyHacked(server);
moneyGained = Math.floor(server.moneyAvailable * moneyGained) * threads;
- //Safety check
+ //Over-the-top safety checks
if (moneyGained <= 0) {moneyGained = 0;}
-
+ if (moneyGained > server.moneyAvailable) {moneyGained = server.moneyAvailable;}
server.moneyAvailable -= moneyGained;
+ if (server.moneyAvailable < 0) {server.moneyAvailable = 0;}
+
Player.gainMoney(moneyGained);
workerScript.scriptRef.onlineMoneyMade += moneyGained;
workerScript.scriptRef.recordHack(server.ip, moneyGained, threads);
diff --git a/src/NetscriptWorker.js b/src/NetscriptWorker.js
index 8009b0a0e..3a4935fd8 100644
--- a/src/NetscriptWorker.js
+++ b/src/NetscriptWorker.js
@@ -133,10 +133,10 @@ function runScriptsLoop() {
}
}
//Reset the correspondings script's maps to save space
- //workerScripts[i].scriptRef.moneyStolenMap = {};
- //workerScripts[i].scriptRef.numTimesHackMap = {};
- //workerScripts[i].scriptRef.numTimesGrowMap = {};
- //workerScripts[i].scriptRef.numTimesWeakenMap = {};
+ workerScripts[i].scriptRef.moneyStolenMap = {};
+ workerScripts[i].scriptRef.numTimesHackMap = {};
+ workerScripts[i].scriptRef.numTimesGrowMap = {};
+ workerScripts[i].scriptRef.numTimesWeakenMap = {};
//Free RAM
AllServers[ip].ramUsed -= workerScripts[i].ramUsage;
diff --git a/src/Script.js b/src/Script.js
index 7c6c439e1..0059e2756 100644
--- a/src/Script.js
+++ b/src/Script.js
@@ -372,8 +372,20 @@ scriptCalculateOfflineProduction = function(script) {
//4 hours (14400 sec) then we are completely confident in its ability
var confidence = (script.onlineRunningTime) / 14400;
if (confidence >= 1) {confidence = 1;}
- console.log("onlineRunningTime: " + script.onlineRunningTime);
- console.log("Confidence: " + confidence);
+
+ //Grow
+ for (var ip in script.numTimesGrowMap) {
+ if (script.numTimesGrowMap.hasOwnProperty(ip)) {
+ if (script.numTimesGrowMap[ip] == 0 || script.numTimesGrowMap[ip] == null) {continue;}
+ var serv = AllServers[ip];
+ if (serv == null) {continue;}
+ var timesGrown = Math.round(0.5 * script.numTimesGrowMap[ip] / script.onlineRunningTime * timePassed);
+ console.log(script.filename + " called grow() on " + serv.hostname + " " + timesGrown + " times while offline");
+ script.log("Called grow() on " + serv.hostname + " " + timesGrown + " times while offline");
+ var growth = processSingleServerGrowth(serv, timesGrown * 450);
+ script.log(serv.hostname + " grown by " + formatNumber(growth * 100 - 100, 6) + "% from grow() calls made while offline");
+ }
+ }
var totalOfflineProduction = 0;
for (var ip in script.moneyStolenMap) {
@@ -433,20 +445,6 @@ scriptCalculateOfflineProduction = function(script) {
}
}
- //Grow
- for (var ip in script.numTimesGrowMap) {
- if (script.numTimesGrowMap.hasOwnProperty(ip)) {
- if (script.numTimesGrowMap[ip] == 0 || script.numTimesGrowMap[ip] == null) {continue;}
- var serv = AllServers[ip];
- if (serv == null) {continue;}
- var timesGrown = Math.round(0.5 * script.numTimesGrowMap[ip] / script.onlineRunningTime * timePassed);
- console.log(script.filename + " called grow() on " + serv.hostname + " " + timesGrown + " times while offline");
- script.log("Called grow() on " + serv.hostname + " " + timesGrown + " times while offline");
- var growth = processSingleServerGrowth(serv, timesGrown * 450);
- script.log(serv.hostname + " grown by " + formatNumber(growth * 100 - 100, 6) + "% from grow() calls made while offline");
- }
- }
-
return totalOfflineProduction;
}
diff --git a/src/Terminal.js b/src/Terminal.js
index 6ebf3d1f9..24d05e666 100644
--- a/src/Terminal.js
+++ b/src/Terminal.js
@@ -1237,7 +1237,10 @@ var Terminal = {
server.runningScripts.push(script.filename); //Push onto runningScripts
//Initialize the maps for counting grow/hack/weaken
- //script.moneyStolenMap = new AllServersMap();
+ script.moneyStolenMap = new AllServersMap();
+ script.numTimesHackMap = new AllServersMap();
+ script.numTimesGrowMap = new AllServersMap();
+ script.numTimesWeakenMap = new AllServersMap();
addWorkerScript(script, server);
return;
diff --git a/src/engine.js b/src/engine.js
index 809937fd3..92f77ff39 100644
--- a/src/engine.js
+++ b/src/engine.js
@@ -908,13 +908,17 @@ var Engine = {
return false;
});
- //Character Overview Save button
- var charOverviewSaveButton = document.getElementById("character-overview-save-button");
- charOverviewSaveButton.addEventListener("click", function() {
+ //Character Overview buttons
+ document.getElementById("character-overview-save-button").addEventListener("click", function() {
saveObject.saveGame();
return false;
});
+ document.getElementById("character-overview-options-button").addEventListener("click", function() {
+ gameOptionsBoxOpen();
+ return false;
+ });
+
//Script Editor Netscript documentation button
var netscriptDocButton = document.getElementById("script-editor-netscript-doc-button");
netscriptDocButton.addEventListener("click", function() {