Minor bugfixes for a variety of NS functions. After infiltration, UI returns to corp page rather than city page

This commit is contained in:
danielyxie
2019-07-05 00:26:22 -07:00
committed by danielyxie
parent 200ccd3ad0
commit 6ae7b0136c
5 changed files with 30 additions and 4 deletions
+9 -1
View File
@@ -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");