mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-24 07:02:26 +01:00
Added RAM usage calculations for wget() Netscript fn
This commit is contained in:
parent
22e909eb14
commit
c248ca9383
@ -85,6 +85,7 @@ let CONSTANTS = {
|
|||||||
ScriptGetScriptRamCost: 0.1,
|
ScriptGetScriptRamCost: 0.1,
|
||||||
ScriptGetHackTimeRamCost: 0.05,
|
ScriptGetHackTimeRamCost: 0.05,
|
||||||
ScriptGetFavorToDonate: 0.10,
|
ScriptGetFavorToDonate: 0.10,
|
||||||
|
ScriptWgetRamCost: 5,
|
||||||
ScriptCodingContractBaseRamCost:10,
|
ScriptCodingContractBaseRamCost:10,
|
||||||
|
|
||||||
ScriptSingularityFn1RamCost: 1,
|
ScriptSingularityFn1RamCost: 1,
|
||||||
|
@ -2262,6 +2262,10 @@ function NetscriptFunctions(workerScript) {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
wget : async function(url, target, ip=workerScript.serverIp) {
|
wget : async function(url, target, ip=workerScript.serverIp) {
|
||||||
|
if (workerScript.checkingRam) {
|
||||||
|
return updateStaticRam("wget", CONSTANTS.ScriptWgetRamCost);
|
||||||
|
}
|
||||||
|
updateDynamicRam("wget", CONSTANTS.ScriptWgetRamCost);
|
||||||
if (!isScriptFilename(target) && !target.endsWith(".txt")) {
|
if (!isScriptFilename(target) && !target.endsWith(".txt")) {
|
||||||
workerSript.log(`ERROR: wget() failed because of an invalid target file: ${target}. Target file must be a script or text file`);
|
workerSript.log(`ERROR: wget() failed because of an invalid target file: ${target}. Target file must be a script or text file`);
|
||||||
return false;
|
return false;
|
||||||
|
@ -517,6 +517,12 @@ function parseOnlyRamCalculate(server, code, workerScript) {
|
|||||||
function applyFuncRam(func) {
|
function applyFuncRam(func) {
|
||||||
if (typeof func === "function") {
|
if (typeof func === "function") {
|
||||||
try {
|
try {
|
||||||
|
let res;
|
||||||
|
if (func instance of (async () => {}).constructor) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
let res = func.apply(null, []);
|
let res = func.apply(null, []);
|
||||||
if (typeof res === "number") {
|
if (typeof res === "number") {
|
||||||
return res;
|
return res;
|
||||||
|
Loading…
Reference in New Issue
Block a user