From 6d28c7dfd0eae21f7b492cf71963bd4c2606f4ae Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Sun, 8 May 2011 19:47:59 +0200 Subject: [PATCH] [11445] Correct a possible crash, if caster of aura has disconnected after aura applied A small code adjustment in addition, no need for caster at aura remove. Signed-off-by: NoFantasy --- src/game/SpellAuras.cpp | 6 +++--- src/game/SpellHandler.cpp | 6 ++++-- src/shared/revision_nr.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index a0dca8e3f..afcd17e00 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -8040,11 +8040,11 @@ void Aura::HandleAuraMirrorImage(bool apply, bool Real) // Target of aura should always be creature (ref Spell::CheckCast) Creature* pCreature = (Creature*)GetTarget(); - // Caster can be player or creature, the unit who pCreature will become an clone of. - Unit* caster = GetCaster(); - if (apply) { + // Caster can be player or creature, the unit who pCreature will become an clone of. + Unit* caster = GetCaster(); + pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 0, caster->getRace()); pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 1, caster->getClass()); pCreature->SetByteValue(UNIT_FIELD_BYTES_0, 2, caster->getGender()); diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index 9925ff29b..39af52b8e 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -638,7 +638,7 @@ void WorldSession::HandleGetMirrorimageData(WorldPacket& recv_data) data << (uint8)pCreature->getGender(); data << (uint8)pCreature->getClass(); - if (pCaster->GetTypeId() == TYPEID_PLAYER) + if (pCaster && pCaster->GetTypeId() == TYPEID_PLAYER) { Player* pPlayer = (Player*)pCaster; @@ -677,7 +677,9 @@ void WorldSession::HandleGetMirrorimageData(WorldPacket& recv_data) } else { - // No data when cloner is not player, data is taken from CreatureDisplayInfoExtraEntry by model already + // pCaster may have been NULL (usually not expected, but may happen at disconnect, etc) + // OR + // pCaster is not player, data is taken from CreatureDisplayInfoExtraEntry by model already data << (uint8)0; data << (uint8)0; data << (uint8)0; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 104eebd15..463715536 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11444" + #define REVISION_NR "11445" #endif // __REVISION_NR_H__