diff --git a/source/glest_game/gui/selection.cpp b/source/glest_game/gui/selection.cpp index 8e20633b..53fac478 100644 --- a/source/glest_game/gui/selection.cpp +++ b/source/glest_game/gui/selection.cpp @@ -71,6 +71,16 @@ bool Selection::select(Unit *unit) { return false; } + //check if selectable + if(unit->getType()->isSelectable() == false) { + return false; + } + + //check if selectable + if(unit->getType()->isCommandable() == false && isEmpty() == false) { + return false; + } + //check if multisel if(unit->getType()->getMultiSelect() == false && isEmpty() == false) { return false; @@ -181,7 +191,8 @@ bool Selection::isCommandable() const { return isEmpty() == false && isEnemy() == false && - (selectedUnits.size() == 1 && selectedUnits.front()->isAlive() == false) == false; + (selectedUnits.size() == 1 && selectedUnits.front()->isAlive() == false) == false && + selectedUnits.front()->getType()->isCommandable(); } bool Selection::isCancelable() const { diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index 39129206..f45fe5ba 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -89,6 +89,8 @@ UnitType::UnitType() : ProducibleType() { lightColor= Vec3f(0.f); light= false; multiSelect= false; + selectable= true; + commandable= true; armorType= NULL; rotatedBuildPos=0; @@ -333,6 +335,14 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, //multi selection multiSelect= parametersNode->getChild("multi-selection")->getAttribute("value")->getBoolValue(); + //selectable + if(parametersNode->hasChild("selectable")){ + selectable= parametersNode->getChild("selectable")->getAttribute("value")->getBoolValue(); + } + //commandable + if(parametersNode->hasChild("commandable")){ + commandable= parametersNode->getChild("commandable")->getAttribute("value")->getBoolValue(); + } //cellmap allowEmptyCellMap = false; const XmlNode *cellMapNode= parametersNode->getChild("cellmap"); @@ -1240,6 +1250,8 @@ std::string UnitType::toString() const { result += " light = " + intToStr(light); result += " lightColor = " + lightColor.getString(); result += " multiSelect = " + intToStr(multiSelect); + result += " selectable = " + intToStr(selectable); + result += " commandable = " + intToStr(commandable); result += " sight = " + intToStr(sight); result += " size = " + intToStr(size); result += " height = " + intToStr(height); diff --git a/source/glest_game/types/unit_type.h b/source/glest_game/types/unit_type.h index 1738406d..30e11cf1 100644 --- a/source/glest_game/types/unit_type.h +++ b/source/glest_game/types/unit_type.h @@ -171,6 +171,8 @@ private: bool light; Vec3f lightColor; bool multiSelect; + bool selectable; + bool commandable; int sight; int size; //size in cells int renderSize; //size to render in cells @@ -255,6 +257,8 @@ public: inline bool getRotationAllowed() const {return rotationAllowed;} inline Vec3f getLightColor() const {return lightColor;} inline bool getMultiSelect() const {return multiSelect;} + inline bool isSelectable() const {return selectable;} + inline bool isCommandable() const {return commandable;} inline int getSight() const {return sight;} inline int getSize() const {return size;} inline int getRenderSize() const {return renderSize;}