From af2e04db1058dc9a57166d29b761163e1739161c Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Wed, 13 Jun 2018 03:57:25 -0400 Subject: [PATCH] window and document symbold now occur impossibly high ram cost in nsjs --- src/Constants.js | 1 + src/Script.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Constants.js b/src/Constants.js index 3e9055f13..b968247fc 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -43,6 +43,7 @@ let CONSTANTS = { /* Netscript Constants */ //RAM Costs for different commands ScriptBaseRamCost: 1.4, + ScriptCheatRamCost: 1e21, // if someone tries to cheat by using window or document we just spike the ram cost. ScriptWhileRamCost: 0.2, ScriptForRamCost: 0.2, ScriptIfRamCost: 0.15, diff --git a/src/Script.js b/src/Script.js index 8b7b1ee7f..53d03e3c4 100644 --- a/src/Script.js +++ b/src/Script.js @@ -448,6 +448,7 @@ function parseOnlyRamCalculate(server, code, workerScript) { if (ref == specialReferenceFOR) ram += CONSTANTS.ScriptForRamCost; if (ref == specialReferenceWHILE) ram += CONSTANTS.ScriptWhileRamCost; if (ref == "hacknetnodes") ram += CONSTANTS.ScriptHacknetNodesRamCost; + if (ref == "document" || ref == "window") ram += CONSTANTS.ScriptCheatRamCost; // Check if this ident is a function in the workerscript env. If it is, then we need to // get its RAM cost. We do this by calling it, which works because the running script