Browse Source

Fixed http://bugs.vcmi.eu/view.php?id=482

AlexVinS 9 years ago
parent
commit
52ae5b4a86
2 changed files with 13 additions and 5 deletions
  1. 5 2
      client/battle/CBattleInterface.cpp
  2. 8 3
      client/windows/CSpellWindow.cpp

+ 5 - 2
client/battle/CBattleInterface.cpp

@@ -1783,6 +1783,9 @@ void CBattleInterface::blockUI(bool on)
 {
 	ESpellCastProblem::ESpellCastProblem spellcastingProblem;
 	bool canCastSpells = curInt->cb->battleCanCastSpell(&spellcastingProblem);
+	//if magic is blocked, we leave button active, so the message can be displayed (cf bug #97)
+	if(!canCastSpells)
+		canCastSpells = spellcastingProblem == ESpellCastProblem::MAGIC_IS_BLOCKED;
 	bool canWait = activeStack ? !activeStack->waited() : false;
 
 	bOptions->block(on);
@@ -1804,8 +1807,8 @@ void CBattleInterface::blockUI(bool on)
 		bConsoleDown->block(on);
 	}
 
-	//if magic is blocked, we leave button active, so the message can be displayed (cf bug #97)
-	bSpell->block(on || (!canCastSpells && spellcastingProblem != ESpellCastProblem::MAGIC_IS_BLOCKED));
+
+	bSpell->block(on || tacticsMode || !canCastSpells);
 	bWait->block(on || tacticsMode || !canWait);
 	bDefence->block(on || tacticsMode);
 }

+ 8 - 3
client/windows/CSpellWindow.cpp

@@ -618,9 +618,7 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
 		int spellCost = owner->myInt->cb->getSpellCost(sp, owner->myHero);
 		if(spellCost > owner->myHero->mana) //insufficient mana
 		{
-			char msgBuf[500];
-			sprintf(msgBuf, CGI->generaltexth->allTexts[206].c_str(), spellCost, owner->myHero->mana);
-			owner->myInt->showInfoDialog(std::string(msgBuf));
+			owner->myInt->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[206]) % spellCost % owner->myHero->mana));
 			return;
 		}
 		//battle spell on adv map or adventure map spell during combat => display infowindow, not cast
@@ -702,6 +700,13 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
 					owner->myInt->showInfoDialog(CGI->generaltexth->allTexts[185]);
 				}
 				break;
+			default:
+				{
+					// General message:
+					std::string text = CGI->generaltexth->allTexts[541], caster = owner->myHero->name;
+					text = boost::str(boost::format(text) % caster);
+					owner->myInt->showInfoDialog(text);
+				}
 			}
 		}
 		else if(sp->isAdventureSpell() && !owner->myInt->battleInt) //adventure spell and not in battle