Ticket #2179: unit_commands.js.patch

File unit_commands.js.patch, 1.1 KB (added by RefinedCode, 11 years ago)

Small optimization of one of the functions called during the selection panel GUI update.

  • binaries/data/mods/public/gui/session/unit_commands.js

     
    12751275// Get all of the available entities which can be built by the selected entities
    12761276function getAllBuildableEntities(selection)
    12771277{
     1278    //Array to contain already processed entity templates so buildableEnts wont be a huge set of duplicates
     1279    var alreadyIncluded = [];
     1280   
    12781281    var buildableEnts = [];
    12791282    var state;
    12801283    // Get all buildable entities
    12811284    for (var i in selection)
    12821285    {
    1283         if ((state = GetEntityState(selection[i])) && state.buildEntities && state.buildEntities.length)
     1286        if ((state = GetEntityState(selection[i])) && state.buildEntities && state.buildEntities.length && (alreadyIncluded.indexOf(state.template)) == -1)
     1287        {
    12841288            buildableEnts = buildableEnts.concat(state.buildEntities);
     1289            //add the entity's template to the alreadyIncluded array
     1290            alreadyIncluded.push(state.template);
     1291        }
    12851292    }
    12861293
    12871294    // Remove duplicates