Finishing up PR comments

This commit is contained in:
dannuic 2026-04-30 11:36:02 -06:00
parent eae065acb5
commit 8c59dda61f
12 changed files with 35 additions and 40 deletions

View File

@ -32,13 +32,14 @@ concept AllConstChar = (std::is_convertible_v<Args, const char*> && ...);
class IMessage
{
public:
using FormattedArgs = std::array<const char*, 9>;
IMessage() = default;
virtual ~IMessage() = default;
// these two are the basic string message packets
virtual std::unique_ptr<EQApplicationPacket> Simple(uint32_t color, uint32_t id) const = 0;
virtual std::unique_ptr<EQApplicationPacket> Formatted(uint32_t color, uint32_t id,
const std::array<const char*, 9>& 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<EQApplicationPacket> InterruptSpell(uint32_t message, uint32_t spawn_id,

View File

@ -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 <iostream>
#include <sstream>
#include "zone/client.h"
#include "zone/mob.h"
namespace SoD
{

View File

@ -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 <sstream>
#include "zone/mob.h"
namespace Titanium
{
@ -3902,8 +3901,8 @@ std::unique_ptr<EQApplicationPacket> MessageComponent::Simple(uint32_t color, ui
return nullptr;
}
std::unique_ptr<EQApplicationPacket> MessageComponent::Formatted(
uint32_t color, uint32_t id, const std::array<const char*, 9>& args) const
std::unique_ptr<EQApplicationPacket> 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<EQApplicationPacket> MessageComponent::InterruptSpell(uint32_t m
}
std::unique_ptr<EQApplicationPacket> 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<EQApplicationPacket>(OP_InterruptCast, sizeof(InterruptCast_Struct) + strlen(name) + 1);
auto ic = reinterpret_cast<InterruptCast_Struct*>(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<const char*, 9>&
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;

View File

@ -50,7 +50,7 @@ public:
std::unique_ptr<EQApplicationPacket> Simple(uint32_t color, uint32_t id) const override;
std::unique_ptr<EQApplicationPacket> Formatted(uint32_t color, uint32_t id,
const std::array<const char*, 9>& args) const override;
const FormattedArgs& args) const override;
std::unique_ptr<EQApplicationPacket> InterruptSpell(uint32_t message, uint32_t spawn_id,
const char* spell_link) const override;

View File

@ -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 <iostream>
#include <sstream>
@ -44,12 +49,6 @@ Copyright (C) 2001-2026 EQEmu Development Team
#include <cinttypes>
#include <set>
#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<const char*, 9>&
}
std::unique_ptr<EQApplicationPacket> MessageComponent::Formatted(uint32_t color, uint32_t id,
const std::array<const char*, 9>& args) const
const FormattedArgs& args) const
{
uint32_t string_id = ResolveID(id);
if (string_id > 0) {
@ -5605,7 +5604,7 @@ std::unique_ptr<EQApplicationPacket> MessageComponent::InterruptSpell(uint32_t m
auto ic = reinterpret_cast<InterruptCast_Struct*>(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<EQApplicationPacket> MessageComponent::InterruptSpellOther(Mob*
auto ic = reinterpret_cast<InterruptCast_Struct*>(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;
}

View File

@ -49,7 +49,7 @@ public:
~MessageComponent() override = default;
std::unique_ptr<EQApplicationPacket> Formatted(uint32_t color, uint32_t id,
const std::array<const char*, 9>& args) const override;
const FormattedArgs& args) const override;
std::unique_ptr<EQApplicationPacket> InterruptSpell(uint32_t message, uint32_t spawn_id,
const char* spell_link) const override;

View File

@ -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 <iostream>
#include <sstream>
#include "zone/mob.h"
namespace UF
{

View File

@ -3811,10 +3811,10 @@ void Client::MessageString(uint32 type, uint32 string_id, uint32 distance)
return;
if (distance > 0)
ClientPatch::CloseMessageString(this, false, static_cast<float>(distance))(
ClientPatch::BroadcastMessageStringInRadius(this, false, static_cast<float>(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<float>(distance))(type, string_id, message1,
ClientPatch::BroadcastMessageStringInRadius(this, false, static_cast<float>(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);
}

View File

@ -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 <numbers>
#include <set>
#include "client_version.h"
extern QueryServ* QServ;
extern Zone* zone;
extern volatile bool is_zone_loaded;

View File

@ -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 <AllConstChar... Args>
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<IMessage>(c), type, id);
} else {
std::array<const char*, 9> a = {args...};
IMessage::FormattedArgs a = {args...};
QueuePacket(c, &IMessage::Formatted, GetClientComponent<IMessage>(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<IMessage>, type, id);
} else {
std::array<const char*, 9> a = {args...};
IMessage::FormattedArgs a = {args...};
return queue_close_clients(&IMessage::Formatted, GetClientComponent<IMessage>, type, id, a);
}
};

View File

@ -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.

View File

@ -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);