[8583] Prevent crash at casting DK spells by non-DK characters.

This commit is contained in:
VladimirMangos 2009-10-02 21:54:10 +04:00
parent 5440deddea
commit e167a567d5
5 changed files with 10 additions and 3 deletions

View file

@ -1972,6 +1972,9 @@ void Player::Regenerate(Powers power, uint32 diff)
} break; } break;
case POWER_RUNE: case POWER_RUNE:
{ {
if (getClass() != CLASS_DEATH_KNIGHT)
break;
for(uint32 i = 0; i < MAX_RUNES; ++i) for(uint32 i = 0; i < MAX_RUNES; ++i)
{ {
if(uint16 cd = GetRuneCooldown(i)) // if we have cooldown, reduce it... if(uint16 cd = GetRuneCooldown(i)) // if we have cooldown, reduce it...

View file

@ -2208,6 +2208,8 @@ class MANGOS_DLL_SPEC Player : public Unit
bool isAllowedToLoot(Creature* creature); bool isAllowedToLoot(Creature* creature);
DeclinedName const* GetDeclinedNames() const { return m_declinedname; } DeclinedName const* GetDeclinedNames() const { return m_declinedname; }
// Rune functions, need check getClass() == CLASS_DEATH_KNIGHT before access
uint8 GetRunesState() const { return m_runes->runeState; } uint8 GetRunesState() const { return m_runes->runeState; }
RuneType GetBaseRune(uint8 index) const { return RuneType(m_runes->runes[index].BaseRune); } RuneType GetBaseRune(uint8 index) const { return RuneType(m_runes->runes[index].BaseRune); }
RuneType GetCurrentRune(uint8 index) const { return RuneType(m_runes->runes[index].CurrentRune); } RuneType GetCurrentRune(uint8 index) const { return RuneType(m_runes->runes[index].CurrentRune); }
@ -2220,6 +2222,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void ResyncRunes(uint8 count); void ResyncRunes(uint8 count);
void AddRunePower(uint8 index); void AddRunePower(uint8 index);
void InitRunes(); void InitRunes();
AchievementMgr& GetAchievementMgr() { return m_achievementMgr; } AchievementMgr& GetAchievementMgr() { return m_achievementMgr; }
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0, Unit *unit=NULL, uint32 time=0); void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0, Unit *unit=NULL, uint32 time=0);
bool HasTitle(uint32 bitIndex); bool HasTitle(uint32 bitIndex);

View file

@ -3164,7 +3164,7 @@ void Spell::SendSpellGo()
if ( castFlags & CAST_FLAG_UNKNOWN7 ) // rune cooldowns list if ( castFlags & CAST_FLAG_UNKNOWN7 ) // rune cooldowns list
{ {
uint8 v1 = m_runesState; uint8 v1 = m_runesState;
uint8 v2 = ((Player*)m_caster)->GetRunesState(); uint8 v2 = m_caster->getClass() == CLASS_DEATH_KNIGHT ? ((Player*)m_caster)->GetRunesState() : 0;
data << uint8(v1); // runes state before data << uint8(v1); // runes state before
data << uint8(v2); // runes state after data << uint8(v2); // runes state after
for(uint8 i = 0; i < MAX_RUNES; ++i) for(uint8 i = 0; i < MAX_RUNES; ++i)

View file

@ -7008,7 +7008,8 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB
// Blade Barrier // Blade Barrier
if (auraSpellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && auraSpellInfo->SpellIconID == 85) if (auraSpellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && auraSpellInfo->SpellIconID == 85)
{ {
if (this->GetTypeId() != TYPEID_PLAYER || !((Player*)this)->IsBaseRuneSlotsOnCooldown(RUNE_BLOOD)) if (GetTypeId() != TYPEID_PLAYER || getClass() != CLASS_DEATH_KNIGHT ||
!((Player*)this)->IsBaseRuneSlotsOnCooldown(RUNE_BLOOD))
return false; return false;
} }

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 "8582" #define REVISION_NR "8583"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__