diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 203f6a6f..3a3a9ebc 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -3263,7 +3263,8 @@ void Game::checkWinnerStandard() { std::map teamsAlive; for(int i = 0; i < world.getFactionCount(); ++i) { if(i != world.getThisFactionIndex()) { - if(hasBuilding(world.getFaction(i))) { + //if(hasBuilding(world.getFaction(i))) { + if(factionLostGame(world.getFaction(i)) == false) { teamsAlive[world.getFaction(i)->getTeam()] = teamsAlive[world.getFaction(i)->getTeam()] + 1; } } @@ -3306,7 +3307,8 @@ void Game::checkWinnerStandard() { else { //lose bool lose= false; - if(hasBuilding(world.getThisFaction()) == false) { + //if(hasBuilding(world.getThisFaction()) == false) { + if(factionLostGame(world.getThisFaction()) == true) { lose= true; for(int i=0; igetPersonalityType() != fpt_Observer) { @@ -3342,7 +3344,9 @@ void Game::checkWinnerStandard() { for(int i = 0; i < world.getFactionCount(); ++i) { if(i != world.getThisFactionIndex()) { if(world.getFaction(i)->getPersonalityType() != fpt_Observer) { - if(hasBuilding(world.getFaction(i)) && world.getFaction(i)->isAlly(world.getThisFaction()) == false) { + //if(hasBuilding(world.getFaction(i)) && + if(factionLostGame(world.getFaction(i)) == false && + world.getFaction(i)->isAlly(world.getThisFaction()) == false) { win= false; } } @@ -3413,6 +3417,22 @@ void Game::checkWinnerScripted() { } } +bool Game::factionLostGame(const Faction *faction) { + for(int i=0; igetUnitCount(); ++i) { + const UnitType *ut = faction->getUnit(i)->getType(); + if(ut->getCountInVictoryConditions() == ucvcNotSet) { + if(faction->getUnit(i)->getType()->hasSkillClass(scBeBuilt)) { + return false; + } + } + else if(ut->getCountInVictoryConditions() == ucvcTrue) { + return false; + } + } + return true; + +} + bool Game::hasBuilding(const Faction *faction) { for(int i=0; igetUnitCount(); ++i) { if(faction->getUnit(i)->getType()->hasSkillClass(scBeBuilt)) { diff --git a/source/glest_game/game/game.h b/source/glest_game/game/game.h index 16609116..e5f00f8b 100644 --- a/source/glest_game/game/game.h +++ b/source/glest_game/game/game.h @@ -256,6 +256,7 @@ private: void checkWinnerStandard(); void checkWinnerScripted(); bool hasBuilding(const Faction *faction); + bool factionLostGame(const Faction *faction); void incSpeed(); void decSpeed(); int getUpdateLoops(); diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index 9f1b8514..e5120ccc 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -76,6 +76,7 @@ const char *UnitType::propertyNames[]= {"burnable", "rotated_climb"}; UnitType::UnitType() : ProducibleType() { + countInVictoryConditions = ucvcNotSet; meetingPointImage = NULL; lightColor= Vec3f(0.f); light= false; @@ -173,6 +174,16 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, const const XmlNode *parametersNode= unitNode->getChild("parameters"); + if(parametersNode->hasChild("count-in-victory-conditions") == true) { + bool countUnit = parametersNode->getChild("count-in-victory-conditions")->getAttribute("value")->getBoolValue(); + if(countUnit == true) { + countInVictoryConditions = ucvcTrue; + } + else { + countInVictoryConditions = ucvcFalse; + } + } + //size //checkItemInVault(&(this->size),this->size); size= parametersNode->getChild("size")->getAttribute("value")->getIntValue(); @@ -1053,6 +1064,8 @@ std::string UnitType::toString() const { result += " meetingPoint = " + intToStr(meetingPoint); + result += " countInVictoryConditions = " + intToStr(countInVictoryConditions); + return result; } diff --git a/source/glest_game/types/unit_type.h b/source/glest_game/types/unit_type.h index 38644907..0ed1dfa8 100644 --- a/source/glest_game/types/unit_type.h +++ b/source/glest_game/types/unit_type.h @@ -77,6 +77,12 @@ enum UnitClass { typedef vector DamageParticleSystemTypes; +enum UnitCountsInVictoryConditions { + ucvcNotSet, + ucvcTrue, + ucvcFalse +}; + class UnitType: public ProducibleType, public ValueCheckerVault { public: enum Property { @@ -148,6 +154,8 @@ private: const CommandType *firstCommandTypeOfClass[ccCount]; const SkillType *firstSkillTypeOfClass[scCount]; + UnitCountsInVictoryConditions countInVictoryConditions; + public: //creation and loading UnitType(); @@ -159,6 +167,7 @@ public: virtual string getName(bool translatedValue=false) const; + UnitCountsInVictoryConditions getCountInVictoryConditions() const { return countInVictoryConditions; } //get inline int getId() const {return id;} inline int getMaxHp() const {return maxHp;}