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 200ccd3ad0
commit 6ae7b0136c
5 changed files with 30 additions and 4 deletions

@ -15,6 +15,7 @@ getNodeStats() Netscript Function
ram: Node's RAM,
cores: Node's number of cores,
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
timeOnline: Number of seconds since Node has been purchased,
totalProduction: Total amount that the Node has produced

@ -222,9 +222,17 @@ export let CONSTANTS: IMap<any> = {
LatestUpdate:
`
v0.47.2
-------
Netscript Changes
* Added tail() Netscript function
* Added 'Solarized Dark' theme to CodeMirror editor
* Bug fix: Stock Market UI should no longer crash for certain locale settings
* hacknet.getNodeStats() function now returns an additional property for Hacknet Servers: hashCapacity
* 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-escape");
Engine.loadLocationContent();
Engine.loadLocationContent(false);
}
function nextInfiltrationLevel(inst) {

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

@ -405,7 +405,7 @@ function NetscriptFunctions(workerScript) {
const node = getHacknetNode(i);
const hasUpgraded = hasHacknetServers();
const res = {
name: node.name,
name: hasUpgraded ? node.hostname : node.name,
level: node.level,
ram: hasUpgraded ? node.maxRam : node.ram,
cores: node.cores,
@ -416,6 +416,7 @@ function NetscriptFunctions(workerScript) {
if (hasUpgraded) {
res.cache = node.cache;
res.hashCapacity = node.hashCapacity;
}
return res;
@ -1993,6 +1994,13 @@ function NetscriptFunctions(workerScript) {
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();
if (server == null) {
throw makeRuntimeRejectMsg(workerScript, "Error getting Server for this script in write(). This is a bug please contact game dev");