Merge pull request #941 from danielyxie/dev

hotfix for some stuff
This commit is contained in:
hydroflame 2021-05-05 21:07:09 -04:00 committed by GitHub
commit ce0c3d71f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 43 additions and 38 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,11 +1,12 @@
hashGainRate() Netscript Function hashGainRate() Netscript Function
========================================== ==========================================
.. js:function:: hashGainRate(level, ram, core[, mult]) .. js:function:: hashGainRate(level, ramUsed, maxRam, core[, mult])
:RAM cost: 0 GB :RAM cost: 0 GB
:param number level: level of the server. :param number level: level of the server.
:param number ram: ram of the server. :param number ramUsed: ram used on the server.
:param number maxRam: max ram of the server.
:param number core: cores of the server. :param number core: cores of the server.
:returns: Money per second that a server with those stats would gain per second. :returns: Money per second that a server with those stats would gain per second.
@ -18,7 +19,7 @@ hashGainRate() Netscript Function
.. code-block:: javascript .. code-block:: javascript
server = hacknet.getNodeStats(1); server = hacknet.getNodeStats(1);
currentRate = formulas.hacknetNodes.hashGainRate(server.level, server.ram, server.cores); currentRate = formulas.hacknetNodes.hashGainRate(server.level, 0, server.ram, server.cores);
levelRate = formulas.hacknetNodes.hashGainRate(server.level+1, server.ram, server.cores); levelRate = formulas.hacknetNodes.hashGainRate(server.level+1, 0, server.ram, server.cores);
ramRate = formulas.hacknetNodes.hashGainRate(server.level, server.ram*2, server.cores); ramRate = formulas.hacknetNodes.hashGainRate(server.level, 0, server.ram*2, server.cores);
coresRate = formulas.hacknetNodes.hashGainRate(server.level, server.ram, server.cores+1); coresRate = formulas.hacknetNodes.hashGainRate(server.level, 0, server.ram, server.cores+1);

@ -4,4 +4,4 @@ maxNumNodes() Netscript Function
.. js:function:: maxNumNodes() .. js:function:: maxNumNodes()
:RAM cost: 0 GB :RAM cost: 0 GB
:returns: Maximum number of Hacknet Nodes you can own. :returns: Maximum number of Hacknet Nodes you can own, unless you have not unlocked HackNet servers. Then, it returns Infinity.

@ -587,14 +587,14 @@
Copy Save data to Clipboard Copy Save data to Clipboard
</button> </button>
<button id="debug-delete-scripts-link" class="a-link-button tooltip"> <button id="debug-delete-scripts-link" class="a-link-button tooltip">
(DEBUG) Delete Active Scripts Delete all active scripts
<span class="tooltiptextleft"> <span class="tooltiptextleft">
Debug option used to forcefully kill all active running scripts, in case there is a bug or some unexpected issue with the game. After Forcefully kill all active running scripts, in case there is a bug or some unexpected issue with the game. After
using this, save the game and then reload the page. using this, save the game and then reload the page.
</span> </span>
</button> </button>
<button id="debug-soft-reset" class="a-link-button tooltip"> <button id="debug-soft-reset" class="a-link-button tooltip">
(DEBUG) Soft Reset Soft Reset
<span class="tooltiptextleft"> <span class="tooltiptextleft">
Perform a soft reset. Resets everything as if you had just purchased an Augmentation. Perform a soft reset. Resets everything as if you had just purchased an Augmentation.
</span> </span>

@ -4447,9 +4447,9 @@ function NetscriptFunctions(workerScript) {
}, },
}, },
hacknetServers: { hacknetServers: {
hashGainRate: function(level, ram, cores, mult=1) { hashGainRate: function(level, ramUsed, maxRam, cores, mult=1) {
checkFormulasAccess("hacknetServers.hashGainRate", 9); checkFormulasAccess("hacknetServers.hashGainRate", 9);
return HScalculateHashGainRate(level, ram, cores, mult); return HScalculateHashGainRate(level, ramUsed, maxRam, cores, mult=1);
}, },
levelUpgradeCost: function(startingLevel, extraLevels=1, costMult=1) { levelUpgradeCost: function(startingLevel, extraLevels=1, costMult=1) {
checkFormulasAccess("hacknetServers.levelUpgradeCost", 9); checkFormulasAccess("hacknetServers.levelUpgradeCost", 9);

@ -586,7 +586,8 @@ let Terminal = {
const org = currServ.organizationName const org = currServ.organizationName
post("Organization name: " + (!isHacknet ? org : "Player")); post("Organization name: " + (!isHacknet ? org : "Player"));
const admin = currServ.hasAdminRights; const admin = currServ.hasAdminRights;
post("Root Access: " + (!isHacknet ? "YES" : "NO")); let hasAdminRights = !isHacknet && currServ.hasAdminRights || isHacknet;
post("Root Access: " + (hasAdminRights ? "YES" : "NO"));
const hackingSkill = currServ.requiredHackingSkill const hackingSkill = currServ.requiredHackingSkill
post("Required hacking skill: " + (!isHacknet ? hackingSkill : "N/A")); post("Required hacking skill: " + (!isHacknet ? hackingSkill : "N/A"));
const security = currServ.hackDifficulty; const security = currServ.hackDifficulty;
@ -965,7 +966,8 @@ let Terminal = {
} }
const server = Player.getCurrentServer(); const server = Player.getCurrentServer();
if(!server.scripts.some(script => script.filename.startsWith(evaledDir))) { if(!server.scripts.some(script => script.filename.startsWith(evaledDir)) &&
!server.textFiles.some(file => file.fn.startsWith(evaledDir))) {
postError("Invalid path. Failed to change directories"); postError("Invalid path. Failed to change directories");
return; return;
} }

@ -107,10 +107,10 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
{ {
desc: (n: number): string => { desc: (n: number): string => {
return ["It is possible write four as a sum in exactly four different ways:\n\n", return ["It is possible write four as a sum in exactly four different ways:\n\n",
" 3 + 1\n", "&nbsp;&nbsp;&nbsp;&nbsp;3 + 1\n",
" 2 + 2\n", "&nbsp;&nbsp;&nbsp;&nbsp;2 + 2\n",
" 2 + 1 + 1\n", "&nbsp;&nbsp;&nbsp;&nbsp;2 + 1 + 1\n",
" 1 + 1 + 1 + 1\n\n", "&nbsp;&nbsp;&nbsp;&nbsp;1 + 1 + 1 + 1\n\n",
`How many different ways can the number ${n} be written as a sum of at least`, `How many different ways can the number ${n} be written as a sum of at least`,
"two positive integers?"].join(" "); "two positive integers?"].join(" ");
}, },
@ -142,17 +142,17 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
} }
d += ["\nHere is an example of what spiral order should be:", d += ["\nHere is an example of what spiral order should be:",
"\nExample:", "\nExample:",
" [\n", "&nbsp;&nbsp;&nbsp;&nbsp;[\n",
" [1, 2, 3],\n", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[1, 2, 3],\n",
" [4, 5, 6],\n", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[4, 5, 6],\n",
" [7, 8, 9]\n", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[7, 8, 9]\n",
" ] should result in [1, 2, 3, 6, 9, 8 ,7, 4, 5]\n\n", "&nbsp;&nbsp;&nbsp;&nbsp;] should result in [1, 2, 3, 6, 9, 8 ,7, 4, 5]\n\n",
"Note that the matrix will not always be square:\n", "Note that the matrix will not always be square:\n",
" [\n", "&nbsp;&nbsp;&nbsp;&nbsp;[\n",
" [1, 2, 3, 4]\n", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[1, 2, 3, 4]\n",
" [5, 6, 7, 8]\n", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[5, 6, 7, 8]\n",
" [9, 10, 11, 12]\n", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[9, 10, 11, 12]\n",
" ] should result in [1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7"].join(" "); "&nbsp;&nbsp;&nbsp;&nbsp;] should result in [1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7"].join(" ");
return d; return d;
}, },

@ -63,7 +63,7 @@ import {
scriptEditorInit, scriptEditorInit,
updateScriptEditorContent, updateScriptEditorContent,
} from "./Script/ScriptHelpers"; } from "./Script/ScriptHelpers";
import { initForeignServers } from "./Server/AllServers"; import { initForeignServers, AllServers } from "./Server/AllServers";
import { Settings } from "./Settings/Settings"; import { Settings } from "./Settings/Settings";
import { updateSourceFileFlags } from "./SourceFile/SourceFileFlags"; import { updateSourceFileFlags } from "./SourceFile/SourceFileFlags";
import { initSpecialServerIps } from "./Server/SpecialServerIps"; import { initSpecialServerIps } from "./Server/SpecialServerIps";
@ -1542,8 +1542,10 @@ const Engine = {
// DEBUG Delete active Scripts on home // DEBUG Delete active Scripts on home
document.getElementById("debug-delete-scripts-link").addEventListener("click", function() { document.getElementById("debug-delete-scripts-link").addEventListener("click", function() {
Player.getHomeComputer().runningScripts = []; for(const hostname of Object.keys(AllServers)) {
dialogBoxCreate("Forcefully deleted all running scripts on home computer. Please save and refresh page"); AllServers[hostname].runningScripts = [];
}
dialogBoxCreate("Forcefully deleted all running scripts. Please save and refresh page.");
gameOptionsBoxClose(); gameOptionsBoxClose();
return false; return false;
}); });

@ -600,14 +600,14 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
Copy Save data to Clipboard Copy Save data to Clipboard
</button> </button>
<button id="debug-delete-scripts-link" class="a-link-button tooltip"> <button id="debug-delete-scripts-link" class="a-link-button tooltip">
(DEBUG) Delete Active Scripts Delete all active scripts
<span class="tooltiptextleft"> <span class="tooltiptextleft">
Debug option used to forcefully kill all active running scripts, in case there is a bug or some unexpected issue with the game. After Forcefully kill all active running scripts, in case there is a bug or some unexpected issue with the game. After
using this, save the game and then reload the page. using this, save the game and then reload the page.
</span> </span>
</button> </button>
<button id="debug-soft-reset" class="a-link-button tooltip"> <button id="debug-soft-reset" class="a-link-button tooltip">
(DEBUG) Soft Reset Soft Reset
<span class="tooltiptextleft"> <span class="tooltiptextleft">
Perform a soft reset. Resets everything as if you had just purchased an Augmentation. Perform a soft reset. Resets everything as if you had just purchased an Augmentation.
</span> </span>

@ -42,7 +42,7 @@ export class CodingContractPopup extends React.Component<IProps, IState>{
const contractType: CodingContractType = CodingContractTypes[this.props.c.type]; const contractType: CodingContractType = CodingContractTypes[this.props.c.type];
let description = []; let description = [];
for (const [i, value] of contractType.desc(this.props.c.data).split('\n').entries()) for (const [i, value] of contractType.desc(this.props.c.data).split('\n').entries())
description.push(<span key={i}>{value}<br/></span>); description.push(<span key={i} dangerouslySetInnerHTML={{__html: value+'<br />'}}></span>);
return ( return (
<div> <div>
<CopyableText value={this.props.c.type} tag={ClickableTag.Tag_h1} /> <CopyableText value={this.props.c.type} tag={ClickableTag.Tag_h1} />