aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2012-03-19 17:03:39 +0100
committerShauren <shauren.trinity@gmail.com>2012-03-19 17:03:39 +0100
commitf0ac821e0bb9d72b7fe7d54ee8769a5d29e8f469 (patch)
tree99ad5c33f8b14ae1eff85708fdb905df027b7880
parent847b4366f338390fc907b8d8c455696cce33e8be (diff)
Scripts/Serpentshrine Cavern: Fixed crash in boss_leotheras_the_blind caused by uninitialized variable; also replaced unsafe AI typecasting with Get/SetGUID
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp
index ecca909914c..ad718504465 100644
--- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp
+++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp
@@ -53,6 +53,7 @@ EndScriptData */
#define MODEL_NIGHTELF 20514
#define DEMON_FORM 21875
#define MOB_SPELLBINDER 21806
+#define INNER_DEMON_VICTIM 1
#define SAY_AGGRO -1548009
#define SAY_SWITCH_TO_DEMON -1548010
@@ -94,6 +95,20 @@ public:
ShadowBolt_Timer = 10000;
Link_Timer = 1000;
}
+
+ void SetGUID(uint64 guid, int32 id/* = 0 */)
+ {
+ if (id == INNER_DEMON_VICTIM)
+ victimGUID = guid;
+ }
+
+ uint64 GetGUID(int32 id/* = 0 */)
+ {
+ if (id == INNER_DEMON_VICTIM)
+ return victimGUID;
+ return 0;
+ }
+
void JustDied(Unit* /*victim*/)
{
Unit* unit = Unit::GetUnit((*me), victimGUID);
@@ -219,6 +234,7 @@ public:
IsFinalForm = false;
NeedThreatReset = false;
EnrageUsed = false;
+ memset(InnderDemon, 0, sizeof(InnderDemon));
InnerDemon_Count = 0;
me->SetSpeed(MOVE_RUN, 2.0f, true);
me->SetDisplayId(MODEL_NIGHTELF);
@@ -357,7 +373,7 @@ public:
Creature* unit = Unit::GetCreature((*me), InnderDemon[i]);
if (unit && unit->isAlive())
{
- Unit* unit_target = Unit::GetUnit(*unit, CAST_AI(mob_inner_demon::mob_inner_demonAI, unit->AI())->victimGUID);
+ Unit* unit_target = Unit::GetUnit(*unit, unit->AI()->GetGUID(INNER_DEMON_VICTIM));
if (unit_target && unit_target->isAlive())
{
unit->CastSpell(unit_target, SPELL_CONSUMING_MADNESS, true);
@@ -525,7 +541,7 @@ public:
if (demon)
{
demon->AI()->AttackStart((*itr));
- CAST_AI(mob_inner_demon::mob_inner_demonAI, demon->AI())->victimGUID = (*itr)->GetGUID();
+ demon->AI()->SetGUID((*itr)->GetGUID(), INNER_DEMON_VICTIM);
(*itr)->AddAura(SPELL_INSIDIOUS_WHISPER, *itr);