浏览代码

fixed http://bugs.vcmi.eu/view.php?id=2499

AlexVinS 9 年之前
父节点
当前提交
21de5817e3
共有 1 个文件被更改,包括 17 次插入8 次删除
  1. 17 8
      client/battle/CBattleInterface.cpp

+ 17 - 8
client/battle/CBattleInterface.cpp

@@ -3010,18 +3010,27 @@ void CBattleInterface::showHighlightedHexes(SDL_Surface * to)
 			}
 			if (settings["battle"]["mouseShadow"].Bool())
 			{
-				if(spellToCast) //when casting spell
+				const ISpellCaster * caster = nullptr;
+				const CSpell * spell = nullptr;
+
+                if(spellToCast)//hero casts spell
 				{
-					//calculating spell school level
-					const CSpell & spToCast =  *CGI->spellh->objects[spellToCast->additionalInfo];
-					ui8 schoolLevel = 0;
+					spell = SpellID(spellToCast->additionalInfo).toSpell();
+					caster = activeStack->attackerOwned ? attackingHeroInstance : defendingHeroInstance;
+				}
+				else if(creatureSpellToCast >= 0 && stackCanCastSpell && creatureCasting)//stack casts spell
+				{
+                    spell = SpellID(creatureSpellToCast).toSpell();
+                    caster = activeStack;
+				}
 
-					auto caster = activeStack->attackerOwned ? attackingHeroInstance : defendingHeroInstance;
-					if (caster)
-						schoolLevel = caster->getSpellSchoolLevel(&spToCast);
+				if(caster && spell) //when casting spell
+				{
+					//calculating spell school level
+					ui8 schoolLevel = caster->getSpellSchoolLevel(spell);
 
 					// printing shaded hex(es)
-					auto shaded = spToCast.rangeInHexes(currentlyHoveredHex, schoolLevel, curInt->cb->battleGetMySide());
+					auto shaded = spell->rangeInHexes(currentlyHoveredHex, schoolLevel, curInt->cb->battleGetMySide());
 					for(BattleHex shadedHex : shaded)
 					{
 						if ((shadedHex.getX() != 0) && (shadedHex.getX() != GameConstants::BFIELD_WIDTH -1))