From 61cea12ca237b85e3b86fcff0028b8fcadebb13d Mon Sep 17 00:00:00 2001 From: lethern Date: Wed, 19 Jan 2022 19:09:33 +0100 Subject: [PATCH] purchaseServer: improved error message for ram > maxRam --- src/NetscriptFunctions.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index dfa931e6c..faafef35c 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -1631,7 +1631,12 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { const cost = getPurchaseServerCost(ram); if (cost === Infinity) { - workerScript.log("purchaseServer", () => `Invalid argument: ram='${ram}' must be a positive power of 2`); + if(ram > getPurchaseServerMaxRam()){ + workerScript.log("purchaseServer", () => `Invalid argument: ram='${ram}' must not be greater than getPurchaseServerMaxRam`); + }else{ + workerScript.log("purchaseServer", () => `Invalid argument: ram='${ram}' must be a positive power of 2`); + } + return ""; }