From 4bf3e55dfc65dfd5f65db324a349abc4278b8915 Mon Sep 17 00:00:00 2001 From: titiger Date: Sun, 5 Mar 2017 00:43:37 +0100 Subject: [PATCH] Select only operative or non operative units with property "uniformSelecion" --- source/glest_game/gui/gui.cpp | 2 +- source/glest_game/gui/selection.cpp | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/source/glest_game/gui/gui.cpp b/source/glest_game/gui/gui.cpp index 3658e26d..71a30eaa 100644 --- a/source/glest_game/gui/gui.cpp +++ b/source/glest_game/gui/gui.cpp @@ -1156,7 +1156,7 @@ void Gui::computeSelected(bool doubleClick, bool force){ for(int i=0; igetFaction(factionIndex)->getUnitCount(); ++i){ Unit *unit= world->getFaction(factionIndex)->getUnit(i); if(unit->getPos().dist(refUnit->getPosNotThreadSafe())getType()==refUnit->getType()) + unit->getType()==refUnit->getType() && unit->isOperative()==refUnit->isOperative() ) { units.push_back(unit); } diff --git a/source/glest_game/gui/selection.cpp b/source/glest_game/gui/selection.cpp index 46834a37..f23dd007 100644 --- a/source/glest_game/gui/selection.cpp +++ b/source/glest_game/gui/selection.cpp @@ -83,15 +83,16 @@ bool Selection::select(Unit *unit, bool addToSelection) { //check if multitypesel if(selectedUnits.size() > 0) { - if(selectedUnits.front()->getType()->getUniformSelect() == true && selectedUnits.front()->getType() != unit->getType()) { + bool isUnifromSelectOK = ( selectedUnits.front()->getType() == unit->getType() && unit->isOperative() == selectedUnits.front()->isOperative()); + if(selectedUnits.front()->getType()->getUniformSelect() == true && !isUnifromSelectOK ) { if(addToSelection) return false; else clear(); } - } - if(selectedUnits.size() > 0) { - if(unit->getType()->getUniformSelect() == true && selectedUnits.front()->getType() != unit->getType()) { + + if (unit->getType()->getUniformSelect() == true + && !isUnifromSelectOK ) { return false; } } @@ -286,15 +287,17 @@ bool Selection::addUnitToGroup(int groupIndex,Unit *unit) { } // check for uniformselect units - if((int)groups[groupIndex].size()>0 ){ + if((int)groups[groupIndex].size()>0 ) { Unit* unitInGroup=groups[groupIndex][0]; - if( unit->getType()->getUniformSelect() && unitInGroup->getType() != unit->getType()) { - //dont add uniform selection unit - return false; - } - if( unitInGroup->getType()->getUniformSelect() && unitInGroup->getType() != unit->getType()){ - //dont add another unit to a group of uniform selection units - return false; + if( unit->getType()->getUniformSelect() || unitInGroup->getType()->getUniformSelect() ) { + if( unit->isOperative() != unitInGroup->isOperative()) { + //dont add units that are not in same operative state + return false; + } + if( unitInGroup->getType() != unit->getType()){ + //dont add another unit to a group of uniform selection units + return false; + } } }