1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-23 00:28:08 +02:00

Fix a crash

This commit is contained in:
AlexVinS
2014-11-27 00:53:08 +03:00
parent 256894d18a
commit f4cf12d3f8
2 changed files with 7 additions and 6 deletions

View File

@ -59,6 +59,7 @@ public:
struct DLL_LINKAGE BattleSpellCastParameters struct DLL_LINKAGE BattleSpellCastParameters
{ {
public: public:
BattleSpellCastParameters(const BattleInfo * cb): cb(cb){};
int spellLvl; int spellLvl;
BattleHex destination; BattleHex destination;
ui8 casterSide; ui8 casterSide;

View File

@ -3774,7 +3774,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
complain("That stack can't cast spells!"); complain("That stack can't cast spells!");
else else
{ {
BattleSpellCastParameters p; BattleSpellCastParameters p(gs->curB);
p.spellLvl = 0; p.spellLvl = 0;
if (spellcaster) if (spellcaster)
@ -3983,7 +3983,7 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
const CSpell * s = SpellID(ba.additionalInfo).toSpell(); const CSpell * s = SpellID(ba.additionalInfo).toSpell();
BattleSpellCastParameters parameters; BattleSpellCastParameters parameters(gs->curB);
parameters.spellLvl = h->getSpellSchoolLevel(s); parameters.spellLvl = h->getSpellSchoolLevel(s);
parameters.destination = ba.destinationTile; parameters.destination = ba.destinationTile;
parameters.casterSide = ba.side; parameters.casterSide = ba.side;
@ -4137,7 +4137,7 @@ void CGameHandler::stackTurnTrigger(const CStack * st)
const CSpell * spell = SpellID(spellID).toSpell(); const CSpell * spell = SpellID(spellID).toSpell();
if (gs->curB->battleCanCastThisSpell(st->owner, spell, ECastingMode::ENCHANTER_CASTING) == ESpellCastProblem::OK) //TODO: select another available? if (gs->curB->battleCanCastThisSpell(st->owner, spell, ECastingMode::ENCHANTER_CASTING) == ESpellCastProblem::OK) //TODO: select another available?
{ {
BattleSpellCastParameters parameters; BattleSpellCastParameters parameters(gs->curB);
parameters.spellLvl = bonus->val; parameters.spellLvl = bonus->val;
parameters.destination = BattleHex::INVALID; parameters.destination = BattleHex::INVALID;
parameters.casterSide = side; parameters.casterSide = side;
@ -4836,7 +4836,7 @@ void CGameHandler::attackCasting(const BattleAttack & bat, Bonus::BonusType atta
{ {
const CSpell * spell = SpellID(spellID).toSpell(); const CSpell * spell = SpellID(spellID).toSpell();
BattleSpellCastParameters parameters; BattleSpellCastParameters parameters(gs->curB);
parameters.spellLvl = spellLevel; parameters.spellLvl = spellLevel;
parameters.destination = destination; parameters.destination = destination;
parameters.casterSide = !attacker->attackerOwned; parameters.casterSide = !attacker->attackerOwned;
@ -4871,7 +4871,7 @@ void CGameHandler::handleAfterAttackCasting( const BattleAttack & bat )
{ {
const CSpell * spell = SpellID(spellID).toSpell(); const CSpell * spell = SpellID(spellID).toSpell();
BattleSpellCastParameters parameters; BattleSpellCastParameters parameters(gs->curB);
parameters.spellLvl = 0; parameters.spellLvl = 0;
parameters.destination = gs->curB->battleGetStackByID(bat.bsa.at(0).stackAttacked)->position; parameters.destination = gs->curB->battleGetStackByID(bat.bsa.at(0).stackAttacked)->position;
parameters.casterSide = !attacker->attackerOwned; parameters.casterSide = !attacker->attackerOwned;
@ -5391,7 +5391,7 @@ void CGameHandler::runBattle()
{ {
TBonusListPtr bl = h->getBonuses(Selector::type(Bonus::OPENING_BATTLE_SPELL)); TBonusListPtr bl = h->getBonuses(Selector::type(Bonus::OPENING_BATTLE_SPELL));
BattleSpellCastParameters parameters; BattleSpellCastParameters parameters(gs->curB);
parameters.spellLvl = 3; parameters.spellLvl = 3;
parameters.destination = BattleHex::INVALID; parameters.destination = BattleHex::INVALID;
parameters.casterSide = 0; parameters.casterSide = 0;