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
* '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.
* ns2 stack trace works on Firefox now.
Misc.
* 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;
dialogBoxCreate("Mission won! You earned " +
numeralWrapper.format(gain, '0.000a') + " reputation with " + this.faction.name);
console.log(`diff ${this.difficulty}`);
Player.gainIntelligenceExp(this.difficulty * CONSTANTS.IntelligenceHackingMissionBaseExpGain);
this.faction.playerReputation += gain;
} else {

@ -406,16 +406,42 @@ function NetscriptFunctions(workerScript) {
}
if(!filename) continue
const lineRe = /.*:(\d+):\d+.*/;
const lineMatch = stackline.match(lineRe);
function parseChromeStackline(line) {
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 (.+) \(.*/;
const funcMatch = stackline.match(funcRe);
let func = funcMatch[1];
if(func.includes('.')) func = func.split('.')[1];
function parseFirefoxStackline(line) {
const lineRe = /.*:(\d+):\d+$/;
const lineMatch = line.match(lineRe);
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);
@ -1688,8 +1714,6 @@ function NetscriptFunctions(workerScript) {
checkTixApiAccess("buyStock");
const stock = getStockFromSymbol(symbol, "buyStock");
const res = buyStock(stock, shares, workerScript, { rerenderFn: displayStockMarketContent });
console.log(stock);
console.log(res);
return res ? stock.price : 0;
},
sellStock: function(symbol, shares) {