Replaced strict equality comparisons for null with loose eq comparisons

This commit is contained in:
danielyxie
2017-10-25 17:05:12 -05:00
parent 7614c62507
commit 7c4ac00f5a
8 changed files with 109 additions and 80 deletions
+38 -38
View File
@@ -21805,7 +21805,7 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log(args.toString());
},
tprint : function(args) {
if (args === undefined || args === null) {
if (args === undefined || args == null) {
throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "tprint() call has incorrect number of arguments. Takes 1 argument");
}
var x = args.toString();
@@ -22140,7 +22140,7 @@ function NetscriptFunctions(workerScript) {
throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ls() failed because of invalid arguments. Usage: ls(ip/hostname, [grep filter])");
}
var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip);
if (server === null) {
if (server == null) {
workerScript.scriptRef.log("ls() failed. Invalid IP or hostname passed in: " + ip);
throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ls() failed. Invalid IP or hostname passed in: " + ip);
}
@@ -22714,11 +22714,11 @@ function NetscriptFunctions(workerScript) {
} else if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["f" /* isString */])(port)) { //Write to text file
var fn = port;
var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp);
if (server === null) {
if (server == null) {
throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error getting Server for this script in write(). This is a bug please contact game dev");
}
var txtFile = Object(__WEBPACK_IMPORTED_MODULE_20__TextFile_js__["b" /* getTextFile */])(fn, server);
if (txtFile === null) {
if (txtFile == null) {
txtFile = Object(__WEBPACK_IMPORTED_MODULE_20__TextFile_js__["a" /* createTextFile */])(fn, data, server);
return true;
}
@@ -22751,7 +22751,7 @@ function NetscriptFunctions(workerScript) {
} else if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["f" /* isString */])(port)) { //Read from text file
var fn = port;
var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp);
if (server === null) {
if (server == null) {
throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error getting Server for this script in read(). This is a bug please contact game dev");
}
var txtFile = Object(__WEBPACK_IMPORTED_MODULE_20__TextFile_js__["b" /* getTextFile */])(fn, server);
@@ -22839,7 +22839,7 @@ function NetscriptFunctions(workerScript) {
} else {
//Get income for a particular script
var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip);
if (server === null) {
if (server == null) {
workerScript.scriptRef.log("getScriptIncome() failed. Invalid IP or hostnamed passed in: " + ip);
throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getScriptIncome() failed. Invalid IP or hostnamed passed in: " + ip);
}
@@ -22865,7 +22865,7 @@ function NetscriptFunctions(workerScript) {
} else {
//Get income for a particular script
var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip);
if (server === null) {
if (server == null) {
workerScript.scriptRef.log("getScriptExpGain() failed. Invalid IP or hostnamed passed in: " + ip);
throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getScriptExpGain() failed. Invalid IP or hostnamed passed in: " + ip);
}
@@ -23393,7 +23393,7 @@ function NetscriptFunctions(workerScript) {
}
var company = __WEBPACK_IMPORTED_MODULE_4__Company_js__["a" /* Companies */][companyName];
if (company === null || !(company instanceof __WEBPACK_IMPORTED_MODULE_4__Company_js__["b" /* Company */])) {
if (company == null || !(company instanceof __WEBPACK_IMPORTED_MODULE_4__Company_js__["b" /* Company */])) {
workerScript.scriptRef.log("ERROR: Invalid companyName passed into getCompanyRep(): " + companyName);
return -1;
}
@@ -23801,7 +23801,7 @@ function NetscriptFunctions(workerScript) {
}
var fac = __WEBPACK_IMPORTED_MODULE_9__Faction_js__["b" /* Factions */][faction];
if (fac === null || !(fac instanceof __WEBPACK_IMPORTED_MODULE_9__Faction_js__["a" /* Faction */])) {
if (fac == null || !(fac instanceof __WEBPACK_IMPORTED_MODULE_9__Faction_js__["a" /* Faction */])) {
workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because of invalid faction name: " + faction);
return false;
}
@@ -23812,7 +23812,7 @@ function NetscriptFunctions(workerScript) {
}
var aug = __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */][name];
if (aug === null || !(aug instanceof __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["a" /* Augmentation */])) {
if (aug == null || !(aug instanceof __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["a" /* Augmentation */])) {
workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because of invalid augmentation name: " + name);
return false;
}
@@ -29389,7 +29389,7 @@ function createActiveScriptsText(workerscript, item) {
function updateActiveScriptsText(workerscript, item, statsEl=null) {
var itemId = item.id
var itemTextStats = document.getElementById(itemId + "-stats");
if (itemTextStats === null || itemTextStats === undefined) {
if (itemTextStats == null || itemTextStats === undefined) {
itemTextStats = statsEl;
}
@@ -35020,7 +35020,7 @@ function placeOrder(stock, shares, price, type, position, workerScript=null) {
}
return false;
}
if (StockMarket["Orders"] === null) {
if (StockMarket["Orders"] == null) {
var orders = {};
for (var name in StockMarket) {
if (StockMarket.hasOwnProperty(name)) {
@@ -35041,7 +35041,7 @@ function placeOrder(stock, shares, price, type, position, workerScript=null) {
//Returns true if successfully cancels an order, false otherwise
function cancelOrder(params, workerScript=null) {
var tixApi = (workerScript instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]);
if (StockMarket["Orders"] === null) {return false;}
if (StockMarket["Orders"] == null) {return false;}
if (params.order && params.order instanceof Order) {
var order = params.order;
//An 'Order' object is passed in
@@ -35424,7 +35424,7 @@ function sellStock(stock, shares) {
//Returns true if successful and false otherwise
function shortStock(stock, shares, workerScript=null) {
var tixApi = (workerScript instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]);
if (stock === null || isNaN(shares) || shares < 0) {
if (stock == null || isNaN(shares) || shares < 0) {
if (tixApi) {
workerScript.scriptRef.log("ERROR: shortStock() failed because of invalid arguments.");
} else {
@@ -35473,7 +35473,7 @@ function shortStock(stock, shares, workerScript=null) {
//Returns true if successful and false otherwise
function sellShort(stock, shares, workerScript=null) {
var tixApi = (workerScript instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]);
if (stock === null || isNaN(shares) || shares < 0) {
if (stock == null || isNaN(shares) || shares < 0) {
if (tixApi) {
workerScript.scriptRef.log("ERROR: sellShort() failed because of invalid arguments.");
} else {
@@ -35575,7 +35575,7 @@ function updateStockPrices() {
//Checks and triggers any orders for the specified stock
function processOrders(stock, orderType, posType) {
var orderBook = StockMarket["Orders"];
if (orderBook === null) {
if (orderBook == null) {
var orders = {};
for (var name in StockMarket) {
if (StockMarket.hasOwnProperty(name)) {
@@ -35588,7 +35588,7 @@ function processOrders(stock, orderType, posType) {
return; //Newly created, so no orders to process
}
var stockOrders = orderBook[stock.symbol];
if (stockOrders === null || !(stockOrders.constructor === Array)) {
if (stockOrders == null || !(stockOrders.constructor === Array)) {
console.log("ERROR: Invalid Order book for " + stock.symbol + " in processOrders()");
stockOrders = [];
return;
@@ -35931,7 +35931,7 @@ function createStockTicker(stock) {
function setStockTickerClickHandlers() {
var stockList = document.getElementById("stock-market-list");
var tickerHdrs = stockList.getElementsByClassName("accordion-header");
if (tickerHdrs === null) {
if (tickerHdrs == null) {
console.log("ERROR: Could not find header elements for stock tickers");
return;
}
@@ -35960,7 +35960,7 @@ function updateStockTicker(stock, increase) {
var tickerId = "stock-market-ticker-" + stock.symbol;
var hdr = document.getElementById(tickerId + "-hdr");
if (hdr === null) {
if (hdr == null) {
console.log("ERROR: Couldn't find ticker element for stock: " + stock.symbol);
return;
}
@@ -35985,7 +35985,7 @@ function updateStockPlayerPosition(stock) {
if (!(stock.posTxtEl instanceof Element)) {
stock.posTxtEl = document.getElementById(tickerId + "-position-text");
}
if (stock.posTxtEl === null) {
if (stock.posTxtEl == null) {
console.log("ERROR: Could not find stock position element for: " + stock.symbol);
return;
}
@@ -37321,7 +37321,7 @@ HackingMission.prototype.createNodeDomElement = function(nodeObj) {
}
HackingMission.prototype.updateNodeDomElement = function(nodeObj) {
if (nodeObj.el === null) {
if (nodeObj.el == null) {
console.log("ERR: Calling updateNodeDomElement on a Node without an element");
return;
}
@@ -37393,7 +37393,7 @@ HackingMission.prototype.getNodeFromElement = function(el) {
function selectNode(hackMissionInst, el) {
var nodeObj = hackMissionInst.getNodeFromElement(el);
if (nodeObj === null) {console.log("Error getting Node object");}
if (nodeObj == null) {console.log("Error getting Node object");}
if (!nodeObj.plyrCtrl) {return;}
if (hackMissionInst.selectedNode instanceof Node) {
@@ -37409,7 +37409,7 @@ function selectNode(hackMissionInst, el) {
//Note: Does NOT change its css class. This is handled by Node.setControlledBy...
HackingMission.prototype.configurePlayerNodeElement = function(el) {
var nodeObj = this.getNodeFromElement(el);
if (nodeObj === null) {console.log("Error getting Node object");}
if (nodeObj == null) {console.log("Error getting Node object");}
//Add event listener
var self = this;
@@ -37445,7 +37445,7 @@ HackingMission.prototype.nodeReachable = function(node) {
}
HackingMission.prototype.nodeReachableByEnemy = function(node) {
if (node === null) {return false;}
if (node == null) {return false;}
var x = node.pos[0], y = node.pos[1];
if (x > 0 && this.map[x-1][y].enmyCtrl) {return true;}
if (x < 7 && this.map[x+1][y].enmyCtrl) {return true;}
@@ -37650,7 +37650,7 @@ HackingMission.prototype.process = function(numCycles=1) {
//Returns a bool representing whether defenses need to be re-calculated
HackingMission.prototype.processNode = function(nodeObj, numCycles=1) {
if (nodeObj.action === null) {
if (nodeObj.action == null) {
return;
}
@@ -37680,18 +37680,18 @@ HackingMission.prototype.processNode = function(nodeObj, numCycles=1) {
var enmyHacking = this.difficulty * __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionDifficultyToHacking;
switch(nodeObj.action) {
case NodeActions.Attack:
if (nodeObj.conn === null) {break;}
if (nodeObj.conn == null) {break;}
var dmg = this.calculateAttackDamage(atk, def, plyr ? __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill : enmyHacking);
targetNode.hp -= (dmg/5 * numCycles);
break;
case NodeActions.Scan:
if (nodeObj.conn === null) {break;}
if (nodeObj.conn == null) {break;}
var eff = this.calculateScanEffect(atk, def, plyr ? __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill : enmyHacking);
targetNode.def -= (eff/5 * numCycles);
calcStats = true;
break;
case NodeActions.Weaken:
if (nodeObj.conn === null) {break;}
if (nodeObj.conn == null) {break;}
var eff = this.calculateWeakenEffect(atk, def, plyr ? __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill : enmyHacking);
targetNode.atk -= (eff/5 * numCycles);
calcStats = true;
@@ -37852,13 +37852,13 @@ HackingMission.prototype.processNode = function(nodeObj, numCycles=1) {
//Enemy "AI" for CPU Core and Transfer Nodes
HackingMission.prototype.enemyAISelectAction = function(nodeObj) {
if (nodeObj === null) {return;}
if (nodeObj == null) {return;}
switch(nodeObj.type) {
case NodeTypes.Core:
//Select a single RANDOM target from miscNodes and player's Nodes
//If it is reachable, it will target it. If not, no target will
//be selected for now, and the next time process() gets called this will repeat
if (nodeObj.conn === null) {
if (nodeObj.conn == null) {
if (this.miscNodes.length === 0) {
//Randomly pick a player node and attack it if its reachable
var rand = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["d" /* getRandomInt */])(0, this.playerNodes.length-1);
@@ -37916,7 +37916,7 @@ HackingMission.prototype.enemyAISelectAction = function(nodeObj) {
} else {
targetNode = this.getNodeFromElement(nodeObj.conn.targetId);
}
if (targetNode === null) {
if (targetNode == null) {
console.log("Error getting Target node Object in enemyAISelectAction()");
}
@@ -38386,7 +38386,7 @@ GangMember.prototype.assignToTask = function(taskName) {
//Gains are per cycle
GangMember.prototype.calculateRespectGain = function() {
var task = this.task;
if (task === null || !(task instanceof GangMemberTask) || task.baseRespect === 0) {return 0;}
if (task == null || !(task instanceof GangMemberTask) || task.baseRespect === 0) {return 0;}
var statWeight = (task.hackWeight/100) * this.hack +
(task.strWeight/100) * this.str +
(task.defWeight/100) * this.def +
@@ -38403,7 +38403,7 @@ GangMember.prototype.calculateRespectGain = function() {
GangMember.prototype.calculateWantedLevelGain = function() {
var task = this.task;
if (task === null || !(task instanceof GangMemberTask) || task.baseWanted === 0) {return 0;}
if (task == null || !(task instanceof GangMemberTask) || task.baseWanted === 0) {return 0;}
var statWeight = (task.hackWeight/100) * this.hack +
(task.strWeight/100) * this.str +
(task.defWeight/100) * this.def +
@@ -38423,7 +38423,7 @@ GangMember.prototype.calculateWantedLevelGain = function() {
GangMember.prototype.calculateMoneyGain = function() {
var task = this.task;
if (task === null || !(task instanceof GangMemberTask) || task.baseMoney === 0) {return 0;}
if (task == null || !(task instanceof GangMemberTask) || task.baseMoney === 0) {return 0;}
var statWeight = (task.hackWeight/100) * this.hack +
(task.strWeight/100) * this.str +
(task.defWeight/100) * this.def +
@@ -38440,7 +38440,7 @@ GangMember.prototype.calculateMoneyGain = function() {
GangMember.prototype.gainExperience = function(numCycles=1) {
var task = this.task;
if (task === null || !(task instanceof GangMemberTask)) {return;}
if (task == null || !(task instanceof GangMemberTask)) {return;}
this.hack_exp += (task.hackWeight / 1500) * task.difficulty * numCycles;
this.str_exp += (task.strWeight / 1500) * task.difficulty * numCycles;
this.def_exp += (task.defWeight / 1500) * task.difficulty * numCycles;
@@ -39140,7 +39140,7 @@ function updateGangContent() {
var repCost = Math.pow(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].GangRecruitCostMultiplier, numMembers);
}
var faction = __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */][__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].gang.facName];
if (faction === null) {
if (faction == null) {
Object(__WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Could not find your gang's faction. This is probably a bug please report to dev");
return;
}
@@ -92806,7 +92806,7 @@ BitburnerSaveObject.prototype.saveGame = function(db) {
}
function loadGame(saveString) {
if (saveString === "" || saveString === null || saveString === undefined) {
if (saveString === "" || saveString == null || saveString === undefined) {
if (!window.localStorage.getItem("bitburnerSave")) {
console.log("No save file to load");
return false;
@@ -92875,7 +92875,7 @@ function loadGame(saveString) {
if (saveObj.hasOwnProperty("VersionSave")) {
try {
var ver = JSON.parse(saveObj.VersionSave, __WEBPACK_IMPORTED_MODULE_17__utils_JSONReviver_js__["c" /* Reviver */]);
if (__WEBPACK_IMPORTED_MODULE_8__Player_js__["a" /* Player */].bitNodeN === null || __WEBPACK_IMPORTED_MODULE_8__Player_js__["a" /* Player */].bitNodeN === 0) {
if (__WEBPACK_IMPORTED_MODULE_8__Player_js__["a" /* Player */].bitNodeN == null || __WEBPACK_IMPORTED_MODULE_8__Player_js__["a" /* Player */].bitNodeN === 0) {
__WEBPACK_IMPORTED_MODULE_8__Player_js__["a" /* Player */].setBitNodeNumber(1);
}
if (ver.startsWith("0.27.") || ver.startsWith("0.28.")) {