diff --git a/source/glest_game/type_instances/faction.cpp b/source/glest_game/type_instances/faction.cpp index cb6eba76..e3984f0e 100644 --- a/source/glest_game/type_instances/faction.cpp +++ b/source/glest_game/type_instances/faction.cpp @@ -179,18 +179,15 @@ bool Faction::reqsOk(const RequirableType *rt) const{ } } - if(dynamic_cast(rt) != NULL ){ - const CommandType *ct=(CommandType *) rt; - if(ct->getProduced() != NULL && dynamic_cast(ct->getProduced()) != NULL ){ - - const UnitType *producedUnitType= (UnitType *) ct->getProduced(); - if(producedUnitType->getMaxUnitCount()>0){ - if(producedUnitType->getMaxUnitCount()<=getCountForMaxUnitCount(producedUnitType)){ - return false; - } - } - } + if(dynamic_cast(rt) != NULL ){ + const UnitType *producedUnitType=(UnitType *) rt; + if(producedUnitType->getMaxUnitCount()>0){ + if(producedUnitType->getMaxUnitCount()<=getCountForMaxUnitCount(producedUnitType)){ + return false; + } + } } + return true; } diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index ba4d42a0..9c27bb48 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -690,13 +690,20 @@ int Unit::getCountOfProducedUnits(const UnitType *ut) const{ int count=0; for(Commands::const_iterator it= commands.begin(); it!=commands.end(); ++it){ const CommandType* ct=(*it)->getCommandType(); - if(ct->getClass()==ccProduce || ct->getClass()==ccMorph || ct->getClass()==ccBuild ){ + if(ct->getClass()==ccProduce || ct->getClass()==ccMorph ){ const UnitType *producedUnitType= static_cast(ct->getProduced()); if(producedUnitType==ut) { count++; } } + if(ct->getClass()==ccBuild){ + const UnitType *builtUnitType= (*it)->getUnitType(); + if(builtUnitType==ut) + { + count++; + } + } } return count; }