Fix some crashes caused by spell scripts without checking unit type. Fix #3216 and #3217.

This commit is contained in:
megamage
2011-09-26 09:03:33 -04:00
parent 738f94eed3
commit a35deba186
2 changed files with 8 additions and 8 deletions
@@ -237,12 +237,12 @@ class spell_intense_cold : public SpellScriptLoader
void HandlePeriodicTick(AuraEffect const* aurEff) void HandlePeriodicTick(AuraEffect const* aurEff)
{ {
Unit* caster = GetCaster(); if (aurEff->GetBase()->GetStackAmount() < 2)
if (!caster)
return; return;
Unit* caster = GetCaster();
if (aurEff->GetBase()->GetStackAmount() >= 2) if (!caster || !caster->GetAI())
caster->GetAI()->SetGUID(GetTarget()->GetGUID(), DATA_INTENSE_COLD); return;
caster->GetAI()->SetGUID(GetTarget()->GetGUID(), DATA_INTENSE_COLD);
} }
void Register() void Register()
+3 -3
View File
@@ -167,9 +167,9 @@ class spell_dk_anti_magic_zone : public SpellScriptLoader
{ {
SpellInfo const* talentSpell = sSpellMgr->GetSpellInfo(DK_SPELL_ANTI_MAGIC_SHELL_TALENT); SpellInfo const* talentSpell = sSpellMgr->GetSpellInfo(DK_SPELL_ANTI_MAGIC_SHELL_TALENT);
amount = talentSpell->Effects[EFFECT_0].CalcValue(GetCaster()); amount = talentSpell->Effects[EFFECT_0].CalcValue(GetCaster());
// assume caster is a player here Unit* caster = GetCaster();
if (Unit* caster = GetCaster()) if(Player* player = caster->ToPlayer())
amount += int32(2 * caster->ToPlayer()->GetTotalAttackPowerValue(BASE_ATTACK)); amount += int32(2 * player->GetTotalAttackPowerValue(BASE_ATTACK));
} }
void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount) void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)