diff --git a/binaries/data/mods/public/simulation/ai/aegis/aegis.js b/binaries/data/mods/public/simulation/ai/aegis/aegis.js index d02b714cd2..c262178463 100644 --- a/binaries/data/mods/public/simulation/ai/aegis/aegis.js +++ b/binaries/data/mods/public/simulation/ai/aegis/aegis.js @@ -5,7 +5,6 @@ var m = {}; // "local" global variables for stuffs that will need a unique ID // Note that since order of loading is alphabetic, this means this file must go before any other file using them. m.playerGlobals = []; -m.DebugEnabled = false; m.AegisBot = function AegisBot(settings) { API3.BaseAI.call(this, settings); @@ -248,24 +247,18 @@ AegisBot.prototype.Serialize = function() return {}; };*/ -m.debug = function(output){ - if (m.DebugEnabled){ - if (typeof output === "string"){ - warn(output); - }else{ - warn(uneval(output)); - } - } -}; +// For the moment we just use the debugging flag and the debugging function from the API. +// Maybe it will make sense in the future to separate them. +m.DebugEnabled = function() +{ + return API3.DebugEnabled; +} + +m.debug = function(output) +{ + API3.debug(output); +} -m.copyPrototype = function(descendant, parent) { - var sConstructor = parent.toString(); - var aMatch = sConstructor.match( /\s*function (.*)\(/ ); - if ( aMatch != null ) { descendant.prototype[aMatch[1]] = parent; } - for (var m in parent.prototype) { - descendant.prototype[m] = parent.prototype[m]; - } -}; return m; }()); diff --git a/binaries/data/mods/public/simulation/ai/aegis/base-manager.js b/binaries/data/mods/public/simulation/ai/aegis/base-manager.js index 46d7e394b5..e718c0b129 100644 --- a/binaries/data/mods/public/simulation/ai/aegis/base-manager.js +++ b/binaries/data/mods/public/simulation/ai/aegis/base-manager.js @@ -321,7 +321,7 @@ m.BaseManager.prototype.initializeDropsite = function (gameState, ent, type) { // TODO: get workers on those resources and do something with them. } - if (m.DebugEnabled) + if (m.DebugEnabled()) { // Make resources glow wildly if (type == "food") { @@ -455,7 +455,7 @@ m.BaseManager.prototype.findBestDropsiteLocation = function(gameState, resource) } } - if (m.DebugEnabled) + if (m.DebugEnabled()) friendlyTiles.dumpIm("DP_" + resource + "_" + gameState.getTimeElapsed() + ".png"); var best = friendlyTiles.findBestTile(2, obstructions); // try to find a spot to place a DP. diff --git a/binaries/data/mods/public/simulation/ai/aegis/headquarters.js b/binaries/data/mods/public/simulation/ai/aegis/headquarters.js index b948ed6ca2..884e3fd73b 100644 --- a/binaries/data/mods/public/simulation/ai/aegis/headquarters.js +++ b/binaries/data/mods/public/simulation/ai/aegis/headquarters.js @@ -89,7 +89,7 @@ m.HQ.prototype.init = function(gameState, events, queues){ this.baseManagers[1].initTerritory(this, gameState); this.baseManagers[1].initGatheringFunctions(this, gameState); - if (m.DebugEnabled) + if (m.DebugEnabled()) this.basesMap.dumpIm("basesMap.png"); var self = this; @@ -116,7 +116,7 @@ m.HQ.prototype.init = function(gameState, events, queues){ } var map = new API3.Map(gameState.sharedScript, gameState.sharedScript.CCResourceMaps["wood"].map); - if (m.DebugEnabled) + if (m.DebugEnabled()) map.dumpIm("map_CC_Wood.png"); //this.reassignIdleWorkers(gameState); @@ -650,7 +650,7 @@ m.HQ.prototype.findBestEcoCCLocation = function(gameState, resource){ var best = friendlyTiles.findBestTile(6, obstructions); var bestIdx = best[0]; - if (m.DebugEnabled) + if (m.DebugEnabled()) { friendlyTiles.map[bestIdx] = 270; friendlyTiles.dumpIm("cc_placement_base_" + gameState.getTimeElapsed() + "_" + resource + "_" + best[1] + ".png",301); diff --git a/binaries/data/mods/public/simulation/ai/aegis/queue-manager.js b/binaries/data/mods/public/simulation/ai/aegis/queue-manager.js index b831cef1aa..7282bd8ec2 100644 --- a/binaries/data/mods/public/simulation/ai/aegis/queue-manager.js +++ b/binaries/data/mods/public/simulation/ai/aegis/queue-manager.js @@ -288,7 +288,7 @@ m.QueueManager.prototype.printQueues = function(gameState){ // nice readable HTML version. m.QueueManager.prototype.HTMLprintQueues = function(gameState){ - if (!m.DebugEnabled) + if (!m.DebugEnabled()) return; log("