From c9857202e27232e02d6ffd410f8480d00531a055 Mon Sep 17 00:00:00 2001 From: dannuic Date: Thu, 30 Apr 2026 01:01:02 -0600 Subject: [PATCH] Moved buff target type calculation to zone --- common/patches/IBuff.h | 2 +- common/patches/sod.cpp | 18 +++--------------- common/patches/sod.h | 2 +- common/patches/titanium.cpp | 2 +- common/patches/titanium.h | 2 +- common/patches/tob.cpp | 18 +++--------------- common/patches/tob.h | 2 +- zone/client_version.cpp | 21 +++++++++++++++++++-- 8 files changed, 30 insertions(+), 37 deletions(-) diff --git a/common/patches/IBuff.h b/common/patches/IBuff.h index 758c3be2f..1d6d7cf84 100644 --- a/common/patches/IBuff.h +++ b/common/patches/IBuff.h @@ -47,7 +47,7 @@ public: bool fade) const = 0; virtual std::unique_ptr RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove, bool buff_timers_suspended, const std::vector& slots) const = 0; - virtual void SetRefreshType(std::unique_ptr& packet, Mob* source, Client* target) const = 0; + virtual void SetRefreshType(std::unique_ptr& packet, uint8_t refresh_type) const = 0; virtual bool NeedsWearMessage() const = 0; uint32_t ServerToPatchBuffSlot(uint32_t slot) const; diff --git a/common/patches/sod.cpp b/common/patches/sod.cpp index 2ebec80a9..d9207b722 100644 --- a/common/patches/sod.cpp +++ b/common/patches/sod.cpp @@ -4257,22 +4257,10 @@ namespace SoD } // 0 = self buff window, 1 = self target window, 2 = pet buff or target window, 4 = group, 5 = PC, 7 = NPC -void BuffComponent::SetRefreshType(std::unique_ptr& packet, Mob* source, Client* target) const +void BuffComponent::SetRefreshType(std::unique_ptr& packet, uint8_t refresh_type) const { - if (packet) { - unsigned char* type = &packet->pBuffer[packet->size - 1]; - - if (target->GetID() == source->GetID()) - *type = 1; - else if (target->IsPet()) - *type = 2; - else if (target->HasGroup() && source->GetGroup() == target->GetGroup()) - *type = 4; - else if (target->IsClient()) - *type = 5; - else - *type = 7; - } + if (packet) + packet->pBuffer[packet->size - 1] = refresh_type; } } /*SoD*/ diff --git a/common/patches/sod.h b/common/patches/sod.h index d507c94c4..c5b7dbfad 100644 --- a/common/patches/sod.h +++ b/common/patches/sod.h @@ -50,7 +50,7 @@ public: std::unique_ptr RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove, bool buff_timers_suspended, const std::vector& slots) const override; - void SetRefreshType(std::unique_ptr& packet, Mob* source, Client* target) const override; + void SetRefreshType(std::unique_ptr& packet, uint8_t refresh_type) const override; }; } /*SoD*/ diff --git a/common/patches/titanium.cpp b/common/patches/titanium.cpp index b64a491d5..10f046035 100644 --- a/common/patches/titanium.cpp +++ b/common/patches/titanium.cpp @@ -4058,6 +4058,6 @@ std::unique_ptr BuffComponent::RefreshBuffs(EmuOpcode opcod bool BuffComponent::NeedsWearMessage() const { return true; } -void BuffComponent::SetRefreshType(std::unique_ptr& packet, Mob* source, Client* target) const {} +void BuffComponent::SetRefreshType(std::unique_ptr& packet, uint8_t refresh_type) const {} } /*Titanium*/ diff --git a/common/patches/titanium.h b/common/patches/titanium.h index 356695be0..f13e04d07 100644 --- a/common/patches/titanium.h +++ b/common/patches/titanium.h @@ -75,7 +75,7 @@ public: std::unique_ptr RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove, bool buff_timers_suspended, const std::vector& slots) const override; bool NeedsWearMessage() const override; - void SetRefreshType(std::unique_ptr& packet, Mob* source, Client* target) const override; + void SetRefreshType(std::unique_ptr& packet, uint8_t refresh_type) const override; }; } /*Titanium*/ diff --git a/common/patches/tob.cpp b/common/patches/tob.cpp index b6d2f01c2..94a23fecc 100644 --- a/common/patches/tob.cpp +++ b/common/patches/tob.cpp @@ -5725,22 +5725,10 @@ std::unique_ptr BuffComponent::RefreshBuffs(EmuOpcode opcod bool BuffComponent::NeedsWearMessage() const { return false; } // 0 = self buff window, 1 = self target window, 2 = pet buff or target window, 4 = group, 5 = PC, 7 = NPC -void BuffComponent::SetRefreshType(std::unique_ptr& packet, Mob* source, Client* target) const +void BuffComponent::SetRefreshType(std::unique_ptr& packet, uint8_t refresh_type) const { - if (packet) { - unsigned char* type = &packet->pBuffer[packet->size - 2]; - - if (target->GetID() == source->GetID()) - *type = 1; - else if (target->IsPet()) - *type = 2; - else if (target->HasGroup() && source->GetGroup() == target->GetGroup()) - *type = 4; - else if (target->IsClient()) - *type = 5; - else - *type = 7; - } + if (packet) + packet->pBuffer[packet->size - 2] = refresh_type; } } /*TOB*/ \ No newline at end of file diff --git a/common/patches/tob.h b/common/patches/tob.h index 8f15c9819..d2efbd7fc 100644 --- a/common/patches/tob.h +++ b/common/patches/tob.h @@ -73,7 +73,7 @@ public: std::unique_ptr RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove, bool buff_timers_suspended, const std::vector& slots) const override; bool NeedsWearMessage() const override; - void SetRefreshType(std::unique_ptr& packet, Mob* source, Client* target) const override; + void SetRefreshType(std::unique_ptr& packet, uint8_t refresh_type) const override; }; }; /*TOB*/ diff --git a/zone/client_version.cpp b/zone/client_version.cpp index 5a6c9d1e3..052a554c2 100644 --- a/zone/client_version.cpp +++ b/zone/client_version.cpp @@ -74,6 +74,23 @@ static bool ShouldSendTargetBuffs(Client* c) { return false; } +static void SetRefreshType(std::unique_ptr& packet, Mob* source, Client* target) +{ + uint8_t type = 0; + if (target->GetID() == source->GetID()) + type = 1; + else if (source->IsPet()) + type = 2; + else if (target->HasGroup() && source->GetGroup() == target->GetGroup()) + type = 4; + else if (source->IsClient()) + type = 5; + else + type = 7; + + ClientPatch::GetClientComponent(target)->SetRefreshType(packet, type); +} + void ClientPatch::SendFullBuffRefresh(Mob* sender, bool remove, bool ackreq) { bool suspended = zone->BuffTimersSuspended(); std::vector slots; @@ -94,7 +111,7 @@ void ClientPatch::SendFullBuffRefresh(Mob* sender, bool remove, bool ackreq) { // finally send to all clients targeting the mob, will need to mutate the packet to set the type auto mutate = [sender](std::unique_ptr& packet, Client* c) { - GetClientComponent(c)->SetRefreshType(packet, sender, c); + SetRefreshType(packet, sender, c); }; QueueClientsByTarget(sender, ackreq, ShouldSendTargetBuffs, mutate)( @@ -131,7 +148,7 @@ void ClientPatch::SendSingleBuffChange(Mob* sender, const Buffs_Struct& buff, in } auto mutate = [sender](std::unique_ptr& packet, Client* c) { - GetClientComponent(c)->SetRefreshType(packet, sender, c); + SetRefreshType(packet, sender, c); }; QueueClientsByTarget(sender, ackreq, ShouldSendTargetBuffs, mutate)(