Removed any 'legacy' functions from the new code

This commit is contained in:
dannuic
2026-04-27 17:52:45 -06:00
parent f3634e54ae
commit d16c1b2483
14 changed files with 141 additions and 132 deletions
+1 -6
View File
@@ -24,14 +24,9 @@ public:
IBuff() = default; IBuff() = default;
virtual ~IBuff() = default; virtual ~IBuff() = default;
// TODO: I think all of the legacy stuff can just be rolled into regular buff functions and the call sites modified
virtual std::unique_ptr<EQApplicationPacket> MakeLegacyBuffsPacket(Mob* mob, bool for_target,
bool clear_buffs) const = 0;
virtual std::unique_ptr<EQApplicationPacket> LegacyBuffDefinition(Mob* mob, Buffs_Struct& buff, int slot) const = 0; // TODO: add the buffs definition packet
virtual std::unique_ptr<EQApplicationPacket> BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot, virtual std::unique_ptr<EQApplicationPacket> BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot,
bool fade) const = 0; bool fade) const = 0;
virtual std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, int32_t timer, bool remove, virtual std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const = 0; bool buff_timers_suspended, const std::vector<uint32_t>& slots) const = 0;
virtual void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const = 0; virtual void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const = 0;
}; };
+26 -17
View File
@@ -35,6 +35,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include "zone/client.h"
#include "zone/mob.h" #include "zone/mob.h"
@@ -4290,21 +4291,15 @@ namespace SoD
namespace Buff { namespace Buff {
std::unique_ptr<EQApplicationPacket> SoD::MakeLegacyBuffsPacket(Mob* mob, bool for_target, bool clear_buffs) const std::unique_ptr<EQApplicationPacket> SoD::RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const
{ {
// SoD only supports target refresh, not self refresh packets // SoD only supports target refresh, not self refresh packets
if (for_target) { if (opcode == OP_RefreshTargetBuffs) {
uint32 count = 0; uint32 count = 0;
uint32 buff_count; uint32 buff_count;
// for self we want all buffs, for target, we want to skip song window buffs buff_count = mob->GetMaxTotalSlots();
// since NPCs and pets don't have a song window, we still see it for them :P
if (for_target) {
buff_count = (clear_buffs) ? 0 : mob->GetMaxBuffSlots();
}
else {
buff_count = mob->GetMaxTotalSlots();
}
Buffs_Struct* buffs = mob->GetBuffs(); Buffs_Struct* buffs = mob->GetBuffs();
@@ -4314,7 +4309,7 @@ std::unique_ptr<EQApplicationPacket> SoD::MakeLegacyBuffsPacket(Mob* mob, bool f
} }
} }
auto outapp = std::make_unique<EQApplicationPacket>(OP_RefreshTargetBuffs, auto outapp = std::make_unique<EQApplicationPacket>(opcode,
sizeof(BuffIcon_Struct) + sizeof(BuffIconEntry_Struct) * count); sizeof(BuffIcon_Struct) + sizeof(BuffIconEntry_Struct) * count);
BuffIcon_Struct *buff = (BuffIcon_Struct*)outapp->pBuffer; BuffIcon_Struct *buff = (BuffIcon_Struct*)outapp->pBuffer;
@@ -4322,12 +4317,8 @@ std::unique_ptr<EQApplicationPacket> SoD::MakeLegacyBuffsPacket(Mob* mob, bool f
buff->count = count; buff->count = count;
buff->all_buffs = 1; buff->all_buffs = 1;
buff->tic_timer = mob->GetRemainingTicTime(); buff->tic_timer = mob->GetRemainingTicTime();
// there are more types, the client doesn't seem to really care though. The others are also currently hard to fill in here ... // (see comment in common/eq_packet_structs.h), mutated in SetRefreshType
// (see comment in common/eq_packet_structs.h) buff->type = mob->IsClient() ? 5 : 7;
if (for_target)
buff->type = mob->IsClient() ? 5 : 7;
else
buff->type = 0;
buff->name_lengths = 0; // hacky shit buff->name_lengths = 0; // hacky shit
uint32 index = 0; uint32 index = 0;
@@ -4349,4 +4340,22 @@ std::unique_ptr<EQApplicationPacket> SoD::MakeLegacyBuffsPacket(Mob* mob, bool f
return nullptr; return nullptr;
} }
// 0 = self buff window, 1 = self target window, 2 = pet buff or target window, 4 = group, 5 = PC, 7 = NPC
void SoD::SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const
{
if (packet) {
BuffIcon_Struct *buff = (BuffIcon_Struct*)packet->pBuffer;
if (target->GetID() == source->GetID())
buff->type = 1;
else if (target->IsPet())
buff->type = 2;
else if (target->HasGroup() && source->GetGroup() == target->GetGroup())
buff->type = 4;
else if (target->IsClient())
buff->type = 5;
else
buff->type = 7;
}
}
} // namespace Buff } // namespace Buff
+3 -2
View File
@@ -69,8 +69,9 @@ public:
SoD() = default; SoD() = default;
~SoD() override = default; ~SoD() override = default;
std::unique_ptr<EQApplicationPacket> MakeLegacyBuffsPacket(Mob* mob, bool for_target, std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool clear_buffs) const override; bool buff_timers_suspended, const std::vector<uint32_t>& slots) const override;
void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const override;
}; };
} // namespace Buff } // namespace Buff
+4 -13
View File
@@ -4019,12 +4019,9 @@ void Titanium::ResolveArguments(uint32_t id, std::array<const char*, 9>& args) c
} // namespace Message } // namespace Message
namespace Buff { namespace Buff {
std::unique_ptr<EQApplicationPacket> Titanium::MakeLegacyBuffsPacket(Mob* mob, bool for_target, bool clear_buffs) const
{
return nullptr;
}
std::unique_ptr<EQApplicationPacket> Titanium::LegacyBuffDefinition(Mob* mob, Buffs_Struct& buff, int slot) const std::unique_ptr<EQApplicationPacket> Titanium::BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot,
bool fade) const
{ {
auto outapp = std::make_unique<EQApplicationPacket>(OP_BuffDefinition, sizeof(SpellBuffPacket_Struct)); auto outapp = std::make_unique<EQApplicationPacket>(OP_BuffDefinition, sizeof(SpellBuffPacket_Struct));
SpellBuffPacket_Struct* sbf = (SpellBuffPacket_Struct*) outapp->pBuffer; SpellBuffPacket_Struct* sbf = (SpellBuffPacket_Struct*) outapp->pBuffer;
@@ -4052,18 +4049,12 @@ std::unique_ptr<EQApplicationPacket> Titanium::LegacyBuffDefinition(Mob* mob, Bu
sbf->buff.z = buff.caston_z; sbf->buff.z = buff.caston_z;
sbf->slotid = slot; sbf->slotid = slot;
sbf->bufffade = 0; sbf->bufffade = fade;
return outapp; return outapp;
} }
std::unique_ptr<EQApplicationPacket> Titanium::BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot, std::unique_ptr<EQApplicationPacket> Titanium::RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool fade) const
{
return nullptr;
}
std::unique_ptr<EQApplicationPacket> Titanium::RefreshBuffs(EmuOpcode opcode, Mob* mob, int32_t timer, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const bool buff_timers_suspended, const std::vector<uint32_t>& slots) const
{ {
return nullptr; return nullptr;
+3 -7
View File
@@ -85,13 +85,9 @@ public:
Titanium() = default; Titanium() = default;
~Titanium() override = default; ~Titanium() override = default;
std::unique_ptr<EQApplicationPacket> MakeLegacyBuffsPacket(Mob* mob, bool for_target, std::unique_ptr<EQApplicationPacket> BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot,
bool clear_buffs) const override; bool fade) const override;
std::unique_ptr<EQApplicationPacket> LegacyBuffDefinition(Mob* mob, Buffs_Struct& buff, int slot) const override; std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
std::unique_ptr<EQApplicationPacket>
BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot, bool fade) const override;
std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, int32_t timer, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const override; bool buff_timers_suspended, const std::vector<uint32_t>& slots) const override;
void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const override; void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const override;
}; };
+17 -16
View File
@@ -5613,7 +5613,6 @@ std::unique_ptr<EQApplicationPacket> TOB::InterruptSpellOther(Mob* sender, uint3
} // namespace Message } // namespace Message
namespace Buff { namespace Buff {
// std::unique_ptr<EQApplicationPacket> TOB::MakeLegacyBuffsPacket(Mob* mob, bool for_target, bool clear_buffs) const { return nullptr; }
std::unique_ptr<EQApplicationPacket> TOB::BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot, bool fade) const std::unique_ptr<EQApplicationPacket> TOB::BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot, bool fade) const
{ {
@@ -5641,7 +5640,7 @@ std::unique_ptr<EQApplicationPacket> TOB::BuffDefinition(Mob* mob, const Buffs_S
affect->affect.flags = 0; affect->affect.flags = 0;
affect->affect.spell_id = buff.spellid; affect->affect.spell_id = buff.spellid;
affect->affect.duration = buff.ticsremaining; affect->affect.duration = buff.ticsremaining;
affect->affect.initial_duration = buff.ticsremaining; // this isn't correct, it's the total duration affect->affect.initial_duration = buff.ticsremaining; // TODO: this isn't correct, it's the total duration
affect->affect.hit_count = buff.hit_number; affect->affect.hit_count = buff.hit_number;
affect->affect.viral_timer = 0; affect->affect.viral_timer = 0;
affect->affect.modifier = static_cast<float>(buff.instrument_mod) / 10.f; affect->affect.modifier = static_cast<float>(buff.instrument_mod) / 10.f;
@@ -5667,7 +5666,7 @@ std::unique_ptr<EQApplicationPacket> TOB::BuffDefinition(Mob* mob, const Buffs_S
return packet; return packet;
} }
std::unique_ptr<EQApplicationPacket> TOB::RefreshBuffs(EmuOpcode opcode, Mob* mob, int32_t timer, bool remove, std::unique_ptr<EQApplicationPacket> TOB::RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const bool buff_timers_suspended, const std::vector<uint32_t>& slots) const
{ {
Buffs_Struct* buffs = mob->GetBuffs(); Buffs_Struct* buffs = mob->GetBuffs();
@@ -5692,8 +5691,8 @@ std::unique_ptr<EQApplicationPacket> TOB::RefreshBuffs(EmuOpcode opcode, Mob* mo
SerializeBuffer buffer(buffer_size); SerializeBuffer buffer(buffer_size);
buffer.WriteUInt32(mob->GetID()); buffer.WriteUInt32(mob->GetID());
buffer.WriteInt32(timer); buffer.WriteInt32(mob->GetRemainingTicTime());
buffer.WriteUInt8(slots.empty() ? 1 : 0); // 1 indicates all buffs on the player (0 to add or remove a single buff) buffer.WriteUInt8(slots.empty() ? 1 : 0); // 1 indicates all buffs on the mob (0 to add or remove a single buff)
buffer.WriteUInt16(send_slots.size()); buffer.WriteUInt16(send_slots.size());
for (uint32_t slot : send_slots) { for (uint32_t slot : send_slots) {
@@ -5713,18 +5712,20 @@ std::unique_ptr<EQApplicationPacket> TOB::RefreshBuffs(EmuOpcode opcode, Mob* mo
// 0 = self buff window, 1 = self target window, 2 = pet buff or target window, 4 = group, 5 = PC, 7 = NPC // 0 = self buff window, 1 = self target window, 2 = pet buff or target window, 4 = group, 5 = PC, 7 = NPC
void TOB::SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const void TOB::SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const
{ {
unsigned char* type = &packet->pBuffer[packet->size - 2]; if (packet) {
unsigned char* type = &packet->pBuffer[packet->size - 2];
if (target->GetID() == source->GetID()) if (target->GetID() == source->GetID())
*type = 1; *type = 1;
else if (target->IsPet()) else if (target->IsPet())
*type = 2; *type = 2;
else if (target->HasGroup() && source->GetGroup() == target->GetGroup()) else if (target->HasGroup() && source->GetGroup() == target->GetGroup())
*type = 4; *type = 4;
else if (target->IsClient()) else if (target->IsClient())
*type = 5; *type = 5;
else else
*type = 7; *type = 7;
}
} }
} // namespace Buff } // namespace Buff
+1 -4
View File
@@ -65,12 +65,9 @@ public:
TOB() = default; TOB() = default;
~TOB() override = default; ~TOB() override = default;
// std::unique_ptr<EQApplicationPacket> MakeLegacyBuffsPacket(Mob* mob, bool for_target,
// bool clear_buffs) const override;
std::unique_ptr<EQApplicationPacket> std::unique_ptr<EQApplicationPacket>
BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot, bool fade) const override; BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot, bool fade) const override;
std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, int32_t timer, bool remove, std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const override; bool buff_timers_suspended, const std::vector<uint32_t>& slots) const override;
void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const override; void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const override;
}; };
+5 -15
View File
@@ -5239,21 +5239,15 @@ namespace UF
namespace Buff { namespace Buff {
std::unique_ptr<EQApplicationPacket> UF::MakeLegacyBuffsPacket(Mob* mob, bool for_target, bool clear_buffs) const std::unique_ptr<EQApplicationPacket> UF::RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const
{ {
// UF introduced the self update buff packet // UF introduced the self update buff packet
uint32 count = 0; uint32 count = 0;
uint32 buff_count; uint32 buff_count;
// for self we want all buffs, for target, we want to skip song window buffs buff_count = mob->GetMaxTotalSlots();
// since NPCs and pets don't have a song window, we still see it for them :P
if (for_target) {
buff_count = (clear_buffs) ? 0 : mob->GetMaxBuffSlots();
}
else {
buff_count = mob->GetMaxTotalSlots();
}
Buffs_Struct* buffs = mob->GetBuffs(); Buffs_Struct* buffs = mob->GetBuffs();
@@ -5264,7 +5258,7 @@ std::unique_ptr<EQApplicationPacket> UF::MakeLegacyBuffsPacket(Mob* mob, bool fo
} }
//Create it for a targeting window, else create it for a create buff packet. //Create it for a targeting window, else create it for a create buff packet.
auto outapp = std::make_unique<EQApplicationPacket>(for_target ? OP_RefreshTargetBuffs : OP_RefreshBuffs, auto outapp = std::make_unique<EQApplicationPacket>(opcode,
sizeof(BuffIcon_Struct) + sizeof(BuffIconEntry_Struct) * count); sizeof(BuffIcon_Struct) + sizeof(BuffIconEntry_Struct) * count);
BuffIcon_Struct *buff = (BuffIcon_Struct*)outapp->pBuffer; BuffIcon_Struct *buff = (BuffIcon_Struct*)outapp->pBuffer;
@@ -5272,12 +5266,8 @@ std::unique_ptr<EQApplicationPacket> UF::MakeLegacyBuffsPacket(Mob* mob, bool fo
buff->count = count; buff->count = count;
buff->all_buffs = 1; buff->all_buffs = 1;
buff->tic_timer = mob->GetRemainingTicTime(); buff->tic_timer = mob->GetRemainingTicTime();
// there are more types, the client doesn't seem to really care though. The others are also currently hard to fill in here ...
// (see comment in common/eq_packet_structs.h) // (see comment in common/eq_packet_structs.h)
if (for_target) buff->type = mob->IsClient() ? 5 : 7;
buff->type = mob->IsClient() ? 5 : 7;
else
buff->type = 0;
buff->name_lengths = 0; // hacky shit buff->name_lengths = 0; // hacky shit
uint32 index = 0; uint32 index = 0;
+2 -2
View File
@@ -69,8 +69,8 @@ public:
UF() = default; UF() = default;
~UF() override = default; ~UF() override = default;
std::unique_ptr<EQApplicationPacket> MakeLegacyBuffsPacket(Mob* mob, bool for_target, std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool clear_buffs) const override; bool buff_timers_suspended, const std::vector<uint32_t>& slots) const override;
}; };
} // namespace Buff } // namespace Buff
+2 -3
View File
@@ -935,8 +935,7 @@ void Client::CompleteConnect()
delete pack; delete pack;
} }
if (IsClient()) Buff::SendFullBuffRefresh(this);
Buff::SendLegacyBuffsPacket(CastToClient(), this, false);
// TODO: load these states // TODO: load these states
// We at least will set them to the correct state for now // We at least will set them to the correct state for now
@@ -15108,7 +15107,7 @@ void Client::Handle_OP_TargetMouse(const EQApplicationPacket *app)
if (nt) if (nt)
{ {
SetTarget(nt); SetTarget(nt);
Buff::SendLegacyBuffsPacket(this, nt); Buff::SendFullBuffRefresh(nt);
} }
else else
{ {
+1 -2
View File
@@ -2309,8 +2309,7 @@ void Client::ClearHover()
entity_list.QueueClients(this, outapp, false); entity_list.QueueClients(this, outapp, false);
safe_delete(outapp); safe_delete(outapp);
if (IsClient()) Buff::SendFullBuffRefresh(this);
Buff::SendLegacyBuffsPacket(CastToClient(), this, false);
dead = false; dead = false;
} }
+69 -23
View File
@@ -19,6 +19,7 @@ namespace ClientPatch {
using ClientList = std::unordered_map<uint16, Client*>; using ClientList = std::unordered_map<uint16, Client*>;
template<typename Obj> using ComponentGetter = std::function<Obj*(const Client*)>; template<typename Obj> using ComponentGetter = std::function<Obj*(const Client*)>;
using SendPredicate = std::function<bool(Client*)>; using SendPredicate = std::function<bool(Client*)>;
using MutatePacket = std::function<void(std::unique_ptr<EQApplicationPacket>&, Client*)>;
template <typename Fun, typename Obj, typename... Args> template <typename Fun, typename Obj, typename... Args>
requires std::is_member_function_pointer_v<Fun> requires std::is_member_function_pointer_v<Fun>
@@ -106,7 +107,7 @@ static void FastQueuePacket(Client* c, Fun fun, Obj* obj, Args&&... args)
} }
} }
static auto QueueClientsByTarget(Mob* sender, bool ackreq, bool HoTT, const SendPredicate& ShouldSend) static auto QueueClientsByTarget(Mob* sender, bool ackreq, bool HoTT, const SendPredicate& should_send, const MutatePacket& mutate)
{ {
return [=]<typename Fun, typename Obj, typename... Args>(Fun fun, const ComponentGetter<Obj> component, Args&&... args) return [=]<typename Fun, typename Obj, typename... Args>(Fun fun, const ComponentGetter<Obj> component, Args&&... args)
requires std::is_member_function_pointer_v<Fun> requires std::is_member_function_pointer_v<Fun>
@@ -115,17 +116,18 @@ static auto QueueClientsByTarget(Mob* sender, bool ackreq, bool HoTT, const Send
std::array<std::unique_ptr<EQApplicationPacket>, EQ::versions::ClientVersionCount> build_packets; std::array<std::unique_ptr<EQApplicationPacket>, EQ::versions::ClientVersionCount> build_packets;
for (auto [_, c] : entity_list.GetClientList()) { for (auto [_, c] : entity_list.GetClientList()) {
if (c != sender) { Mob* Target = c->GetTarget();
Mob* Target = c->GetTarget(); if ((Target == sender || (HoTT && Target != nullptr && Target->GetTarget() == sender)) &&
if ((Target == sender || (HoTT && Target != nullptr && Target->GetTarget() == sender)) && ShouldSend(c)) { (Target == c || should_send(c))) {
auto& packet = build_packets.at(static_cast<uint32_t>(c->ClientVersion())); auto& packet = build_packets.at(static_cast<uint32_t>(c->ClientVersion()));
if (!packet) if (!packet)
if (auto comp = component(c); comp != nullptr) if (auto comp = component(c); comp != nullptr)
packet = std::invoke(fun, comp, std::forward<Args>(args)...); packet = std::invoke(fun, comp, std::forward<Args>(args)...);
if (packet) mutate(packet, c);
c->QueuePacket(packet.get(), ackreq, Client::CLIENT_CONNECTED);
} if (packet)
c->QueuePacket(packet.get(), ackreq, Client::CLIENT_CONNECTED);
} }
} }
} }
@@ -203,7 +205,7 @@ static bool ShouldSendTargetBuffs(Client* c)
// to a client (c) for targeted mobs // to a client (c) for targeted mobs
if (c->GetGM() || RuleB(Spells, AlwaysSendTargetsBuffs)) { // this rule bypasses LAA abilities, always return true if (c->GetGM() || RuleB(Spells, AlwaysSendTargetsBuffs)) { // this rule bypasses LAA abilities, always return true
if (c->GetGM()) { if (c->GetGM()) {
if (!c->EntityVariableExists(SEE_BUFFS_FLAG)) { if (!c->EntityVariableExists(SEE_BUFFS_FLAG)) { // This flag just ensures that the following message is only sent once
c->Message(Chat::White, c->Message(Chat::White,
"Your GM flag allows you to always see your targets' buffs."); "Your GM flag allows you to always see your targets' buffs.");
c->SetEntityVariable(SEE_BUFFS_FLAG, "1"); c->SetEntityVariable(SEE_BUFFS_FLAG, "1");
@@ -233,22 +235,66 @@ static bool ShouldSendTargetBuffs(Client* c)
return false; return false;
} }
inline void SendLegacyBuffsPacket(Client* c, Mob* sender, bool for_target = true, bool clear_buffs = false) inline void SendFullBuffRefresh(Mob* sender, bool remove = false, bool ackreq = true)
{ {
ClientPatch::FastQueuePacket(c, &IBuff::MakeLegacyBuffsPacket, GetComponent(c), sender, for_target, clear_buffs); bool suspended = zone->BuffTimersSuspended();
std::vector<uint32_t> slots;
// first, send to self if self is client
if (sender->IsClient()) {
Client* c = sender->CastToClient();
ClientPatch::FastQueuePacket(c, &IBuff::RefreshBuffs, GetComponent(c), OP_RefreshBuffs, sender, false, suspended, slots);
}
// next, send to owner if self is a pet to a client
if (sender->IsPet() && sender->GetOwner()->IsClient()) {
if (Mob* owner = sender->GetOwner(); owner != nullptr && owner->IsClient()) {
Client* c = owner->CastToClient();
ClientPatch::FastQueuePacket(c, &IBuff::RefreshBuffs, GetComponent(c), OP_RefreshPetBuffs, sender, false, suspended, slots);
}
}
// finally send to all clients targeting the mob, will need to mutate the packet to set the type
auto mutate = [sender](std::unique_ptr<EQApplicationPacket>& packet, Client* c) {
GetComponent(c)->SetRefreshType(packet, sender, c);
};
ClientPatch::QueueClientsByTarget(sender, ackreq, false, ShouldSendTargetBuffs, mutate)(
&IBuff::RefreshBuffs, GetComponent, OP_RefreshTargetBuffs, sender, false, suspended, slots);
// if we have remove set, this will clear any target windows that shouldn't see the buffs
if (remove)
ClientPatch::QueueClientsByTarget(sender, ackreq, true,
[](Client* c) { return !ShouldSendTargetBuffs(c); }, mutate)(
&IBuff::RefreshBuffs, GetComponent, OP_RefreshTargetBuffs, sender, true, suspended, slots);
} }
inline void SendLegacyBuffsPacketToClients(Mob* sender, bool ackreq = true, bool HoTT = false, bool clear_buffs = false) inline void SendSingleBuffChange(Mob* sender, const Buffs_Struct& buff, int slot, bool remove = false, bool ackreq = true)
{ {
ClientPatch::QueueClientsByTarget(sender, ackreq, HoTT, ShouldSendTargetBuffs)( bool suspended = zone->BuffTimersSuspended();
&IBuff::MakeLegacyBuffsPacket, GetComponent, sender, true, clear_buffs); std::vector slots = { static_cast<uint32_t>(slot) };
}
inline void SendCharmDroppedBuffsPacket(Mob* sender, bool ackreq = true) // first, send to self if self is client, which takes the definition and the refresh
{ if (sender->IsClient()) {
// dropping charm means that we want to remove the buff list from clients that shouldn't see non-pet buffs Client* c = sender->CastToClient();
ClientPatch::QueueClientsByTarget(sender, ackreq, false, [](Client* c) { return !ShouldSendTargetBuffs(c); })( ClientPatch::FastQueuePacket(c, &IBuff::BuffDefinition, GetComponent(c), sender, buff, slot, remove);
&IBuff::MakeLegacyBuffsPacket, GetComponent, sender, true, true); ClientPatch::FastQueuePacket(c, &IBuff::RefreshBuffs, GetComponent(c), OP_RefreshBuffs, sender, remove, suspended, slots);
}
// the rest of the buff packets do not take the definition, only the refresh
if (sender->IsPet() && sender->GetOwner()->IsClient()) {
if (Mob* owner = sender->GetOwner(); owner != nullptr && owner->IsClient()) {
Client* c = owner->CastToClient();
ClientPatch::FastQueuePacket(c, &IBuff::RefreshBuffs, GetComponent(c), OP_RefreshPetBuffs, sender, remove, suspended, slots);
}
}
auto mutate = [sender](std::unique_ptr<EQApplicationPacket>& packet, Client* c) {
GetComponent(c)->SetRefreshType(packet, sender, c);
};
ClientPatch::QueueClientsByTarget(sender, ackreq, false, ShouldSendTargetBuffs, mutate)(
&IBuff::RefreshBuffs, GetComponent, OP_RefreshTargetBuffs, sender, remove, suspended, slots);
} }
} // namespace Buff } // namespace Buff
+5 -15
View File
@@ -152,8 +152,7 @@ bool Mob::SpellEffect(Mob* caster, int32 spell_id, float partial, int level_over
if (spells[spell_id].endurance_upkeep > 0) if (spells[spell_id].endurance_upkeep > 0)
SetEndurUpkeep(true); SetEndurUpkeep(true);
if (IsClient()) Buff::SendFullBuffRefresh(this);
Buff::SendLegacyBuffsPacket(CastToClient(), this, false);
} }
if (IsClient()) { if (IsClient()) {
@@ -812,7 +811,7 @@ bool Mob::SpellEffect(Mob* caster, int32 spell_id, float partial, int level_over
// This was done in AddBuff, but we were not a pet yet, so // This was done in AddBuff, but we were not a pet yet, so
// the target windows didn't get updated. // the target windows didn't get updated.
Buff::SendLegacyBuffsPacketToClients(this); Buff::SendFullBuffRefresh(this);
if(caster->IsClient()){ if(caster->IsClient()){
auto app = new EQApplicationPacket(OP_Charm, sizeof(Charm_Struct)); auto app = new EQApplicationPacket(OP_Charm, sizeof(Charm_Struct));
@@ -4432,7 +4431,7 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses)
// no longer see the buffs on the old pet. // no longer see the buffs on the old pet.
// QueueClientsByTarget preserves GM and leadership cases. // QueueClientsByTarget preserves GM and leadership cases.
Buff::SendCharmDroppedBuffsPacket(this); Buff::SendFullBuffRefresh(this, true);
if (IsAIControlled()) if (IsAIControlled())
{ {
@@ -4656,17 +4655,8 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses)
RemoveNimbusEffect(spells[buffs[slot].spellid].nimbus_effect); RemoveNimbusEffect(spells[buffs[slot].spellid].nimbus_effect);
buffs[slot].spellid = SPELL_UNKNOWN; buffs[slot].spellid = SPELL_UNKNOWN;
if(IsPet() && GetOwner() && GetOwner()->IsClient()) { Buff::SendSingleBuffChange(this, buffs[slot], slot, true);
SendPetBuffsToClient(); Buff::SendFullBuffRefresh(this);
}
Buff::SendLegacyBuffsPacketToClients(this);
if (IsClient() && GetTarget() == this)
Buff::SendLegacyBuffsPacket(CastToClient(), this);
if (IsClient())
Buff::SendLegacyBuffsPacket(CastToClient(), this, false);
// we will eventually call CalcBonuses() even if we skip it right here, so should correct itself if we still have them // we will eventually call CalcBonuses() even if we skip it right here, so should correct itself if we still have them
degenerating_effects = false; degenerating_effects = false;
+2 -7
View File
@@ -3741,13 +3741,8 @@ int Mob::AddBuff(Mob *caster, int32 spell_id, int duration, int32 level_override
} }
LogSpells("Buff [{}] added to slot [{}] with caster level [{}]", spell_id, emptyslot, caster_level); LogSpells("Buff [{}] added to slot [{}] with caster level [{}]", spell_id, emptyslot, caster_level);
if (IsPet() && GetOwner() && GetOwner()->IsClient()) Buff::SendSingleBuffChange(this, buffs[emptyslot], emptyslot);
SendPetBuffsToClient(); Buff::SendFullBuffRefresh(this);
Buff::SendLegacyBuffsPacketToClients(this);
if (IsClient() && GetTarget() == this)
Buff::SendLegacyBuffsPacket(CastToClient(), this);
// recalculate bonuses since we stripped/added buffs // recalculate bonuses since we stripped/added buffs
CalcBonuses(); CalcBonuses();