Core/Packets: converted SMSG_CLEAR_COOLDOWN and SMSG_CLEAR_COOLDOWNS to packet class

This commit is contained in:
Ovahlord
2021-08-16 11:02:22 +02:00
parent 8ac7e71690
commit da5564fa47
6 changed files with 72 additions and 37 deletions

View File

@@ -2614,10 +2614,10 @@ void Player::InitStatsForLevel(bool reapplyMods)
pet->SynchronizeLevelWithOwner();
}
void Player::SendKnownSpells()
void Player::SendKnownSpells(bool firstLogin /*= false*/)
{
WorldPackets::Spells::SendKnownSpells knownSpells;
knownSpells.InitialLogin = false; /// @todo
knownSpells.InitialLogin = firstLogin;
knownSpells.KnownSpells.reserve(m_spells.size());
for (PlayerSpellMap::value_type const& spell : m_spells)
@@ -23341,7 +23341,7 @@ void Player::SetGroup(Group* group, int8 subgroup)
UpdateObjectVisibility(false);
}
void Player::SendInitialPacketsBeforeAddToMap()
void Player::SendInitialPacketsBeforeAddToMap(bool firstLogin /*= false*/)
{
/// SMSG_CONTROL_UPDATE
SetClientControl(this, true);

View File

@@ -1036,7 +1036,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
bool IsInWater() const override { return m_isInWater; }
bool IsInAreaTriggerRadius(AreaTriggerEntry const* trigger) const;
void SendInitialPacketsBeforeAddToMap();
void SendInitialPacketsBeforeAddToMap(bool firstLogin = false);
void SendInitialPacketsAfterAddToMap();
void SendSupercededSpell(uint32 oldSpell, uint32 newSpell) const;
void SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8 arg = 0) const;
@@ -1575,7 +1575,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
bool IsCurrentSpecMasterySpell(SpellInfo const* spellInfo) const;
void SendProficiency(ItemClass itemClass, uint32 itemSubclassMask) const;
void SendKnownSpells();
void SendKnownSpells(bool firstLogin = false);
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);

View File

@@ -862,7 +862,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder const& holder)
hotfixInfo.Hotfixes = sDB2Manager.GetHotfixData();
SendPacket(hotfixInfo.Write());
pCurrChar->SendInitialPacketsBeforeAddToMap();
pCurrChar->SendInitialPacketsBeforeAddToMap(true);
// Send MOTD
{

View File

@@ -981,3 +981,39 @@ void WorldPackets::Spells::UpdateMissileTrajectory::Read()
_worldPacket.ReadByteSeq(Status->guid[6]);
}
}
WorldPacket const* WorldPackets::Spells::ClearCooldown::Write()
{
_worldPacket << int32(SpellID);
_worldPacket << CasterGUID;
return &_worldPacket;
}
WorldPacket const* WorldPackets::Spells::ClearCooldowns::Write()
{
_worldPacket.WriteBit(Guid[1]);
_worldPacket.WriteBit(Guid[3]);
_worldPacket.WriteBit(Guid[6]);
_worldPacket.WriteBits(SpellID.size(), 24);
_worldPacket.WriteBit(Guid[7]);
_worldPacket.WriteBit(Guid[5]);
_worldPacket.WriteBit(Guid[2]);
_worldPacket.WriteBit(Guid[4]);
_worldPacket.WriteBit(Guid[0]);
_worldPacket.WriteByteSeq(Guid[7]);
_worldPacket.WriteByteSeq(Guid[2]);
_worldPacket.WriteByteSeq(Guid[4]);
_worldPacket.WriteByteSeq(Guid[5]);
_worldPacket.WriteByteSeq(Guid[1]);
_worldPacket.WriteByteSeq(Guid[3]);
if (!SpellID.empty())
_worldPacket.append(SpellID.data(), SpellID.size());
_worldPacket.WriteByteSeq(Guid[0]);
_worldPacket.WriteByteSeq(Guid[6]);
return &_worldPacket;
}

View File

@@ -506,6 +506,28 @@ namespace WorldPackets
TaggedPosition<Position::XYZ> ImpactPos;
Optional<MovementInfo> Status;
};
class ClearCooldown final : public ServerPacket
{
public:
ClearCooldown() : ServerPacket(SMSG_CLEAR_COOLDOWN, 4 + 8) { }
WorldPacket const* Write() override;
ObjectGuid CasterGUID;
int32 SpellID = 0;
};
class ClearCooldowns final : public ServerPacket
{
public:
ClearCooldowns() : ServerPacket(SMSG_CLEAR_COOLDOWNS, 8) { }
WorldPacket const* Write() override;
ObjectGuid Guid;
std::vector<int32> SpellID;
};
}
}

View File

@@ -467,10 +467,10 @@ void SpellHistory::ResetCooldown(CooldownStorageType::iterator& itr, bool update
{
if (Player* playerOwner = GetPlayerOwner())
{
WorldPacket data(SMSG_CLEAR_COOLDOWN, 4 + 8);
data << uint32(itr->first);
data << uint64(_owner->GetGUID());
playerOwner->SendDirectMessage(&data);
WorldPackets::Spells::ClearCooldown packet;
packet.SpellID = itr->first;
packet.CasterGUID = _owner->GetGUID();
playerOwner->SendDirectMessage(packet.Write());
}
}
@@ -664,33 +664,10 @@ void SpellHistory::SendClearCooldowns(std::vector<int32> const& cooldowns) const
{
if (Player* playerOwner = GetPlayerOwner())
{
ObjectGuid guid = playerOwner->GetGUID();
WorldPacket data(SMSG_CLEAR_COOLDOWNS, 4 + 8);
data.WriteBit(guid[1]);
data.WriteBit(guid[3]);
data.WriteBit(guid[6]);
data.WriteBits(cooldowns.size(), 24); // Spell Count
data.WriteBit(guid[7]);
data.WriteBit(guid[5]);
data.WriteBit(guid[2]);
data.WriteBit(guid[4]);
data.WriteBit(guid[0]);
data.FlushBits();
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[2]);
data.WriteByteSeq(guid[4]);
data.WriteByteSeq(guid[5]);
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[3]);
for (int32 spell : cooldowns)
data << uint32(spell); // Spell ID
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[6]);
playerOwner->SendDirectMessage(&data);
WorldPackets::Spells::ClearCooldowns packet;
packet.Guid = playerOwner->GetGUID();
packet.SpellID = cooldowns;
playerOwner->SendDirectMessage(packet.Write());
}
}