diff --git a/src/Constants.js b/src/Constants.js index 587c42636..bdbdc3057 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -492,22 +492,23 @@ let CONSTANTS = { LatestUpdate: "v0.40.2
" + - "* Bladeburner Changes:
" + - "*** Added getSkillUpgradeCost() Netscript function to the API
" + - "*** Added getBonusTime() Netscript function to the API
" + - "*** Buffed the effects of many Bladeburner Augmentations
" + - "*** The Blade's Simulacrum Augmentation requires significantly less reputation but slightly more money
" + - "*** Slightly increased the amount of successes needed for a Contract/Operation in order to increase its max level
" + - "*** Increased the amount of money gained from Contracts by ~25%
" + - "*** Increased the base amount of rank gained from Operations by 10%
" + - "*** Significantly increased the 'randomness' in determining a Contract/Operation's initial count and rate of count increase
" + - "*** The number (count) of Operations should now increase significantly faster
" + - "*** There are now, on average, more Synthoid communities in a city
" + - "*** If automation is enabled (the feature in Bladeburner console), then switching to another action such as working for a company will now disable the automation
" + - "* There is now a setting for enabling/disabling the popup that appears when you are hospitalized
" + - "* Bug Fix: Stock market should now be correctly initialized in BitNode-8 (by Kline-)
" + - "* Bug Fix: bladeburner.getCurrentAction() should now properly an 'Idle' object rather than null (by Kline-)
" + - "* Bug Fix: Bladeburner skill cost multiplier should now properly increase in BitNode-12 (by hydroflame)
" + "* Bladeburner Changes:
" + + "*** Added getSkillUpgradeCost() Netscript function to the API
" + + "*** Added getBonusTime() Netscript function to the API
" + + "*** Buffed the effects of many Bladeburner Augmentations
" + + "*** The Blade's Simulacrum Augmentation requires significantly less reputation but slightly more money
" + + "*** Slightly increased the amount of successes needed for a Contract/Operation in order to increase its max level
" + + "*** Increased the amount of money gained from Contracts by ~25%
" + + "*** Increased the base amount of rank gained from Operations by 10%
" + + "*** Significantly increased the 'randomness' in determining a Contract/Operation's initial count and rate of count increase
" + + "*** The number (count) of Operations should now increase significantly faster
" + + "*** There are now, on average, more Synthoid communities in a city
" + + "*** If automation is enabled (the feature in Bladeburner console), then switching to another action such as working for a company will now disable the automation
" + + "* There is now a setting for enabling/disabling the popup that appears when you are hospitalized
" + + "* Bug Fix: Stock market should now be correctly initialized in BitNode-8 (by Kline-)
" + + "* Bug Fix: bladeburner.getCurrentAction() should now properly an 'Idle' object rather than null (by Kline-)
" + + "* Bug Fix: Bladeburner skill cost multiplier should now properly increase in BitNode-12 (by hydroflame)
" + + "* Bug Fix: 'document', 'hacknet', and 'window' keywords should no longer be counted multiple times in RAM calculations
" } diff --git a/src/Script.js b/src/Script.js index ea8e4b923..fca23dc83 100644 --- a/src/Script.js +++ b/src/Script.js @@ -462,6 +462,18 @@ function parseOnlyRamCalculate(server, code, workerScript) { const resolvedRefs = new Set(); while (unresolvedRefs.length > 0) { const ref = unresolvedRefs.shift(); + + // Check if this is one of the special keys, and add the appropriate ram cost if so. + if (ref === "hacknet" && !resolvedRefs.has("hacknet")) { + ram += CONSTANTS.ScriptHacknetNodesRamCost; + } + if (ref === "document" && !resolvedRefs.has("document")) { + ram += CONSTANTS.ScriptDomRamCost; + } + if (ref === "window" && !resolvedRefs.has("window")) { + ram += CONSTANTS.ScriptDomRamCost; + } + resolvedRefs.add(ref); if (ref.endsWith(".*")) { @@ -479,13 +491,6 @@ function parseOnlyRamCalculate(server, code, workerScript) { } } - // Check if this is one of the special keys, and add the appropriate ram cost if so. - if (ref == specialReferenceIF) ram += CONSTANTS.ScriptIfRamCost; - if (ref == specialReferenceFOR) ram += CONSTANTS.ScriptForRamCost; - if (ref == specialReferenceWHILE) ram += CONSTANTS.ScriptWhileRamCost; - if (ref == "hacknet") ram += CONSTANTS.ScriptHacknetNodesRamCost; - if (ref == "document" || ref == "window") ram += CONSTANTS.ScriptDomRamCost; - // 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 // is in checkingRam mode.