Skip to content

Commit

Permalink
Improve Nullbot gateway performance.
Browse files Browse the repository at this point in the history
  • Loading branch information
KJeff01 committed Apr 10, 2019
1 parent a6b6bf3 commit db51614
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
5 changes: 2 additions & 3 deletions data/mp/multiplay/skirmish/nb_includes/build.js
Expand Up @@ -195,10 +195,9 @@ function buildGateways() {
if (oils <= 0)
return BUILDRET.FAILURE;
// lets not cycle through all gateways on the map
var gates = whereAreTheGateways();
if (gates.length === 0)
if (!areThereGW())
return BUILDRET.FAILURE;
var gates = gates.filter(function(gate) {
var gates = gateways.filter(function(gate) {
var l = gate.x1 - gate.x2 + gate.y1 - gate.y2;
if (l < 0)
l = -l;
Expand Down
12 changes: 2 additions & 10 deletions data/mp/multiplay/skirmish/nb_includes/misc.js
Expand Up @@ -4,6 +4,7 @@
*
*/

const gateways = enumGateways();
var baseLocation = startPositions[me];

function distanceToBase(loc) {
Expand Down Expand Up @@ -57,18 +58,9 @@ function goEasy() {

function areThereGW() {
function uncached() { //should only need to be evaluated once at the start
if(enumGateways().length > 0)
if(gateways.length > 0)
return true;
return false;
}
return cached(uncached, Infinity);
}

function whereAreTheGateways(){
function uncached() { //should only need to be evaluated once at the start
var gateways = [];
gateways = enumGateways();
return gateways;
}
return cached(uncached, Infinity);
}

0 comments on commit db51614

Please sign in to comment.