From 72d7819c2e35000ba42919895f0bf83e5f037004 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Wed, 21 Oct 2020 21:58:22 +0200 Subject: [PATCH] Core/Misc: converted more packets to packet class and implement some new fields for them --- src/server/game/Entities/Player/Player.cpp | 513 +++++++++--------- src/server/game/Entities/Player/Player.h | 12 +- .../game/Server/Packets/MiscPackets.cpp | 92 ++++ src/server/game/Server/Packets/MiscPackets.h | 106 ++++ .../game/Server/Packets/SpellPackets.cpp | 77 +++ src/server/game/Server/Packets/SpellPackets.h | 88 +++ src/server/game/Server/Protocol/Opcodes.cpp | 12 +- src/server/game/Server/Protocol/Opcodes.h | 12 +- .../game/Spells/Auras/SpellAuraEffects.cpp | 2 +- src/server/game/Spells/SpellEffects.cpp | 12 +- src/server/game/Spells/SpellHistory.cpp | 20 +- src/server/game/Spells/SpellHistory.h | 3 +- 12 files changed, 647 insertions(+), 302 deletions(-) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 3a2336a1ab..59a739b9bd 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -686,22 +686,14 @@ void Player::SendMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 Curre StopMirrorTimer(Type); return; } - WorldPacket data(SMSG_START_MIRROR_TIMER, (21)); - data << (uint32)Type; - data << CurrentValue; - data << MaxValue; - data << Regen; - data << (uint8)0; - data << (uint32)0; // spell id - SendDirectMessage(&data); + + SendDirectMessage(WorldPackets::Misc::StartMirrorTimer(Type, CurrentValue, MaxValue, Regen, 0, false).Write()); } void Player::StopMirrorTimer(MirrorTimerType Type) { m_MirrorTimer[Type] = DISABLED_MIRROR_TIMER; - WorldPacket data(SMSG_STOP_MIRROR_TIMER, 4); - data << (uint32)Type; - SendDirectMessage(&data); + SendDirectMessage(WorldPackets::Misc::StopMirrorTimer(Type).Write()); } bool Player::IsImmuneToEnvironmentalDamage() const @@ -973,11 +965,13 @@ void Player::SetDrunkValue(uint8 newDrunkValue, uint32 itemId /*= 0*/) if (newDrunkenState == oldDrunkenState) return; - WorldPacket data(SMSG_CROSSED_INEBRIATION_THRESHOLD, (8+4+4)); - data << uint64(GetGUID()); - data << uint32(newDrunkenState); - data << uint32(itemId); - SendMessageToSet(&data, true); + + WorldPackets::Misc::CrossedInebriationThreshold data; + data.Guid = GetGUID(); + data.Threshold = newDrunkenState; + data.ItemID = itemId; + + SendMessageToSet(data.Write(), true); } void Player::Update(uint32 p_time) @@ -2311,21 +2305,24 @@ void Player::GiveLevel(uint8 level) uint32 basehp = 0, basemana = 0; sObjectMgr->GetPlayerClassLevelInfo(getClass(), level, basehp, basemana); - // send levelup info to client - WorldPacket data(SMSG_LEVELUP_INFO, (4+4+MAX_POWERS_PER_CLASS*4+MAX_STATS*4)); - data << uint32(level); - data << uint32(int32(basehp) - int32(GetCreateHealth())); - // for (int i = 0; i < MAX_STORED_POWERS; ++i) // Powers loop (0-10) - data << uint32(int32(basemana) - int32(GetCreateMana())); - data << uint32(0); - data << uint32(0); - data << uint32(0); - data << uint32(0); - // end for - for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i) // Stats loop (0-4) - data << uint32(int32(info.stats[i]) - GetCreateStat(Stats(i))); - SendDirectMessage(&data); + WorldPackets::Misc::LevelUpInfo packet; + packet.Level = level; + packet.HealthDelta = 0; + + /// @todo find some better solution + // for (int i = 0; i < MAX_STORED_POWERS; ++i) + packet.PowerDelta[0] = int32(basemana) - int32(GetCreateMana()); + packet.PowerDelta[1] = 0; + packet.PowerDelta[2] = 0; + packet.PowerDelta[3] = 0; + packet.PowerDelta[4] = 0; + packet.PowerDelta[5] = 0; + + for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i) + packet.StatDelta[i] = int32(info.stats[i]) - GetCreateStat(Stats(i)); + + SendDirectMessage(packet.Write()); SetUInt32Value(PLAYER_NEXT_LEVEL_XP, sObjectMgr->GetXPForLevel(level)); @@ -2617,83 +2614,33 @@ void Player::InitStatsForLevel(bool reapplyMods) pet->SynchronizeLevelWithOwner(); } -void Player::SendInitialSpells() +void Player::SendKnownSpells() { - uint16 spellCooldowns = GetSpellHistory()->GetCooldownsSizeForPacket(); - uint16 spellCount = 0; + WorldPackets::Spells::SendKnownSpells knownSpells; + knownSpells.InitialLogin = false; /// @todo - WorldPacket data(SMSG_INITIAL_SPELLS, (1 + 2 + 4 * m_spells.size() + 2 + spellCooldowns * (2 + 2 + 2 + 4 + 4))); - data << uint8(0); - - size_t countPos = data.wpos(); - data << uint16(spellCount); // spell count placeholder - - for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) + knownSpells.KnownSpells.reserve(m_spells.size()); + for (PlayerSpellMap::value_type const& spell : m_spells) { - if (itr->second.state == PLAYERSPELL_REMOVED) + if (spell.second.state == PLAYERSPELL_REMOVED) continue; - if (!itr->second.active || itr->second.disabled) + if (!spell.second.active || spell.second.disabled) continue; - data << uint32(itr->first); - data << uint16(0); // it's not slot id + knownSpells.KnownSpells.push_back(spell.first); - ++spellCount; - } - - data.put(countPos, spellCount); // write real count value - - GetSpellHistory()->WritePacket(data); - - SendDirectMessage(&data); -} - -void Player::SendUnlearnSpells() -{ - WorldPacket data(SMSG_SEND_UNLEARN_SPELLS, 4 + 4 * m_spells.size()); - - uint32 spellCount = 0; - size_t countPos = data.wpos(); - data << uint32(spellCount); // spell count placeholder - - for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) - { - if (itr->second.state == PLAYERSPELL_REMOVED) - continue; - - if (itr->second.active || itr->second.disabled) - continue; - - auto skillLineAbilities = sSpellMgr->GetSkillLineAbilityMapBounds(itr->first); - if (skillLineAbilities.first == skillLineAbilities.second) - continue; - - bool hasSupercededSpellInfoInClient = false; - for (auto boundsItr = skillLineAbilities.first; boundsItr != skillLineAbilities.second; ++boundsItr) + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell.first)) { - if (boundsItr->second->SupercededBySpell) - { - hasSupercededSpellInfoInClient = true; - break; - } + uint32 cooldown = GetSpellHistory()->GetRemainingCooldown(spellInfo, false); + uint32 categoryCooldown = GetSpellHistory()->GetRemainingCategoryCooldown(spellInfo); + + if (cooldown || categoryCooldown) + knownSpells.SpellHistoryEntries.push_back({ spellInfo->Id, 0, uint16(spellInfo->CategoryEntry->ID), int32(cooldown), int32(categoryCooldown) }); } - - if (hasSupercededSpellInfoInClient) - continue; - - uint32 nextRank = sSpellMgr->GetNextSpellInChain(itr->first); - if (!nextRank || !HasSpell(nextRank)) - continue; - - data << uint32(itr->first); - - ++spellCount; } - data.put(countPos, spellCount); // write real count value - - SendDirectMessage(&data); + SendDirectMessage(knownSpells.Write()); } void Player::RemoveMail(uint32 id) @@ -2843,31 +2790,6 @@ bool Player::AddTalent(uint32 spellId, uint8 spec, bool learning) return false; } -static bool IsUnlearnSpellsPacketNeededForSpell(uint32 spellId) -{ - SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(spellId); - if (spellInfo->IsRanked() && !spellInfo->IsStackableWithRanks()) - { - auto skillLineAbilities = sSpellMgr->GetSkillLineAbilityMapBounds(spellId); - if (skillLineAbilities.first != skillLineAbilities.second) - { - bool hasSupercededSpellInfoInClient = false; - for (auto boundsItr = skillLineAbilities.first; boundsItr != skillLineAbilities.second; ++boundsItr) - { - if (boundsItr->second->SupercededBySpell) - { - hasSupercededSpellInfoInClient = true; - break; - } - } - - return !hasSupercededSpellInfoInClient; - } - } - - return false; -} - bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading /*= false*/, uint32 fromSkill /*= 0*/) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); @@ -2967,13 +2889,11 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent { if (next_active_spell_id) SendSupercededSpell(spellId, next_active_spell_id); - if (IsUnlearnSpellsPacketNeededForSpell(spellId)) - SendUnlearnSpells(); else { - WorldPacket data(SMSG_REMOVED_SPELL, 4); - data << uint32(spellId); - SendDirectMessage(&data); + WorldPackets::Spells::UnlearnedSpells unlearnedSpells; + unlearnedSpells.SpellID = spellId; + SendDirectMessage(unlearnedSpells.Write()); } } @@ -3048,8 +2968,6 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent newspell.dependent = dependent; newspell.disabled = disabled; - bool needsUnlearnSpellsPacket = false; - // replace spells in action bars and spellbook to bigger rank if only one spell rank must be accessible if (newspell.active && !newspell.disabled && !spellInfo->IsStackableWithRanks() && spellInfo->IsRanked()) { @@ -3069,10 +2987,7 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent if (spellInfo->IsHighRankOf(i_spellInfo)) { if (IsInWorld()) // not send spell (re-/over-)learn packets at loading - { SendSupercededSpell(itr2->first, spellId); - needsUnlearnSpellsPacket = needsUnlearnSpellsPacket || IsUnlearnSpellsPacketNeededForSpell(itr2->first); - } // mark old spell as disable (SMSG_SUPERCEDED_SPELL replace it in client by new) itr2->second.active = false; @@ -3083,10 +2998,7 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent else { if (IsInWorld()) // not send spell (re-/over-)learn packets at loading - { SendSupercededSpell(spellId, itr2->first); - needsUnlearnSpellsPacket = needsUnlearnSpellsPacket || IsUnlearnSpellsPacketNeededForSpell(spellId); - } // mark new spell as disable (not learned yet for client and will not learned) newspell.active = false; @@ -3098,9 +3010,6 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent } } - if (needsUnlearnSpellsPacket) - SendUnlearnSpells(); - // return false if spell disabled if (newspell.disabled) return false; @@ -3432,7 +3341,6 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) // activate lesser rank in spellbook/action bar, and cast it if need bool prev_activate = false; - bool needsUnlearnSpellsPacket = false; if (uint32 prev_id = sSpellMgr->GetPrevSpellInChain(spell_id)) { @@ -3465,7 +3373,6 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) { // downgrade spell ranks in spellbook and action bar SendSupercededSpell(spell_id, prev_id); - needsUnlearnSpellsPacket = IsUnlearnSpellsPacketNeededForSpell(prev_id); prev_activate = true; } } @@ -3496,15 +3403,12 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) if (sWorld->getBoolConfig(CONFIG_OFFHAND_CHECK_AT_SPELL_UNLEARN)) AutoUnequipOffhandIfNeed(); - if (needsUnlearnSpellsPacket) - SendUnlearnSpells(); - // remove from spell book if not replaced by lesser rank if (!prev_activate) { - WorldPacket data(SMSG_REMOVED_SPELL, 4); - data << uint32(spell_id); - SendDirectMessage(&data); + WorldPackets::Spells::UnlearnedSpells unlearnedSpells; + unlearnedSpells.SpellID = spell_id; + SendDirectMessage(unlearnedSpells.Write()); } if (Guild* guild = GetGuild()) @@ -5870,30 +5774,17 @@ int16 Player::GetSkillTempBonusValue(uint32 skill) const void Player::SendActionButtons(uint32 state) const { - WorldPacket data(SMSG_ACTION_BUTTONS, 1+(MAX_ACTION_BUTTONS*4)); - /* - state can be 0, 1, 2 - 0 - Sends initial action buttons, client does not validate if we have the spell or not - 1 - Used used after spec swaps, client validates if a spell is known. - 2 - Clears the action bars client sided. This is sent during spec swap before unlearning and before sending the new buttons - */ + WorldPackets::Spells::UpdateActionButtons packet; + if (state != 2) { - for (uint8 button = 0; button < MAX_ACTION_BUTTONS; ++button) - { - ActionButtonList::const_iterator itr = m_actionButtons.find(button); - if (itr != m_actionButtons.end() && itr->second.uState != ACTIONBUTTON_DELETED) - data << uint32(itr->second.packedData); - else - data << uint32(0); - } + for (auto itr = m_actionButtons.begin(); itr != m_actionButtons.end(); ++itr) + if (itr->second.uState != ACTIONBUTTON_DELETED && itr->first < packet.ActionButtons.size()) + packet.ActionButtons[itr->first] = itr->second.packedData; } - else - data.resize(MAX_ACTION_BUTTONS * 4); // insert crap, client doesnt even parse this for state == 2 + packet.Reason = state; - data << uint8(state); - SendDirectMessage(&data); - TC_LOG_DEBUG("network", "SMSG_ACTION_BUTTONS sent '%u' spec '%u' Sent", GetGUID().GetCounter(), GetActiveSpec()); + SendDirectMessage(packet.Write()); } bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) const @@ -16933,6 +16824,15 @@ void Player::SetHomebind(WorldLocation const& loc, uint32 areaId) CharacterDatabase.Execute(stmt); } +void Player::SendBindPointUpdate() const +{ + WorldPackets::Misc::BindPointUpdate packet; + packet.BindPosition = Position(m_homebindX, m_homebindY, m_homebindZ); + packet.BindMapID = m_homebindMapId; + packet.BindAreaID = m_homebindAreaId; + SendDirectMessage(packet.Write()); +} + uint32 Player::GetUInt32ValueFromArray(Tokenizer const& data, uint16 index) { if (index >= data.size()) @@ -21423,12 +21323,12 @@ void Player::ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell* s case SPELLMOD_CASTING_TIME: { SpellModifier* modInstantSpell = nullptr; - for (SpellModifier* mod : m_spellMods[op]) + for (SpellModifier* mod : m_spellMods[op][SPELLMOD_PCT]) { if (!IsAffectedBySpellmod(spellInfo, mod, spell)) continue; - if (mod->type == SPELLMOD_PCT && basevalue < T(10000) && mod->value <= -100) + if (basevalue < T(10000) && mod->value <= -100) { modInstantSpell = mod; break; @@ -21447,12 +21347,12 @@ void Player::ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell* s case SPELLMOD_CRITICAL_CHANCE: { SpellModifier* modCritical = nullptr; - for (SpellModifier* mod : m_spellMods[op]) + for (SpellModifier* mod : m_spellMods[op][SPELLMOD_FLAT]) { if (!IsAffectedBySpellmod(spellInfo, mod, spell)) continue; - if (mod->type == SPELLMOD_FLAT && mod->value >= 100) + if (mod->value >= 100) { modCritical = mod; break; @@ -21471,44 +21371,35 @@ void Player::ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell* s break; } - for (SpellModifier* mod : m_spellMods[op]) + for (SpellModifier* mod : m_spellMods[op][SPELLMOD_FLAT]) { if (!IsAffectedBySpellmod(spellInfo, mod, spell)) continue; - switch (mod->type) - { - case SPELLMOD_FLAT: - totalflat += mod->value; - break; - case SPELLMOD_PCT: - { - // skip percent mods with null basevalue (most important for spell mods with charges) - if (basevalue == T(0)) - continue; - - // special case (skip > 10sec spell casts for instant cast setting) - if (op == SPELLMOD_CASTING_TIME && mod->value <= -100 && basevalue >= T(10000)) - continue; - else if (!Player::HasSpellModApplied(mod, spell)) - { - // special case for Surge of Light, don't apply critical chance reduction if other mods not applied (ie procs while casting another spell) - // (Surge of Light is the only PCT_MOD on critical chance) - if (op == SPELLMOD_CRITICAL_CHANCE) - continue; - // special case for Backdraft, dont' apply GCD reduction if cast time reduction wasn't applied (ie when Backlash is consumed first) - // (Backdraft is the only PCT_MOD on global cooldown) - else if (op == SPELLMOD_GLOBAL_COOLDOWN) - continue; - } - - totalmul += CalculatePct(1.0f, mod->value); - break; - } - } - + totalflat += mod->value; Player::ApplyModToSpell(mod, spell); } + + for (SpellModifier* mod : m_spellMods[op][SPELLMOD_PCT]) + { + if (!IsAffectedBySpellmod(spellInfo, mod, spell)) + continue; + + // skip percent mods for null basevalue (most important for spell mods with charges) + if (basevalue + totalflat == T(0)) + continue; + + // special case (skip > 10sec spell casts for instant cast setting) + if (op == SPELLMOD_CASTING_TIME) + { + if (basevalue >= T(10000) && mod->value <= -100) + continue; + } + + totalmul *= 1.0f + CalculatePct(1.0f, mod->value); + Player::ApplyModToSpell(mod, spell); + } + basevalue = T(float(basevalue + totalflat) * totalmul); } @@ -21519,43 +21410,64 @@ template TC_GAME_API void Player::ApplySpellMod(uint32 spellId, SpellModOp op, f void Player::AddSpellMod(SpellModifier* mod, bool apply) { TC_LOG_DEBUG("spells", "Player::AddSpellMod: Player '%s' (%s), SpellID: %d", GetName().c_str(), GetGUID().ToString().c_str(), mod->spellId); - OpcodeServer opcode = OpcodeServer((mod->type == SPELLMOD_FLAT) ? SMSG_SET_FLAT_SPELL_MODIFIER : SMSG_SET_PCT_SPELL_MODIFIER); - int i = 0; - flag96 _mask = 0; - uint32 modTypeCount = 0; // count of mods per one mod->op - WorldPacket data(opcode); - data << uint32(1); // count of different mod->op's in packet - size_t writePos = data.wpos(); - data << uint32(modTypeCount); - data << uint8(mod->op); - for (int32 eff = 0; eff < 96; ++eff) - { - if (eff != 0 && (eff % 32) == 0) - _mask[i++] = 0; - - _mask[i] = uint32(1) << (eff - (32 * i)); - if (mod->mask & _mask) - { - int32 val = 0; - for (SpellModifier* spellMod : m_spellMods[mod->op]) - { - if (spellMod->type == mod->type && (spellMod->mask & _mask)) - val += spellMod->value; - } - val += apply ? mod->value : -(mod->value); - - data << uint8(eff); - data << float(val); - ++modTypeCount; - } - } - data.put(writePos, modTypeCount); - SendDirectMessage(&data); + /// First, manipulate our spellmodifier container if (apply) - m_spellMods[mod->op].insert(mod); + m_spellMods[mod->op][mod->type].insert(mod); else - m_spellMods[mod->op].erase(mod); + m_spellMods[mod->op][mod->type].erase(mod); + + /// Now, send spellmodifier packet + if (!IsLoading()) + { + OpcodeServer opcode = (mod->type == SPELLMOD_FLAT) ? SMSG_SET_FLAT_SPELL_MODIFIER : SMSG_SET_PCT_SPELL_MODIFIER; + + WorldPackets::Spells::SetSpellModifier packet(opcode); + + /// @todo Implement sending of bulk modifiers instead of single + packet.Modifiers.resize(1); + WorldPackets::Spells::SpellModifier& spellMod = packet.Modifiers[0]; + + spellMod.ModIndex = mod->op; + + for (int eff = 0; eff < 96; ++eff) + { + flag96 mask; + mask[eff / 32] = 1u << (eff % 32); + if (mod->mask & mask) + { + WorldPackets::Spells::SpellModifierData modData; + + if (mod->type == SPELLMOD_FLAT) + { + modData.ModifierValue = 0.0f; + for (SpellModifier* spellMod : m_spellMods[mod->op][SPELLMOD_FLAT]) + if (spellMod->mask & mask) + modData.ModifierValue += spellMod->value; + } + else + { + modData.ModifierValue = 0.0f; + for (SpellModifier* spellMod : m_spellMods[mod->op][SPELLMOD_PCT]) + { + if (spellMod->mask & mask) + { + if (modData.ModifierValue > 0.f) + AddPct(modData.ModifierValue, spellMod->value); + else + modData.ModifierValue += spellMod->value; + } + } + } + + modData.ClassIndex = eff; + + spellMod.ModifierData.push_back(modData); + } + } + + SendDirectMessage(packet.Write()); + } } bool Player::HasSpellModApplied(SpellModifier* mod, Spell* spell) @@ -21590,6 +21502,64 @@ void Player::SetSpellModTakingSpell(Spell* spell, bool apply) m_spellModTakingSpell = apply ? spell : nullptr; } +void Player::SendSpellModifiers() const +{ + WorldPackets::Spells::SetSpellModifier flatMods(SMSG_SET_FLAT_SPELL_MODIFIER); + WorldPackets::Spells::SetSpellModifier pctMods(SMSG_SET_PCT_SPELL_MODIFIER); + for (uint8 i = 0; i < MAX_SPELLMOD; ++i) + { + WorldPackets::Spells::SpellModifier flatMod; + flatMod.ModifierData.resize(96); + WorldPackets::Spells::SpellModifier pctMod; + pctMod.ModifierData.resize(96); + flatMod.ModIndex = pctMod.ModIndex = i; + for (uint8 j = 0; j < 96; ++j) + { + flag96 mask; + mask[j / 32] = 1u << (j % 32); + + flatMod.ModifierData[j].ClassIndex = j; + flatMod.ModifierData[j].ModifierValue = 0.0f; + pctMod.ModifierData[j].ClassIndex = j; + pctMod.ModifierData[j].ModifierValue = 0.0f; + + for (SpellModifier* mod : m_spellMods[i][SPELLMOD_FLAT]) + if (mod->mask & mask) + flatMod.ModifierData[j].ModifierValue += mod->value; + + for (SpellModifier* mod : m_spellMods[i][SPELLMOD_PCT]) + { + if (mod->mask & mask) + { + if (flatMod.ModifierData[j].ModifierValue > 0.f) + AddPct(flatMod.ModifierData[j].ModifierValue, mod->value); + else + flatMod.ModifierData[j].ModifierValue += mod->value; + } + } + } + + flatMod.ModifierData.erase(std::remove_if(flatMod.ModifierData.begin(), flatMod.ModifierData.end(), [](WorldPackets::Spells::SpellModifierData const& mod) + { + return G3D::fuzzyEq(mod.ModifierValue, 0.0f); + }), flatMod.ModifierData.end()); + + pctMod.ModifierData.erase(std::remove_if(pctMod.ModifierData.begin(), pctMod.ModifierData.end(), [](WorldPackets::Spells::SpellModifierData const& mod) + { + return G3D::fuzzyEq(mod.ModifierValue, 1.0f); + }), pctMod.ModifierData.end()); + + flatMods.Modifiers.emplace_back(std::move(flatMod)); + pctMods.Modifiers.emplace_back(std::move(pctMod)); + } + + if (!flatMods.Modifiers.empty()) + SendDirectMessage(flatMods.Write()); + + if (!pctMods.Modifiers.empty()) + SendDirectMessage(pctMods.Write()); +} + // send Proficiency void Player::SendProficiency(ItemClass itemClass, uint32 itemSubclassMask) const { @@ -23390,63 +23360,64 @@ void Player::SendInitialPacketsBeforeAddToMap() /// Pass 'this' as argument because we're not stored in ObjectAccessor yet GetSocial()->SendSocialList(this, SOCIAL_FLAG_ALL); - // guild bank list wtf? - - // Homebind - WorldPacket data(SMSG_BINDPOINTUPDATE, 5*4); - data << m_homebindX << m_homebindY << m_homebindZ; - data << (uint32) m_homebindMapId; - data << (uint32) m_homebindAreaId; - SendDirectMessage(&data); + /// SMSG_BIND_POINT_UPDATE + SendBindPointUpdate(); // SMSG_SET_PROFICIENCY // SMSG_SET_PCT_SPELL_MODIFIER // SMSG_SET_FLAT_SPELL_MODIFIER - // SMSG_UPDATE_AURA_DURATION + /// SMSG_TALENTS_INFO SendTalentsInfoData(false); - data.Initialize(SMSG_WORLD_SERVER_INFO, 1 + 1 + 4 + 4); - data.WriteBit(0); // HasRestrictedLevel - data.WriteBit(0); // HasRestrictedMoney - data.WriteBit(0); // IneligibleForLoot - data.FlushBits(); - //if (IneligibleForLoot) - // data << uint32(0); // EncounterMask + /// SMSG_SEND_KNOWN_SPELLS + SendKnownSpells(); - data << uint8(0); // IsOnTournamentRealm - //if (HasRestrictedMoney) - // data << uint32(100000); // RestrictedMoney (starter accounts) - //if (HasRestrictedLevel) - // data << uint32(20); // RestrictedLevel (starter accounts) - - data << uint32(sWorld->GetNextWeeklyQuestsResetTime() - WEEK); // LastWeeklyReset (not instance reset) - data << uint32(GetMap()->GetDifficulty()); - SendDirectMessage(&data); - - SendInitialSpells(); - SendUnlearnSpells(); + /// SMSG_SEND_UNLEARN_SPELLS + SendDirectMessage(WorldPackets::Spells::SendUnlearnSpells().Write()); + /// SMSG_UPDATE_ACTION_BUTTONS SendInitialActionButtons(); - m_reputationMgr->SendInitialReputations(); - m_achievementMgr->SendAllAchievementData(this); + /// SMSG_INITIALIZE_FACTIONS + m_reputationMgr->SendInitialReputations(); + + /// SMSG_SET_FORCED_REACTIONS + GetReputationMgr().SendForceReactions(); + + /// SMSG_SETUP_CURRENCY + SendCurrencies(); + + /// SMSG_EQUIPMENT_SET_LIST SendEquipmentSetList(); - data.Initialize(SMSG_LOGIN_SETTIMESPEED, 4 + 4 + 4); - data.AppendPackedTime(GameTime::GetGameTime()); - data << float(0.01666667f); // game speed - data << uint32(0); // added in 3.1.2 - SendDirectMessage(&data); + m_achievementMgr->SendAllAchievementData(this); - GetReputationMgr().SendForceReactions(); // SMSG_SET_FORCED_REACTIONS + /// SMSG_LOGIN_SET_TIME_SPEED + static float const TimeSpeed = 0.01666667f; + WorldPackets::Misc::LoginSetTimeSpeed loginSetTimeSpeed; + loginSetTimeSpeed.NewSpeed = TimeSpeed; + loginSetTimeSpeed.GameTime = GameTime::GetGameTime(); + loginSetTimeSpeed.GameTimeHolidayOffset = 0; /// @todo + SendDirectMessage(loginSetTimeSpeed.Write()); + + /// SMSG_WORLD_SERVER_INFO + WorldPackets::Misc::WorldServerInfo worldServerInfo; + worldServerInfo.IsTournamentRealm = 0; /// @todo + // worldServerInfo.RestrictedAccountMaxLevel; /// @todo + // worldServerInfo.RestrictedAccountMaxMoney; /// @todo + worldServerInfo.DifficultyID = GetMap()->GetDifficulty(); + worldServerInfo.WeeklyReset = sWorld->GetNextWeeklyQuestsResetTime() - WEEK; + SendDirectMessage(worldServerInfo.Write()); + + // Spell modifiers + SendSpellModifiers(); // SMSG_TALENTS_INFO x 2 for pet (unspent points and talents in separate packets...) // SMSG_PET_GUIDS // SMSG_UPDATE_WORLD_STATE // SMSG_POWER_UPDATE - SendCurrencies(); SetMover(this); } diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 9823b5e99d..ab7058b89a 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -95,8 +95,9 @@ typedef std::deque PlayerMails; // Note: SPELLMOD_* values is aura types in fact enum SpellModType : uint8 { - SPELLMOD_FLAT = SPELL_AURA_ADD_FLAT_MODIFIER, - SPELLMOD_PCT = SPELL_AURA_ADD_PCT_MODIFIER + SPELLMOD_FLAT = 0, // SPELL_AURA_ADD_FLAT_MODIFIER + SPELLMOD_PCT = 1, // SPELL_AURA_ADD_PCT_MODIFIER + SPELLMOD_END }; // 2^n values, Player::m_isunderwater is a bitmask. These are Trinity internal values, they are never send to any client @@ -1591,8 +1592,7 @@ class TC_GAME_API Player : public Unit, public GridObject bool IsCurrentSpecMasterySpell(SpellInfo const* spellInfo) const; void SendProficiency(ItemClass itemClass, uint32 itemSubclassMask) const; - void SendInitialSpells(); - void SendUnlearnSpells(); + void SendKnownSpells(); bool AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading = false, uint32 fromSkill = 0); void LearnSpell(uint32 spell_id, bool dependent, uint32 fromSkill = 0); void RemoveSpell(uint32 spell_id, bool disabled = false, bool learn_low_rank = true); @@ -1673,6 +1673,7 @@ class TC_GAME_API Player : public Unit, public GridObject static void ApplyModToSpell(SpellModifier* mod, Spell* spell); static bool HasSpellModApplied(SpellModifier* mod, Spell* spell); void SetSpellModTakingSpell(Spell* spell, bool apply); + void SendSpellModifiers() const; void RemoveArenaSpellCooldowns(bool removeActivePetCooldowns = false); uint32 GetLastPotionId() const { return m_lastPotionId; } @@ -2176,6 +2177,7 @@ class TC_GAME_API Player : public Unit, public GridObject void Recall() { TeleportTo(m_recall_location); } void SetHomebind(WorldLocation const& loc, uint32 areaId); + void SendBindPointUpdate() const; // Homebind coordinates uint32 m_homebindMapId; @@ -2601,7 +2603,7 @@ class TC_GAME_API Player : public Unit, public GridObject uint32 m_baseHealthRegen; int32 m_spellPenetrationItemMod; - SpellModContainer m_spellMods[MAX_SPELLMOD]; + SpellModContainer m_spellMods[MAX_SPELLMOD][SPELLMOD_END]; EnchantDurationList m_enchantDuration; ItemDurationList m_itemDuration; diff --git a/src/server/game/Server/Packets/MiscPackets.cpp b/src/server/game/Server/Packets/MiscPackets.cpp index f031728d40..23dccecfe8 100644 --- a/src/server/game/Server/Packets/MiscPackets.cpp +++ b/src/server/game/Server/Packets/MiscPackets.cpp @@ -289,3 +289,95 @@ WorldPacket const* WorldPackets::Misc::SetPlayHoverAnim::Write() return &_worldPacket; } + +WorldPacket const* WorldPackets::Misc::StartMirrorTimer::Write() +{ + _worldPacket << int32(Timer); + _worldPacket << int32(Value); + _worldPacket << int32(MaxValue); + _worldPacket << int32(Scale); + _worldPacket << uint8(Paused); + _worldPacket << int32(SpellID); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Misc::PauseMirrorTimer::Write() +{ + _worldPacket << int32(Timer); + _worldPacket << uint8(Paused); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Misc::StopMirrorTimer::Write() +{ + _worldPacket << int32(Timer); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Misc::CrossedInebriationThreshold::Write() +{ + _worldPacket << Guid; + _worldPacket << int32(Threshold); + _worldPacket << int32(ItemID); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Misc::LevelUpInfo::Write() +{ + _worldPacket << int32(Level); + _worldPacket << int32(HealthDelta); + + for (int32 power : PowerDelta) + _worldPacket << power; + + for (int32 stat : StatDelta) + _worldPacket << stat; + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Misc::BindPointUpdate::Write() +{ + _worldPacket << BindPosition; + _worldPacket << uint32(BindMapID); + _worldPacket << uint32(BindAreaID); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Misc::WorldServerInfo::Write() +{ + _worldPacket.WriteBit(RestrictedAccountMaxLevel.is_initialized()); + _worldPacket.WriteBit(RestrictedAccountMaxMoney.is_initialized()); + _worldPacket.WriteBit(IneligibleForLootMask.is_initialized()); + _worldPacket.FlushBits(); + + if (IneligibleForLootMask) + _worldPacket << uint32(*IneligibleForLootMask); + + _worldPacket << uint8(IsTournamentRealm); + + if (RestrictedAccountMaxMoney) + _worldPacket << uint32(*RestrictedAccountMaxMoney); + + if (RestrictedAccountMaxLevel) + _worldPacket << uint32(*RestrictedAccountMaxLevel); + + _worldPacket << uint32(WeeklyReset); + _worldPacket << uint32(DifficultyID); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Misc::LoginSetTimeSpeed::Write() +{ + _worldPacket.AppendPackedTime(GameTime); + _worldPacket << float(NewSpeed); + _worldPacket << uint32(GameTimeHolidayOffset); + + return &_worldPacket; +} diff --git a/src/server/game/Server/Packets/MiscPackets.h b/src/server/game/Server/Packets/MiscPackets.h index 3ef8db75e0..0283deb939 100644 --- a/src/server/game/Server/Packets/MiscPackets.h +++ b/src/server/game/Server/Packets/MiscPackets.h @@ -21,6 +21,8 @@ #include "Packet.h" #include "ObjectGuid.h" #include "Optional.h" +#include "SharedDefines.h" +#include "Position.h" enum WeatherState : uint32; @@ -338,6 +340,110 @@ namespace WorldPackets ObjectGuid UnitGUID; bool PlayHoverAnim = false; }; + + class StartMirrorTimer final : public ServerPacket + { + public: + StartMirrorTimer() : ServerPacket(SMSG_START_MIRROR_TIMER, 4 + 4 + 4 + 4 + 4 + 1) { } + StartMirrorTimer(int32 timer, int32 value, int32 maxValue, int32 scale, int32 spellID, bool paused) : + ServerPacket(SMSG_START_MIRROR_TIMER, 21), Scale(scale), MaxValue(maxValue), Timer(timer), SpellID(spellID), Value(value), Paused(paused) { } + + WorldPacket const* Write() override; + + int32 Scale = 0; + int32 MaxValue = 0; + int32 Timer = 0; + int32 SpellID = 0; + int32 Value = 0; + bool Paused = false; + }; + + class PauseMirrorTimer final : public ServerPacket + { + public: + PauseMirrorTimer() : ServerPacket(SMSG_PAUSE_MIRROR_TIMER, 4 + 1) { } + PauseMirrorTimer(int32 timer, bool paused) : ServerPacket(SMSG_PAUSE_MIRROR_TIMER, 5), Timer(timer), Paused(paused) { } + + WorldPacket const* Write() override; + + int32 Timer = 0; + bool Paused = true; + }; + + class StopMirrorTimer final : public ServerPacket + { + public: + StopMirrorTimer() : ServerPacket(SMSG_STOP_MIRROR_TIMER, 4) { } + StopMirrorTimer(int32 timer) : ServerPacket(SMSG_STOP_MIRROR_TIMER, 4), Timer(timer) { } + + WorldPacket const* Write() override; + + int32 Timer = 0; + }; + + class CrossedInebriationThreshold final : public ServerPacket + { + public: + CrossedInebriationThreshold() : ServerPacket(SMSG_CROSSED_INEBRIATION_THRESHOLD, 8 + 4 + 4) { } + + WorldPacket const* Write() override; + + ObjectGuid Guid; + int32 ItemID = 0; + int32 Threshold = 0; + }; + + class LevelUpInfo final : public ServerPacket + { + public: + LevelUpInfo() : ServerPacket(SMSG_LEVEL_UP_INFO, 48) { } + + WorldPacket const* Write() override; + + int32 Level = 0; + int32 HealthDelta = 0; + std::array PowerDelta = { }; + std::array StatDelta = { }; + }; + + class BindPointUpdate final : public ServerPacket + { + public: + BindPointUpdate() : ServerPacket(SMSG_BIND_POINT_UPDATE, 20) { } + + WorldPacket const* Write() override; + + uint32 BindMapID = 0; + TaggedPosition BindPosition; + uint32 BindAreaID = 0; + }; + + class WorldServerInfo final : public ServerPacket + { + public: + WorldServerInfo() : ServerPacket(SMSG_WORLD_SERVER_INFO, 10) { } + + WorldPacket const* Write() override; + + uint32 DifficultyID = 0; + uint32 WeeklyReset = 0; + uint8 IsTournamentRealm = 0; + Optional IneligibleForLootMask; + Optional RestrictedAccountMaxLevel; + Optional RestrictedAccountMaxMoney; + }; + + class LoginSetTimeSpeed final : public ServerPacket + { + public: + LoginSetTimeSpeed() : ServerPacket(SMSG_LOGIN_SET_TIME_SPEED, 12) { } + + WorldPacket const* Write() override; + + float NewSpeed = 0.0f; + uint32 GameTime = 0; + uint32 GameTimeHolidayOffset = 0; + }; } } diff --git a/src/server/game/Server/Packets/SpellPackets.cpp b/src/server/game/Server/Packets/SpellPackets.cpp index 6da5ad2f72..fa708a2d28 100644 --- a/src/server/game/Server/Packets/SpellPackets.cpp +++ b/src/server/game/Server/Packets/SpellPackets.cpp @@ -329,3 +329,80 @@ WorldPacket const* WorldPackets::Spells::PlaySpellVisualKit::Write() return &_worldPacket; } + +WorldPacket const* WorldPackets::Spells::SendKnownSpells::Write() +{ + _worldPacket.reserve(1 + 2 + 6 * KnownSpells.size() + 2 + 14 * SpellHistoryEntries.size()); + + _worldPacket << uint8(InitialLogin); + _worldPacket << uint16(KnownSpells.size()); + + for (uint32 SpellID : KnownSpells) + { + _worldPacket << uint32(SpellID); + _worldPacket << int16(0); // Slot (unused) + } + + _worldPacket << uint16(SpellHistoryEntries.size()); + for (SpellHistoryEntry const& entry : SpellHistoryEntries) + { + _worldPacket << uint32(entry.SpellID); + _worldPacket << uint32(entry.ItemID); + _worldPacket << uint16(entry.Category); + _worldPacket << int32(entry.RecoveryTime); + _worldPacket << int32(entry.CategoryRecoveryTime); + } + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Spells::SendUnlearnSpells::Write() +{ + _worldPacket << uint32(Spells.size()); + for (uint32 spellId : Spells) + _worldPacket << uint32(spellId); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Spells::UnlearnedSpells::Write() +{ + _worldPacket << uint32(SpellID); + + return &_worldPacket; +} + +WorldPacket const* WorldPackets::Spells::UpdateActionButtons::Write() +{ + _worldPacket.append(ActionButtons.data(), ActionButtons.size()); + _worldPacket << Reason; + + return &_worldPacket; +} + +ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellModifierData const& spellModifierData) +{ + data << uint8(spellModifierData.ClassIndex); + data << float(spellModifierData.ModifierValue); + + return data; +} + +ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::SpellModifier const& spellModifier) +{ + data << uint32(spellModifier.ModifierData.size()); + data << uint8(spellModifier.ModIndex); + for (WorldPackets::Spells::SpellModifierData const& modData : spellModifier.ModifierData) + data << modData; + + return data; +} + +WorldPacket const* WorldPackets::Spells::SetSpellModifier::Write() +{ + _worldPacket << uint32(Modifiers.size()); + for (WorldPackets::Spells::SpellModifier const& spellMod : Modifiers) + _worldPacket << spellMod; + + return &_worldPacket; +} diff --git a/src/server/game/Server/Packets/SpellPackets.h b/src/server/game/Server/Packets/SpellPackets.h index 420d28ab14..b7ba94bb79 100644 --- a/src/server/game/Server/Packets/SpellPackets.h +++ b/src/server/game/Server/Packets/SpellPackets.h @@ -262,6 +262,94 @@ namespace WorldPackets int32 KitType = 0; uint32 Duration = 0; }; + + struct SpellHistoryEntry + { + SpellHistoryEntry(uint32 spellId, uint32 itemId, uint16 category, int32 recoveryTime, int32 categoryRecoveryTime) : + SpellID(spellId), ItemID(itemId), Category(category), RecoveryTime(recoveryTime), CategoryRecoveryTime(categoryRecoveryTime) { } + + uint32 SpellID = 0; + uint32 ItemID = 0; + uint16 Category = 0; + int32 RecoveryTime = 0; + int32 CategoryRecoveryTime = 0; + }; + + class SendKnownSpells final : public ServerPacket + { + public: + SendKnownSpells() : ServerPacket(SMSG_SEND_KNOWN_SPELLS, 1) { } + + WorldPacket const* Write() override; + + bool InitialLogin = false; + std::vector KnownSpells; + std::vector SpellHistoryEntries; + }; + + class SendUnlearnSpells final : public ServerPacket + { + public: + SendUnlearnSpells() : ServerPacket(SMSG_SEND_UNLEARN_SPELLS, 4) { } + + WorldPacket const* Write() override; + + std::vector Spells; + }; + + class UnlearnedSpells final : public ServerPacket + { + public: + UnlearnedSpells() : ServerPacket(SMSG_UNLEARNED_SPELLS, 4) { } + + WorldPacket const* Write() override; + + uint32 SpellID = 0; + }; + + class UpdateActionButtons final : public ServerPacket + { + public: + static std::size_t constexpr NumActionButtons = 144; + + UpdateActionButtons() : ServerPacket(SMSG_UPDATE_ACTION_BUTTONS, NumActionButtons * 8 + 1) + { + ActionButtons.fill(0); + } + + WorldPacket const* Write() override; + + std::array ActionButtons; + uint8 Reason = 0; + /* + Reason can be 0, 1, 2 + 0 - Sends initial action buttons, client does not validate if we have the spell or not + 1 - Used used after spec swaps, client validates if a spell is known. + 2 - Clears the action bars client sided. This is sent during spec swap before unlearning and before sending the new buttons + */ + }; + + struct SpellModifierData + { + float ModifierValue = 0.0f; + uint8 ClassIndex = 0; + }; + + struct SpellModifier + { + uint8 ModIndex = 0; + std::vector ModifierData; + }; + + class TC_GAME_API SetSpellModifier final : public ServerPacket + { + public: + SetSpellModifier(OpcodeServer opcode) : ServerPacket(opcode, 20) { } + + WorldPacket const* Write() override; + + std::vector Modifiers; + }; } } diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index d9fbb6dab3..be2e6c27fd 100644 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -658,7 +658,6 @@ void OpcodeTable::Initialize() DEFINE_SERVER_OPCODE_HANDLER(SMSG_ACCOUNT_RESTRICTED_WARNING, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_ACHIEVEMENT_DELETED, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_ACHIEVEMENT_EARNED, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_ACTION_BUTTONS, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_ACTIVATETAXIREPLY, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_ADDON_INFO, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_ADD_RUNE_POWER, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); @@ -721,7 +720,7 @@ void OpcodeTable::Initialize() DEFINE_SERVER_OPCODE_HANDLER(SMSG_BATTLEGROUND_PLAYER_JOINED, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_BATTLEGROUND_PLAYER_LEFT, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_BINDER_CONFIRM, STATUS_NEVER, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_BINDPOINTUPDATE, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_BIND_POINT_UPDATE, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_BINDZONEREPLY, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_BREAK_TARGET, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_BUY_BANK_SLOT_RESULT, STATUS_NEVER, CONNECTION_TYPE_REALM); @@ -935,7 +934,7 @@ void OpcodeTable::Initialize() DEFINE_SERVER_OPCODE_HANDLER(SMSG_HOTFIX_NOTIFY, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_HOTFIX_NOTIFY_BLOB, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_INITIALIZE_FACTIONS, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_INITIAL_SPELLS, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_SEND_KNOWN_SPELLS, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_SETUP_CURRENCY, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_INIT_WORLD_STATES, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_INSPECT_HONOR_STATS, STATUS_NEVER, CONNECTION_TYPE_REALM); @@ -964,7 +963,7 @@ void OpcodeTable::Initialize() DEFINE_SERVER_OPCODE_HANDLER(SMSG_KICK_REASON, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_LEARNED_DANCE_MOVES, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_LEARNED_SPELL, STATUS_NEVER, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_LEVELUP_INFO, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_LEVEL_UP_INFO, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_LFG_BOOT_PROPOSAL_UPDATE, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_LFG_DISABLED, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_LFG_JOIN_RESULT, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); @@ -990,7 +989,7 @@ void OpcodeTable::Initialize() DEFINE_SERVER_OPCODE_HANDLER(SMSG_LF_GUILD_RECRUIT_LIST_UPDATED, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_VENDOR_INVENTORY, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_LOAD_CUF_PROFILES, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_LOGIN_SETTIMESPEED, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_LOGIN_SET_TIME_SPEED, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_LOGIN_VERIFY_WORLD, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_LOGOUT_CANCEL_ACK, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_LOGOUT_COMPLETE, STATUS_NEVER, CONNECTION_TYPE_REALM); @@ -1172,7 +1171,6 @@ void OpcodeTable::Initialize() DEFINE_SERVER_OPCODE_HANDLER(SMSG_REFER_A_FRIEND_EXPIRED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_REFER_A_FRIEND_FAILURE, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_REFORGE_RESULT, STATUS_NEVER, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_REMOVED_SPELL, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_REPORT_PVP_AFK_RESULT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_REQUEST_CEMETERY_LIST_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_REQUEST_PVP_REWARDS_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_REALM); @@ -1190,6 +1188,7 @@ void OpcodeTable::Initialize() DEFINE_SERVER_OPCODE_HANDLER(SMSG_SELL_ITEM, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_SEND_MAIL_RESULT, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_SEND_UNLEARN_SPELLS, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_UNLEARNED_SPELLS, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_SERVERTIME, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_SERVER_FIRST_ACHIEVEMENT, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_SERVER_INFO_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_REALM); @@ -1309,6 +1308,7 @@ void OpcodeTable::Initialize() DEFINE_SERVER_OPCODE_HANDLER(SMSG_UNIT_SPELLCAST_START, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_UPDATE_ACCOUNT_DATA, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_UPDATE_ACTION_BUTTONS, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_UPDATE_COMBO_POINTS, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_UPDATE_CURRENCY, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_UPDATE_CURRENCY_WEEK_LIMIT, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); diff --git a/src/server/game/Server/Protocol/Opcodes.h b/src/server/game/Server/Protocol/Opcodes.h index 61894c2be7..070343b281 100644 --- a/src/server/game/Server/Protocol/Opcodes.h +++ b/src/server/game/Server/Protocol/Opcodes.h @@ -587,7 +587,6 @@ enum OpcodeServer SMSG_ACCOUNT_RESTRICTED_WARNING = 0x51A7, SMSG_ACHIEVEMENT_DELETED = 0x6A16, SMSG_ACHIEVEMENT_EARNED = 0x4405, - SMSG_ACTION_BUTTONS = 0x38B5, SMSG_ACTIVATETAXIREPLY = 0x6A37, SMSG_ADDON_INFO = 0x2C14, SMSG_ADD_RUNE_POWER = 0x6915, @@ -651,7 +650,7 @@ enum OpcodeServer SMSG_BATTLEGROUND_PLAYER_JOINED = 0x50B0, SMSG_BATTLEGROUND_PLAYER_LEFT = 0x59A6, SMSG_BINDER_CONFIRM = 0x2835, - SMSG_BINDPOINTUPDATE = 0x0527, + SMSG_BIND_POINT_UPDATE = 0x0527, SMSG_BINDZONEREPLY = 0x4C34, SMSG_BREAK_TARGET = 0x0105, SMSG_BUY_BANK_SLOT_RESULT = 0x4806, @@ -879,7 +878,7 @@ enum OpcodeServer SMSG_IGNORE_DIMINISHING_RETURNS_CHEAT = 0x0125, SMSG_IGNORE_REQUIREMENTS_CHEAT = 0x4E36, SMSG_INITIALIZE_FACTIONS = 0x4634, - SMSG_INITIAL_SPELLS = 0x0104, + SMSG_SEND_KNOWN_SPELLS = 0x0104, SMSG_SETUP_CURRENCY = 0x15A5, SMSG_INIT_WORLD_STATES = 0x4C15, SMSG_INSPECT = 0x0000, @@ -910,7 +909,7 @@ enum OpcodeServer SMSG_KICK_REASON = 0x4027, SMSG_LEARNED_DANCE_MOVES = 0x0E05, SMSG_LEARNED_SPELL = 0x58A2, - SMSG_LEVELUP_INFO = 0x0435, + SMSG_LEVEL_UP_INFO = 0x0435, SMSG_LFG_BOOT_PROPOSAL_UPDATE = 0x0F05, SMSG_LFG_DISABLED = 0x0815, SMSG_LFG_JOIN_RESULT = 0x38B6, @@ -938,7 +937,7 @@ enum OpcodeServer SMSG_LF_GUILD_RECRUIT_LIST_UPDATED = 0x1CB2, SMSG_VENDOR_INVENTORY = 0x7CB0, SMSG_LOAD_CUF_PROFILES = 0x50B1, - SMSG_LOGIN_SETTIMESPEED = 0x4D15, + SMSG_LOGIN_SET_TIME_SPEED = 0x4D15, SMSG_LOGIN_VERIFY_WORLD = 0x2005, SMSG_LOGOUT_CANCEL_ACK = 0x6514, SMSG_LOGOUT_COMPLETE = 0x2137, @@ -1130,7 +1129,6 @@ enum OpcodeServer SMSG_REFER_A_FRIEND_EXPIRED = 0x4934, SMSG_REFER_A_FRIEND_FAILURE = 0x2037, SMSG_REFORGE_RESULT = 0x58A4, - SMSG_REMOVED_SPELL = 0x4804, SMSG_REPORT_PVP_AFK_RESULT = 0x2D06, SMSG_REQUEST_CEMETERY_LIST_RESPONSE = 0x30A7, SMSG_REQUEST_PVP_REWARDS_RESPONSE = 0x5DA4, @@ -1149,6 +1147,7 @@ enum OpcodeServer SMSG_SELL_ITEM = 0x6105, SMSG_SEND_MAIL_RESULT = 0x4927, SMSG_SEND_UNLEARN_SPELLS = 0x4E25, + SMSG_UNLEARNED_SPELLS = 0x4804, SMSG_SERVERTIME = 0x6327, SMSG_SERVER_FIRST_ACHIEVEMENT = 0x6424, SMSG_SERVER_INFO_RESPONSE = 0x74B5, @@ -1269,6 +1268,7 @@ enum OpcodeServer SMSG_UNIT_SPELLCAST_START = 0x2517, SMSG_UPDATE_ACCOUNT_DATA = 0x6837, SMSG_UPDATE_ACCOUNT_DATA_COMPLETE = 0x2015, + SMSG_UPDATE_ACTION_BUTTONS = 0x38B5, SMSG_UPDATE_COMBO_POINTS = 0x6B34, SMSG_UPDATE_CURRENCY = 0x59B0, SMSG_UPDATE_CURRENCY_WEEK_LIMIT = 0x70A7, diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 0f98e55a19..ddc69a64f1 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -693,7 +693,7 @@ void AuraEffect::CalculateSpellMod() m_spellmod = new SpellModifier(GetBase()); m_spellmod->op = SpellModOp(GetMiscValue()); - m_spellmod->type = SpellModType(uint32(GetAuraType())); // SpellModType value == spell aura types + m_spellmod->type = GetAuraType() == SPELL_AURA_ADD_PCT_MODIFIER ? SPELLMOD_PCT : SPELLMOD_FLAT; m_spellmod->spellId = GetId(); m_spellmod->mask = GetSpellInfo()->Effects[GetEffIndex()].SpellClassMask; } diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 3e681b0ff5..7edb47c996 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -5503,21 +5503,13 @@ void Spell::EffectBind(SpellEffIndex effIndex) homeLoc = player->GetWorldLocation(); player->SetHomebind(homeLoc, areaId); - - // binding - WorldPacket data(SMSG_BINDPOINTUPDATE, 4 + 4 + 4 + 4 + 4); - data << float(homeLoc.GetPositionX()); - data << float(homeLoc.GetPositionY()); - data << float(homeLoc.GetPositionZ()); - data << uint32(homeLoc.GetMapId()); - data << uint32(areaId); - player->SendDirectMessage(&data); + player->SendBindPointUpdate(); TC_LOG_DEBUG("spells", "EffectBind: New homebind X: %f, Y: %f, Z: %f, MapId: %u, AreaId: %u", homeLoc.GetPositionX(), homeLoc.GetPositionY(), homeLoc.GetPositionZ(), homeLoc.GetMapId(), areaId); // zone update - data.Initialize(SMSG_PLAYERBOUND, 8 + 4); + WorldPacket data(SMSG_PLAYERBOUND, 8 + 4); data << uint64(m_caster->GetGUID()); data << uint32(areaId); player->SendDirectMessage(&data); diff --git a/src/server/game/Spells/SpellHistory.cpp b/src/server/game/Spells/SpellHistory.cpp index db59681ca5..e338d5fbe2 100644 --- a/src/server/game/Spells/SpellHistory.cpp +++ b/src/server/game/Spells/SpellHistory.cpp @@ -523,13 +523,13 @@ bool SpellHistory::HasCooldown(uint32 spellId, uint32 itemId /*= 0*/, bool ignor return HasCooldown(sSpellMgr->AssertSpellInfo(spellId), itemId, ignoreCategoryCooldown); } -uint32 SpellHistory::GetRemainingCooldown(SpellInfo const* spellInfo) const +uint32 SpellHistory::GetRemainingCooldown(SpellInfo const* spellInfo, bool withCategoryCooldown /*= true*/) const { Clock::time_point end; auto itr = _spellCooldowns.find(spellInfo->Id); if (itr != _spellCooldowns.end()) end = itr->second.CooldownEnd; - else + else if (withCategoryCooldown) { auto catItr = _categoryCooldowns.find(spellInfo->GetCategory()); if (catItr == _categoryCooldowns.end()) @@ -546,6 +546,22 @@ uint32 SpellHistory::GetRemainingCooldown(SpellInfo const* spellInfo) const return uint32(std::chrono::duration_cast(remaining).count()); } +uint32 SpellHistory::GetRemainingCategoryCooldown(SpellInfo const* spellInfo) const +{ + Clock::time_point end; + auto catItr = _categoryCooldowns.find(spellInfo->GetCategory()); + if (catItr == _categoryCooldowns.end()) + return 0; + + end = catItr->second->CategoryEnd; + Clock::time_point now = GameTime::GetGameTimeSystemPoint(); + if (end < now) + return 0; + + Clock::duration remaining = end - now; + return uint32(std::chrono::duration_cast(remaining).count()); +} + void SpellHistory::LockSpellSchool(SpellSchoolMask schoolMask, uint32 lockoutTime) { Clock::time_point now = GameTime::GetGameTimeSystemPoint(); diff --git a/src/server/game/Spells/SpellHistory.h b/src/server/game/Spells/SpellHistory.h index 7e5fae46b8..cffc0458e4 100644 --- a/src/server/game/Spells/SpellHistory.h +++ b/src/server/game/Spells/SpellHistory.h @@ -116,7 +116,8 @@ public: void ResetAllCooldowns(); bool HasCooldown(SpellInfo const* spellInfo, uint32 itemId = 0, bool ignoreCategoryCooldown = false) const; bool HasCooldown(uint32 spellId, uint32 itemId = 0, bool ignoreCategoryCooldown = false) const; - uint32 GetRemainingCooldown(SpellInfo const* spellInfo) const; + uint32 GetRemainingCooldown(SpellInfo const* spellInfo, bool withCategoryCooldown = true) const; + uint32 GetRemainingCategoryCooldown(SpellInfo const* spellInfo) const; // School lockouts void LockSpellSchool(SpellSchoolMask schoolMask, uint32 lockoutTime);