mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-18 15:58:21 +00:00
Removed any 'legacy' functions from the new code
This commit is contained in:
@@ -935,8 +935,7 @@ void Client::CompleteConnect()
|
||||
delete pack;
|
||||
}
|
||||
|
||||
if (IsClient())
|
||||
Buff::SendLegacyBuffsPacket(CastToClient(), this, false);
|
||||
Buff::SendFullBuffRefresh(this);
|
||||
|
||||
// TODO: load these states
|
||||
// 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)
|
||||
{
|
||||
SetTarget(nt);
|
||||
Buff::SendLegacyBuffsPacket(this, nt);
|
||||
Buff::SendFullBuffRefresh(nt);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -2309,8 +2309,7 @@ void Client::ClearHover()
|
||||
entity_list.QueueClients(this, outapp, false);
|
||||
safe_delete(outapp);
|
||||
|
||||
if (IsClient())
|
||||
Buff::SendLegacyBuffsPacket(CastToClient(), this, false);
|
||||
Buff::SendFullBuffRefresh(this);
|
||||
|
||||
dead = false;
|
||||
}
|
||||
|
||||
+69
-23
@@ -19,6 +19,7 @@ namespace ClientPatch {
|
||||
using ClientList = std::unordered_map<uint16, Client*>;
|
||||
template<typename Obj> using ComponentGetter = std::function<Obj*(const Client*)>;
|
||||
using SendPredicate = std::function<bool(Client*)>;
|
||||
using MutatePacket = std::function<void(std::unique_ptr<EQApplicationPacket>&, Client*)>;
|
||||
|
||||
template <typename Fun, typename Obj, typename... Args>
|
||||
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)
|
||||
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;
|
||||
|
||||
for (auto [_, c] : entity_list.GetClientList()) {
|
||||
if (c != sender) {
|
||||
Mob* Target = c->GetTarget();
|
||||
if ((Target == sender || (HoTT && Target != nullptr && Target->GetTarget() == sender)) && ShouldSend(c)) {
|
||||
auto& packet = build_packets.at(static_cast<uint32_t>(c->ClientVersion()));
|
||||
if (!packet)
|
||||
if (auto comp = component(c); comp != nullptr)
|
||||
packet = std::invoke(fun, comp, std::forward<Args>(args)...);
|
||||
Mob* Target = c->GetTarget();
|
||||
if ((Target == sender || (HoTT && Target != nullptr && Target->GetTarget() == sender)) &&
|
||||
(Target == c || should_send(c))) {
|
||||
auto& packet = build_packets.at(static_cast<uint32_t>(c->ClientVersion()));
|
||||
if (!packet)
|
||||
if (auto comp = component(c); comp != nullptr)
|
||||
packet = std::invoke(fun, comp, std::forward<Args>(args)...);
|
||||
|
||||
if (packet)
|
||||
c->QueuePacket(packet.get(), ackreq, Client::CLIENT_CONNECTED);
|
||||
}
|
||||
mutate(packet, c);
|
||||
|
||||
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
|
||||
if (c->GetGM() || RuleB(Spells, AlwaysSendTargetsBuffs)) { // this rule bypasses LAA abilities, always return true
|
||||
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,
|
||||
"Your GM flag allows you to always see your targets' buffs.");
|
||||
c->SetEntityVariable(SEE_BUFFS_FLAG, "1");
|
||||
@@ -233,22 +235,66 @@ static bool ShouldSendTargetBuffs(Client* c)
|
||||
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)(
|
||||
&IBuff::MakeLegacyBuffsPacket, GetComponent, sender, true, clear_buffs);
|
||||
}
|
||||
bool suspended = zone->BuffTimersSuspended();
|
||||
std::vector slots = { static_cast<uint32_t>(slot) };
|
||||
|
||||
inline void SendCharmDroppedBuffsPacket(Mob* sender, bool ackreq = true)
|
||||
{
|
||||
// dropping charm means that we want to remove the buff list from clients that shouldn't see non-pet buffs
|
||||
ClientPatch::QueueClientsByTarget(sender, ackreq, false, [](Client* c) { return !ShouldSendTargetBuffs(c); })(
|
||||
&IBuff::MakeLegacyBuffsPacket, GetComponent, sender, true, true);
|
||||
// first, send to self if self is client, which takes the definition and the refresh
|
||||
if (sender->IsClient()) {
|
||||
Client* c = sender->CastToClient();
|
||||
ClientPatch::FastQueuePacket(c, &IBuff::BuffDefinition, GetComponent(c), sender, buff, slot, remove);
|
||||
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
|
||||
|
||||
+5
-15
@@ -152,8 +152,7 @@ bool Mob::SpellEffect(Mob* caster, int32 spell_id, float partial, int level_over
|
||||
if (spells[spell_id].endurance_upkeep > 0)
|
||||
SetEndurUpkeep(true);
|
||||
|
||||
if (IsClient())
|
||||
Buff::SendLegacyBuffsPacket(CastToClient(), this, false);
|
||||
Buff::SendFullBuffRefresh(this);
|
||||
}
|
||||
|
||||
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
|
||||
// the target windows didn't get updated.
|
||||
Buff::SendLegacyBuffsPacketToClients(this);
|
||||
Buff::SendFullBuffRefresh(this);
|
||||
|
||||
if(caster->IsClient()){
|
||||
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.
|
||||
// QueueClientsByTarget preserves GM and leadership cases.
|
||||
|
||||
Buff::SendCharmDroppedBuffsPacket(this);
|
||||
Buff::SendFullBuffRefresh(this, true);
|
||||
|
||||
if (IsAIControlled())
|
||||
{
|
||||
@@ -4656,17 +4655,8 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses)
|
||||
RemoveNimbusEffect(spells[buffs[slot].spellid].nimbus_effect);
|
||||
|
||||
buffs[slot].spellid = SPELL_UNKNOWN;
|
||||
if(IsPet() && GetOwner() && GetOwner()->IsClient()) {
|
||||
SendPetBuffsToClient();
|
||||
}
|
||||
|
||||
Buff::SendLegacyBuffsPacketToClients(this);
|
||||
|
||||
if (IsClient() && GetTarget() == this)
|
||||
Buff::SendLegacyBuffsPacket(CastToClient(), this);
|
||||
|
||||
if (IsClient())
|
||||
Buff::SendLegacyBuffsPacket(CastToClient(), this, false);
|
||||
Buff::SendSingleBuffChange(this, buffs[slot], slot, true);
|
||||
Buff::SendFullBuffRefresh(this);
|
||||
|
||||
// we will eventually call CalcBonuses() even if we skip it right here, so should correct itself if we still have them
|
||||
degenerating_effects = false;
|
||||
|
||||
+2
-7
@@ -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);
|
||||
if (IsPet() && GetOwner() && GetOwner()->IsClient())
|
||||
SendPetBuffsToClient();
|
||||
|
||||
Buff::SendLegacyBuffsPacketToClients(this);
|
||||
|
||||
if (IsClient() && GetTarget() == this)
|
||||
Buff::SendLegacyBuffsPacket(CastToClient(), this);
|
||||
Buff::SendSingleBuffChange(this, buffs[emptyslot], emptyslot);
|
||||
Buff::SendFullBuffRefresh(this);
|
||||
|
||||
// recalculate bonuses since we stripped/added buffs
|
||||
CalcBonuses();
|
||||
|
||||
Reference in New Issue
Block a user