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
+1 -1
View File
@@ -16,7 +16,7 @@ class Mob;
class EQApplicationPacket; class EQApplicationPacket;
class Buffs_Struct; class Buffs_Struct;
namespace Buff { namespace ClientPatch {
class IBuff class IBuff
{ {
+1 -1
View File
@@ -25,7 +25,7 @@ class Client;
class Mob; class Mob;
class EQApplicationPacket; class EQApplicationPacket;
namespace Message { namespace ClientPatch {
template<typename... Args> template<typename... Args>
concept AllConstChar = (std::is_convertible_v<Args, const char*> && ...); concept AllConstChar = (std::is_convertible_v<Args, const char*> && ...);
+20 -18
View File
@@ -36,32 +36,32 @@ struct ClientComponents
{ {
switch (version) { switch (version) {
case Version::TOB: case Version::TOB:
buffComponent = std::make_unique<Buff::TOB>(); buffComponent = std::make_unique<TOB::BuffComponent>();
messageComponent = std::make_unique<Message::TOB>(); messageComponent = std::make_unique<TOB::MessageComponent>();
break; break;
case Version::RoF2: case Version::RoF2:
buffComponent = std::make_unique<Buff::UF>(); buffComponent = std::make_unique<UF::BuffComponent>();
messageComponent = std::make_unique<Message::Titanium>(); messageComponent = std::make_unique<Titanium::MessageComponent>();
break; break;
case Version::RoF: case Version::RoF:
buffComponent = std::make_unique<Buff::UF>(); buffComponent = std::make_unique<UF::BuffComponent>();
messageComponent = std::make_unique<Message::Titanium>(); messageComponent = std::make_unique<Titanium::MessageComponent>();
break; break;
case Version::UF: case Version::UF:
buffComponent = std::make_unique<Buff::UF>(); buffComponent = std::make_unique<UF::BuffComponent>();
messageComponent = std::make_unique<Message::Titanium>(); messageComponent = std::make_unique<Titanium::MessageComponent>();
break; break;
case Version::SoD: case Version::SoD:
buffComponent = std::make_unique<Buff::SoD>(); buffComponent = std::make_unique<SoD::BuffComponent>();
messageComponent = std::make_unique<Message::Titanium>(); messageComponent = std::make_unique<Titanium::MessageComponent>();
break; break;
case Version::SoF: case Version::SoF:
buffComponent = std::make_unique<Buff::Titanium>(); buffComponent = std::make_unique<Titanium::BuffComponent>();
messageComponent = std::make_unique<Message::Titanium>(); messageComponent = std::make_unique<Titanium::MessageComponent>();
break; break;
case Version::Titanium: case Version::Titanium:
buffComponent = std::make_unique<Buff::Titanium>(); buffComponent = std::make_unique<Titanium::BuffComponent>();
messageComponent = std::make_unique<Message::Titanium>(); messageComponent = std::make_unique<Titanium::MessageComponent>();
break; break;
default: default:
break; break;
@@ -69,8 +69,8 @@ struct ClientComponents
} }
const Version version; const Version version;
std::unique_ptr<Buff::IBuff> buffComponent; std::unique_ptr<ClientPatch::IBuff> buffComponent;
std::unique_ptr<Message::IMessage> messageComponent; std::unique_ptr<ClientPatch::IMessage> messageComponent;
}; };
// this array must be in the same order as the Version enum because it converts Version to index directly // this array must be in the same order as the Version enum because it converts Version to index directly
@@ -88,12 +88,14 @@ static const std::array<ClientComponents, EQ::versions::ClientVersionCount> s_pa
} }
}; };
const std::unique_ptr<Buff::IBuff>& GetBuffComponent(Version version) template<>
const std::unique_ptr<ClientPatch::IBuff>& GetComponent(Version version)
{ {
return s_patches.at(static_cast<uint32_t>(version)).buffComponent; return s_patches.at(static_cast<uint32_t>(version)).buffComponent;
} }
const std::unique_ptr<Message::IMessage>& GetMessageComponent(Version version) template<>
const std::unique_ptr<ClientPatch::IMessage>& GetComponent(Version version)
{ {
return s_patches.at(static_cast<uint32_t>(version)).messageComponent; return s_patches.at(static_cast<uint32_t>(version)).messageComponent;
} }
+20 -4
View File
@@ -7,10 +7,26 @@
#include "common/emu_versions.h" #include "common/emu_versions.h"
#include <memory> #include <memory>
namespace Buff { class IBuff; } #include "zone/client.h"
namespace Message { class IMessage; }
namespace ClientPatch {
class IBuff;
class IMessage;
}
// store all static functions for the different patches here // store all static functions for the different patches here
// store all static functions for the different patches here, this can return nullptr for unsupported patches // store all static functions for the different patches here, this can return nullptr for unsupported patches
const std::unique_ptr<Buff::IBuff>& GetBuffComponent(EQ::versions::ClientVersion version); template <typename Component>
const std::unique_ptr<Message::IMessage>& GetMessageComponent(EQ::versions::ClientVersion version); const std::unique_ptr<Component>& GetComponent(EQ::versions::ClientVersion version);
template <>
const std::unique_ptr<ClientPatch::IBuff>& GetComponent(EQ::versions::ClientVersion version);
template <>
const std::unique_ptr<ClientPatch::IMessage>& GetComponent(EQ::versions::ClientVersion version);
template <typename Component>
static Component* GetClientComponent(const Client* client)
{
return GetComponent<Component>(client->GetClientVersion()).get();
}
+15 -22
View File
@@ -22,30 +22,23 @@
class EQStreamIdentifier; class EQStreamIdentifier;
namespace RoF namespace RoF {
extern void Register(EQStreamIdentifier& into);
extern void Reload();
class Strategy : public StructStrategy
{ {
public:
Strategy();
//these are the only public member of this namespace. protected:
extern void Register(EQStreamIdentifier &into); virtual std::string Describe() const;
extern void Reload(); virtual const EQ::versions::ClientVersion ClientVersion() const;
//magic macro to declare our opcode processors
#include "ss_declare.h"
//you should not directly access anything below.. #include "rof_ops.h"
//I just dont feel like making a seperate header for it. };
class Strategy : public StructStrategy {
public:
Strategy();
protected:
virtual std::string Describe() const;
virtual const EQ::versions::ClientVersion ClientVersion() const;
//magic macro to declare our opcode processors
#include "ss_declare.h"
#include "rof_ops.h"
};
} /*RoF*/ } /*RoF*/
+15 -22
View File
@@ -22,30 +22,23 @@
class EQStreamIdentifier; class EQStreamIdentifier;
namespace RoF2 namespace RoF2 {
extern void Register(EQStreamIdentifier& into);
extern void Reload();
class Strategy : public StructStrategy
{ {
public:
Strategy();
//these are the only public member of this namespace. protected:
extern void Register(EQStreamIdentifier &into); virtual std::string Describe() const;
extern void Reload(); virtual const EQ::versions::ClientVersion ClientVersion() const;
//magic macro to declare our opcode processors
#include "ss_declare.h"
//you should not directly access anything below.. #include "rof2_ops.h"
//I just dont feel like making a seperate header for it. };
class Strategy : public StructStrategy {
public:
Strategy();
protected:
virtual std::string Describe() const;
virtual const EQ::versions::ClientVersion ClientVersion() const;
//magic macro to declare our opcode processors
#include "ss_declare.h"
#include "rof2_ops.h"
};
}; /*RoF2*/ }; /*RoF2*/
+5 -7
View File
@@ -4287,12 +4287,10 @@ namespace SoD
// we're a normal buff // we're a normal buff
return index; // as long as we guard against bad slots server side, we should be fine return index; // as long as we guard against bad slots server side, we should be fine
} }
} /*SoD*/
namespace Buff { std::unique_ptr<EQApplicationPacket> BuffComponent::RefreshBuffs(EmuOpcode opcode, Mob* mob,
bool remove,
std::unique_ptr<EQApplicationPacket> SoD::RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove, bool buff_timers_suspended, const std::vector<uint32_t>& slots) const
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const
{ {
// SoD only supports target refresh, not self refresh packets // SoD only supports target refresh, not self refresh packets
if (opcode == OP_RefreshTargetBuffs) { if (opcode == OP_RefreshTargetBuffs) {
@@ -4341,7 +4339,7 @@ std::unique_ptr<EQApplicationPacket> SoD::RefreshBuffs(EmuOpcode opcode, Mob* mo
} }
// 0 = self buff window, 1 = self target window, 2 = pet buff or target window, 4 = group, 5 = PC, 7 = NPC // 0 = self buff window, 1 = self target window, 2 = pet buff or target window, 4 = group, 5 = PC, 7 = NPC
void SoD::SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const void BuffComponent::SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const
{ {
if (packet) { if (packet) {
BuffIcon_Struct *buff = (BuffIcon_Struct*)packet->pBuffer; BuffIcon_Struct *buff = (BuffIcon_Struct*)packet->pBuffer;
@@ -4358,4 +4356,4 @@ void SoD::SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* sour
} }
} }
} // namespace Buff } /*SoD*/
+21 -32
View File
@@ -22,45 +22,34 @@
class EQStreamIdentifier; class EQStreamIdentifier;
namespace SoD namespace SoD {
{
//these are the only public member of this namespace. extern void Register(EQStreamIdentifier& into);
extern void Register(EQStreamIdentifier &into); extern void Reload();
extern void Reload();
class Strategy : public StructStrategy
//you should not directly access anything below..
//I just dont feel like making a seperate header for it.
class Strategy : public StructStrategy {
public:
Strategy();
protected:
virtual std::string Describe() const;
virtual const EQ::versions::ClientVersion ClientVersion() const;
//magic macro to declare our opcode processors
#include "ss_declare.h"
#include "sod_ops.h"
};
} /*SoD*/
namespace Buff {
class SoD : public Titanium
{ {
public: public:
SoD() = default; Strategy();
~SoD() override = default;
protected:
virtual std::string Describe() const;
virtual const EQ::versions::ClientVersion ClientVersion() const;
//magic macro to declare our opcode processors
#include "ss_declare.h"
#include "sod_ops.h"
};
class BuffComponent : public Titanium::BuffComponent
{
public:
BuffComponent() = default;
~BuffComponent() override = default;
std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove, std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const override; bool buff_timers_suspended, const std::vector<uint32_t>& slots) const override;
void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const override; void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const override;
}; };
} // namespace Buff } /*SoD*/
+15 -22
View File
@@ -22,30 +22,23 @@
class EQStreamIdentifier; class EQStreamIdentifier;
namespace SoF namespace SoF {
extern void Register(EQStreamIdentifier& into);
extern void Reload();
class Strategy : public StructStrategy
{ {
public:
Strategy();
//these are the only public member of this namespace. protected:
extern void Register(EQStreamIdentifier &into); virtual std::string Describe() const;
extern void Reload(); virtual const EQ::versions::ClientVersion ClientVersion() const;
//magic macro to declare our opcode processors
#include "ss_declare.h"
//you should not directly access anything below.. #include "sof_ops.h"
//I just dont feel like making a seperate header for it. };
class Strategy : public StructStrategy {
public:
Strategy();
protected:
virtual std::string Describe() const;
virtual const EQ::versions::ClientVersion ClientVersion() const;
//magic macro to declare our opcode processors
#include "ss_declare.h"
#include "sof_ops.h"
};
} /*SoF*/ } /*SoF*/
+13 -20
View File
@@ -23,27 +23,20 @@ class EQStreamIdentifier;
namespace TEMPLATE { namespace TEMPLATE {
//these are the only public member of this namespace. extern void Register(EQStreamIdentifier& into);
extern void Register(EQStreamIdentifier &into); extern void Reload();
extern void Reload();
class Strategy : public StructStrategy
{
public:
Strategy();
protected:
//you should not directly access anything below.. virtual std::string Describe() const;
//I just dont feel like making a seperate header for it. virtual const EQClientVersion ClientVersion() const;
//magic macro to declare our opcodes
class Strategy : public StructStrategy { #include "ss_declare.h"
public: #include "TEMPLATE_ops.h"
Strategy(); };
protected:
virtual std::string Describe() const;
virtual const EQClientVersion ClientVersion() const;
//magic macro to declare our opcodes
#include "ss_declare.h"
#include "TEMPLATE_ops.h"
};
}; };
+10 -16
View File
@@ -3921,10 +3921,8 @@ namespace Titanium
// we're a normal buff // we're a normal buff
return index; // as long as we guard against bad slots server side, we should be fine return index; // as long as we guard against bad slots server side, we should be fine
} }
} /*Titanium*/
namespace Message { std::unique_ptr<EQApplicationPacket> MessageComponent::Simple(uint32_t color, uint32_t id) const
std::unique_ptr<EQApplicationPacket> Titanium::Simple(uint32_t color, uint32_t id) const
{ {
uint32_t string_id = ResolveID(id); uint32_t string_id = ResolveID(id);
if (string_id > 0) { if (string_id > 0) {
@@ -3940,7 +3938,7 @@ std::unique_ptr<EQApplicationPacket> Titanium::Simple(uint32_t color, uint32_t i
return nullptr; return nullptr;
} }
std::unique_ptr<EQApplicationPacket> Titanium::Formatted( std::unique_ptr<EQApplicationPacket> MessageComponent::Formatted(
uint32_t color, uint32_t id, const std::array<const char*, 9>& args) const uint32_t color, uint32_t id, const std::array<const char*, 9>& args) const
{ {
uint32_t string_id = ResolveID(id); uint32_t string_id = ResolveID(id);
@@ -3968,7 +3966,7 @@ std::unique_ptr<EQApplicationPacket> Titanium::Formatted(
return nullptr; return nullptr;
} }
std::unique_ptr<EQApplicationPacket> Titanium::InterruptSpell(uint32_t message, uint32_t spawn_id, std::unique_ptr<EQApplicationPacket> MessageComponent::InterruptSpell(uint32_t message, uint32_t spawn_id,
const char* spell_link) const const char* spell_link) const
{ {
auto outapp = std::make_unique<EQApplicationPacket>(OP_InterruptCast, sizeof(InterruptCast_Struct)); auto outapp = std::make_unique<EQApplicationPacket>(OP_InterruptCast, sizeof(InterruptCast_Struct));
@@ -3980,7 +3978,7 @@ std::unique_ptr<EQApplicationPacket> Titanium::InterruptSpell(uint32_t message,
return outapp; return outapp;
} }
std::unique_ptr<EQApplicationPacket> Titanium::InterruptSpellOther(Mob* sender, uint32_t message, uint32_t spawn_id, std::unique_ptr<EQApplicationPacket> MessageComponent::InterruptSpellOther(Mob* sender, uint32_t message, uint32_t spawn_id,
const char* name, const char* name,
const char* spell_link) const const char* spell_link) const
{ {
@@ -3993,14 +3991,14 @@ std::unique_ptr<EQApplicationPacket> Titanium::InterruptSpellOther(Mob* sender,
} }
// A value of 0 means that the string isn't mapped in this client, valid string ids start at 1 // A value of 0 means that the string isn't mapped in this client, valid string ids start at 1
uint32_t Titanium::ResolveID(uint32_t id) const uint32_t MessageComponent::ResolveID(uint32_t id) const
{ {
// passthrough — string IDs are defined at the base client level; // passthrough — string IDs are defined at the base client level;
// override in patches where IDs need remapping // override in patches where IDs need remapping
return id; return id;
} }
void Titanium::ResolveArguments(uint32_t id, std::array<const char*, 9>& args) const void MessageComponent::ResolveArguments(uint32_t id, std::array<const char*, 9>& args) const
{ {
switch (id) { switch (id) {
case SPELL_FIZZLE: case SPELL_FIZZLE:
@@ -4016,11 +4014,7 @@ void Titanium::ResolveArguments(uint32_t id, std::array<const char*, 9>& args) c
} }
} }
} // namespace Message std::unique_ptr<EQApplicationPacket> BuffComponent::BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot,
namespace Buff {
std::unique_ptr<EQApplicationPacket> Titanium::BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot,
bool fade) const bool fade) const
{ {
auto outapp = std::make_unique<EQApplicationPacket>(OP_BuffDefinition, sizeof(SpellBuffPacket_Struct)); auto outapp = std::make_unique<EQApplicationPacket>(OP_BuffDefinition, sizeof(SpellBuffPacket_Struct));
@@ -4054,12 +4048,12 @@ std::unique_ptr<EQApplicationPacket> Titanium::BuffDefinition(Mob* mob, const Bu
return outapp; return outapp;
} }
std::unique_ptr<EQApplicationPacket> Titanium::RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove, std::unique_ptr<EQApplicationPacket> BuffComponent::RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const bool buff_timers_suspended, const std::vector<uint32_t>& slots) const
{ {
return nullptr; return nullptr;
} }
void Titanium::SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const {} void BuffComponent::SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const {}
} // namespace Buff } /*Titanium*/
+24 -40
View File
@@ -23,42 +23,30 @@
class EQStreamIdentifier; class EQStreamIdentifier;
namespace Titanium namespace Titanium {
{
//these are the only public member of this namespace. extern void Register(EQStreamIdentifier& into);
extern void Register(EQStreamIdentifier &into); extern void Reload();
extern void Reload();
class Strategy : public StructStrategy
//you should not directly access anything below..
//I just dont feel like making a seperate header for it.
class Strategy : public StructStrategy {
public:
Strategy();
protected:
virtual std::string Describe() const;
virtual const EQ::versions::ClientVersion ClientVersion() const;
//magic macro to declare our opcode processors
#include "ss_declare.h"
#include "titanium_ops.h"
};
} /*Titanium*/
// out-going message packets
namespace Message {
class Titanium : public IMessage
{ {
public: public:
Titanium() = default; Strategy();
~Titanium() override = default;
protected:
virtual std::string Describe() const;
virtual const EQ::versions::ClientVersion ClientVersion() const;
//magic macro to declare our opcode processors
#include "ss_declare.h"
#include "titanium_ops.h"
};
class MessageComponent : public ClientPatch::IMessage
{
public:
MessageComponent() = default;
~MessageComponent() override = default;
std::unique_ptr<EQApplicationPacket> Simple(uint32_t color, uint32_t id) const override; std::unique_ptr<EQApplicationPacket> Simple(uint32_t color, uint32_t id) const override;
std::unique_ptr<EQApplicationPacket> Formatted(uint32_t color, uint32_t id, std::unique_ptr<EQApplicationPacket> Formatted(uint32_t color, uint32_t id,
@@ -75,15 +63,11 @@ protected:
virtual void ResolveArguments(uint32_t id, std::array<const char*, 9>& args) const; virtual void ResolveArguments(uint32_t id, std::array<const char*, 9>& args) const;
}; };
} // namespace Message class BuffComponent : public ClientPatch::IBuff
namespace Buff {
class Titanium : public IBuff
{ {
public: public:
Titanium() = default; BuffComponent() = default;
~Titanium() override = default; ~BuffComponent() override = default;
std::unique_ptr<EQApplicationPacket> BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot, std::unique_ptr<EQApplicationPacket> BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot,
bool fade) const override; bool fade) const override;
@@ -92,5 +76,5 @@ public:
void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const override; void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const override;
}; };
} // namespace Buff } /*Titanium*/
+34 -37
View File
@@ -5478,16 +5478,13 @@ namespace TOB
// we're a normal buff // we're a normal buff
return index; // as long as we guard against bad slots server side, we should be fine return index; // as long as we guard against bad slots server side, we should be fine
} }
} /*TOB*/
namespace Message {
struct TOBStringIDs struct TOBStringIDs
{ {
static constexpr uint32_t DisarmedTrap = 1458; // You successfully disarmed the trap static constexpr uint32_t DisarmedTrap = 1458; // You successfully disarmed the trap
}; };
uint32_t TOB::ResolveID(uint32_t id) const uint32_t MessageComponent::ResolveID(uint32_t id) const
{ {
switch (id) { switch (id) {
case YOU_FLURRY: case YOU_FLURRY:
@@ -5531,11 +5528,11 @@ uint32_t TOB::ResolveID(uint32_t id) const
case DISARMED_TRAP: case DISARMED_TRAP:
return TOBStringIDs::DisarmedTrap; return TOBStringIDs::DisarmedTrap;
default: default:
return Titanium::ResolveID(id); return Titanium::MessageComponent::ResolveID(id);
} }
} }
void TOB::ResolveArguments(uint32_t id, std::array<const char*, 9>& args) const void MessageComponent::ResolveArguments(uint32_t id, std::array<const char*, 9>& args) const
{ {
switch (id) { switch (id) {
case SPELL_FIZZLE: case SPELL_FIZZLE:
@@ -5545,12 +5542,12 @@ void TOB::ResolveArguments(uint32_t id, std::array<const char*, 9>& args) const
// take all arguments (spell link) // take all arguments (spell link)
break; break;
default: default:
Titanium::ResolveArguments(id, args); Titanium::MessageComponent::ResolveArguments(id, args);
break; break;
} }
} }
std::unique_ptr<EQApplicationPacket> TOB::Formatted(uint32_t color, uint32_t id, std::unique_ptr<EQApplicationPacket> MessageComponent::Formatted(uint32_t color, uint32_t id,
const std::array<const char*, 9>& args) const const std::array<const char*, 9>& args) const
{ {
uint32_t string_id = ResolveID(id); uint32_t string_id = ResolveID(id);
@@ -5583,7 +5580,7 @@ std::unique_ptr<EQApplicationPacket> TOB::Formatted(uint32_t color, uint32_t id,
return nullptr; return nullptr;
} }
std::unique_ptr<EQApplicationPacket> TOB::InterruptSpell(uint32_t message, uint32_t spawn_id, std::unique_ptr<EQApplicationPacket> MessageComponent::InterruptSpell(uint32_t message, uint32_t spawn_id,
const char* spell_link) const const char* spell_link) const
{ {
auto outapp = std::make_unique<EQApplicationPacket>(OP_InterruptCast, sizeof(InterruptCast_Struct) + strlen(spell_link) + 1); auto outapp = std::make_unique<EQApplicationPacket>(OP_InterruptCast, sizeof(InterruptCast_Struct) + strlen(spell_link) + 1);
@@ -5596,7 +5593,7 @@ std::unique_ptr<EQApplicationPacket> TOB::InterruptSpell(uint32_t message, uint3
return outapp; return outapp;
} }
std::unique_ptr<EQApplicationPacket> TOB::InterruptSpellOther(Mob* sender, uint32_t message, uint32_t spawn_id, std::unique_ptr<EQApplicationPacket> MessageComponent::InterruptSpellOther(Mob* sender, uint32_t message, uint32_t spawn_id,
const char* name, const char* name,
const char* spell_link) const const char* spell_link) const
{ {
@@ -5610,21 +5607,19 @@ std::unique_ptr<EQApplicationPacket> TOB::InterruptSpellOther(Mob* sender, uint3
return outapp; return outapp;
} }
} // namespace Message std::unique_ptr<EQApplicationPacket> BuffComponent::BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot, bool fade) const
namespace Buff {
std::unique_ptr<EQApplicationPacket> TOB::BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot, bool fade) const
{ {
auto packet = std::make_unique<EQApplicationPacket>(OP_BuffDefinition, sizeof(::TOB::structs::EQAffectPacket_Struct)); auto packet = std::make_unique<EQApplicationPacket>(OP_BuffDefinition, sizeof(structs::EQAffectPacket_Struct));
auto affect = reinterpret_cast<::TOB::structs::EQAffectPacket_Struct*>(packet->pBuffer); auto affect = reinterpret_cast<structs::EQAffectPacket_Struct*>(packet->pBuffer);
// base packet // base packet
affect->entity_id = mob->GetID(); affect->entity_id = mob->GetID();
affect->unknown004 = 0; affect->unknown004 = 0;
affect->slot_id = ::TOB::ServerToTOBBuffSlot(slot); affect->slot_id = ServerToTOBBuffSlot(slot);
affect->buff_fade = fade ? 1 : 2; // 1 is remove, 2 is modify, 3 is add (only seen 1 and 2 sent) affect->buff_fade = fade ? 1 : 2; // 1 is remove, 2 is modify, 3 is add (only seen 1 and 2 sent)
memset(&affect->affect, 0, sizeof(affect->affect));
// affect slots // affect slots
for (int affect_slot = 0; affect_slot < 6; ++affect_slot) { for (int affect_slot = 0; affect_slot < 6; ++affect_slot) {
// all of this is unknown, just what we've seen // all of this is unknown, just what we've seen
@@ -5633,22 +5628,24 @@ std::unique_ptr<EQApplicationPacket> TOB::BuffDefinition(Mob* mob, const Buffs_S
affect->affect.slots[affect_slot].value = 0; // this is always 0 affect->affect.slots[affect_slot].value = 0; // this is always 0
} }
// affect info if (!fade) {
affect->affect.caster_id.Id = buff.casterid; // affect info
affect->affect.caster_id.WorldId = RuleI(World, Id); affect->affect.caster_id.Id = buff.casterid;
affect->affect.caster_id.Reserved = 0; affect->affect.caster_id.WorldId = RuleI(World, Id);
affect->affect.flags = 0; affect->affect.caster_id.Reserved = 0;
affect->affect.spell_id = buff.spellid; affect->affect.flags = 0;
affect->affect.duration = buff.ticsremaining; affect->affect.spell_id = buff.spellid;
affect->affect.initial_duration = buff.ticsremaining; // TODO: this isn't correct, it's the total duration affect->affect.duration = buff.ticsremaining;
affect->affect.hit_count = buff.hit_number; affect->affect.initial_duration = buff.ticsremaining; // TODO: this isn't correct, it's the total duration
affect->affect.viral_timer = 0; affect->affect.hit_count = buff.hit_number;
affect->affect.modifier = static_cast<float>(buff.instrument_mod) / 10.f; affect->affect.viral_timer = 0;
affect->affect.y = static_cast<float>(buff.caston_y); affect->affect.modifier = static_cast<float>(buff.instrument_mod) / 10.f;
affect->affect.x = static_cast<float>(buff.caston_x); affect->affect.y = static_cast<float>(buff.caston_y);
affect->affect.z = static_cast<float>(buff.caston_z); affect->affect.x = static_cast<float>(buff.caston_x);
affect->affect.type = 2; affect->affect.z = static_cast<float>(buff.caston_z);
affect->affect.level = buff.casterlevel > 0 ? buff.casterlevel : mob->GetLevel(); affect->affect.type = 2;
affect->affect.level = buff.casterlevel > 0 ? buff.casterlevel : mob->GetLevel();
}
//no idea if these are right; eqlib doesn't seem to know either //no idea if these are right; eqlib doesn't seem to know either
if (buff.dot_rune > 0) if (buff.dot_rune > 0)
@@ -5666,7 +5663,7 @@ std::unique_ptr<EQApplicationPacket> TOB::BuffDefinition(Mob* mob, const Buffs_S
return packet; return packet;
} }
std::unique_ptr<EQApplicationPacket> TOB::RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove, std::unique_ptr<EQApplicationPacket> BuffComponent::RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const bool buff_timers_suspended, const std::vector<uint32_t>& slots) const
{ {
Buffs_Struct* buffs = mob->GetBuffs(); Buffs_Struct* buffs = mob->GetBuffs();
@@ -5710,7 +5707,7 @@ std::unique_ptr<EQApplicationPacket> TOB::RefreshBuffs(EmuOpcode opcode, Mob* mo
} }
// 0 = self buff window, 1 = self target window, 2 = pet buff or target window, 4 = group, 5 = PC, 7 = NPC // 0 = self buff window, 1 = self target window, 2 = pet buff or target window, 4 = group, 5 = PC, 7 = NPC
void TOB::SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const void BuffComponent::SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const
{ {
if (packet) { if (packet) {
unsigned char* type = &packet->pBuffer[packet->size - 2]; unsigned char* type = &packet->pBuffer[packet->size - 2];
@@ -5728,4 +5725,4 @@ void TOB::SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* sour
} }
} }
} // namespace Buff } /*TOB*/
+24 -40
View File
@@ -5,42 +5,30 @@
class EQStreamIdentifier; class EQStreamIdentifier;
namespace TOB namespace TOB {
{
//these are the only public member of this namespace. extern void Register(EQStreamIdentifier& into);
extern void Register(EQStreamIdentifier& into); extern void Reload();
extern void Reload();
class Strategy : public StructStrategy
//you should not directly access anything below..
//I just dont feel like making a seperate header for it.
class Strategy : public StructStrategy {
public:
Strategy();
protected:
virtual std::string Describe() const;
virtual const EQ::versions::ClientVersion ClientVersion() const;
//magic macro to declare our opcode processors
#include "ss_declare.h"
#include "tob_ops.h"
};
}; /*TOB*/
namespace Message {
class TOB : public Titanium
{ {
public: public:
TOB() = default; Strategy();
~TOB() override = default;
protected:
virtual std::string Describe() const;
virtual const EQ::versions::ClientVersion ClientVersion() const;
//magic macro to declare our opcode processors
#include "ss_declare.h"
#include "tob_ops.h"
};
class MessageComponent : public Titanium::MessageComponent
{
public:
MessageComponent() = default;
~MessageComponent() override = default;
std::unique_ptr<EQApplicationPacket> Formatted(uint32_t color, uint32_t id, std::unique_ptr<EQApplicationPacket> Formatted(uint32_t color, uint32_t id,
const std::array<const char*, 9>& args) const override; const std::array<const char*, 9>& args) const override;
@@ -55,15 +43,11 @@ protected:
void ResolveArguments(uint32_t id, std::array<const char*, 9>& args) const override; void ResolveArguments(uint32_t id, std::array<const char*, 9>& args) const override;
}; };
} // namespace Message class BuffComponent : public UF::BuffComponent
namespace Buff {
class TOB : public UF
{ {
public: public:
TOB() = default; BuffComponent() = default;
~TOB() override = default; ~BuffComponent() override = default;
std::unique_ptr<EQApplicationPacket> std::unique_ptr<EQApplicationPacket>
BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot, bool fade) const override; BuffDefinition(Mob* mob, const Buffs_Struct& buff, int slot, bool fade) const override;
@@ -72,4 +56,4 @@ public:
void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const override; void SetRefreshType(std::unique_ptr<EQApplicationPacket>& packet, Mob* source, Client* target) const override;
}; };
} // namespace Buff }; /*TOB*/
+4 -6
View File
@@ -5235,12 +5235,10 @@ namespace UF
// we're a normal buff // we're a normal buff
return index; // as long as we guard against bad slots server side, we should be fine return index; // as long as we guard against bad slots server side, we should be fine
} }
} /*UF*/
namespace Buff { std::unique_ptr<EQApplicationPacket> BuffComponent::RefreshBuffs(EmuOpcode opcode, Mob* mob,
bool remove,
std::unique_ptr<EQApplicationPacket> UF::RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove, bool buff_timers_suspended, const std::vector<uint32_t>& slots) const
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const
{ {
// UF introduced the self update buff packet // UF introduced the self update buff packet
@@ -5286,4 +5284,4 @@ std::unique_ptr<EQApplicationPacket> UF::RefreshBuffs(EmuOpcode opcode, Mob* mob
return outapp; return outapp;
} }
} // namespace Buff } /*UF*/
+21 -32
View File
@@ -22,44 +22,33 @@
class EQStreamIdentifier; class EQStreamIdentifier;
namespace UF namespace UF {
{
//these are the only public member of this namespace. extern void Register(EQStreamIdentifier& into);
extern void Register(EQStreamIdentifier &into); extern void Reload();
extern void Reload();
class Strategy : public StructStrategy
//you should not directly access anything below..
//I just dont feel like making a seperate header for it.
class Strategy : public StructStrategy {
public:
Strategy();
protected:
virtual std::string Describe() const;
virtual const EQ::versions::ClientVersion ClientVersion() const;
//magic macro to declare our opcode processors
#include "ss_declare.h"
#include "uf_ops.h"
};
}; /*UF*/
namespace Buff {
class UF : public SoD
{ {
public: public:
UF() = default; Strategy();
~UF() override = default;
protected:
virtual std::string Describe() const;
virtual const EQ::versions::ClientVersion ClientVersion() const;
//magic macro to declare our opcode processors
#include "ss_declare.h"
#include "uf_ops.h"
};
class BuffComponent : public SoD::BuffComponent
{
public:
BuffComponent() = default;
~BuffComponent() override = default;
std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove, std::unique_ptr<EQApplicationPacket> RefreshBuffs(EmuOpcode opcode, Mob* mob, bool remove,
bool buff_timers_suspended, const std::vector<uint32_t>& slots) const override; bool buff_timers_suspended, const std::vector<uint32_t>& slots) const override;
}; };
} // namespace Buff }; /*UF*/
+6 -6
View File
@@ -3811,10 +3811,10 @@ void Client::MessageString(uint32 type, uint32 string_id, uint32 distance)
return; return;
if (distance > 0) if (distance > 0)
Message::CloseMessageString(this, false, static_cast<float>(distance))( ClientPatch::CloseMessageString(this, false, static_cast<float>(distance))(
type, string_id); type, string_id);
else 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; type = 4;
if (distance > 0) 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); message2, message3, message4, message5, message6, message7, message8, message9);
else 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); message6, message7, message8, message9);
} }
@@ -6326,7 +6326,7 @@ void Client::SuspendMinion(int value)
if(value >= 1) if(value >= 1)
{ {
CurrentPet->SetPetState(m_suspendedminion.Buffs, m_suspendedminion.Items); CurrentPet->SetPetState(m_suspendedminion.Buffs, m_suspendedminion.Items);
Buff::SendFullBuffRefresh(CurrentPet); ClientPatch::SendFullBuffRefresh(CurrentPet);
} }
CurrentPet->CalcBonuses(); CurrentPet->CalcBonuses();
@@ -8930,7 +8930,7 @@ int Client::GetQuiverHaste(int delay)
return (pi->GetItem()->BagWR * 0.0025f * delay) + 1; 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 // arbitrary size limit
if (message.size() > 512) // live does send this with empty strings sometimes ... 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 *message7 = nullptr, const char *message8 = nullptr,
const char *message9 = nullptr); const char *message9 = nullptr);
void Tell_StringID(uint32 string_id, const char *who, const char *message); 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 SendTraderItem(uint32 item_id,uint16 quantity, TraderRepository::Trader &trader);
void DoBazaarSearch(BazaarSearchCriteria_Struct search_criteria); void DoBazaarSearch(BazaarSearchCriteria_Struct search_criteria);
uint16 FindTraderItem(int32 SerialNumber,uint16 Quantity); uint16 FindTraderItem(int32 SerialNumber,uint16 Quantity);
+3 -3
View File
@@ -760,7 +760,7 @@ void Client::CompleteConnect()
Mob* pet = GetPet(); Mob* pet = GetPet();
if (pet) { if (pet) {
pet->SendWearChangeAndLighting(EQ::textures::LastTexture); pet->SendWearChangeAndLighting(EQ::textures::LastTexture);
Buff::SendFullBuffRefresh(pet); ClientPatch::SendFullBuffRefresh(pet);
} }
if (GetGroup()) if (GetGroup())
@@ -935,7 +935,7 @@ void Client::CompleteConnect()
delete pack; delete pack;
} }
Buff::SendFullBuffRefresh(this); ClientPatch::SendFullBuffRefresh(this);
// TODO: load these states // TODO: load these states
// We at least will set them to the correct state for now // 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) if (nt)
{ {
SetTarget(nt); SetTarget(nt);
Buff::SendFullBuffRefresh(nt); ClientPatch::SendFullBuffRefresh(nt);
} }
else else
{ {
+1 -1
View File
@@ -2309,7 +2309,7 @@ void Client::ClearHover()
entity_list.QueueClients(this, outapp, false); entity_list.QueueClients(this, outapp, false);
safe_delete(outapp); safe_delete(outapp);
Buff::SendFullBuffRefresh(this); ClientPatch::SendFullBuffRefresh(this);
dead = false; dead = false;
} }
+33 -57
View File
@@ -17,7 +17,7 @@
namespace ClientPatch { namespace ClientPatch {
using ClientList = std::unordered_map<uint16, Client*>; 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 SendPredicate = std::function<bool(Client*)>;
using MutatePacket = std::function<void(std::unique_ptr<EQApplicationPacket>&, 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 // packet generator queue functions
static auto QueueClients(Mob* sender, bool ignore_sender = false, bool ackreq = true) 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> requires std::is_member_function_pointer_v<Fun>
{ {
std::array<std::unique_ptr<EQApplicationPacket>, EQ::versions::ClientVersionCount> build_packets; 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()); 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> requires std::is_member_function_pointer_v<Fun>
{ {
if (sender == nullptr) { 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) 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> requires std::is_member_function_pointer_v<Fun>
{ {
if (sender != nullptr) { if (sender != nullptr) {
@@ -128,32 +128,22 @@ static auto QueueClientsByTarget(Mob* sender, bool ackreq, bool HoTT, const Send
if (packet) if (packet)
c->QueuePacket(packet.get(), ackreq, Client::CLIENT_CONNECTED); 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 // Helper functions to wrap the packet construction in sends
template <AllConstChar... Args> template <AllConstChar... Args>
requires (sizeof...(Args) <= 9) requires (sizeof...(Args) <= 9)
void MessageString(Client* c, uint32_t type, uint32_t id, Args&&... args) void MessageString(Client* c, uint32_t type, uint32_t id, Args&&... args)
{ {
if constexpr (sizeof...(Args) == 0) { if constexpr (sizeof...(Args) == 0) {
ClientPatch::QueuePacket(c, &IMessage::Simple, GetComponent(c), type, id); QueuePacket(c, &IMessage::Simple, GetClientComponent<IMessage>(c), type, id);
} else { } else {
std::array<const char*, 9> a = {args...}; 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) return [=]<AllConstChar... Args>(uint32_t type, uint32_t id, Args&&... args)
requires (sizeof...(Args) <= 9) 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); is_ack_required, filter);
if constexpr (sizeof...(Args) == 0) { 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 { } else {
std::array<const char*, 9> a = {args...}; 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) 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, inline void InterruptSpellOther(Mob* sender, uint32_t message, uint32_t spawn_id, const char* name,
const char* spell_link) 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)( 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) 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 // 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 // first, send to self if self is client
if (sender->IsClient()) { if (sender->IsClient()) {
Client* c = sender->CastToClient(); 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 // next, send to owner if self is a pet to a client
if (sender->IsPet() && sender->GetOwner()->IsClient()) { if (sender->IsPet() && sender->GetOwner()->IsClient()) {
if (Mob* owner = sender->GetOwner(); owner != nullptr && owner->IsClient()) { if (Mob* owner = sender->GetOwner(); owner != nullptr && owner->IsClient()) {
Client* c = owner->CastToClient(); 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 // 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) { 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)( QueueClientsByTarget(sender, ackreq, false, ShouldSendTargetBuffs, mutate)(
&IBuff::RefreshBuffs, GetComponent, OP_RefreshTargetBuffs, sender, false, suspended, slots); &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 we have remove set, this will clear any target windows that shouldn't see the buffs
if (remove) if (remove)
ClientPatch::QueueClientsByTarget(sender, ackreq, true, QueueClientsByTarget(sender, ackreq, true,
[](Client* c) { return !ShouldSendTargetBuffs(c); }, mutate)( [](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) 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 // first, send to self if self is client, which takes the definition and the refresh
if (sender->IsClient()) { if (sender->IsClient()) {
Client* c = sender->CastToClient(); Client* c = sender->CastToClient();
ClientPatch::FastQueuePacket(c, &IBuff::BuffDefinition, GetComponent(c), sender, buff, slot, remove); // FastQueuePacket(c, &IBuff::BuffDefinition, GetClientComponent<IBuff>(c), sender, buff, slot, false);
ClientPatch::FastQueuePacket(c, &IBuff::RefreshBuffs, GetComponent(c), OP_RefreshBuffs, sender, remove, suspended, slots); // 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 // the rest of the buff packets do not take the definition, only the refresh
if (sender->IsPet() && sender->GetOwner()->IsClient()) { if (sender->IsPet() && sender->GetOwner()->IsClient()) {
if (Mob* owner = sender->GetOwner(); owner != nullptr && owner->IsClient()) { if (Mob* owner = sender->GetOwner(); owner != nullptr && owner->IsClient()) {
Client* c = owner->CastToClient(); 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) { 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)( QueueClientsByTarget(sender, ackreq, false, ShouldSendTargetBuffs, mutate)(
&IBuff::RefreshBuffs, GetComponent, OP_RefreshTargetBuffs, sender, remove, suspended, slots); &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) // the client doesn't automatically do this for some reason, only send it to the sender
// TODO: hook this up to QueueClients, or figure out if there's another missing packet to display the fade text // if (remove && sender->IsClient())
if (remove && sender->IsClient()) // sender->CastToClient()->SendColoredText(Chat::Spells, spells[buff.spellid].spell_fades);
{
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());
}
} }
} // 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) if (spells[spell_id].endurance_upkeep > 0)
SetEndurUpkeep(true); SetEndurUpkeep(true);
Buff::SendFullBuffRefresh(this); ClientPatch::SendFullBuffRefresh(this);
} }
if (IsClient()) { 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 // This was done in AddBuff, but we were not a pet yet, so
// the target windows didn't get updated. // the target windows didn't get updated.
Buff::SendFullBuffRefresh(this); ClientPatch::SendFullBuffRefresh(this);
if(caster->IsClient()){ if(caster->IsClient()){
auto app = new EQApplicationPacket(OP_Charm, sizeof(Charm_Struct)); 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; ps->command = 1;
entity_list.QueueClients(this, app); entity_list.QueueClients(this, app);
safe_delete(app); safe_delete(app);
Buff::SendFullBuffRefresh(this); ClientPatch::SendFullBuffRefresh(this);
SendAppearancePacket(AppearanceType::Pet, caster->GetID(), true, true); 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 // this is for older clients. Newer clients will simply discard this packet
if (IsClient() && buffs[buffs_i].UpdateClient == true) { 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; buffs[buffs_i].UpdateClient = false;
} }
} }
} }
Buff::SendFullBuffRefresh(this); ClientPatch::SendFullBuffRefresh(this);
} }
void Mob::DoBuffTic(const Buffs_Struct &buff, int slot, Mob *caster) void Mob::DoBuffTic(const Buffs_Struct &buff, int slot, Mob *caster)
@@ -4244,7 +4244,7 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses)
return; return;
if (IsClient() && !CastToClient()->IsDead()) 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); 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. // no longer see the buffs on the old pet.
// QueueClientsByTarget preserves GM and leadership cases. // QueueClientsByTarget preserves GM and leadership cases.
Buff::SendFullBuffRefresh(this, true); ClientPatch::SendFullBuffRefresh(this, true);
if (IsAIControlled()) if (IsAIControlled())
{ {
@@ -4651,8 +4651,8 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses)
RemoveNimbusEffect(spells[buffs[slot].spellid].nimbus_effect); RemoveNimbusEffect(spells[buffs[slot].spellid].nimbus_effect);
buffs[slot].spellid = SPELL_UNKNOWN; buffs[slot].spellid = SPELL_UNKNOWN;
Buff::SendSingleBuffChange(this, buffs[slot], slot, true); ClientPatch::SendSingleBuffChange(this, buffs[slot], slot, true);
Buff::SendFullBuffRefresh(this); ClientPatch::SendFullBuffRefresh(this);
// we will eventually call CalcBonuses() even if we skip it right here, so should correct itself if we still have them // we will eventually call CalcBonuses() even if we skip it right here, so should correct itself if we still have them
degenerating_effects = false; degenerating_effects = false;
@@ -7010,7 +7010,7 @@ void Mob::CheckNumHitsRemaining(NumHit type, int32 buff_slot, int32 spell_id)
if (!TryFadeEffect(d)) if (!TryFadeEffect(d))
BuffFadeBySlot(d, true); BuffFadeBySlot(d, true);
} else if (IsClient()) { // still have numhits and client, update } 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)) if (!TryFadeEffect(buff_slot))
BuffFadeBySlot(buff_slot , true); BuffFadeBySlot(buff_slot , true);
} else if (IsClient()) { // still have numhits and client, update } 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)) if (!TryFadeEffect(d))
BuffFadeBySlot(d, true); BuffFadeBySlot(d, true);
} else if (IsClient()) { // still have numhits and client, update } 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); Links::FormatSpellLink(spell_link, Links::MAX_LINK_SIZE, spell_id);
if (IsClient()) if (IsClient())
Message::MessageString(CastToClient(), Chat::SpellFailure, fizzle_msg, spell_link); ClientPatch::MessageString(CastToClient(), Chat::SpellFailure, fizzle_msg, spell_link);
/** /**
* Song Failure message * Song Failure message
*/ */
Message::CloseMessageString(this, true, RuleI(Range, SpellMessages), ClientPatch::CloseMessageString(this, true, RuleI(Range, SpellMessages),
nullptr, true, IsClient() ? FilterPCSpells : FilterNPCSpells)( nullptr, true, IsClient() ? FilterPCSpells : FilterNPCSpells)(
Chat::SpellFailure, fizzle_msg == MISS_NOTE ? MISSED_NOTE_OTHER : SPELL_FIZZLE_OTHER, GetName(), spell_link); 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 // the interrupt message
char spell_link[Links::MAX_LINK_SIZE]; char spell_link[Links::MAX_LINK_SIZE];
Links::FormatSpellLink(spell_link, Links::MAX_LINK_SIZE, spellid); 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); 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 // this is the actual message, it works the same as a formatted message
char spell_link[Links::MAX_LINK_SIZE]; char spell_link[Links::MAX_LINK_SIZE];
Links::FormatSpellLink(spell_link, Links::MAX_LINK_SIZE, spellid); 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 // 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)) { if (IsClient() && IsEffectInSpell(spell_id, SpellEffect::BindSight)) {
for (int i = 0; i < GetMaxTotalSlots(); i++) { for (int i = 0; i < GetMaxTotalSlots(); i++) {
if (buffs[i].spellid == spell_id) { 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) { if (IsClient() && spells[spell_id].hit_number) {
for (int i = 0; i < GetMaxTotalSlots(); i++) { for (int i = 0; i < GetMaxTotalSlots(); i++) {
if (buffs[i].spellid == spell_id && buffs[i].hit_number > 0) { if (buffs[i].spellid == spell_id && buffs[i].hit_number > 0) {
Buff::SendSingleBuffChange(this, buffs[i], i); ClientPatch::SendSingleBuffChange(this, buffs[i], i);
break; 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); LogSpells("Buff [{}] added to slot [{}] with caster level [{}]", spell_id, emptyslot, caster_level);
Buff::SendSingleBuffChange(this, buffs[emptyslot], emptyslot); ClientPatch::SendSingleBuffChange(this, buffs[emptyslot], emptyslot);
Buff::SendFullBuffRefresh(this); ClientPatch::SendFullBuffRefresh(this);
// recalculate bonuses since we stripped/added buffs // recalculate bonuses since we stripped/added buffs
CalcBonuses(); CalcBonuses();
@@ -6462,7 +6462,7 @@ void Mob::BuffModifyDurationBySpellID(int32 spell_id, int32 newDuration)
if (buffs[i].spellid == spell_id) if (buffs[i].spellid == spell_id)
{ {
buffs[i].ticsremaining = newDuration; 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) { if (cast_time != 0) {
char spell_link[Links::MAX_LINK_SIZE]; char spell_link[Links::MAX_LINK_SIZE];
Links::FormatSpellLink(spell_link, Links::MAX_LINK_SIZE, spell_id); 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(); ZeroCastingVars();
ZeroBardPulseVars(); ZeroBardPulseVars();