[8300] Re-enable in more clear way anti-crash client protection at enslave demon.

Report about DB data problem related to prevented crash
This commit is contained in:
VladimirMangos 2009-08-03 15:27:29 +04:00
parent 27e12424e5
commit f05ac51b8a
2 changed files with 14 additions and 11 deletions

View file

@ -3304,9 +3304,17 @@ void Aura::HandleModCharm(bool apply, bool Real)
CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo(); CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
if(cinfo && cinfo->type == CREATURE_TYPE_DEMON) if(cinfo && cinfo->type == CREATURE_TYPE_DEMON)
{ {
//does not appear to have relevance. Why code added initially? See note below at !apply // creature with pet number expected have class set
//to prevent client crash if(m_target->GetByteValue(UNIT_FIELD_BYTES_0, 1)==0)
//m_target->SetFlag(UNIT_FIELD_BYTES_0, 2048); {
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 //just to enable stat window
charmInfo->SetPetNumber(objmgr.GeneratePetNumber(), true); charmInfo->SetPetNumber(objmgr.GeneratePetNumber(), true);
//if charmed two demons the same session, the 2nd gets the 1st one's name //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 // restore UNIT_FIELD_BYTES_0
if(cinfo && caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK && cinfo->type == CREATURE_TYPE_DEMON) 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 must have proper class set in field at loading, not req. restore, including workaround case at apply
//db field removed and replaced with better way to set class, restore using this if problems // m_target->SetByteValue(UNIT_FIELD_BYTES_0, 1, cinfo->unit_class);
/*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);*/
if(m_target->GetCharmInfo()) if(m_target->GetCharmInfo())
m_target->GetCharmInfo()->SetPetNumber(0, true); m_target->GetCharmInfo()->SetPetNumber(0, true);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8299" #define REVISION_NR "8300"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__