瀏覽代碼

Fixed #1367. Removed confusing code for speed calculation.

DjWarmonger 12 年之前
父節點
當前提交
4ec9faa789
共有 2 個文件被更改,包括 7 次插入20 次删除
  1. 6 17
      lib/HeroBonus.cpp
  2. 1 3
      lib/HeroBonus.h

+ 6 - 17
lib/HeroBonus.cpp

@@ -486,32 +486,21 @@ si32 IBonusBearer::magicResistance() const
 	return valOfBonuses(Bonus::MAGIC_RESISTANCE);
 }
 
-ui32 CBonusSystemNode::Speed( int turn /*= 0*/ , bool useBind /* = false*/) const
+ui32 IBonusBearer::Speed( int turn /*= 0*/ , bool useBind /* = false*/) const
 {
-	if(hasBonus(Selector::type(Bonus::SIEGE_WEAPON).And(Selector::turns(turn)))) //war machines cannot move
-		return 0;
-
-	int speed = valOfBonuses(Selector::type(Bonus::STACKS_SPEED).And(Selector::turns(turn)));
-
-	int percentBonus = 0;
-	for(const Bonus *b : getBonusList())
+	//war machines cannot move
+	if(hasBonus(Selector::type(Bonus::SIEGE_WEAPON).And(Selector::turns(turn))))
 	{
-		if(b->type == Bonus::STACKS_SPEED)
-		{
-			percentBonus += b->additionalInfo;
-		}
+		return 0;
 	}
-
-	speed = ((100 + percentBonus) * speed)/100;
-
 	//bind effect check - doesn't influence stack initiative
 	if (useBind && getEffect (SpellID::BIND))
 	{
 		return 0;
 	}
 
-	return speed;
-}
+	return valOfBonuses(Selector::type(Bonus::STACKS_SPEED).And(Selector::turns(turn)));
+}	
 
 bool IBonusBearer::isLiving() const //TODO: theoreticaly there exists "LIVING" bonus in stack experience documentation
 {

+ 1 - 3
lib/HeroBonus.h

@@ -592,6 +592,7 @@ public:
 	ui32 MaxHealth() const; //get max HP of stack with all modifiers
 	bool isLiving() const; //non-undead, non-non living or alive
 	virtual si32 magicResistance() const;
+	ui32 Speed(int turn = 0, bool useBind = false) const; //get speed of creature with all modificators
 	const Bonus * getEffect(ui16 id, int turn = 0) const; //effect id (SP)
 	ui8 howManyEffectsSet(ui16 id) const; //returns amount of effects with given id set for this stack
 
@@ -675,9 +676,6 @@ public:
 	virtual std::string bonusToString(const Bonus *bonus, bool description) const {return "";}; //description or bonus name
 	virtual std::string nodeName() const;
 
-	ui32 Speed(int turn = 0, bool useBind = false) const; //get speed of creature with all modificators
-	//FIXME: this interface should be moved to IBonusBearer, but bonus list is required for original implementation to compile
-
 	void deserializationFix();
 	void exportBonus(Bonus * b);
 	void exportBonuses();