Ticket #2475: map_replacement_v2.diff
File map_replacement_v2.diff, 3.2 KB (added by , 10 years ago) |
---|
-
binaries/data/mods/public/simulation/ai/common-api/entity.js
8 8 _init: function(template) 9 9 { 10 10 this._template = template; 11 this._tpCache = {};11 this._tpCache = new Map(); 12 12 }, 13 13 14 14 // helper function to return a template value, optionally adjusting for tech. … … 16 16 get: function(string) 17 17 { 18 18 var value = this._template; 19 if (this._auraTemplateModif && this._auraTemplateModif [string]) {20 return this._auraTemplateModif [string];21 } else if (this._techModif && this._techModif [string]) {22 return this._techModif [string];19 if (this._auraTemplateModif && this._auraTemplateModif.has(string)) { 20 return this._auraTemplateModif.get(string); 21 } else if (this._techModif && this._techModif.has(string)) { 22 return this._techModif.get(string); 23 23 } else { 24 if ( this._tpCache[string] == null)24 if (!this._tpCache.has(string)) 25 25 { 26 26 var args = string.split("/"); 27 27 for (var i = 0; i < args.length; ++i) … … 32 32 value = undefined; 33 33 break; 34 34 } 35 this._tpCache [string] = value;35 this._tpCache.set(string, value); 36 36 } 37 return this._tpCache[string]; 38 } 37 return this._tpCache.get(string); 38 } 39 39 40 }, 40 41 41 42 genericName: function() { … … 510 511 511 512 this._templateName = entity.template; 512 513 this._entity = entity; 513 this._auraTemplateModif = {}; // template modification from auras. this is only for this entity.514 this._auraTemplateModif = new Map(); // template modification from auras. this is only for this entity. 514 515 this._ai = sharedAI; 515 516 if (!sharedAI._techModifications[entity.owner][this._templateName]) 516 sharedAI._techModifications[entity.owner][this._templateName] = {};517 sharedAI._techModifications[entity.owner][this._templateName] = new Map(); 517 518 this._techModif = sharedAI._techModifications[entity.owner][this._templateName]; // save a reference to the template tech modifications 518 519 }, 519 520 -
binaries/data/mods/public/simulation/ai/common-api/shared.js
324 324 continue; // dead, presumably. 325 325 var changes = state.changedEntityTemplateInfo[id]; 326 326 for each (var change in changes) 327 this._entities[id]._auraTemplateModif [change.variable] = change.value;327 this._entities[id]._auraTemplateModif.set(change.variable, change.value); 328 328 } 329 329 Engine.ProfileStop(); 330 330 }; … … 340 340 { 341 341 var changes = playerDiff[template]; 342 342 if (!this._techModifications[player][template]) 343 this._techModifications[player][template] = {};343 this._techModifications[player][template] = new Map(); 344 344 for each (var change in changes) 345 this._techModifications[player][template] [change.variable] = change.value;345 this._techModifications[player][template].set(change.variable, change.value); 346 346 } 347 347 } 348 348 Engine.ProfileStop();