diff --git a/dist/engine.bundle.js b/dist/engine.bundle.js index d6cb67557..82e4ecfd4 100644 --- a/dist/engine.bundle.js +++ b/dist/engine.bundle.js @@ -31192,7 +31192,22 @@ function NetscriptFunctions(workerScript) { throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "Invalid scriptname or numThreads argument passed to spawn()"); } setTimeout(()=>{ - NetscriptFunctions(workerScript).run.apply(this, arguments); + if (scriptname === undefined) { + throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "spawn() call has incorrect number of arguments. Usage: spawn(scriptname, numThreads, [arg1], [arg2]...)"); + } + if (isNaN(threads) || threads < 1) { + throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument for thread count passed into run(). Must be numeric and greater than 0"); + } + var argsForNewScript = []; + for (var i = 2; i < arguments.length; ++i) { + argsForNewScript.push(arguments[i]); + } + var scriptServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_18__["getServer"])(workerScript.serverIp); + if (scriptServer == null) { + throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "Could not find server. This is a bug in the game. Report to game dev"); + } + + return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["runScriptFromScript"])(scriptServer, scriptname, argsForNewScript, workerScript, threads); }, 20000); if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.spawn == null) { workerScript.scriptRef.log("spawn() will execute " + scriptname + " in 20 seconds"); @@ -31257,10 +31272,7 @@ function NetscriptFunctions(workerScript) { return scriptsRunning; }, exit : function() { - if (workerScript.checkingRam) { - return updateStaticRam("exit", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptKillRamCost); - } - updateDynamicRam("exit", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptKillRamCost); + if (workerScript.checkingRam) {return 0;} var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_18__["getServer"])(workerScript.serverIp); if (server == null) { throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "Error getting Server for this script in exit(). This is a bug please contact game dev"); diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst index 44e406d3e..54ae22a3f 100644 --- a/doc/source/changelog.rst +++ b/doc/source/changelog.rst @@ -3,6 +3,21 @@ Changelog ========= +v0.38.1 - 6/15/2018 +------------------- +* Bug Fix: Using 'Object.prototype' functions like toLocaleString() or toString() should no longer cause errors in NetscriptJS +* Implemented by Github user hydroflame: + * Accessing the 'window' and 'document' objects in Netscript JS now requires a large amount of RAM (100 GB) + * Added game option to suppress travel confirmation + * Text on buttons can no longer be highlighted + * Bug Fix: Fixed an issue that caused NaN values when exporting Real Estate in Corporations + * Bug Fix: Competition and Demand displays in Corporation are now correct (were reversed before) + * Added ps() Netscript function + * Bug Fix: grow() should no longer return/log a negative value when it runs on a server that's already at max money + * Bug Fix: serverExists() Netscript function should now properly return false for non-existent hostname/ips + * Bug Fix: Sever's security level should now properly increase when its money is grown to max value + + v0.38.0 - 6/12/2018 ------------------- * New BitNode: BN-12 The Recursion - Implemented by Github user hydroflame diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index 3f0ab4243..4bb78213c 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -646,7 +646,22 @@ function NetscriptFunctions(workerScript) { throw makeRuntimeRejectMsg(workerScript, "Invalid scriptname or numThreads argument passed to spawn()"); } setTimeout(()=>{ - NetscriptFunctions(workerScript).run.apply(this, arguments); + if (scriptname === undefined) { + throw makeRuntimeRejectMsg(workerScript, "spawn() call has incorrect number of arguments. Usage: spawn(scriptname, numThreads, [arg1], [arg2]...)"); + } + if (isNaN(threads) || threads < 1) { + throw makeRuntimeRejectMsg(workerScript, "Invalid argument for thread count passed into run(). Must be numeric and greater than 0"); + } + var argsForNewScript = []; + for (var i = 2; i < arguments.length; ++i) { + argsForNewScript.push(arguments[i]); + } + var scriptServer = getServer(workerScript.serverIp); + if (scriptServer == null) { + throw makeRuntimeRejectMsg(workerScript, "Could not find server. This is a bug in the game. Report to game dev"); + } + + return runScriptFromScript(scriptServer, scriptname, argsForNewScript, workerScript, threads); }, 20000); if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.spawn == null) { workerScript.scriptRef.log("spawn() will execute " + scriptname + " in 20 seconds"); @@ -711,10 +726,7 @@ function NetscriptFunctions(workerScript) { return scriptsRunning; }, exit : function() { - if (workerScript.checkingRam) { - return updateStaticRam("exit", CONSTANTS.ScriptKillRamCost); - } - updateDynamicRam("exit", CONSTANTS.ScriptKillRamCost); + if (workerScript.checkingRam) {return 0;} var server = getServer(workerScript.serverIp); if (server == null) { throw makeRuntimeRejectMsg(workerScript, "Error getting Server for this script in exit(). This is a bug please contact game dev");