Ticket #2180: AIFix_.2.patch

File AIFix_.2.patch, 4.2 KB (added by sanderd17, 10 years ago)
  • binaries/data/mods/public/simulation/ai/aegis/base-manager.js

     
    483483    // for each dropsite, recalculate
    484484    for (i in this.dropsites)
    485485    {
     486        warn(uneval(i));
    486487        for (type in this.dropsites[i])
    487488        {
    488489            this.updateDropsite(gameState,gameState.getEntityById(i),type);
  • 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            warn(uneval(evt.msg));
     304            if (!state.entities[evt.msg.newentity])
     305                continue;
     306
     307            warn("first check");
     308            this._entities[evt.msg.newentity] = new Entity(this, state.entities[evt.msg.newentity]);
     309            this.entities.addEnt(this._entities[evt.msg.newentity]);
     310           
     311            // Update all the entity collections since the create operation affects static properties as well as dynamic
     312            for (var entCollection in this._entityCollections)
     313                this._entityCollections[entCollection].updateEnt(this._entities[evt.msg.newentity]);
     314
     315            if (!this._entities[evt.msg.entity])
     316                continue;
     317           
     318            warn("second check");
     319            // Dunno if this is relevant on renaming.
     320            if (foundationFinished[evt.msg.entity])
     321                evt.msg["SuccessfulFoundation"] = true;
     322           
     323            // Switch the metadata
     324            for (var i in this._players)
     325                this._entityMetadata[this._players[i]][evt.msg.entity] = this._entityMetadata[this._players[i]][evt.msg.entity];
     326           
     327            for each (var entCol in this._entityCollections)
     328                entCol.removeEnt(this._entities[evt.msg.entity]);
     329            this.entities.removeEnt(this._entities[evt.msg.entity]);
     330        }
    300331        else if (evt.type == "TrainingFinished")
    301332        {
    302333            // Apply metadata stored in training queues
  • binaries/data/mods/public/simulation/components/AIInterface.js

     
    8181    this.events.push({"type": "PlayerDefeated", "msg": msg});
    8282};
    8383
     84AIInterface.prototype.OnGlobalEntityRenamed = function(msg)
     85{
     86    this.events.push({"type": "EntityRenamed", "msg": msg});
     87};
     88
    8489Engine.RegisterComponentType(IID_AIInterface, "AIInterface", AIInterface);
  • binaries/data/mods/public/simulation/components/SkirmishReplacer.js

     
    5555    var cmpReplacementOwnership = Engine.QueryInterface(replacement, IID_Ownership);
    5656    cmpReplacementOwnership.SetOwner(cmpCurOwnership.GetOwner());
    5757
     58    Engine.BroadcastMessage(MT_EntityRenamed, { entity: this.entity, newentity: replacement});
    5859    Engine.DestroyEntity(this.entity);
    5960};
    6061
  • binaries/data/mods/public/simulation/templates/skirmish/structures/default_civil_centre.xml

     
    33  <Identity>
    44    <Civ>skirm</Civ>
    55  </Identity>
     6  <ResourceDropsite disable=""/>
    67  <SkirmishReplacer>
    78    <general>structures/{civ}_civil_centre</general>
    89  </SkirmishReplacer>