From 8c59dda61f1984a604c2b54e05cb976a9652ec0f Mon Sep 17 00:00:00 2001 From: dannuic Date: Thu, 30 Apr 2026 11:36:02 -0600 Subject: [PATCH] Finishing up PR comments --- common/patches/IMessage.h | 3 ++- common/patches/sod.cpp | 5 ++--- common/patches/titanium.cpp | 16 +++++++--------- common/patches/titanium.h | 2 +- common/patches/tob.cpp | 18 +++++++++--------- common/patches/tob.h | 2 +- common/patches/uf.cpp | 3 +-- zone/client.cpp | 8 ++++---- zone/client_packet.cpp | 3 +-- zone/client_version.h | 9 ++++----- zone/spell_effects.cpp | 2 +- zone/spells.cpp | 4 ++-- 12 files changed, 35 insertions(+), 40 deletions(-) diff --git a/common/patches/IMessage.h b/common/patches/IMessage.h index 948163e69..0e8fa1930 100644 --- a/common/patches/IMessage.h +++ b/common/patches/IMessage.h @@ -32,13 +32,14 @@ concept AllConstChar = (std::is_convertible_v && ...); class IMessage { public: + using FormattedArgs = std::array; IMessage() = default; virtual ~IMessage() = default; // these two are the basic string message packets virtual std::unique_ptr Simple(uint32_t color, uint32_t id) const = 0; virtual std::unique_ptr Formatted(uint32_t color, uint32_t id, - const std::array& args) const = 0; + const FormattedArgs& args) const = 0; // These aren't technically messages, but they use the same format and are similar enough to include here virtual std::unique_ptr InterruptSpell(uint32_t message, uint32_t spawn_id, diff --git a/common/patches/sod.cpp b/common/patches/sod.cpp index d9207b722..e2faabae0 100644 --- a/common/patches/sod.cpp +++ b/common/patches/sod.cpp @@ -31,13 +31,12 @@ #include "common/raid.h" #include "common/rulesys.h" #include "common/strings.h" +#include "zone/client.h" +#include "zone/mob.h" #include #include -#include "zone/client.h" -#include "zone/mob.h" - namespace SoD { diff --git a/common/patches/titanium.cpp b/common/patches/titanium.cpp index 10f046035..67164e714 100644 --- a/common/patches/titanium.cpp +++ b/common/patches/titanium.cpp @@ -32,12 +32,11 @@ #include "common/raid.h" #include "common/rulesys.h" #include "common/strings.h" +#include "zone/mob.h" #include "zone/string_ids.h" #include -#include "zone/mob.h" - namespace Titanium { @@ -3902,8 +3901,8 @@ std::unique_ptr MessageComponent::Simple(uint32_t color, ui return nullptr; } -std::unique_ptr MessageComponent::Formatted( - uint32_t color, uint32_t id, const std::array& args) const +std::unique_ptr MessageComponent::Formatted(uint32_t color, uint32_t id, + const FormattedArgs& args) const { uint32_t string_id = ResolveID(id); if (string_id > 0) { @@ -3943,14 +3942,13 @@ std::unique_ptr MessageComponent::InterruptSpell(uint32_t m } std::unique_ptr MessageComponent::InterruptSpellOther(Mob* sender, uint32_t message, uint32_t spawn_id, - const char* name, - const char* spell_link) const + const char* name, const char* spell_link) const { auto outapp = std::make_unique(OP_InterruptCast, sizeof(InterruptCast_Struct) + strlen(name) + 1); auto ic = reinterpret_cast(outapp->pBuffer); ic->messageid = ResolveID(message); ic->spawnid = spawn_id; - fmt::format_to_n(ic->message, strlen(name) + 1, "{}\0", name); + strcpy(ic->message, spell_link); return outapp; } @@ -3967,11 +3965,11 @@ void MessageComponent::ResolveArguments(uint32_t id, std::array& switch (id) { case SPELL_FIZZLE: case MISS_NOTE: - args[0] = nullptr; // drop spell link + args[0] = nullptr; // the 0th (and only) argument here is the spell link, not supported before TOB break; case SPELL_FIZZLE_OTHER: case MISSED_NOTE_OTHER: - args[1] = nullptr; // drop spell link + args[1] = nullptr; // the 1st argument here is the spell link, not supported before TOB break; default: break; diff --git a/common/patches/titanium.h b/common/patches/titanium.h index f13e04d07..4fa4c2add 100644 --- a/common/patches/titanium.h +++ b/common/patches/titanium.h @@ -50,7 +50,7 @@ public: std::unique_ptr Simple(uint32_t color, uint32_t id) const override; std::unique_ptr Formatted(uint32_t color, uint32_t id, - const std::array& args) const override; + const FormattedArgs& args) const override; std::unique_ptr InterruptSpell(uint32_t message, uint32_t spawn_id, const char* spell_link) const override; diff --git a/common/patches/tob.cpp b/common/patches/tob.cpp index 94a23fecc..e40bda653 100644 --- a/common/patches/tob.cpp +++ b/common/patches/tob.cpp @@ -34,8 +34,13 @@ Copyright (C) 2001-2026 EQEmu Development Team #include "common/rulesys.h" #include "common/path_manager.h" #include "common/classes.h" +#include "common/packet_dump.h" #include "common/races.h" #include "common/raid.h" +#include "world/sof_char_create_data.h" +#include "zone/client.h" +#include "zone/mob.h" +#include "zone/string_ids.h" #include #include @@ -44,12 +49,6 @@ Copyright (C) 2001-2026 EQEmu Development Team #include #include -#include "common/packet_dump.h" -#include "world/sof_char_create_data.h" -#include "zone/client.h" -#include "zone/mob.h" -#include "zone/string_ids.h" - namespace TOB { static const char* name = "TOB"; @@ -5566,7 +5565,7 @@ void MessageComponent::ResolveArguments(uint32_t id, std::array& } std::unique_ptr MessageComponent::Formatted(uint32_t color, uint32_t id, - const std::array& args) const + const FormattedArgs& args) const { uint32_t string_id = ResolveID(id); if (string_id > 0) { @@ -5605,7 +5604,7 @@ std::unique_ptr MessageComponent::InterruptSpell(uint32_t m auto ic = reinterpret_cast(outapp->pBuffer); ic->messageid = ResolveID(message); ic->spawnid = spawn_id; - fmt::format_to_n(ic->message, strlen(spell_link) + 1, "{}\0", spell_link); + strcpy(ic->message, spell_link); outapp->priority = 5; return outapp; @@ -5620,7 +5619,8 @@ std::unique_ptr MessageComponent::InterruptSpellOther(Mob* auto ic = reinterpret_cast(outapp->pBuffer); ic->messageid = ResolveID(message); ic->spawnid = spawn_id; - fmt::format_to_n(ic->message, strlen(name) + strlen(spell_link) + 2, "{}\0{}\0", name, spell_link); + strcpy(ic->message, name); + strcpy(&ic->message[strlen(name) + 1], spell_link); return outapp; } diff --git a/common/patches/tob.h b/common/patches/tob.h index d2efbd7fc..e4f473494 100644 --- a/common/patches/tob.h +++ b/common/patches/tob.h @@ -49,7 +49,7 @@ public: ~MessageComponent() override = default; std::unique_ptr Formatted(uint32_t color, uint32_t id, - const std::array& args) const override; + const FormattedArgs& args) const override; std::unique_ptr InterruptSpell(uint32_t message, uint32_t spawn_id, const char* spell_link) const override; diff --git a/common/patches/uf.cpp b/common/patches/uf.cpp index b98b691b7..aa4715763 100644 --- a/common/patches/uf.cpp +++ b/common/patches/uf.cpp @@ -33,13 +33,12 @@ #include "common/raid.h" #include "common/rulesys.h" #include "common/strings.h" +#include "zone/mob.h" #include "cereal/types/vector.hpp" #include #include -#include "zone/mob.h" - namespace UF { diff --git a/zone/client.cpp b/zone/client.cpp index 7757f6367..030515807 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -3811,10 +3811,10 @@ void Client::MessageString(uint32 type, uint32 string_id, uint32 distance) return; if (distance > 0) - ClientPatch::CloseMessageString(this, false, static_cast(distance))( + ClientPatch::BroadcastMessageStringInRadius(this, false, static_cast(distance))( type, string_id); else - ClientPatch::MessageString(this, type, string_id); + ClientPatch::SendMessageString(this, type, string_id); } // @@ -3843,10 +3843,10 @@ void Client::MessageString(uint32 type, uint32 string_id, const char* message1, type = 4; if (distance > 0) - ClientPatch::CloseMessageString(this, false, static_cast(distance))(type, string_id, message1, + ClientPatch::BroadcastMessageStringInRadius(this, false, static_cast(distance))(type, string_id, message1, message2, message3, message4, message5, message6, message7, message8, message9); else - ClientPatch::MessageString(this, type, string_id, message1, message2, message3, message4, message5, + ClientPatch::SendMessageString(this, type, string_id, message1, message2, message3, message4, message5, message6, message7, message8, message9); } diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 3334c8b0c..768a63ba6 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -37,6 +37,7 @@ #include "common/rulesys.h" #include "common/shared_tasks.h" #include "zone/bot.h" +#include "zone/client_version.h" #include "zone/dialogue_window.h" #include "zone/dynamic_zone.h" #include "zone/event_codes.h" @@ -61,8 +62,6 @@ #include #include -#include "client_version.h" - extern QueryServ* QServ; extern Zone* zone; extern volatile bool is_zone_loaded; diff --git a/zone/client_version.h b/zone/client_version.h index f0f9fddba..5dd2ca64c 100644 --- a/zone/client_version.h +++ b/zone/client_version.h @@ -123,7 +123,6 @@ void FastQueuePacket(Client* c, Fun fun, Obj* obj, Args&&... args) if (app) { // FastQueuePacket specifically takes lifetime management of packet, so release here EQApplicationPacket* packet = app.release(); - LogNetcode("S->C FastQueuePacket {}", DumpPacketToString(packet)); c->FastQueuePacket(&packet); } } @@ -158,17 +157,17 @@ inline auto QueueClientsByTarget(Mob* sender, bool ackreq, const SendPredicate& // Helper functions to wrap the packet construction in sends template requires (sizeof...(Args) <= 9) -void MessageString(Client* c, uint32_t type, uint32_t id, Args&&... args) +void SendMessageString(Client* c, uint32_t type, uint32_t id, Args&&... args) { if constexpr (sizeof...(Args) == 0) { QueuePacket(c, &IMessage::Simple, GetClientComponent(c), type, id); } else { - std::array a = {args...}; + IMessage::FormattedArgs a = {args...}; QueuePacket(c, &IMessage::Formatted, GetClientComponent(c), type, id, a); } } -inline auto CloseMessageString( +inline auto BroadcastMessageStringInRadius( Mob* sender, bool ignore_sender = false, float distance = 200.f, Mob* skipped_mob = nullptr, bool is_ack_required = true, eqFilterType filter = FilterNone) @@ -182,7 +181,7 @@ inline auto CloseMessageString( if constexpr (sizeof...(Args) == 0) { return queue_close_clients(&IMessage::Simple, GetClientComponent, type, id); } else { - std::array a = {args...}; + IMessage::FormattedArgs a = {args...}; return queue_close_clients(&IMessage::Formatted, GetClientComponent, type, id, a); } }; diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 4a7900877..ae2163c31 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -4420,7 +4420,7 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses) owner->SetPet(0); } - // Any client that has a previous charmed pet targetted shouldo + // Any client that has a previous charmed pet targeted should // no longer see the buffs on the old pet. // QueueClientsByTarget preserves GM and leadership cases. diff --git a/zone/spells.cpp b/zone/spells.cpp index e9ee26f86..2471ae602 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -339,12 +339,12 @@ bool Mob::DoCastSpell(int32 spell_id, uint16 target_id, CastingSlot slot, Links::FormatSpellLink(spell_link, Links::MAX_LINK_SIZE, spell_id); if (IsClient()) - ClientPatch::MessageString(CastToClient(), Chat::SpellFailure, fizzle_msg, spell_link); + ClientPatch::SendMessageString(CastToClient(), Chat::SpellFailure, fizzle_msg, spell_link); /** * Song Failure message */ - ClientPatch::CloseMessageString(this, true, RuleI(Range, SpellMessages), + ClientPatch::BroadcastMessageStringInRadius(this, true, RuleI(Range, SpellMessages), nullptr, true, IsClient() ? FilterPCSpells : FilterNPCSpells)( Chat::SpellFailure, fizzle_msg == MISS_NOTE ? MISSED_NOTE_OTHER : SPELL_FIZZLE_OTHER, GetName(), spell_link);