max-unit-count works for buildings
This commit is contained in:
parent
ae010f85ab
commit
59b2cdb78f
|
@ -179,18 +179,15 @@ bool Faction::reqsOk(const RequirableType *rt) const{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dynamic_cast<const CommandType *>(rt) != NULL ){
|
if(dynamic_cast<const UnitType *>(rt) != NULL ){
|
||||||
const CommandType *ct=(CommandType *) rt;
|
const UnitType *producedUnitType=(UnitType *) rt;
|
||||||
if(ct->getProduced() != NULL && dynamic_cast<const UnitType *>(ct->getProduced()) != NULL ){
|
if(producedUnitType->getMaxUnitCount()>0){
|
||||||
|
if(producedUnitType->getMaxUnitCount()<=getCountForMaxUnitCount(producedUnitType)){
|
||||||
const UnitType *producedUnitType= (UnitType *) ct->getProduced();
|
return false;
|
||||||
if(producedUnitType->getMaxUnitCount()>0){
|
}
|
||||||
if(producedUnitType->getMaxUnitCount()<=getCountForMaxUnitCount(producedUnitType)){
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -690,13 +690,20 @@ int Unit::getCountOfProducedUnits(const UnitType *ut) const{
|
||||||
int count=0;
|
int count=0;
|
||||||
for(Commands::const_iterator it= commands.begin(); it!=commands.end(); ++it){
|
for(Commands::const_iterator it= commands.begin(); it!=commands.end(); ++it){
|
||||||
const CommandType* ct=(*it)->getCommandType();
|
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<const UnitType*>(ct->getProduced());
|
const UnitType *producedUnitType= static_cast<const UnitType*>(ct->getProduced());
|
||||||
if(producedUnitType==ut)
|
if(producedUnitType==ut)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(ct->getClass()==ccBuild){
|
||||||
|
const UnitType *builtUnitType= (*it)->getUnitType();
|
||||||
|
if(builtUnitType==ut)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue