From efb10637de30479334bdec909d8a54a3d4a3b4cb Mon Sep 17 00:00:00 2001 From: Shauren Date: Tue, 18 Jun 2024 21:18:48 +0200 Subject: Fix GCC 11 build (cherry picked from commit c727e35d05ed6b5657a97cf576aa8f28bfd159a1) --- src/server/game/Entities/Player/Player.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 84478b62597..2d3778bc3e7 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -21715,16 +21715,24 @@ void Player::AddSpellMod(SpellModifier* mod, bool apply) if (mod->type == SPELLMOD_FLAT) { modData.ModifierValue = 0.0f; - for (SpellModifier* spellMod : std::ranges::equal_range(m_spellMods, std::make_pair(mod->op, SPELLMOD_FLAT), std::ranges::less(), [](SpellModifier const* sm) { return std::make_pair(sm->op, sm->type); })) - if (static_cast(spellMod)->mask[classIndex / 32] & (1u << (classIndex % 32))) - modData.ModifierValue += static_cast(spellMod)->value; + auto itr = std::ranges::lower_bound(m_spellMods, std::make_pair(mod->op, SPELLMOD_FLAT), std::ranges::less(), [](SpellModifier const* sm) { return std::make_pair(sm->op, sm->type); }); + while (itr != m_spellMods.end() && (*itr)->op == mod->op && (*itr)->type == SPELLMOD_FLAT) + { + SpellModifierByClassMask const* spellMod = static_cast(*itr++); + if (spellMod->mask[classIndex / 32] & (1u << (classIndex % 32))) + modData.ModifierValue += spellMod->value; + } } else { modData.ModifierValue = 1.0f; - for (SpellModifier* spellMod : std::ranges::equal_range(m_spellMods, std::make_pair(mod->op, SPELLMOD_PCT), std::ranges::less(), [](SpellModifier const* sm) { return std::make_pair(sm->op, sm->type); })) - if (static_cast(spellMod)->mask[classIndex / 32] & (1u << (classIndex % 32))) - modData.ModifierValue *= 1.0f + CalculatePct(1.0f, static_cast(spellMod)->value); + auto itr = std::ranges::lower_bound(m_spellMods, std::make_pair(mod->op, SPELLMOD_PCT), std::ranges::less(), [](SpellModifier const* sm) { return std::make_pair(sm->op, sm->type); }); + while (itr != m_spellMods.end() && (*itr)->op == mod->op && (*itr)->type == SPELLMOD_PCT) + { + SpellModifierByClassMask const* spellMod = static_cast(*itr++); + if (spellMod->mask[classIndex / 32] & (1u << (classIndex % 32))) + modData.ModifierValue *= 1.0f + CalculatePct(1.0f, spellMod->value); + } } modData.ClassIndex = classIndex; -- cgit v1.2.3