mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 01:37:37 +01:00
Core/Spells: fixed sending cooldown data in SMSG_SEND_KNOWN_SPELLS
This commit is contained in:
@@ -2627,16 +2627,10 @@ void Player::SendKnownSpells()
|
||||
|
||||
knownSpells.KnownSpells.push_back(spell.first);
|
||||
|
||||
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell.first))
|
||||
{
|
||||
uint32 cooldown = GetSpellHistory()->GetRemainingCooldown(spellInfo, false);
|
||||
uint32 categoryCooldown = GetSpellHistory()->GetRemainingCategoryCooldown(spellInfo);
|
||||
|
||||
if (cooldown || categoryCooldown)
|
||||
knownSpells.SpellHistoryEntries.push_back({ spellInfo->Id, 0, uint16(spellInfo->GetCategory()), int32(cooldown), int32(categoryCooldown) });
|
||||
}
|
||||
}
|
||||
|
||||
GetSpellHistory()->WriteSpellHistoryEntries<Player>(knownSpells.SpellHistoryEntries);
|
||||
|
||||
SendDirectMessage(knownSpells.Write());
|
||||
}
|
||||
|
||||
|
||||
@@ -265,8 +265,7 @@ namespace WorldPackets
|
||||
|
||||
struct SpellHistoryEntry
|
||||
{
|
||||
SpellHistoryEntry(uint32 spellId, uint32 itemId, uint16 category, int32 recoveryTime, int32 categoryRecoveryTime) :
|
||||
SpellID(spellId), ItemID(itemId), Category(category), RecoveryTime(recoveryTime), CategoryRecoveryTime(categoryRecoveryTime) { }
|
||||
SpellHistoryEntry() { }
|
||||
|
||||
uint32 SpellID = 0;
|
||||
uint32 ItemID = 0;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "Spell.h"
|
||||
#include "SpellInfo.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "SpellPackets.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
|
||||
@@ -238,45 +239,35 @@ void SpellHistory::WritePacket<Pet>(WorldPacket& packet) const
|
||||
}
|
||||
|
||||
template<>
|
||||
void SpellHistory::WritePacket<Player>(WorldPacket& packet) const
|
||||
void SpellHistory::WriteSpellHistoryEntries<Player>(std::vector<WorldPackets::Spells::SpellHistoryEntry>& spellHistoryEntries) const
|
||||
{
|
||||
Clock::time_point now = GameTime::GetGameTimeSystemPoint();
|
||||
|
||||
packet << uint16(_spellCooldowns.size());
|
||||
|
||||
for (auto const& spellCooldown : _spellCooldowns)
|
||||
{
|
||||
packet << uint32(spellCooldown.first);
|
||||
packet << uint32(spellCooldown.second.ItemId); // cast item id
|
||||
packet << uint16(spellCooldown.second.CategoryId); // spell category
|
||||
WorldPackets::Spells::SpellHistoryEntry& historyEntry = spellHistoryEntries.emplace_back();
|
||||
|
||||
historyEntry.SpellID = spellCooldown.first;
|
||||
historyEntry.ItemID = spellCooldown.second.ItemId;
|
||||
historyEntry.Category = spellCooldown.second.CategoryId;
|
||||
|
||||
// send infinity cooldown in special format
|
||||
if (spellCooldown.second.OnHold)
|
||||
{
|
||||
packet << uint32(1); // cooldown
|
||||
packet << uint32(0x80000000); // category cooldown
|
||||
historyEntry.RecoveryTime = 1; // cooldown
|
||||
historyEntry.CategoryRecoveryTime = 0x80000000; // category cooldown
|
||||
continue;
|
||||
}
|
||||
|
||||
std::chrono::milliseconds cooldownDuration = std::chrono::duration_cast<std::chrono::milliseconds>(spellCooldown.second.CooldownEnd - now);
|
||||
if (cooldownDuration.count() <= 0)
|
||||
{
|
||||
packet << uint32(0);
|
||||
packet << uint32(0);
|
||||
continue;
|
||||
}
|
||||
|
||||
std::chrono::milliseconds categoryDuration = std::chrono::duration_cast<std::chrono::milliseconds>(spellCooldown.second.CategoryEnd - now);
|
||||
if (categoryDuration.count() >= 0)
|
||||
{
|
||||
packet << uint32(0); // cooldown
|
||||
packet << uint32(categoryDuration.count()); // category cooldown
|
||||
}
|
||||
historyEntry.CategoryRecoveryTime = categoryDuration.count(); // category cooldown
|
||||
else
|
||||
{
|
||||
packet << uint32(cooldownDuration.count()); // cooldown
|
||||
packet << uint32(0); // category cooldown
|
||||
}
|
||||
historyEntry.RecoveryTime = cooldownDuration.count(); // cooldown
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,14 @@ class Unit;
|
||||
class WorldPacket;
|
||||
struct SpellCategoryEntry;
|
||||
|
||||
namespace WorldPackets
|
||||
{
|
||||
namespace Spells
|
||||
{
|
||||
struct SpellHistoryEntry;
|
||||
}
|
||||
}
|
||||
|
||||
/// Spell cooldown flags sent in SMSG_SPELL_COOLDOWN
|
||||
enum SpellCooldownFlags
|
||||
{
|
||||
@@ -75,6 +83,8 @@ public:
|
||||
bool IsReady(SpellInfo const* spellInfo, uint32 itemId = 0, bool ignoreCategoryCooldown = false) const;
|
||||
template<class OwnerType>
|
||||
void WritePacket(WorldPacket& packet) const;
|
||||
template<class OwnerType>
|
||||
void WriteSpellHistoryEntries(std::vector<WorldPackets::Spells::SpellHistoryEntry>& spellHistoryEntries) const;
|
||||
|
||||
// Cooldowns
|
||||
static Clock::duration const InfinityCooldownDelay; // used for set "infinity cooldowns" for spells and check
|
||||
|
||||
Reference in New Issue
Block a user