Explorar o código

- Updated TODOs, removed unused method declaration, updated comments
- Fixed hero strength calculation (power, knowledge should be included as well)

beegee1 %!s(int64=11) %!d(string=hai) anos
pai
achega
a03d01bd3f

+ 1 - 3
lib/CGameState.cpp

@@ -1212,7 +1212,7 @@ const CCampaignScenario * CGameState::getCampaignScenarioForCrossoverHeroes() co
 
 std::vector<CGHeroInstance *> CGameState::prepareCrossoverHeroes(const CCampaignScenario * campaignScenario)
 {
-	auto crossoverHeroes = campaignScenario->crossoverHeroes; //TODO check if hero instances need to be copied
+	auto crossoverHeroes = campaignScenario->crossoverHeroes; //TODO hero instances need to be copied, warning not trivial
 	const auto & travelOptions = campaignScenario->travelOptions;
 
 	if (!(travelOptions.whatHeroKeeps & 1))
@@ -2767,8 +2767,6 @@ std::vector<std::pair<CGHeroInstance*, ObjectInstanceID> > CGameState::generateC
 					nh->initHeroDefInfo();
 					campaignHeroReplacements.push_back(std::make_pair(nh, gid));
 				}
-
-				//TODO delete hero placeholder
 			}
 		}
 	}

+ 2 - 1
lib/CObjectHandler.cpp

@@ -1364,7 +1364,8 @@ void CGHeroInstance::setPropertyDer( ui8 what, ui32 val )
 
 double CGHeroInstance::getHeroStrength() const
 {
-	return sqrt((1.0 + 0.05*getPrimSkillLevel(PrimarySkill::ATTACK)) * (1.0 + 0.05*getPrimSkillLevel(PrimarySkill::DEFENSE)));
+	return sqrt((1.0 + 0.05*getPrimSkillLevel(PrimarySkill::ATTACK)) * (1.0 + 0.05*getPrimSkillLevel(PrimarySkill::DEFENSE)) *
+				(1.0 + 0.05*getPrimSkillLevel(PrimarySkill::KNOWLEDGE)) * (1.0 + 0.05*getPrimSkillLevel(PrimarySkill::SPELL_POWER)));
 }
 
 ui64 CGHeroInstance::getTotalStrength() const

+ 0 - 1
lib/CObjectHandler.h

@@ -378,7 +378,6 @@ public:
 		}
 	} skillsInfo;
 
-	//BonusList bonuses;
 	//////////////////////////////////////////////////////////////////////////
 
 

+ 1 - 1
lib/mapping/CCampaignHandler.cpp

@@ -329,7 +329,7 @@ const CGHeroInstance * CCampaignScenario::strongestHero( PlayerColor owner ) con
 	auto ownedHeroes = crossoverHeroes | filtered(isOwned);
 
 	auto i = vstd::maxElementByFun(ownedHeroes,
-									[](const CGHeroInstance * h) {return h->getTotalStrength();});
+									[](const CGHeroInstance * h) {return h->getHeroStrength();});
 	return i == ownedHeroes.end() ? nullptr : *i;
 }
 

+ 1 - 2
lib/mapping/CCampaignHandler.h

@@ -108,11 +108,10 @@ public:
 	SScenarioPrologEpilog prolog, epilog;
 
 	CScenarioTravel travelOptions;
-	std::vector<CGHeroInstance *> crossoverHeroes; // contains all heroes with the same state when the camapign scenario was finished
+	std::vector<CGHeroInstance *> crossoverHeroes; // contains all heroes with the same state when the campaign scenario was finished
 
 	const CGHeroInstance * strongestHero(PlayerColor owner) const;
 	void loadPreconditionRegions(ui32 regions);
-	void prepareCrossoverHeroes(std::vector<CGHeroInstance *> heroes);
 	bool isNotVoid() const;
 
 	template <typename Handler> void serialize(Handler &h, const int formatVersion)