Core/PacketIO: Fix SMSG_SET_PCT_SPELL_MODIFIER

This commit is contained in:
funjoker
2024-09-22 22:59:07 +02:00
parent 992f1851e2
commit a80d7937bd
3 changed files with 9 additions and 9 deletions

View File

@@ -21189,7 +21189,7 @@ void Player::AddSpellMod(SpellModifier* mod, bool apply)
WorldPackets::Spells::SpellModifierData& modData = spellModifier.ModifierData.emplace_back();
if (mod->type == SPELLMOD_FLAT)
{
modData.ModifierValue = 0.0f;
modData.ModifierValue = 0;
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)
{
@@ -21200,13 +21200,13 @@ void Player::AddSpellMod(SpellModifier* mod, bool apply)
}
else
{
modData.ModifierValue = 1.0f;
modData.ModifierValue = 0;
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<SpellModifierByClassMask const*>(*itr++);
if (spellMod->mask[classIndex / 32] & (1u << (classIndex % 32)))
modData.ModifierValue *= 1.0f + CalculatePct(1.0f, spellMod->value);
modData.ModifierValue += spellMod->value;
}
}
@@ -21275,7 +21275,7 @@ void Player::SetSpellModTakingSpell(Spell* spell, bool apply)
void Player::SendSpellModifiers() const
{
auto getOrCreateModifierData = [](std::vector<WorldPackets::Spells::SpellModifierData>& datas, uint8 classIndex, float defaultValue) -> float&
auto getOrCreateModifierData = [](std::vector<WorldPackets::Spells::SpellModifierData>& datas, uint8 classIndex, int32 defaultValue) -> int32&
{
auto itr = std::ranges::find(datas, classIndex, &WorldPackets::Spells::SpellModifierData::ClassIndex);
if (itr != datas.end())
@@ -21312,7 +21312,7 @@ void Player::SendSpellModifiers() const
boost::from_block_range(&static_cast<SpellModifierByClassMask const*>(mod)->mask[0], &static_cast<SpellModifierByClassMask const*>(mod)->mask[0] + 4, mask);
for (std::size_t classIndex = mask.find_first(); classIndex != decltype(mask)::npos; classIndex = mask.find_next(classIndex))
{
float& modifierValue = getOrCreateModifierData(flatModifier->ModifierData, classIndex, 0.0f);
int32& modifierValue = getOrCreateModifierData(flatModifier->ModifierData, classIndex, 0);
modifierValue += static_cast<SpellModifierByClassMask const*>(mod)->value;
}
break;
@@ -21325,8 +21325,8 @@ void Player::SendSpellModifiers() const
boost::from_block_range(&static_cast<SpellModifierByClassMask const*>(mod)->mask[0], &static_cast<SpellModifierByClassMask const*>(mod)->mask[0] + 4, mask);
for (std::size_t classIndex = mask.find_first(); classIndex != decltype(mask)::npos; classIndex = mask.find_next(classIndex))
{
float& modifierValue = getOrCreateModifierData(pctModifier->ModifierData, classIndex, 1.0f);
modifierValue *= 1.0f + CalculatePct(1.0f, static_cast<SpellModifierByClassMask const*>(mod)->value);
int32& modifierValue = getOrCreateModifierData(pctModifier->ModifierData, classIndex, 0);
modifierValue += static_cast<SpellModifierByClassMask const*>(mod)->value;
}
break;
default:

View File

@@ -535,7 +535,7 @@ WorldPacket const* PetCastFailed::Write()
ByteBuffer& operator<<(ByteBuffer& data, SpellModifierData const& spellModifierData)
{
data << float(spellModifierData.ModifierValue);
data << int32(spellModifierData.ModifierValue);
data << uint8(spellModifierData.ClassIndex);
return data;

View File

@@ -477,7 +477,7 @@ namespace WorldPackets
struct SpellModifierData
{
float ModifierValue = 0.0f;
int32 ModifierValue = 0;
uint8 ClassIndex = 0;
};