- added guard against NULL commandtype clicking in icon panel (discovered during testing)

This commit is contained in:
Mark Vejvoda
2011-01-10 06:43:47 +00:00
parent b201cebf3b
commit 9b275a5077
2 changed files with 13 additions and 8 deletions

View File

@@ -560,7 +560,8 @@ void Gui::mouseDownDisplayUnitSkills(int posDisplay){
//uniform selection
if(selection.isUniform()) {
if(unit->getFaction()->reqsOk(display.getCommandType(posDisplay))){
const CommandType *ct = display.getCommandType(posDisplay);
if(ct != NULL && unit->getFaction()->reqsOk(ct)) {
activeCommandType= display.getCommandType(posDisplay);
activeCommandClass= activeCommandType->getClass();
}

View File

@@ -213,6 +213,10 @@ int Faction::getCountForMaxUnitCount(const UnitType *unitType) const{
bool Faction::reqsOk(const CommandType *ct) const {
assert(ct != NULL);
if(ct == NULL) {
throw runtime_error("In [Faction::reqsOk] ct == NULL");
}
if(ct->getProduced() != NULL && reqsOk(ct->getProduced()) == false) {
return false;
}