From f05ac51b8aaa30f3529c00280820b619a0d8069b Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 3 Aug 2009 15:27:29 +0400 Subject: [PATCH] [8300] Re-enable in more clear way anti-crash client protection at enslave demon. Report about DB data problem related to prevented crash --- src/game/SpellAuras.cpp | 23 +++++++++++++---------- src/shared/revision_nr.h | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 37a787240..c4f74e0d6 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -3304,9 +3304,17 @@ void Aura::HandleModCharm(bool apply, bool Real) CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo(); if(cinfo && cinfo->type == CREATURE_TYPE_DEMON) { - //does not appear to have relevance. Why code added initially? See note below at !apply - //to prevent client crash - //m_target->SetFlag(UNIT_FIELD_BYTES_0, 2048); + // creature with pet number expected have class set + if(m_target->GetByteValue(UNIT_FIELD_BYTES_0, 1)==0) + { + if(cinfo->unit_class==0) + sLog.outErrorDb("Creature (Entry: %u) have unit_class = 0 but used in charmed spell, that will be result client crash.",cinfo->Entry); + else + sLog.outError("Creature (Entry: %u) have unit_class = %u but at charming have class 0!!! that will be result client crash.",cinfo->Entry,cinfo->unit_class); + + m_target->SetByteValue(UNIT_FIELD_BYTES_0, 1, CLASS_MAGE); + } + //just to enable stat window charmInfo->SetPetNumber(objmgr.GeneratePetNumber(), true); //if charmed two demons the same session, the 2nd gets the 1st one's name @@ -3342,13 +3350,8 @@ void Aura::HandleModCharm(bool apply, bool Real) // restore UNIT_FIELD_BYTES_0 if(cinfo && caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK && cinfo->type == CREATURE_TYPE_DEMON) { - //does not appear to have relevance. Why code added initially? Class, gender, powertype should be same. - //db field removed and replaced with better way to set class, restore using this if problems - /*CreatureDataAddon const *cainfo = ((Creature*)m_target)->GetCreatureAddon(); - if(cainfo && cainfo->bytes0 != 0) - m_target->SetUInt32Value(UNIT_FIELD_BYTES_0, cainfo->bytes0); - else - m_target->RemoveFlag(UNIT_FIELD_BYTES_0, 2048);*/ + // DB must have proper class set in field at loading, not req. restore, including workaround case at apply + // m_target->SetByteValue(UNIT_FIELD_BYTES_0, 1, cinfo->unit_class); if(m_target->GetCharmInfo()) m_target->GetCharmInfo()->SetPetNumber(0, true); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 929510f10..89ce2f0cd 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 "8299" + #define REVISION_NR "8300" #endif // __REVISION_NR_H__