From e167a567d53f233f5c359e24d568dc8968f16bfb Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Fri, 2 Oct 2009 21:54:10 +0400 Subject: [PATCH] [8583] Prevent crash at casting DK spells by non-DK characters. --- src/game/Player.cpp | 3 +++ src/game/Player.h | 3 +++ src/game/Spell.cpp | 2 +- src/game/Unit.cpp | 3 ++- src/shared/revision_nr.h | 2 +- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 11cc7251b..bae8ce3d5 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1972,6 +1972,9 @@ void Player::Regenerate(Powers power, uint32 diff) } break; case POWER_RUNE: { + if (getClass() != CLASS_DEATH_KNIGHT) + break; + for(uint32 i = 0; i < MAX_RUNES; ++i) { if(uint16 cd = GetRuneCooldown(i)) // if we have cooldown, reduce it... diff --git a/src/game/Player.h b/src/game/Player.h index 6bb046765..cd0ea2619 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -2208,6 +2208,8 @@ class MANGOS_DLL_SPEC Player : public Unit bool isAllowedToLoot(Creature* creature); DeclinedName const* GetDeclinedNames() const { return m_declinedname; } + + // Rune functions, need check getClass() == CLASS_DEATH_KNIGHT before access uint8 GetRunesState() const { return m_runes->runeState; } RuneType GetBaseRune(uint8 index) const { return RuneType(m_runes->runes[index].BaseRune); } 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 AddRunePower(uint8 index); void InitRunes(); + AchievementMgr& GetAchievementMgr() { return m_achievementMgr; } void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0, Unit *unit=NULL, uint32 time=0); bool HasTitle(uint32 bitIndex); diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index e0456337c..17c72034e 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -3164,7 +3164,7 @@ void Spell::SendSpellGo() if ( castFlags & CAST_FLAG_UNKNOWN7 ) // rune cooldowns list { 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(v2); // runes state after for(uint8 i = 0; i < MAX_RUNES; ++i) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 48a064330..fe01fdd83 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -7008,7 +7008,8 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB // Blade Barrier 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; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index cfc2bbbf5..2f2538551 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 "8582" + #define REVISION_NR "8583" #endif // __REVISION_NR_H__