瀏覽代碼

fixed and cleanup

AlexVinS 8 年之前
父節點
當前提交
7bf8c9bd69
共有 5 個文件被更改,包括 20 次插入21 次删除
  1. 1 2
      client/CPlayerInterface.cpp
  2. 13 13
      client/battle/CBattleInterface.cpp
  3. 1 1
      lib/CGeneralTextHandler.cpp
  4. 4 4
      lib/HeroBonus.cpp
  5. 1 1
      lib/battle/BattleAttackInfo.cpp

+ 1 - 2
client/CPlayerInterface.cpp

@@ -710,9 +710,8 @@ void CPlayerInterface::battleStacksHealedRes(const std::vector<std::pair<ui32, u
 			battleInt->displayEffect(52, attacker->position); //TODO: transparency
 			CCS->soundh->playSound(soundBase::DRAINLIF);
 
-			int textID = CGI->generaltexth->pluralText(361, attacker->getCount());
 			MetaString text;
-			text.addTxt(MetaString::GENERAL_TXT, textID);
+			attacker->addText(text, MetaString::GENERAL_TXT, 361);
 			attacker->addNameReplacement(text, false);
 			text.addReplacement(healedStacks[0].second);
 			defender->addNameReplacement(text, true);

+ 13 - 13
client/battle/CBattleInterface.cpp

@@ -1365,18 +1365,18 @@ void CBattleInterface::battleStacksEffectsSet(const SetStackEffect & sse)
 		{
 			//defensive stance
 			const CStack * stack = LOCPLINT->cb->battleGetStackByID(*sse.stacks.begin());
-
-			int textId = CGI->generaltexth->pluralText(120, stack->getCount());
-
-			BonusList defenseBonuses = *(stack->getBonuses(Selector::typeSubtype(Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE)));
-			defenseBonuses.remove_if(Bonus::UntilGetsTurn); //remove bonuses gained from defensive stance
-			int val = stack->Defense() - defenseBonuses.totalValue();
-
-			MetaString text;
-			text.addTxt(MetaString::GENERAL_TXT, textId);
-			stack->addNameReplacement(text);
-			text.addReplacement(val);
-			console->addText(text.toString());
+			if(stack)
+			{
+				BonusList defenseBonuses = *(stack->getBonuses(Selector::typeSubtype(Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE)));
+				defenseBonuses.remove_if(Bonus::UntilGetsTurn); //remove bonuses gained from defensive stance
+				int val = stack->Defense() - defenseBonuses.totalValue();
+
+				MetaString text;
+				stack->addText(text, MetaString::GENERAL_TXT, 120);
+				stack->addNameReplacement(text);
+				text.addReplacement(val);
+				console->addText(text.toString());
+			}
 		}
 	}
 
@@ -1752,7 +1752,7 @@ void CBattleInterface::printConsoleAttacked(const CStack * defender, int dmg, in
 	if(attacker) //ignore if stacks were killed by spell
 	{
 		MetaString text;
-		text.addTxt(MetaString::GENERAL_TXT, CGI->generaltexth->pluralText(376, attacker->getCount()));
+		attacker->addText(text, MetaString::GENERAL_TXT, 376);
 		attacker->addNameReplacement(text);
 		text.addReplacement(dmg);
 		formattedText = text.toString();

+ 1 - 1
lib/CGeneralTextHandler.cpp

@@ -515,7 +515,7 @@ int32_t CGeneralTextHandler::pluralText(const int32_t textIndex, const int32_t c
 		return 0;
 	else if(textIndex < 0)
 		return -textIndex;
-    else if(count == 1)
+	else if(count == 1)
 		return textIndex;
 	else
 		return textIndex + 1;

+ 4 - 4
lib/HeroBonus.cpp

@@ -90,11 +90,11 @@ TBonusListPtr CBonusProxy::get() const
 {
 	if(CBonusSystemNode::treeChanged != cachedLast || !data)
 	{
-        data = target->getAllBonuses(selector, nullptr);
-        data->eliminateDuplicates();
-        cachedLast = CBonusSystemNode::treeChanged;
+		//TODO: support limiters
+		data = target->getAllBonuses(selector, nullptr);
+		data->eliminateDuplicates();
+		cachedLast = CBonusSystemNode::treeChanged;
 	}
-
 	return data;
 }
 

+ 1 - 1
lib/battle/BattleAttackInfo.cpp

@@ -12,7 +12,7 @@
 
 
 BattleAttackInfo::BattleAttackInfo(const CStack * Attacker, const CStack * Defender, bool Shooting):
-	attackerHealth(Attacker), defenderHealth(Defender) //todo: copy
+	attackerHealth(Attacker->health), defenderHealth(Defender->health)
 {
 	attacker = Attacker;
 	defender = Defender;