mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-28 12:52:25 +01:00
Core/Players: correct packet content of SMSG_RESYNC_RUNES and send converted runes that have been converted previously since the effect handler for SPELL_AURA_CONVERT_RUNE only sends it when converting an unconverted rune
closes #214
This commit is contained in:
@@ -23401,7 +23401,13 @@ void Player::SendInitialPacketsBeforeAddToMap()
|
||||
|
||||
/// SMSG_RESYNC_RUNES
|
||||
if (getClass() == CLASS_DEATH_KNIGHT)
|
||||
ResyncRunes(0);
|
||||
{
|
||||
// Initialize rune cooldowns
|
||||
ResyncRunes();
|
||||
|
||||
// Send already converted runes
|
||||
SendConvertedRunes();
|
||||
}
|
||||
|
||||
// Spell modifiers
|
||||
SendSpellModifiers();
|
||||
@@ -25448,7 +25454,7 @@ void Player::RestoreBaseRune(uint8 index)
|
||||
}
|
||||
|
||||
ConvertRune(index, GetBaseRune(index));
|
||||
SetRuneConvertAura(index, NULL, SPELL_AURA_NONE, NULL);
|
||||
SetRuneConvertAura(index, nullptr, SPELL_AURA_NONE, nullptr);
|
||||
}
|
||||
|
||||
void Player::ConvertRune(uint8 index, RuneType newType)
|
||||
@@ -25462,15 +25468,34 @@ void Player::ConvertRune(uint8 index, RuneType newType)
|
||||
SendDirectMessage(packet.Write());
|
||||
}
|
||||
|
||||
void Player::ResyncRunes(uint8 count)
|
||||
void Player::ResyncRunes()
|
||||
{
|
||||
WorldPackets::Spells::ResyncRunes packet(count);
|
||||
for (uint32 i = 0; i < count; ++i)
|
||||
packet.Runes.push_back({ uint8(GetCurrentRune(i)), uint8(255 - (GetRuneCooldown(i) * 51)) });
|
||||
WorldPackets::Spells::ResyncRunes packet;
|
||||
for (uint8 i = 0; i < MAX_RUNES; ++i)
|
||||
{
|
||||
WorldPackets::Spells::ResyncRune resyncRune;
|
||||
resyncRune.RuneType = GetCurrentRune(i);
|
||||
resyncRune.Cooldown = uint8(GetRuneCooldown(i) * uint32(255) / uint32(RUNE_BASE_COOLDOWN));
|
||||
packet.Runes.emplace_back(resyncRune);
|
||||
}
|
||||
|
||||
SendDirectMessage(packet.Write());
|
||||
}
|
||||
|
||||
void Player::SendConvertedRunes()
|
||||
{
|
||||
for (uint8 i = 0; i < MAX_RUNES; ++i)
|
||||
{
|
||||
if (GetBaseRune(i) != GetCurrentRune(i))
|
||||
{
|
||||
WorldPackets::Spells::ConvertRune convertRune;
|
||||
convertRune.Index = i;
|
||||
convertRune.Rune = GetCurrentRune(i);
|
||||
SendDirectMessage(convertRune.Write());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Player::AddRunePower(uint8 mask)
|
||||
{
|
||||
WorldPackets::Spells::AddRunePower packet;
|
||||
|
||||
@@ -2327,7 +2327,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
void RemoveRunesByAuraEffect(AuraEffect const* aura);
|
||||
void RestoreBaseRune(uint8 index);
|
||||
void ConvertRune(uint8 index, RuneType newType);
|
||||
void ResyncRunes(uint8 count);
|
||||
void ResyncRunes();
|
||||
void SendConvertedRunes();
|
||||
void AddRunePower(uint8 mask);
|
||||
void InitRunes();
|
||||
|
||||
|
||||
@@ -362,18 +362,19 @@ namespace WorldPackets
|
||||
uint8 Rune = 0;
|
||||
};
|
||||
|
||||
struct ResyncRune
|
||||
{
|
||||
uint8 RuneType = 0;
|
||||
uint8 Cooldown = 0;
|
||||
};
|
||||
|
||||
class ResyncRunes final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
struct ResyncRune
|
||||
{
|
||||
uint8 RuneType = 0;
|
||||
uint8 Cooldown = 0;
|
||||
};
|
||||
|
||||
ResyncRunes(size_t size) : ServerPacket(SMSG_RESYNC_RUNES, 4 + 2 * size) { }
|
||||
ResyncRunes() : ServerPacket(SMSG_RESYNC_RUNES, 4) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
std::vector<ResyncRune> Runes;
|
||||
};
|
||||
|
||||
|
||||
@@ -4982,14 +4982,22 @@ void AuraEffect::HandleAuraConvertRune(AuraApplication const* aurApp, uint8 mode
|
||||
if (player->getClass() != CLASS_DEATH_KNIGHT)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Converts a rune into a new rune type.
|
||||
* MiscValueA describes what rune type can be converted
|
||||
* MiscValueB describes into what rune the eligible rune will be converted into
|
||||
* Amount is the number of runes that will be converted if available
|
||||
*/
|
||||
|
||||
uint32 runes = m_amount;
|
||||
// convert number of runes specified in aura amount of rune type in miscvalue to runetype in miscvalueb
|
||||
|
||||
if (apply)
|
||||
{
|
||||
for (uint32 i = 0; i < MAX_RUNES && runes; ++i)
|
||||
{
|
||||
if (GetMiscValue() != player->GetCurrentRune(i))
|
||||
if (RuneType(GetMiscValue()) != player->GetCurrentRune(i))
|
||||
continue;
|
||||
|
||||
if (!player->GetRuneCooldown(i))
|
||||
{
|
||||
player->AddRuneByAuraEffect(i, RuneType(GetMiscValueB()), this, GetAuraType(), GetSpellInfo());
|
||||
|
||||
Reference in New Issue
Block a user