Minor bugfixes for a variety of NS functions. After infiltration, UI returns to corp page rather than city page

This commit is contained in:
danielyxie 2019-07-05 00:26:22 -07:00 committed by danielyxie
parent ac49b8074f
commit b479a3570e
5 changed files with 30 additions and 4 deletions

@ -15,6 +15,7 @@ getNodeStats() Netscript Function
ram: Node's RAM, ram: Node's RAM,
cores: Node's number of cores, cores: Node's number of cores,
cache: Cache level. Only applicable for Hacknet Servers cache: Cache level. Only applicable for Hacknet Servers
hashCapacity: Hash Capacity provided by this Node. Only applicable for Hacknet Servers
production: Node's production per second production: Node's production per second
timeOnline: Number of seconds since Node has been purchased, timeOnline: Number of seconds since Node has been purchased,
totalProduction: Total amount that the Node has produced totalProduction: Total amount that the Node has produced

@ -222,9 +222,17 @@ export let CONSTANTS: IMap<any> = {
LatestUpdate: LatestUpdate:
` `
v0.47.2 v0.47.2
-------
Netscript Changes
* Added tail() Netscript function * Added tail() Netscript function
* Added 'Solarized Dark' theme to CodeMirror editor * hacknet.getNodeStats() function now returns an additional property for Hacknet Servers: hashCapacity
* Bug fix: Stock Market UI should no longer crash for certain locale settings
* Bug fix: workForFaction() function now properly accounts for disabled logs * Bug fix: workForFaction() function now properly accounts for disabled logs
* When writing to a file, the write() function now casts the data being written to a string (using String())
Misc Changes
* Added 'Solarized Dark' theme to CodeMirror editor
* After Infiltration, you will now return to the company page rather than the city page
* Bug fix: Stock Market UI should no longer crash for certain locale settings
` `
} }

@ -129,7 +129,7 @@ function endInfiltration(inst, success) {
clearEventListeners("infiltration-bribe"); clearEventListeners("infiltration-bribe");
clearEventListeners("infiltration-escape"); clearEventListeners("infiltration-escape");
Engine.loadLocationContent(); Engine.loadLocationContent(false);
} }
function nextInfiltrationLevel(inst) { function nextInfiltrationLevel(inst) {

@ -76,37 +76,46 @@ export class UniversityLocation extends React.Component<IProps, any> {
const managementCost = CONSTANTS.ClassManagementBaseCost * costMult; const managementCost = CONSTANTS.ClassManagementBaseCost * costMult;
const leadershipCost = CONSTANTS.ClassLeadershipBaseCost * costMult; const leadershipCost = CONSTANTS.ClassLeadershipBaseCost * costMult;
const earnHackingExpTooltip = `Gain hacking experience!`
const earnCharismaExpTooltip = `Gain charisma experience!`;
return ( return (
<div> <div>
<StdButton <StdButton
onClick={this.study} onClick={this.study}
style={this.btnStyle} style={this.btnStyle}
text={`Study Computer Science (free)`} text={`Study Computer Science (free)`}
tooltip={earnHackingExpTooltip}
/> />
<StdButton <StdButton
onClick={this.dataStructures} onClick={this.dataStructures}
style={this.btnStyle} style={this.btnStyle}
text={`Take Data Structures course (${numeralWrapper.formatMoney(dataStructuresCost)} / sec)`} text={`Take Data Structures course (${numeralWrapper.formatMoney(dataStructuresCost)} / sec)`}
tooltip={earnHackingExpTooltip}
/> />
<StdButton <StdButton
onClick={this.networks} onClick={this.networks}
style={this.btnStyle} style={this.btnStyle}
text={`Take Networks course (${numeralWrapper.formatMoney(networksCost)} / sec)`} text={`Take Networks course (${numeralWrapper.formatMoney(networksCost)} / sec)`}
tooltip={earnHackingExpTooltip}
/> />
<StdButton <StdButton
onClick={this.algorithms} onClick={this.algorithms}
style={this.btnStyle} style={this.btnStyle}
text={`Take Algorithms course (${numeralWrapper.formatMoney(algorithmsCost)} / sec)`} text={`Take Algorithms course (${numeralWrapper.formatMoney(algorithmsCost)} / sec)`}
tooltip={earnHackingExpTooltip}
/> />
<StdButton <StdButton
onClick={this.management} onClick={this.management}
style={this.btnStyle} style={this.btnStyle}
text={`Take Management course (${numeralWrapper.formatMoney(managementCost)} / sec)`} text={`Take Management course (${numeralWrapper.formatMoney(managementCost)} / sec)`}
tooltip={earnCharismaExpTooltip}
/> />
<StdButton <StdButton
onClick={this.leadership} onClick={this.leadership}
style={this.btnStyle} style={this.btnStyle}
text={`Take Leadership course (${numeralWrapper.formatMoney(leadershipCost)} / sec)`} text={`Take Leadership course (${numeralWrapper.formatMoney(leadershipCost)} / sec)`}
tooltip={earnCharismaExpTooltip}
/> />
</div> </div>
) )

@ -405,7 +405,7 @@ function NetscriptFunctions(workerScript) {
const node = getHacknetNode(i); const node = getHacknetNode(i);
const hasUpgraded = hasHacknetServers(); const hasUpgraded = hasHacknetServers();
const res = { const res = {
name: node.name, name: hasUpgraded ? node.hostname : node.name,
level: node.level, level: node.level,
ram: hasUpgraded ? node.maxRam : node.ram, ram: hasUpgraded ? node.maxRam : node.ram,
cores: node.cores, cores: node.cores,
@ -416,6 +416,7 @@ function NetscriptFunctions(workerScript) {
if (hasUpgraded) { if (hasUpgraded) {
res.cache = node.cache; res.cache = node.cache;
res.hashCapacity = node.hashCapacity;
} }
return res; return res;
@ -1993,6 +1994,13 @@ function NetscriptFunctions(workerScript) {
throw makeRuntimeRejectMsg(workerScript, `write() failed due to invalid filepath: ${fn}`); throw makeRuntimeRejectMsg(workerScript, `write() failed due to invalid filepath: ${fn}`);
} }
// Coerce 'data' to be a string
try {
data = String(data);
} catch (e) {
throw makeRuntimeRejectMsg(workerScript, `write() failed because of invalid data (${e}). Data being written must be convertible to a string`);
}
const server = workerScript.getServer(); const server = workerScript.getServer();
if (server == null) { if (server == null) {
throw makeRuntimeRejectMsg(workerScript, "Error getting Server for this script in write(). This is a bug please contact game dev"); throw makeRuntimeRejectMsg(workerScript, "Error getting Server for this script in write(). This is a bug please contact game dev");