Ticket #1255: #1255-2012-03-28.patch

File #1255-2012-03-28.patch, 1.3 KB (added by leper, 12 years ago)

If we have a unit that isn't part of a formation add a placeholder to ids.

  • binaries/data/mods/public/simulation/helpers/Commands.js

     
    445445{
    446446    var entities = []; // subset of ents that have UnitAI
    447447    var members = {}; // { formationentity: [ent, ent, ...], ... }
     448    var noFormation = false;
    448449    for each (var ent in ents)
    449450    {
    450451        var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
     
    455456                members[fid] = [];
    456457            members[fid].push(ent);
    457458        }
     459        else
     460        {
     461            noFormation = true;
     462        }
    458463        entities.push(ent);
    459464    }
    460465
    461466    var ids = [ id for (id in members) ];
     467    // If we encountered a unit that isn't part of a formation we add it to ids
     468    // to prevent bug #1255.
     469    if (noFormation)
     470        ids.push(null);
    462471
    463472    return { "entities": entities, "members": members, "ids": ids };
    464473}
     
    533542    if (formation.ids.length == 1)
    534543    {
    535544        // Selected units all belong to the same formation.
    536         // Check that it doesn't have any other members
     545        // Check that we have all its members
    537546        var fid = formation.ids[0];
    538547        var cmpFormation = Engine.QueryInterface(+fid, IID_Formation);
    539548        if (cmpFormation && cmpFormation.GetMemberCount() == formation.entities.length)