more hotfixing

Hotfixed usage tips for alias
Hotfixed prestigeHomeComputer to avoid crashing prestige
Added checking at startWorkerScript to try and find instances where script is launched on wrong server
Fixed corp issue with multibuy not providing multibenefits
This commit is contained in:
omuretsu 2023-05-26 14:59:31 -04:00
parent 912fc98d3a
commit 40babcb2ee
4 changed files with 25 additions and 7 deletions

@ -305,7 +305,7 @@ export class Corporation {
if (this.funds < totalCost) return `Not enough funds to purchase ${amount} of upgrade ${upgradeName}.`; if (this.funds < totalCost) return `Not enough funds to purchase ${amount} of upgrade ${upgradeName}.`;
this.funds -= totalCost; this.funds -= totalCost;
this.upgrades[upgradeName].level += amount; this.upgrades[upgradeName].level += amount;
this.upgrades[upgradeName].value += upgrade.benefit; this.upgrades[upgradeName].value += upgrade.benefit * amount;
// Apply effects for upgrades // Apply effects for upgrades
if (upgradeName === CorpUpgradeName.SmartStorage) { if (upgradeName === CorpUpgradeName.SmartStorage) {

@ -261,6 +261,13 @@ function processNetscript1Imports(code: string, workerScript: WorkerScript): { c
* it is active * it is active
*/ */
export function startWorkerScript(runningScript: RunningScript, server: BaseServer, parent?: WorkerScript): number { export function startWorkerScript(runningScript: RunningScript, server: BaseServer, parent?: WorkerScript): number {
if (server.hostname !== runningScript.server) {
// Temporarily adding a check here to see if this ever triggers
console.error(
`Tried to launch a worker script on a different server ${server.hostname} than the runningScript's server ${runningScript.server}`,
);
return 0;
}
if (createAndAddWorkerScript(runningScript, server, parent)) { if (createAndAddWorkerScript(runningScript, server, parent)) {
// Push onto runningScripts. // Push onto runningScripts.
// This has to come after createAndAddWorkerScript() because that fn updates RAM usage // This has to come after createAndAddWorkerScript() because that fn updates RAM usage

@ -11,6 +11,8 @@ import { LiteratureName } from "../Literature/data/LiteratureNames";
import { Person as IPerson } from "@nsdefs"; import { Person as IPerson } from "@nsdefs";
import { isValidNumber } from "../utils/helpers/isValidNumber"; import { isValidNumber } from "../utils/helpers/isValidNumber";
import { Server as IServer } from "@nsdefs"; import { Server as IServer } from "@nsdefs";
import { workerScripts } from "../Netscript/WorkerScripts";
import { killWorkerScriptByPid } from "../Netscript/killWorkerScript";
/** /**
* Constructs a new server, while also ensuring that the new server * Constructs a new server, while also ensuring that the new server
@ -263,7 +265,16 @@ export function prestigeHomeComputer(homeComp: Server): void {
homeComp.messages.length = 0; //Remove .lit and .msg files homeComp.messages.length = 0; //Remove .lit and .msg files
homeComp.messages.push(LiteratureName.HackersStartingHandbook); homeComp.messages.push(LiteratureName.HackersStartingHandbook);
if (homeComp.runningScriptMap.size !== 0) { if (homeComp.runningScriptMap.size !== 0) {
throw new Error("All programs weren't already killed!"); // Temporary verbose logging section to gather data on a bug
console.error("Some runningScripts were still present on home during prestige");
for (const [scriptKey, byPidMap] of homeComp.runningScriptMap) {
console.error(`script key: ${scriptKey}: ${byPidMap.size} scripts`);
for (const pid of byPidMap.keys()) {
if (workerScripts.has(pid)) killWorkerScriptByPid(pid);
}
byPidMap.clear();
}
homeComp.runningScriptMap.clear();
} }
} }

@ -1,7 +1,7 @@
export const TerminalHelpText: string[] = [ export const TerminalHelpText: string[] = [
"Type 'help name' to learn more about the command ", "Type 'help name' to learn more about the command ",
" ", " ",
' alias [-g] [name="value"] Create or display Terminal aliases', ' alias [-g] ["name=value"] Create or display Terminal aliases',
" analyze Get information about the current machine ", " analyze Get information about the current machine ",
" backdoor Install a backdoor on the current machine ", " backdoor Install a backdoor on the current machine ",
" buy [-l/-a/program] Purchase a program through the Dark Web", " buy [-l/-a/program] Purchase a program through the Dark Web",
@ -69,20 +69,20 @@ const TemplatedHelpTexts: Record<string, (command: string) => string[]> = {
export const HelpTexts: Record<string, string[]> = { export const HelpTexts: Record<string, string[]> = {
alias: [ alias: [
'Usage: alias [-g] [name="value"] ', 'Usage: alias [-g] ["name=value"] ',
" ", " ",
"Create or display aliases. An alias enables a replacement of a word with another string. ", "Create or display aliases. An alias enables a replacement of a word with another string. ",
"It can be used to abbreviate a commonly used command, or commonly used parts of a command. The NAME ", "It can be used to abbreviate a commonly used command, or commonly used parts of a command. The NAME ",
"of an alias defines the word that will be replaced, while the VALUE defines what it will be replaced by. For example, ", "of an alias defines the word that will be replaced, while the VALUE defines what it will be replaced by. For example, ",
"you could create the alias 'nuke' for the Terminal command 'run NUKE.exe' using the following: ", "you could create the alias 'nuke' for the Terminal command 'run NUKE.exe' using the following: ",
" ", " ",
' alias nuke="run NUKE.exe"', ' alias "nuke=run NUKE.exe"',
" ", " ",
"Then, to run the NUKE.exe program you would just have to enter 'nuke' in Terminal rather than the full command. ", "Then, to run the NUKE.exe program you would just have to enter 'nuke' in Terminal rather than the full command. ",
"It is important to note that 'default' aliases will only be substituted for the first word of a Terminal command. For ", "It is important to note that 'default' aliases will only be substituted for the first word of a Terminal command. For ",
"example, if the following alias was set: ", "example, if the following alias was set: ",
" ", " ",
' alias worm="HTTPWorm.exe"', ' alias "worm=HTTPWorm.exe"',
" ", " ",
"and then you tried to run the following terminal command: ", "and then you tried to run the following terminal command: ",
" ", " ",
@ -91,7 +91,7 @@ export const HelpTexts: Record<string, string[]> = {
"This would fail because the worm alias is not the first word of a Terminal command. To allow an alias to be substituted ", "This would fail because the worm alias is not the first word of a Terminal command. To allow an alias to be substituted ",
"anywhere in a Terminal command, rather than just the first word, you must set it to be a global alias using the -g flag: ", "anywhere in a Terminal command, rather than just the first word, you must set it to be a global alias using the -g flag: ",
" ", " ",
' alias -g worm="HTTPWorm.exe"', ' alias -g "worm=HTTPWorm.exe"',
" ", " ",
"Now, the 'worm' alias will be substituted anytime it shows up as an individual word in a Terminal command. ", "Now, the 'worm' alias will be substituted anytime it shows up as an individual word in a Terminal command. ",
" ", " ",