mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-21 06:28:22 +00:00
Updated the interface to be more consistent
This commit is contained in:
@@ -32,29 +32,21 @@ public:
|
||||
constexpr IMessage() {}
|
||||
constexpr virtual ~IMessage() {}
|
||||
|
||||
virtual void Simple(Client* c, uint32_t color, uint32_t id, uint32_t distance = 0) const = 0;
|
||||
|
||||
virtual void Formatted(Client* c, uint32_t color, uint32_t id,
|
||||
const char* a1 = nullptr, const char* a2 = nullptr, const char* a3 = nullptr,
|
||||
const char* a4 = nullptr, const char* a5 = nullptr, const char* a6 = nullptr,
|
||||
const char* a7 = nullptr, const char* a8 = nullptr, const char* a9 = nullptr,
|
||||
uint32_t distance = 0) const = 0;
|
||||
// these two are the basic string message packets
|
||||
virtual EQApplicationPacket* Simple(uint32_t color, uint32_t id) const = 0;
|
||||
virtual EQApplicationPacket* Formatted(uint32_t color, uint32_t id,
|
||||
const char* a1 = nullptr, const char* a2 = nullptr, const char* a3 = nullptr,
|
||||
const char* a4 = nullptr, const char* a5 = nullptr, const char* a6 = nullptr,
|
||||
const char* a7 = nullptr, const char* a8 = nullptr, const char* a9 = nullptr) const = 0;
|
||||
|
||||
// These aren't technically messages, but they use the same format and are similar enough to include here
|
||||
virtual EQApplicationPacket* InterruptSpell(Client* c, uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
virtual EQApplicationPacket* InterruptSpell(uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
const char* spell_name_override = "") const = 0;
|
||||
virtual EQApplicationPacket* InterruptSpellOther(Mob* m, uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
virtual EQApplicationPacket* InterruptSpellOther(Mob* sender, uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
const char* spell_name_override = "") const = 0;
|
||||
|
||||
// Everything else is specializations of logic needed to build strings that differ between patches
|
||||
virtual EQApplicationPacket* Fizzle(Mob* m, uint32_t type, uint32_t message, uint32_t spell_id) const = 0;
|
||||
|
||||
protected:
|
||||
virtual uint32_t ResolveID(uint32_t id) const = 0;
|
||||
virtual void SendSimple(Client* c, uint32_t color, uint32_t string_id, uint32_t distance) const = 0;
|
||||
virtual void SendFormatted(Client* c, uint32_t color, uint32_t string_id, uint32_t distance,
|
||||
const char* a1 = nullptr, const char* a2 = nullptr, const char* a3 = nullptr,
|
||||
const char* a4 = nullptr, const char* a5 = nullptr, const char* a6 = nullptr,
|
||||
const char* a7 = nullptr, const char* a8 = nullptr, const char* a9 = nullptr) const = 0;
|
||||
};
|
||||
|
||||
} // namespace Zone::Message
|
||||
|
||||
@@ -24,23 +24,52 @@
|
||||
#include "common/serialize_buffer.h"
|
||||
|
||||
namespace ZoneClient::Message {
|
||||
void Titanium::Simple(Client* c, uint32_t color, uint32_t id, uint32_t distance) const {
|
||||
EQApplicationPacket* Titanium::Simple(uint32_t color, uint32_t id) const {
|
||||
uint32_t string_id = ResolveID(id);
|
||||
if (string_id > 0)
|
||||
SendSimple(c, color, string_id, distance);
|
||||
if (string_id > 0) {
|
||||
auto outapp = new EQApplicationPacket(OP_SimpleMessage, sizeof(SimpleMessage_Struct));
|
||||
auto* sms = reinterpret_cast<SimpleMessage_Struct*>(outapp->pBuffer);
|
||||
sms->string_id = string_id;
|
||||
sms->color = color;
|
||||
sms->unknown8 = 0;
|
||||
|
||||
return outapp;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Titanium::Formatted(Client* c, uint32_t color, uint32_t id,
|
||||
const char* a1, const char* a2, const char* a3,
|
||||
const char* a4, const char* a5, const char* a6,
|
||||
const char* a7, const char* a8, const char* a9,
|
||||
uint32_t distance) const {
|
||||
EQApplicationPacket* Titanium::Formatted(uint32_t color, uint32_t id,
|
||||
const char* a1, const char* a2, const char* a3,
|
||||
const char* a4, const char* a5, const char* a6,
|
||||
const char* a7, const char* a8, const char* a9) const {
|
||||
uint32_t string_id = ResolveID(id);
|
||||
if (string_id > 0)
|
||||
SendFormatted(c, color, string_id, distance, a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
if (string_id > 0) {
|
||||
if (!a1)
|
||||
return Simple(color, id);
|
||||
|
||||
const char* args[] = {a1, a2, a3, a4, a5, a6, a7, a8, a9};
|
||||
|
||||
SerializeBuffer buf(20);
|
||||
buf.WriteInt32(0);
|
||||
buf.WriteInt32(string_id);
|
||||
buf.WriteInt32(color);
|
||||
|
||||
for (const auto* arg : args) {
|
||||
if (!arg)
|
||||
break;
|
||||
buf.WriteString(arg);
|
||||
}
|
||||
|
||||
buf.WriteInt8(0);
|
||||
|
||||
return new EQApplicationPacket(OP_FormattedMessage, std::move(buf));
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EQApplicationPacket* Titanium::InterruptSpell(Client* c, uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
EQApplicationPacket* Titanium::InterruptSpell(uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
const char* spell_name_override) const {
|
||||
auto outapp = new EQApplicationPacket(OP_InterruptCast, sizeof(InterruptCast_Struct));
|
||||
auto ic = reinterpret_cast<InterruptCast_Struct*>(outapp->pBuffer);
|
||||
@@ -51,9 +80,9 @@ EQApplicationPacket* Titanium::InterruptSpell(Client* c, uint32_t message, uint3
|
||||
return outapp;
|
||||
}
|
||||
|
||||
EQApplicationPacket* Titanium::InterruptSpellOther(Mob* m, uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
EQApplicationPacket* Titanium::InterruptSpellOther(Mob* sender, uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
const char* spell_name_override) const {
|
||||
auto name = m->GetCleanName();
|
||||
auto name = sender->GetCleanName();
|
||||
auto outapp = new EQApplicationPacket(OP_InterruptCast, sizeof(InterruptCast_Struct) + strlen(name) + 1);
|
||||
auto ic = reinterpret_cast<InterruptCast_Struct*>(outapp->pBuffer);
|
||||
ic->messageid = ResolveID(message);
|
||||
@@ -73,51 +102,4 @@ uint32_t Titanium::ResolveID(uint32_t id) const {
|
||||
return id;
|
||||
}
|
||||
|
||||
// Could override these in patches if the format of the packets differ, but they are all compatible
|
||||
void Titanium::SendSimple(Client* c, uint32_t color, uint32_t string_id, uint32_t distance) const {
|
||||
auto outapp = new EQApplicationPacket(OP_SimpleMessage, sizeof(SimpleMessage_Struct));
|
||||
auto* sms = reinterpret_cast<SimpleMessage_Struct*>(outapp->pBuffer);
|
||||
sms->string_id = string_id;
|
||||
sms->color = color;
|
||||
sms->unknown8 = 0;
|
||||
|
||||
if (distance > 0)
|
||||
entity_list.QueueCloseClients(c, outapp, false, distance);
|
||||
else
|
||||
c->QueuePacket(outapp);
|
||||
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
void Titanium::SendFormatted(
|
||||
Client* c, uint32_t color, uint32_t string_id, uint32_t distance,
|
||||
const char* a1, const char* a2, const char* a3,
|
||||
const char* a4, const char* a5, const char* a6,
|
||||
const char* a7, const char* a8, const char* a9) const {
|
||||
if (!a1) {
|
||||
SendSimple(c, color, string_id, distance);
|
||||
} else {
|
||||
const char* args[] = {a1, a2, a3, a4, a5, a6, a7, a8, a9};
|
||||
|
||||
SerializeBuffer buf(20);
|
||||
buf.WriteInt32(0);
|
||||
buf.WriteInt32(string_id);
|
||||
buf.WriteInt32(color);
|
||||
|
||||
for (const auto* arg : args) {
|
||||
if (!arg)
|
||||
break;
|
||||
buf.WriteString(arg);
|
||||
}
|
||||
|
||||
buf.WriteInt8(0);
|
||||
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_FormattedMessage, std::move(buf));
|
||||
|
||||
if (distance > 0)
|
||||
entity_list.QueueCloseClients(c, outapp.get(), false, distance);
|
||||
else
|
||||
c->QueuePacket(outapp.get());
|
||||
}
|
||||
}
|
||||
} // namespace ZoneClient::Message
|
||||
|
||||
@@ -26,28 +26,22 @@ public:
|
||||
constexpr Titanium() {}
|
||||
constexpr ~Titanium() override {}
|
||||
|
||||
void Simple(Client* c, uint32_t color, uint32_t id, uint32_t distance = 0) const override;
|
||||
EQApplicationPacket* Simple(uint32_t color, uint32_t id) const override;
|
||||
|
||||
void Formatted(Client* c, uint32_t color, uint32_t id,
|
||||
const char* a1 = nullptr, const char* a2 = nullptr, const char* a3 = nullptr,
|
||||
const char* a4 = nullptr, const char* a5 = nullptr, const char* a6 = nullptr,
|
||||
const char* a7 = nullptr, const char* a8 = nullptr, const char* a9 = nullptr,
|
||||
uint32_t distance = 0) const override;
|
||||
EQApplicationPacket* Formatted(uint32_t color, uint32_t id,
|
||||
const char* a1 = nullptr, const char* a2 = nullptr, const char* a3 = nullptr,
|
||||
const char* a4 = nullptr, const char* a5 = nullptr, const char* a6 = nullptr,
|
||||
const char* a7 = nullptr, const char* a8 = nullptr, const char* a9 = nullptr) const override;
|
||||
|
||||
EQApplicationPacket* InterruptSpell(Client* c, uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
EQApplicationPacket* InterruptSpell(uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
const char* spell_name_override = "") const override;
|
||||
EQApplicationPacket* InterruptSpellOther(Mob* m, uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
EQApplicationPacket* InterruptSpellOther(Mob* sender, uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
const char* spell_name_override = "") const override;
|
||||
|
||||
EQApplicationPacket* Fizzle(Mob* m, uint32_t type, uint32_t message, uint32_t spell_id) const override;
|
||||
|
||||
protected:
|
||||
uint32_t ResolveID(uint32_t id) const override;
|
||||
void SendSimple(Client* c, uint32_t color, uint32_t string_id, uint32_t distance) const override;
|
||||
void SendFormatted(Client* c, uint32_t color, uint32_t string_id, uint32_t distance,
|
||||
const char* a1 = nullptr, const char* a2 = nullptr, const char* a3 = nullptr,
|
||||
const char* a4 = nullptr, const char* a5 = nullptr, const char* a6 = nullptr,
|
||||
const char* a7 = nullptr, const char* a8 = nullptr, const char* a9 = nullptr) const override;
|
||||
virtual uint32_t ResolveID(uint32_t id) const;
|
||||
};
|
||||
|
||||
} // namespace Zone::Message
|
||||
|
||||
@@ -72,7 +72,7 @@ uint32_t TOB::ResolveID(uint32_t id) const {
|
||||
}
|
||||
}
|
||||
|
||||
EQApplicationPacket* TOB::InterruptSpell(Client* c, uint32_t message, uint32_t spawn_id, uint32_t spell_id, const char* spell_name_override) const {
|
||||
EQApplicationPacket* TOB::InterruptSpell(uint32_t message, uint32_t spawn_id, uint32_t spell_id, const char* spell_name_override) const {
|
||||
std::string spell_name = spell_name_override == nullptr || *spell_name_override == '\0'
|
||||
? GetSpellName(spell_id)
|
||||
: spell_name_override;
|
||||
@@ -89,7 +89,7 @@ EQApplicationPacket* TOB::InterruptSpell(Client* c, uint32_t message, uint32_t s
|
||||
return outapp;
|
||||
}
|
||||
|
||||
EQApplicationPacket* TOB::InterruptSpellOther(Mob* m, uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
EQApplicationPacket* TOB::InterruptSpellOther(Mob* sender, uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
const char* spell_name_override) const {
|
||||
std::string spell_name = spell_name_override == nullptr || *spell_name_override == '\0'
|
||||
? GetSpellName(spell_id)
|
||||
@@ -97,7 +97,7 @@ EQApplicationPacket* TOB::InterruptSpellOther(Mob* m, uint32_t message, uint32_t
|
||||
|
||||
std::string spell_link = Links::FormatSpellLink(spell_id, spell_name);
|
||||
|
||||
auto name = m->GetCleanName();
|
||||
auto name = sender->GetCleanName();
|
||||
auto outapp = new EQApplicationPacket(OP_InterruptCast, sizeof(InterruptCast_Struct) + strlen(name) + spell_link.size() + 2);
|
||||
auto ic = reinterpret_cast<InterruptCast_Struct*>(outapp->pBuffer);
|
||||
ic->messageid = ResolveID(message);
|
||||
|
||||
@@ -25,9 +25,9 @@ public:
|
||||
constexpr TOB() {}
|
||||
constexpr ~TOB() override {}
|
||||
|
||||
EQApplicationPacket* InterruptSpell(Client* c, uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
EQApplicationPacket* InterruptSpell(uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
const char* spell_name_override) const override;
|
||||
EQApplicationPacket* InterruptSpellOther(Mob* m, uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
EQApplicationPacket* InterruptSpellOther(Mob* sender, uint32_t message, uint32_t spawn_id, uint32_t spell_id,
|
||||
const char* spell_name_override) const override;
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user