user stack trace now works for firefox

This commit is contained in:
Olivier Gagnon 2021-03-25 02:48:15 -04:00
parent 2ac4cd41bb
commit 8a42f6e49c
3 changed files with 34 additions and 10 deletions

@ -236,6 +236,7 @@ export let CONSTANTS: IMap<any> = {
Netscript Netscript
* 'connect': a new singularity function that connects you to a server. (like the terminal command) * 'connect': a new singularity function that connects you to a server. (like the terminal command)
* 'manualHack': a new singularity function that performs a manual hack on the players current server. * 'manualHack': a new singularity function that performs a manual hack on the players current server.
* ns2 stack trace works on Firefox now.
Misc. Misc.
* New shortcut, Alt + b, brings you to bladeburner * New shortcut, Alt + b, brings you to bladeburner

@ -1516,7 +1516,6 @@ HackingMission.prototype.finishMission = function(win) {
var gain = this.reward * Player.faction_rep_mult * favorMult; var gain = this.reward * Player.faction_rep_mult * favorMult;
dialogBoxCreate("Mission won! You earned " + dialogBoxCreate("Mission won! You earned " +
numeralWrapper.format(gain, '0.000a') + " reputation with " + this.faction.name); numeralWrapper.format(gain, '0.000a') + " reputation with " + this.faction.name);
console.log(`diff ${this.difficulty}`);
Player.gainIntelligenceExp(this.difficulty * CONSTANTS.IntelligenceHackingMissionBaseExpGain); Player.gainIntelligenceExp(this.difficulty * CONSTANTS.IntelligenceHackingMissionBaseExpGain);
this.faction.playerReputation += gain; this.faction.playerReputation += gain;
} else { } else {

@ -406,16 +406,42 @@ function NetscriptFunctions(workerScript) {
} }
if(!filename) continue if(!filename) continue
const lineRe = /.*:(\d+):\d+.*/; function parseChromeStackline(line) {
const lineMatch = stackline.match(lineRe); const lineRe = /.*:(\d+):\d+.*/;
const funcRe = /.*at (.+) \(.*/;
const lineMatch = line.match(lineRe);
const funcMatch = line.match(funcRe);
if(lineMatch && funcMatch) {
let func = funcMatch[1];
return {line: lineMatch[1], func: func};
}
return null;
}
let call = {line: "-1", func: "unknown"};;
let chromeCall = parseChromeStackline(stackline);
if (chromeCall) {
call = chromeCall;
}
const funcRe = /.*at (.+) \(.*/; function parseFirefoxStackline(line) {
const funcMatch = stackline.match(funcRe); const lineRe = /.*:(\d+):\d+$/;
let func = funcMatch[1]; const lineMatch = line.match(lineRe);
if(func.includes('.')) func = func.split('.')[1];
userstack.push(`${filename}:L${lineMatch[1]}@${func}`); const lio = line.lastIndexOf("@");
if(lineMatch && lio !== -1) {
return {line: lineMatch[1], func: line.slice(0, lio)};
}
return null;
}
let firefoxCall = parseFirefoxStackline(stackline);
if (firefoxCall) {
call = firefoxCall;
}
userstack.push(`${filename}:L${call.line}@${call.func}`);
} }
workerScript.log(caller, msg); workerScript.log(caller, msg);
@ -1688,8 +1714,6 @@ function NetscriptFunctions(workerScript) {
checkTixApiAccess("buyStock"); checkTixApiAccess("buyStock");
const stock = getStockFromSymbol(symbol, "buyStock"); const stock = getStockFromSymbol(symbol, "buyStock");
const res = buyStock(stock, shares, workerScript, { rerenderFn: displayStockMarketContent }); const res = buyStock(stock, shares, workerScript, { rerenderFn: displayStockMarketContent });
console.log(stock);
console.log(res);
return res ? stock.price : 0; return res ? stock.price : 0;
}, },
sellStock: function(symbol, shares) { sellStock: function(symbol, shares) {