Updated class naming

This commit is contained in:
dannuic
2026-04-29 13:50:36 -06:00
parent 966ca5cf07
commit a54f93e70f
23 changed files with 309 additions and 410 deletions
+6 -6
View File
@@ -3811,10 +3811,10 @@ void Client::MessageString(uint32 type, uint32 string_id, uint32 distance)
return;
if (distance > 0)
Message::CloseMessageString(this, false, static_cast<float>(distance))(
ClientPatch::CloseMessageString(this, false, static_cast<float>(distance))(
type, string_id);
else
Message::MessageString(this, type, string_id);
ClientPatch::MessageString(this, type, string_id);
}
//
@@ -3843,10 +3843,10 @@ void Client::MessageString(uint32 type, uint32 string_id, const char* message1,
type = 4;
if (distance > 0)
Message::CloseMessageString(this, false, static_cast<float>(distance))(type, string_id, message1,
ClientPatch::CloseMessageString(this, false, static_cast<float>(distance))(type, string_id, message1,
message2, message3, message4, message5, message6, message7, message8, message9);
else
Message::MessageString(this, type, string_id, message1, message2, message3, message4, message5,
ClientPatch::MessageString(this, type, string_id, message1, message2, message3, message4, message5,
message6, message7, message8, message9);
}
@@ -6326,7 +6326,7 @@ void Client::SuspendMinion(int value)
if(value >= 1)
{
CurrentPet->SetPetState(m_suspendedminion.Buffs, m_suspendedminion.Items);
Buff::SendFullBuffRefresh(CurrentPet);
ClientPatch::SendFullBuffRefresh(CurrentPet);
}
CurrentPet->CalcBonuses();
@@ -8930,7 +8930,7 @@ int Client::GetQuiverHaste(int delay)
return (pi->GetItem()->BagWR * 0.0025f * delay) + 1;
}
void Client::SendColoredText(uint32 color, std::string message)
void Client::SendColoredText(uint32 color, const std::string& message)
{
// arbitrary size limit
if (message.size() > 512) // live does send this with empty strings sometimes ...
+1 -1
View File
@@ -355,7 +355,7 @@ public:
const char *message7 = nullptr, const char *message8 = nullptr,
const char *message9 = nullptr);
void Tell_StringID(uint32 string_id, const char *who, const char *message);
void SendColoredText(uint32 color, std::string message);
void SendColoredText(uint32 color, const std::string& message);
void SendTraderItem(uint32 item_id,uint16 quantity, TraderRepository::Trader &trader);
void DoBazaarSearch(BazaarSearchCriteria_Struct search_criteria);
uint16 FindTraderItem(int32 SerialNumber,uint16 Quantity);
+3 -3
View File
@@ -760,7 +760,7 @@ void Client::CompleteConnect()
Mob* pet = GetPet();
if (pet) {
pet->SendWearChangeAndLighting(EQ::textures::LastTexture);
Buff::SendFullBuffRefresh(pet);
ClientPatch::SendFullBuffRefresh(pet);
}
if (GetGroup())
@@ -935,7 +935,7 @@ void Client::CompleteConnect()
delete pack;
}
Buff::SendFullBuffRefresh(this);
ClientPatch::SendFullBuffRefresh(this);
// TODO: load these states
// We at least will set them to the correct state for now
@@ -15107,7 +15107,7 @@ void Client::Handle_OP_TargetMouse(const EQApplicationPacket *app)
if (nt)
{
SetTarget(nt);
Buff::SendFullBuffRefresh(nt);
ClientPatch::SendFullBuffRefresh(nt);
}
else
{
+1 -1
View File
@@ -2309,7 +2309,7 @@ void Client::ClearHover()
entity_list.QueueClients(this, outapp, false);
safe_delete(outapp);
Buff::SendFullBuffRefresh(this);
ClientPatch::SendFullBuffRefresh(this);
dead = false;
}
+33 -57
View File
@@ -17,7 +17,7 @@
namespace ClientPatch {
using ClientList = std::unordered_map<uint16, Client*>;
template<typename Obj> using ComponentGetter = std::function<Obj*(const Client*)>;
template<typename Obj> using ComponentGetter = Obj*(*)(const Client*); //std::function<Obj*(const Client*)>;
using SendPredicate = std::function<bool(Client*)>;
using MutatePacket = std::function<void(std::unique_ptr<EQApplicationPacket>&, Client*)>;
@@ -35,7 +35,7 @@ static void QueuePacket(Client* c, Fun fun, Obj* obj, Args&&... args)
// packet generator queue functions
static auto QueueClients(Mob* sender, bool ignore_sender = false, bool ackreq = true)
{
return [=]<typename Fun, typename Obj, typename... Args>(Fun fun, const ComponentGetter<Obj>& component, Args&&... args)
return [=]<typename Fun, typename Obj, typename... Args>(Fun fun, ComponentGetter<Obj> component, Args&&... args)
requires std::is_member_function_pointer_v<Fun>
{
std::array<std::unique_ptr<EQApplicationPacket>, EQ::versions::ClientVersionCount> build_packets;
@@ -61,7 +61,7 @@ static auto QueueCloseClients(
{
if (distance <= 0) distance = static_cast<float>(zone->GetClientUpdateRange());
return [=]<typename Fun, typename Obj, typename... Args>(Fun fun, const ComponentGetter<Obj>& component, Args&&... args)
return [=]<typename Fun, typename Obj, typename... Args>(Fun fun, ComponentGetter<Obj> component, Args&&... args)
requires std::is_member_function_pointer_v<Fun>
{
if (sender == nullptr) {
@@ -109,7 +109,7 @@ static void FastQueuePacket(Client* c, Fun fun, Obj* obj, Args&&... args)
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, ComponentGetter<Obj> component, Args&&... args)
requires std::is_member_function_pointer_v<Fun>
{
if (sender != nullptr) {
@@ -128,32 +128,22 @@ static auto QueueClientsByTarget(Mob* sender, bool ackreq, bool HoTT, const Send
if (packet)
c->QueuePacket(packet.get(), ackreq, Client::CLIENT_CONNECTED);
}
}
}
}
};
}
} // namespace ClientPatch
// Helpers for the Message interface to send message packets
namespace Message {
// this can return nullptr when the component doesn't exist for the version
static std::function GetComponent = [](const Client* c) -> IMessage* {
return GetMessageComponent(c->GetClientVersion()).get();
};
// 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)
{
if constexpr (sizeof...(Args) == 0) {
ClientPatch::QueuePacket(c, &IMessage::Simple, GetComponent(c), type, id);
QueuePacket(c, &IMessage::Simple, GetClientComponent<IMessage>(c), type, id);
} else {
std::array<const char*, 9> a = {args...};
ClientPatch::QueuePacket(c, &IMessage::Formatted, GetComponent(c), type, id, a);
QueuePacket(c, &IMessage::Formatted, GetClientComponent<IMessage>(c), type, id, a);
}
}
@@ -165,40 +155,31 @@ static auto CloseMessageString(
return [=]<AllConstChar... Args>(uint32_t type, uint32_t id, Args&&... args)
requires (sizeof...(Args) <= 9)
{
auto queue_close_clients = ClientPatch::QueueCloseClients(sender, ignore_sender, distance, skipped_mob,
auto queue_close_clients = QueueCloseClients(sender, ignore_sender, distance, skipped_mob,
is_ack_required, filter);
if constexpr (sizeof...(Args) == 0) {
return queue_close_clients(&IMessage::Simple, GetComponent, type, id);
return queue_close_clients(&IMessage::Simple, GetClientComponent<IMessage>, type, id);
} else {
std::array<const char*, 9> a = {args...};
return queue_close_clients(&IMessage::Formatted, GetComponent, type, id, a);
return queue_close_clients(&IMessage::Formatted, GetClientComponent<IMessage>, type, id, a);
}
};
}
inline void InterruptSpell(Client* c, uint32_t message, uint32_t spawn_id, const char* spell_link)
{
ClientPatch::QueuePacket(c, &IMessage::InterruptSpell, GetComponent(c), message, spawn_id, spell_link);
QueuePacket(c, &IMessage::InterruptSpell, GetClientComponent<IMessage>(c), message, spawn_id, spell_link);
}
inline void InterruptSpellOther(Mob* sender, uint32_t message, uint32_t spawn_id, const char* name,
const char* spell_link)
{
ClientPatch::QueueCloseClients(sender, true, RuleI(Range, SongMessages), nullptr, true,
QueueCloseClients(sender, true, RuleI(Range, SongMessages), nullptr, true,
sender->IsClient() ? FilterPCSpells : FilterNPCSpells)(
&IMessage::InterruptSpellOther, GetComponent, sender, message, spawn_id, name, spell_link);
&IMessage::InterruptSpellOther, GetClientComponent<IMessage>, sender, message, spawn_id, name, spell_link);
}
} // namespace Message
// helper functions to handle sending buffs
namespace Buff {
static std::function GetComponent = [](const Client* c) -> IBuff* {
return GetBuffComponent(c->GetClientVersion()).get();
};
static bool ShouldSendTargetBuffs(Client* c)
{
// this function checks for server rules against LAA and GM status to determine if a buffs packet should be sent
@@ -243,30 +224,30 @@ inline void SendFullBuffRefresh(Mob* sender, bool remove = false, bool ackreq =
// 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);
FastQueuePacket(c, &IBuff::RefreshBuffs, GetClientComponent<IBuff>(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);
FastQueuePacket(c, &IBuff::RefreshBuffs, GetClientComponent<IBuff>(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);
GetClientComponent<IBuff>(c)->SetRefreshType(packet, sender, c);
};
ClientPatch::QueueClientsByTarget(sender, ackreq, false, ShouldSendTargetBuffs, mutate)(
&IBuff::RefreshBuffs, GetComponent, OP_RefreshTargetBuffs, sender, false, suspended, slots);
QueueClientsByTarget(sender, ackreq, false, ShouldSendTargetBuffs, mutate)(
&IBuff::RefreshBuffs, GetClientComponent<IBuff>, 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,
QueueClientsByTarget(sender, ackreq, true,
[](Client* c) { return !ShouldSendTargetBuffs(c); }, mutate)(
&IBuff::RefreshBuffs, GetComponent, OP_RefreshTargetBuffs, sender, true, suspended, slots);
&IBuff::RefreshBuffs, GetClientComponent<IBuff>, OP_RefreshTargetBuffs, sender, true, suspended, slots);
}
inline void SendSingleBuffChange(Mob* sender, const Buffs_Struct& buff, int slot, bool remove = false, bool ackreq = true)
@@ -277,36 +258,31 @@ inline void SendSingleBuffChange(Mob* sender, const Buffs_Struct& buff, int slot
// 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);
// FastQueuePacket(c, &IBuff::BuffDefinition, GetClientComponent<IBuff>(c), sender, buff, slot, false);
// FastQueuePacket(c, &IBuff::RefreshBuffs, GetClientComponent<IBuff>(c), OP_RefreshBuffs, sender, remove, suspended, slots);
// FastQueuePacket(c, &IBuff::BuffDefinition, GetClientComponent<IBuff>(c), sender, buff, slot, remove);
// FastQueuePacket(c, &IBuff::RefreshBuffs, GetClientComponent<IBuff>(c), OP_RefreshBuffs, sender, remove, suspended, slots);
FastQueuePacket(c, &IBuff::RefreshBuffs, GetClientComponent<IBuff>(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);
FastQueuePacket(c, &IBuff::RefreshBuffs, GetClientComponent<IBuff>(c), OP_RefreshPetBuffs, sender, remove, suspended, slots);
}
}
auto mutate = [sender](std::unique_ptr<EQApplicationPacket>& packet, Client* c) {
GetComponent(c)->SetRefreshType(packet, sender, c);
GetClientComponent<IBuff>(c)->SetRefreshType(packet, sender, c);
};
ClientPatch::QueueClientsByTarget(sender, ackreq, false, ShouldSendTargetBuffs, mutate)(
&IBuff::RefreshBuffs, GetComponent, OP_RefreshTargetBuffs, sender, remove, suspended, slots);
QueueClientsByTarget(sender, ackreq, false, ShouldSendTargetBuffs, mutate)(
&IBuff::RefreshBuffs, GetClientComponent<IBuff>, OP_RefreshTargetBuffs, sender, remove, suspended, slots);
// the client doesn't automatically do this for some reason (RoF2? I think this is in TOB)
// TODO: hook this up to QueueClients, or figure out if there's another missing packet to display the fade text
if (remove && sender->IsClient())
{
const char *fadetext = spells[buff.spellid].spell_fades;
auto outapp = std::make_unique<EQApplicationPacket>(OP_ColoredText, sizeof(ColoredText_Struct) + strlen(fadetext));
ColoredText_Struct *bfm = (ColoredText_Struct *) outapp->pBuffer;
bfm->color = Chat::Spells;
memcpy(bfm->msg, fadetext, strlen(fadetext));
sender->CastToClient()->QueuePacket(outapp.get());
}
// the client doesn't automatically do this for some reason, only send it to the sender
// if (remove && sender->IsClient())
// sender->CastToClient()->SendColoredText(Chat::Spells, spells[buff.spellid].spell_fades);
}
} // namespace Buff
} // namespace ClientPatch
+12 -12
View File
@@ -152,7 +152,7 @@ bool Mob::SpellEffect(Mob* caster, int32 spell_id, float partial, int level_over
if (spells[spell_id].endurance_upkeep > 0)
SetEndurUpkeep(true);
Buff::SendFullBuffRefresh(this);
ClientPatch::SendFullBuffRefresh(this);
}
if (IsClient()) {
@@ -811,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::SendFullBuffRefresh(this);
ClientPatch::SendFullBuffRefresh(this);
if(caster->IsClient()){
auto app = new EQApplicationPacket(OP_Charm, sizeof(Charm_Struct));
@@ -821,7 +821,7 @@ bool Mob::SpellEffect(Mob* caster, int32 spell_id, float partial, int level_over
ps->command = 1;
entity_list.QueueClients(this, app);
safe_delete(app);
Buff::SendFullBuffRefresh(this);
ClientPatch::SendFullBuffRefresh(this);
SendAppearancePacket(AppearanceType::Pet, caster->GetID(), true, true);
}
@@ -3866,13 +3866,13 @@ void Mob::BuffProcess()
// this is for older clients. Newer clients will simply discard this packet
if (IsClient() && buffs[buffs_i].UpdateClient == true) {
Buff::SendSingleBuffChange(this, buffs[buffs_i], buffs_i);
ClientPatch::SendSingleBuffChange(this, buffs[buffs_i], buffs_i);
buffs[buffs_i].UpdateClient = false;
}
}
}
Buff::SendFullBuffRefresh(this);
ClientPatch::SendFullBuffRefresh(this);
}
void Mob::DoBuffTic(const Buffs_Struct &buff, int slot, Mob *caster)
@@ -4244,7 +4244,7 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses)
return;
if (IsClient() && !CastToClient()->IsDead())
Buff::SendSingleBuffChange(this, buffs[slot], slot);
ClientPatch::SendSingleBuffChange(this, buffs[slot], slot);
LogSpells("Fading buff [{}] from slot [{}]", buffs[slot].spellid, slot);
@@ -4427,7 +4427,7 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses)
// no longer see the buffs on the old pet.
// QueueClientsByTarget preserves GM and leadership cases.
Buff::SendFullBuffRefresh(this, true);
ClientPatch::SendFullBuffRefresh(this, true);
if (IsAIControlled())
{
@@ -4651,8 +4651,8 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses)
RemoveNimbusEffect(spells[buffs[slot].spellid].nimbus_effect);
buffs[slot].spellid = SPELL_UNKNOWN;
Buff::SendSingleBuffChange(this, buffs[slot], slot, true);
Buff::SendFullBuffRefresh(this);
ClientPatch::SendSingleBuffChange(this, buffs[slot], slot, true);
ClientPatch::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;
@@ -7010,7 +7010,7 @@ void Mob::CheckNumHitsRemaining(NumHit type, int32 buff_slot, int32 spell_id)
if (!TryFadeEffect(d))
BuffFadeBySlot(d, true);
} else if (IsClient()) { // still have numhits and client, update
Buff::SendSingleBuffChange(this, buffs[d], d);
ClientPatch::SendSingleBuffChange(this, buffs[d], d);
}
}
}
@@ -7025,7 +7025,7 @@ void Mob::CheckNumHitsRemaining(NumHit type, int32 buff_slot, int32 spell_id)
if (!TryFadeEffect(buff_slot))
BuffFadeBySlot(buff_slot , true);
} else if (IsClient()) { // still have numhits and client, update
Buff::SendSingleBuffChange(this, buffs[buff_slot], buff_slot);
ClientPatch::SendSingleBuffChange(this, buffs[buff_slot], buff_slot);
}
}
}
@@ -7043,7 +7043,7 @@ void Mob::CheckNumHitsRemaining(NumHit type, int32 buff_slot, int32 spell_id)
if (!TryFadeEffect(d))
BuffFadeBySlot(d, true);
} else if (IsClient()) { // still have numhits and client, update
Buff::SendSingleBuffChange(this, buffs[d], d);
ClientPatch::SendSingleBuffChange(this, buffs[d], d);
}
}
}
+10 -10
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())
Message::MessageString(CastToClient(), Chat::SpellFailure, fizzle_msg, spell_link);
ClientPatch::MessageString(CastToClient(), Chat::SpellFailure, fizzle_msg, spell_link);
/**
* Song Failure message
*/
Message::CloseMessageString(this, true, RuleI(Range, SpellMessages),
ClientPatch::CloseMessageString(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);
@@ -1303,7 +1303,7 @@ void Mob::InterruptSpell(uint16 message, uint16 color, int32 spellid)
// the interrupt message
char spell_link[Links::MAX_LINK_SIZE];
Links::FormatSpellLink(spell_link, Links::MAX_LINK_SIZE, spellid);
Message::InterruptSpell(CastToClient(), message, GetID(), spell_link);
ClientPatch::InterruptSpell(CastToClient(), message, GetID(), spell_link);
SendSpellBarEnable(spellid);
}
@@ -1331,7 +1331,7 @@ void Mob::InterruptSpell(uint16 message, uint16 color, int32 spellid)
// this is the actual message, it works the same as a formatted message
char spell_link[Links::MAX_LINK_SIZE];
Links::FormatSpellLink(spell_link, Links::MAX_LINK_SIZE, spellid);
Message::InterruptSpellOther(this, message_other, GetID(), GetCleanName(), spell_link);
ClientPatch::InterruptSpellOther(this, message_other, GetID(), GetCleanName(), spell_link);
}
// this is like interrupt, just it doesn't spam interrupt packets to everyone
@@ -2856,7 +2856,7 @@ bool Mob::SpellFinished(int32 spell_id, Mob *spell_target, CastingSlot slot, int
if (IsClient() && IsEffectInSpell(spell_id, SpellEffect::BindSight)) {
for (int i = 0; i < GetMaxTotalSlots(); i++) {
if (buffs[i].spellid == spell_id) {
Buff::SendSingleBuffChange(this, buffs[i], i);//its hack, it works.
ClientPatch::SendSingleBuffChange(this, buffs[i], i);//its hack, it works.
}
}
}
@@ -2864,7 +2864,7 @@ bool Mob::SpellFinished(int32 spell_id, Mob *spell_target, CastingSlot slot, int
if (IsClient() && spells[spell_id].hit_number) {
for (int i = 0; i < GetMaxTotalSlots(); i++) {
if (buffs[i].spellid == spell_id && buffs[i].hit_number > 0) {
Buff::SendSingleBuffChange(this, buffs[i], i);
ClientPatch::SendSingleBuffChange(this, buffs[i], i);
break;
}
}
@@ -3741,8 +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);
Buff::SendSingleBuffChange(this, buffs[emptyslot], emptyslot);
Buff::SendFullBuffRefresh(this);
ClientPatch::SendSingleBuffChange(this, buffs[emptyslot], emptyslot);
ClientPatch::SendFullBuffRefresh(this);
// recalculate bonuses since we stripped/added buffs
CalcBonuses();
@@ -6462,7 +6462,7 @@ void Mob::BuffModifyDurationBySpellID(int32 spell_id, int32 newDuration)
if (buffs[i].spellid == spell_id)
{
buffs[i].ticsremaining = newDuration;
Buff::SendSingleBuffChange(this, buffs[i], i);
ClientPatch::SendSingleBuffChange(this, buffs[i], i);
}
}
}
@@ -7037,7 +7037,7 @@ void Mob::DoBardCastingFromItemClick(bool is_casting_bard_song, uint32 cast_time
if (cast_time != 0) {
char spell_link[Links::MAX_LINK_SIZE];
Links::FormatSpellLink(spell_link, Links::MAX_LINK_SIZE, spell_id);
Message::InterruptSpell(CastToClient(), SONG_ENDS, GetID(), spell_link);
ClientPatch::InterruptSpell(CastToClient(), SONG_ENDS, GetID(), spell_link);
ZeroCastingVars();
ZeroBardPulseVars();