1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Merge pull request #187 from vmarkovtsev/issue/2362

Fix 2362 cast spells in town garrison
This commit is contained in:
ArseniyShestakov 2016-02-02 14:49:54 +03:00
commit da4818eeb8
2 changed files with 66 additions and 60 deletions

View File

@ -6,6 +6,7 @@
#include "CAdvmapInterface.h"
#include "GUIClasses.h"
#include "InfoWindows.h"
#include "CCastleInterface.h"
#include "../CBitmapHandler.h"
#include "../CDefHandler.h"
@ -622,10 +623,9 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
owner->myInt->showInfoDialog(std::string(msgBuf));
return;
}
//battle spell on adv map or adventure map spell during combat => display infowindow, not cast
if((sp->isCombatSpell() && !owner->myInt->battleInt)
|| (sp->isAdventureSpell() && owner->myInt->battleInt))
|| (sp->isAdventureSpell() && (owner->myInt->battleInt || owner->myInt->castleInt)))
{
std::vector<CComponent*> hlp(1, new CComponent(CComponent::spell, mySpell, 0));
LOCPLINT->showInfoDialog(sp->getLevelInfo(schoolLevel).description, hlp);

View File

@ -154,6 +154,13 @@ bool DefaultSpellMechanics::adventureCast(const SpellCastEnvironment * env, Adve
}
const CGHeroInstance * caster = parameters.caster;
if(caster->inTownGarrison)
{
env->complain("Attempt to cast an adventure spell in town garrison");
return false;
}
const int cost = caster->getSpellCost(owner);
if(!caster->canCastThisSpell(owner))
@ -857,4 +864,3 @@ void DefaultSpellMechanics::prepareBattleCast(const BattleSpellCastParameters& p
sc.casterStack = (parameters.casterStack ? parameters.casterStack->ID : -1);
sc.manaGained = 0;
}