aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/SpellEffects.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Spells/SpellEffects.cpp')
-rw-r--r--src/server/game/Spells/SpellEffects.cpp70
1 files changed, 44 insertions, 26 deletions
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 56a44e0db6a..98017210f0b 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -3325,45 +3325,63 @@ void Spell::EffectApplyGlyph()
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
+ if (m_misc.GlyphSlot >= MAX_GLYPH_SLOT_INDEX)
+ return;
+
Player* player = m_caster->ToPlayer();
if (!player)
return;
- std::vector<uint32>& glyphs = player->GetGlyphs(player->GetActiveTalentGroup());
- std::size_t replacedGlyph = glyphs.size();
- for (std::size_t i = 0; i < glyphs.size(); ++i)
+ // glyph sockets level requirement
+ uint8 minLevel = 0;
+ switch (m_misc.GlyphSlot)
{
- if (std::vector<uint32> const* activeGlyphBindableSpells = sDB2Manager.GetGlyphBindableSpells(glyphs[i]))
- {
- if (std::find(activeGlyphBindableSpells->begin(), activeGlyphBindableSpells->end(), m_misc.SpellId) != activeGlyphBindableSpells->end())
- {
- replacedGlyph = i;
- player->RemoveAurasDueToSpell(sGlyphPropertiesStore.AssertEntry(glyphs[i])->SpellID);
- break;
- }
- }
+ case 0:
+ case 1: minLevel = 15; break;
+ case 2: minLevel = 50; break;
+ case 3: minLevel = 30; break;
+ case 4: minLevel = 70; break;
+ case 5: minLevel = 80; break;
+ }
+
+ if (minLevel && player->GetLevel() < minLevel)
+ {
+ SendCastResult(SPELL_FAILED_GLYPH_SOCKET_LOCKED);
+ return;
}
uint32 glyphId = effectInfo->MiscValue;
- if (replacedGlyph < glyphs.size())
+ if (!glyphId)
+ return;
+
+ GlyphPropertiesEntry const* glyphProperties = sGlyphPropertiesStore.LookupEntry(glyphId);
+ if (!glyphProperties)
+ return;
+
+ if (GlyphSlotEntry const* glyphSlotEntry = sGlyphSlotStore.LookupEntry(player->GetGlyphSlot(m_misc.GlyphSlot)))
{
- if (glyphId)
- glyphs[replacedGlyph] = glyphId;
- else
- glyphs.erase(glyphs.begin() + replacedGlyph);
+ if (glyphProperties->GlyphSlotFlags != glyphSlotEntry->Type)
+ {
+ SendCastResult(SPELL_FAILED_INVALID_GLYPH);
+ return; // glyph slot mismatch
+ }
}
- else if (glyphId)
- glyphs.push_back(glyphId);
- player->RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags2::ChangeGlyph);
+ // remove old glyph
+ if (uint32 oldglyph = player->GetGlyph(m_misc.GlyphSlot))
+ {
+ if (GlyphPropertiesEntry const* oldGp = sGlyphPropertiesStore.LookupEntry(oldglyph))
+ {
+ player->RemoveAurasDueToSpell(oldGp->SpellID);
+ player->SetGlyph(m_misc.GlyphSlot, 0);
+ }
+ }
- if (GlyphPropertiesEntry const* glyphProperties = sGlyphPropertiesStore.LookupEntry(glyphId))
- player->CastSpell(player, glyphProperties->SpellID, this);
+ player->CastSpell(player, glyphProperties->SpellID, this);
+ player->SetGlyph(m_misc.GlyphSlot, glyphId);
+ player->SendTalentsInfoData();
- WorldPackets::Talent::ActiveGlyphs activeGlyphs;
- activeGlyphs.Glyphs.emplace_back(m_misc.SpellId, uint16(glyphId));
- activeGlyphs.IsFullUpdate = false;
- player->SendDirectMessage(activeGlyphs.Write());
+ player->RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags2::ChangeGlyph);
}
void Spell::EffectEnchantHeldItem()