Core/Spells: Fix static analysis issues and a crash

Fix confusing NULL checks in Raise Ally check cast.
Fix a crash in Raise Ally triggered by executing ".cast back 61999" command targeting a pet in raid while being dead.
This commit is contained in:
jackpoz committed 2016-01-08 23:13:15 +01:00
1 parent ad425f9f17
commit b1d0855624
1 file changed
+7 -4
+7 -4
View File
@@ -1744,11 +1744,14 @@ public:
{
// Raise Ally cannot be casted on alive players
Unit* target = GetExplTargetUnit();
if (target && target->IsAlive())
if (!target)
return SPELL_FAILED_NO_VALID_TARGETS;
if (target->IsAlive())
return SPELL_FAILED_TARGET_NOT_DEAD;
else if (GetCaster()->ToPlayer()->InArena())
return SPELL_FAILED_NOT_IN_ARENA;
else if (target->IsGhouled())
if (Player* playerCaster = GetCaster()->ToPlayer())
if (playerCaster->InArena())
return SPELL_FAILED_NOT_IN_ARENA;
if (target->IsGhouled())
return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW;
return SPELL_CAST_OK;