From 00cc0e3b5c0b3fc107aba71a84e5dabda00dbf55 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 18 Feb 2010 00:53:51 +0300 Subject: [PATCH] [9404] Fixed glyph apply with with specs. This resolve problem when glyph rejetect applied at some spec if it applied already at another spec. --- src/game/CharacterHandler.cpp | 11 ++++------- src/game/Player.cpp | 31 ++++++++++++++++++++----------- src/game/Player.h | 5 +++-- src/game/SpellEffects.cpp | 12 ++---------- src/shared/revision_nr.h | 2 +- 5 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 675b56822a0..e3a3c9b9647 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -1129,14 +1129,11 @@ void WorldSession::HandleRemoveGlyph( WorldPacket & recv_data ) return; } - if(uint32 glyph = _player->GetGlyph(slot)) + if(_player->GetGlyph(slot)) { - if(GlyphPropertiesEntry const *gp = sGlyphPropertiesStore.LookupEntry(glyph)) - { - _player->RemoveAurasDueToSpell(gp->SpellId); - _player->SetGlyph(slot, 0); - _player->SendTalentsInfoData(false); - } + _player->ApplyGlyph(slot, false); + _player->SetGlyph(slot, 0); + _player->SendTalentsInfoData(false); } } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 46c03557c1c..fe9fddf8e7b 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -15018,7 +15018,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) _LoadGlyphs(holder->GetResult(PLAYER_LOGIN_QUERY_LOADGLYPHS)); _LoadAuras(holder->GetResult(PLAYER_LOGIN_QUERY_LOADAURAS), time_diff); - ApplyGlyphAuras(true); + ApplyGlyphs(true); // add ghost flag (must be after aura load: PLAYER_FLAGS_GHOST set in aura) if( HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST) ) @@ -20223,23 +20223,32 @@ void Player::InitGlyphsForLevel() SetUInt32Value(PLAYER_GLYPHS_ENABLED, value); } -void Player::ApplyGlyphAuras(bool apply) +void Player::ApplyGlyph(uint8 slot, bool apply) { - for (uint8 i = 0; i < MAX_GLYPH_SLOT_INDEX; ++i) + if (uint32 glyph = GetGlyph(slot)) { - if (uint32 glyph = GetGlyph(i)) + if(GlyphPropertiesEntry const *gp = sGlyphPropertiesStore.LookupEntry(glyph)) { - if(GlyphPropertiesEntry const *gp = sGlyphPropertiesStore.LookupEntry(glyph)) + if(apply) { - if(apply) - CastSpell(this, gp->SpellId, true); - else - RemoveAurasDueToSpell(gp->SpellId); + CastSpell(this, gp->SpellId, true); + SetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot, glyph); + } + else + { + RemoveAurasDueToSpell(gp->SpellId); + SetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot, 0); } } } } +void Player::ApplyGlyphs(bool apply) +{ + for (uint8 i = 0; i < MAX_GLYPH_SLOT_INDEX; ++i) + ApplyGlyph(i,apply); +} + void Player::EnterVehicle(Vehicle *vehicle) { VehicleEntry const *ve = sVehicleStore.LookupEntry(vehicle->GetVehicleId()); @@ -21390,7 +21399,7 @@ void Player::ActivateSpec(uint8 specNum) // unlearn GetActiveSpec() talents (not learned in specNum); // learn specNum talents - ApplyGlyphAuras(false); + ApplyGlyphs(false); SetActiveSpec(specNum); @@ -21402,7 +21411,7 @@ void Player::ActivateSpec(uint8 specNum) if (!IsActionButtonDataValid(itr->first,itr->second.GetAction(),itr->second.GetType(), this, false)) removeActionButton(m_activeSpec,itr->first); - ApplyGlyphAuras(true); + ApplyGlyphs(true); SendInitialActionButtons(); diff --git a/src/game/Player.h b/src/game/Player.h index 70b3975d4eb..5e85a252800 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1581,9 +1581,10 @@ class MANGOS_DLL_SPEC Player : public Unit void InitGlyphsForLevel(); void SetGlyphSlot(uint8 slot, uint32 slottype) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot, slottype); } uint32 GetGlyphSlot(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot); } - void SetGlyph(uint8 slot, uint32 glyph) { m_glyphs[m_activeSpec][slot].SetId(glyph); SetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot, glyph); } + void SetGlyph(uint8 slot, uint32 glyph) { m_glyphs[m_activeSpec][slot].SetId(glyph); } uint32 GetGlyph(uint8 slot) { return m_glyphs[m_activeSpec][slot].GetId(); } - void ApplyGlyphAuras(bool apply); + void ApplyGlyph(uint8 slot, bool apply); + void ApplyGlyphs(bool apply); uint32 GetFreePrimaryProfessionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2); } void SetFreePrimaryProfessions(uint16 profs) { SetUInt32Value(PLAYER_CHARACTER_POINTS2, profs); } diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index bc0f9251120..0ccae77fae0 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -5951,17 +5951,9 @@ void Spell::EffectApplyGlyph(uint32 i) } // remove old glyph - if(uint32 oldglyph = player->GetGlyph(m_glyphIndex)) - { - if(GlyphPropertiesEntry const *old_gp = sGlyphPropertiesStore.LookupEntry(oldglyph)) - { - player->RemoveAurasDueToSpell(old_gp->SpellId); - player->SetGlyph(m_glyphIndex, 0); - } - } - - player->CastSpell(m_caster, gp->SpellId, true); + player->ApplyGlyph(m_glyphIndex, false); player->SetGlyph(m_glyphIndex, glyph); + player->ApplyGlyph(m_glyphIndex, true); player->SendTalentsInfoData(false); } } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index afe00df4801..d0717631ff0 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 "9403" + #define REVISION_NR "9404" #endif // __REVISION_NR_H__