فهرست منبع

Fixed #756
Extended range (ui64) for army strenght.

DjWarmonger 14 سال پیش
والد
کامیت
423fd2ffb7
6فایلهای تغییر یافته به همراه10 افزوده شده و 9 حذف شده
  1. 1 2
      lib/CArtHandler.cpp
  2. 2 2
      lib/CCreatureSet.cpp
  3. 1 1
      lib/CCreatureSet.h
  4. 3 3
      lib/CObjectHandler.cpp
  5. 1 1
      lib/CObjectHandler.h
  6. 2 0
      lib/NetPacksLib.cpp

+ 1 - 2
lib/CArtHandler.cpp

@@ -1078,13 +1078,12 @@ bool CCombinedArtifactInstance::canBeDisassembled() const
 }
 
 CCombinedArtifactInstance::CCombinedArtifactInstance(CArtifact *Art)
-	: CArtifactInstance(Art)
+	: CArtifactInstance(Art) //TODO: seems unued, but need to be written
 {
 }
 
 CCombinedArtifactInstance::CCombinedArtifactInstance()
 {
-
 }
 
 void CCombinedArtifactInstance::createConstituents()

+ 2 - 2
lib/CCreatureSet.cpp

@@ -209,9 +209,9 @@ bool CCreatureSet::needsLastStack() const
 	return false;
 }
 
-int CCreatureSet::getArmyStrength() const
+ui64 CCreatureSet::getArmyStrength() const
 {
-	int ret = 0;
+	ui64 ret = 0;
 	for(TSlots::const_iterator i = stacks.begin(); i != stacks.end(); i++)
 		ret += i->second->type->AIValue * i->second->count;
 	return ret;

+ 1 - 1
lib/CCreatureSet.h

@@ -147,7 +147,7 @@ public:
 	bool slotEmpty(TSlot slot) const;
 	int stacksCount() const;
 	virtual bool needsLastStack() const; //true if last stack cannot be taken
-	int getArmyStrength() const; //sum of AI values of creatures
+	ui64 getArmyStrength() const; //sum of AI values of creatures
 	ui64 getPower (TSlot slot) const; //value of specific stack
 	std::string getRoughAmount (TSlot slot) const; //rough size of specific stack
 	bool hasStackAtSlot(TSlot slot) const;

+ 3 - 3
lib/CObjectHandler.cpp

@@ -1253,10 +1253,10 @@ double CGHeroInstance::getHeroStrength() const
 	return sqrt((1.0 + 0.05*getPrimSkillLevel(0)) * (1.0 + 0.05*getPrimSkillLevel(1)));
 }
 
-int CGHeroInstance::getTotalStrength() const
+ui64 CGHeroInstance::getTotalStrength() const
 {
 	double ret = getHeroStrength() * getArmyStrength();
-	return (int) ret;
+	return (ui64) ret;
 }
 
 expType CGHeroInstance::calculateXp(expType exp) const
@@ -2867,7 +2867,7 @@ const std::string & CGCreature::getHoverText() const
 		hoverName += "\n\n ";
 		hoverName += (*texts)[0];
 		int choice;
-		float ratio = ((float)getArmyStrength() / selHero->getTotalStrength());
+		double ratio = ((double)getArmyStrength() / selHero->getTotalStrength());
 		if (ratio < 0.1) choice = 1;
 		else if (ratio < 0.25) choice = 2;
 		else if (ratio < 0.6) choice = 3;

+ 1 - 1
lib/CObjectHandler.h

@@ -405,7 +405,7 @@ public:
 	//int getSpellSecLevel(int spell) const; //returns level of secondary ability (fire, water, earth, air magic) known to this hero and applicable to given spell; -1 if error
 	static int3 convertPosition(int3 src, bool toh3m); //toh3m=true: manifest->h3m; toh3m=false: h3m->manifest
 	double getHeroStrength() const;
-	int getTotalStrength() const;
+	ui64 getTotalStrength() const;
 	expType calculateXp(expType exp) const; //apply learning skill
 	ui8 getSpellSchoolLevel(const CSpell * spell, int *outSelectedSchool = NULL) const; //returns level on which given spell would be cast by this hero (0 - none, 1 - basic etc); optionally returns number of selected school by arg - 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic,
 	bool canCastThisSpell(const CSpell * spell) const; //determines if this hero can cast given spell; takes into account existing spell in spellbook, existing spellbook and artifact bonuses

+ 2 - 0
lib/NetPacksLib.cpp

@@ -516,6 +516,8 @@ DLL_EXPORT void NewArtifact::applyGs( CGameState *gs )
 
 	assert(!art->parents.size());
 	art->setType(art->artType);
+	if (CCombinedArtifactInstance* cart = dynamic_cast<CCombinedArtifactInstance*>(art.get()))
+		cart->createConstituents();
 }
 
 DLL_EXPORT const CStackInstance * StackLocation::getStack()