From b479a3570e0c1bc81a05c2c8fc41b4dee01612cc Mon Sep 17 00:00:00 2001 From: danielyxie Date: Fri, 5 Jul 2019 00:26:22 -0700 Subject: [PATCH] Minor bugfixes for a variety of NS functions. After infiltration, UI returns to corp page rather than city page --- doc/source/netscript/hacknetnodeapi/getNodeStats.rst | 1 + src/Constants.ts | 12 ++++++++++-- src/Infiltration.js | 2 +- src/Locations/ui/UniversityLocation.tsx | 9 +++++++++ src/NetscriptFunctions.js | 10 +++++++++- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/doc/source/netscript/hacknetnodeapi/getNodeStats.rst b/doc/source/netscript/hacknetnodeapi/getNodeStats.rst index e538edc40..a4af7d9ac 100644 --- a/doc/source/netscript/hacknetnodeapi/getNodeStats.rst +++ b/doc/source/netscript/hacknetnodeapi/getNodeStats.rst @@ -15,6 +15,7 @@ getNodeStats() Netscript Function ram: Node's RAM, cores: Node's number of cores, cache: Cache level. Only applicable for Hacknet Servers + hashCapacity: Hash Capacity provided by this Node. Only applicable for Hacknet Servers production: Node's production per second timeOnline: Number of seconds since Node has been purchased, totalProduction: Total amount that the Node has produced diff --git a/src/Constants.ts b/src/Constants.ts index acc890591..3b5fd21a4 100644 --- a/src/Constants.ts +++ b/src/Constants.ts @@ -222,9 +222,17 @@ export let CONSTANTS: IMap = { LatestUpdate: ` v0.47.2 + ------- + + Netscript Changes * Added tail() Netscript function - * Added 'Solarized Dark' theme to CodeMirror editor - * Bug fix: Stock Market UI should no longer crash for certain locale settings + * hacknet.getNodeStats() function now returns an additional property for Hacknet Servers: hashCapacity * Bug fix: workForFaction() function now properly accounts for disabled logs + * When writing to a file, the write() function now casts the data being written to a string (using String()) + + Misc Changes + * Added 'Solarized Dark' theme to CodeMirror editor + * After Infiltration, you will now return to the company page rather than the city page + * Bug fix: Stock Market UI should no longer crash for certain locale settings ` } diff --git a/src/Infiltration.js b/src/Infiltration.js index e7a5c95cd..87b7b0052 100644 --- a/src/Infiltration.js +++ b/src/Infiltration.js @@ -129,7 +129,7 @@ function endInfiltration(inst, success) { clearEventListeners("infiltration-bribe"); clearEventListeners("infiltration-escape"); - Engine.loadLocationContent(); + Engine.loadLocationContent(false); } function nextInfiltrationLevel(inst) { diff --git a/src/Locations/ui/UniversityLocation.tsx b/src/Locations/ui/UniversityLocation.tsx index a5b4d4b0c..fbaa3847c 100644 --- a/src/Locations/ui/UniversityLocation.tsx +++ b/src/Locations/ui/UniversityLocation.tsx @@ -76,37 +76,46 @@ export class UniversityLocation extends React.Component { const managementCost = CONSTANTS.ClassManagementBaseCost * costMult; const leadershipCost = CONSTANTS.ClassLeadershipBaseCost * costMult; + const earnHackingExpTooltip = `Gain hacking experience!` + const earnCharismaExpTooltip = `Gain charisma experience!`; + return (
) diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index b6ed66967..7d4deb32c 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -405,7 +405,7 @@ function NetscriptFunctions(workerScript) { const node = getHacknetNode(i); const hasUpgraded = hasHacknetServers(); const res = { - name: node.name, + name: hasUpgraded ? node.hostname : node.name, level: node.level, ram: hasUpgraded ? node.maxRam : node.ram, cores: node.cores, @@ -416,6 +416,7 @@ function NetscriptFunctions(workerScript) { if (hasUpgraded) { res.cache = node.cache; + res.hashCapacity = node.hashCapacity; } return res; @@ -1993,6 +1994,13 @@ function NetscriptFunctions(workerScript) { throw makeRuntimeRejectMsg(workerScript, `write() failed due to invalid filepath: ${fn}`); } + // Coerce 'data' to be a string + try { + data = String(data); + } catch (e) { + throw makeRuntimeRejectMsg(workerScript, `write() failed because of invalid data (${e}). Data being written must be convertible to a string`); + } + const server = workerScript.getServer(); if (server == null) { throw makeRuntimeRejectMsg(workerScript, "Error getting Server for this script in write(). This is a bug please contact game dev");