Ticket #2180: AIFix_.patch

File AIFix_.patch, 2.5 KB (added by wraitii, 10 years ago)
  • binaries/data/mods/public/simulation/ai/common-api-v3/shared.js

     
    214214// applies entity deltas, and each gamestate.
    215215SharedScript.prototype.onUpdate = function(state)
    216216{
    217     if (this.turn !== 0)
    218         this.ApplyEntitiesDelta(state);
     217    this.ApplyEntitiesDelta(state);
    219218
    220219    Engine.ProfileStart("onUpdate");
    221220   
     
    297296            for (var i in this._players)
    298297                delete this._entityMetadata[this._players[i]][evt.msg.entity];
    299298        }
     299        else if (evt.type == "EntityRenamed")
     300        {
     301            //combines destroy and create.
     302
     303            if (!state.entities[evt.msg.newentity])
     304                continue;
     305
     306            this._entities[evt.msg.newentity] = new Entity(this, state.entities[evt.msg.newentity]);
     307            this.entities.addEnt(this._entities[evt.msg.newentity]);
     308           
     309            // Update all the entity collections since the create operation affects static properties as well as dynamic
     310            for (var entCollection in this._entityCollections)
     311                this._entityCollections[entCollection].updateEnt(this._entities[evt.msg.newentity]);
     312
     313            if (!this._entities[evt.msg.entity])
     314                continue;
     315           
     316            // Dunno if this is relevant on renaming.
     317            if (foundationFinished[evt.msg.entity])
     318                evt.msg["SuccessfulFoundation"] = true;
     319           
     320            // Switch the metadata
     321            for (var i in this._players)
     322                this._entityMetadata[this._players[i]][evt.msg.entity] = this._entityMetadata[this._players[i]][evt.msg.entity];
     323           
     324            for each (var entCol in this._entityCollections)
     325                entCol.removeEnt(this._entities[evt.msg.entity]);
     326            this.entities.removeEnt(this._entities[evt.msg.entity]);
     327        }
    300328        else if (evt.type == "TrainingFinished")
    301329        {
    302330            // Apply metadata stored in training queues
  • binaries/data/mods/public/simulation/components/AIProxy.js

     
    288288    cmpAIInterface.PushEvent("TrainingFinished", msg);
    289289};
    290290
     291AIProxy.prototype.OnGlobalEntityRenamed = function(msg)
     292{
     293    var cmpAIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_AIInterface);
     294    cmpAIInterface.PushEvent("EntityRenamed", msg);
     295};
     296
    291297AIProxy.prototype.OnAIMetadata = function(msg)
    292298{
    293299    var cmpAIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_AIInterface);