mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
Refactor client cross zone message helpers
Remove extra cross zone message server opcode and struct. Existing function already exists for normal messages Group CZClientMessageString struct with other CZ structs
This commit is contained in:
+34
-33
@@ -3207,22 +3207,22 @@ void Client::MessageString(uint32 type, uint32 string_id, const char* message1,
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
void Client::MessageString(const ServerCZClientMessageString_Struct* msg)
|
||||
void Client::MessageString(const CZClientMessageString_Struct* msg)
|
||||
{
|
||||
if (msg)
|
||||
{
|
||||
if (msg->string_params_size == 0)
|
||||
if (msg->args_size == 0)
|
||||
{
|
||||
MessageString(msg->chat_type, msg->string_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t outsize = sizeof(FormattedMessage_Struct) + msg->string_params_size;
|
||||
uint32_t outsize = sizeof(FormattedMessage_Struct) + msg->args_size;
|
||||
auto outapp = std::unique_ptr<EQApplicationPacket>(new EQApplicationPacket(OP_FormattedMessage, outsize));
|
||||
auto outbuf = reinterpret_cast<FormattedMessage_Struct*>(outapp->pBuffer);
|
||||
outbuf->string_id = msg->string_id;
|
||||
outbuf->type = msg->chat_type;
|
||||
memcpy(outbuf->message, msg->string_params, msg->string_params_size);
|
||||
memcpy(outbuf->message, msg->args, msg->args_size);
|
||||
QueuePacket(outapp.get());
|
||||
}
|
||||
}
|
||||
@@ -9496,7 +9496,7 @@ void Client::SendCrossZoneMessage(
|
||||
Client* client, const std::string& character_name, uint16_t chat_type, const std::string& message)
|
||||
{
|
||||
// if client is null, falls back to sending a cross zone message by name
|
||||
if (!client)
|
||||
if (!client && !character_name.empty())
|
||||
{
|
||||
client = entity_list.GetClientByName(character_name.c_str());
|
||||
}
|
||||
@@ -9505,16 +9505,14 @@ void Client::SendCrossZoneMessage(
|
||||
{
|
||||
client->Message(chat_type, message.c_str());
|
||||
}
|
||||
else if (message.size() > 0)
|
||||
else if (!character_name.empty() && !message.empty())
|
||||
{
|
||||
uint32_t msg_size = static_cast<uint32_t>(message.size()) + 1;
|
||||
uint32_t pack_size = sizeof(ServerCZClientMessage_Struct) + msg_size;
|
||||
auto pack = std::unique_ptr<ServerPacket>(new ServerPacket(ServerOP_CZClientMessage, pack_size));
|
||||
auto buf = reinterpret_cast<ServerCZClientMessage_Struct*>(pack->pBuffer);
|
||||
buf->chat_type = chat_type;
|
||||
uint32_t pack_size = sizeof(CZMessagePlayer_Struct);
|
||||
auto pack = std::unique_ptr<ServerPacket>(new ServerPacket(ServerOP_CZMessagePlayer, pack_size));
|
||||
auto buf = reinterpret_cast<CZMessagePlayer_Struct*>(pack->pBuffer);
|
||||
buf->type = chat_type;
|
||||
strn0cpy(buf->character_name, character_name.c_str(), sizeof(buf->character_name));
|
||||
buf->message_size = msg_size;
|
||||
strn0cpy(buf->message, message.c_str(), buf->message_size);
|
||||
strn0cpy(buf->message, message.c_str(), sizeof(buf->message));
|
||||
|
||||
worldserver.SendPacket(pack.get());
|
||||
}
|
||||
@@ -9522,32 +9520,35 @@ void Client::SendCrossZoneMessage(
|
||||
|
||||
void Client::SendCrossZoneMessageString(
|
||||
Client* client, const std::string& character_name, uint16_t chat_type,
|
||||
uint32_t string_id, const std::initializer_list<std::string>& parameters)
|
||||
uint32_t string_id, const std::initializer_list<std::string>& arguments)
|
||||
{
|
||||
// if client is null, falls back to sending a cross zone message by name
|
||||
SerializeBuffer parameter_buffer;
|
||||
for (const auto& parameter : parameters)
|
||||
{
|
||||
parameter_buffer.WriteString(parameter);
|
||||
}
|
||||
|
||||
uint32_t pack_size = sizeof(ServerCZClientMessageString_Struct) + static_cast<uint32_t>(parameter_buffer.size());
|
||||
auto pack = std::unique_ptr<ServerPacket>(new ServerPacket(ServerOP_CZClientMessageString, pack_size));
|
||||
auto buf = reinterpret_cast<ServerCZClientMessageString_Struct*>(pack->pBuffer);
|
||||
buf->string_id = string_id;
|
||||
buf->chat_type = chat_type;
|
||||
strn0cpy(buf->character_name, character_name.c_str(), sizeof(buf->character_name));
|
||||
buf->string_params_size = static_cast<uint32_t>(parameter_buffer.size());
|
||||
buf->string_params[0] = '\0';
|
||||
if (parameter_buffer.size()) {
|
||||
memcpy(buf->string_params, parameter_buffer.buffer(), parameter_buffer.size());
|
||||
}
|
||||
|
||||
if (!client) // double check client isn't in this zone
|
||||
if (!client && !character_name.empty()) // double check client isn't in this zone
|
||||
{
|
||||
client = entity_list.GetClientByName(character_name.c_str());
|
||||
}
|
||||
|
||||
if (!client && character_name.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SerializeBuffer argument_buffer;
|
||||
for (const auto& argument : arguments)
|
||||
{
|
||||
argument_buffer.WriteString(argument);
|
||||
}
|
||||
|
||||
uint32_t args_size = static_cast<uint32_t>(argument_buffer.size());
|
||||
uint32_t pack_size = sizeof(CZClientMessageString_Struct) + args_size;
|
||||
auto pack = std::unique_ptr<ServerPacket>(new ServerPacket(ServerOP_CZClientMessageString, pack_size));
|
||||
auto buf = reinterpret_cast<CZClientMessageString_Struct*>(pack->pBuffer);
|
||||
buf->string_id = string_id;
|
||||
buf->chat_type = chat_type;
|
||||
strn0cpy(buf->character_name, character_name.c_str(), sizeof(buf->character_name));
|
||||
buf->args_size = args_size;
|
||||
memcpy(buf->args, argument_buffer.buffer(), argument_buffer.size());
|
||||
|
||||
if (client)
|
||||
{
|
||||
client->MessageString(buf);
|
||||
|
||||
+2
-2
@@ -288,7 +288,7 @@ public:
|
||||
uint8 SlotConvert(uint8 slot,bool bracer=false);
|
||||
void MessageString(uint32 type, uint32 string_id, uint32 distance = 0);
|
||||
void MessageString(uint32 type, uint32 string_id, const char* message,const char* message2=0,const char* message3=0,const char* message4=0,const char* message5=0,const char* message6=0,const char* message7=0,const char* message8=0,const char* message9=0, uint32 distance = 0);
|
||||
void MessageString(const ServerCZClientMessageString_Struct* msg);
|
||||
void MessageString(const CZClientMessageString_Struct* msg);
|
||||
bool FilteredMessageCheck(Mob *sender, eqFilterType filter);
|
||||
void FilteredMessageString(Mob *sender, uint32 type, eqFilterType filter, uint32 string_id);
|
||||
void FilteredMessageString(Mob *sender, uint32 type, eqFilterType filter,
|
||||
@@ -1115,7 +1115,7 @@ public:
|
||||
Client* client, const std::string& client_name, uint16_t chat_type, const std::string& message);
|
||||
static void SendCrossZoneMessageString(
|
||||
Client* client, const std::string& client_name, uint16_t chat_type,
|
||||
uint32_t string_id, const std::initializer_list<std::string>& parameters = {});
|
||||
uint32_t string_id, const std::initializer_list<std::string>& arguments = {});
|
||||
|
||||
void AddExpeditionLockout(const ExpeditionLockoutTimer& lockout, bool update_db = false, bool update_client = true);
|
||||
void AddNewExpeditionLockout(
|
||||
|
||||
+2
-2
@@ -682,9 +682,9 @@ void Expedition::SendClientExpeditionInvite(
|
||||
}
|
||||
|
||||
void Expedition::SendLeaderMessage(
|
||||
Client* leader_client, uint16_t chat_type, uint32_t string_id, const std::initializer_list<std::string>& parameters)
|
||||
Client* leader_client, uint16_t chat_type, uint32_t string_id, const std::initializer_list<std::string>& args)
|
||||
{
|
||||
Client::SendCrossZoneMessageString(leader_client, m_leader.name, chat_type, string_id, parameters);
|
||||
Client::SendCrossZoneMessageString(leader_client, m_leader.name, chat_type, string_id, args);
|
||||
}
|
||||
|
||||
bool Expedition::ProcessAddConflicts(Client* leader_client, Client* add_client, bool swapping)
|
||||
|
||||
+2
-1
@@ -157,7 +157,8 @@ private:
|
||||
void SaveLockouts(ExpeditionRequest& request);
|
||||
void SaveMembers(ExpeditionRequest& request);
|
||||
void SendClientExpeditionInvite(Client* client, const std::string& inviter_name, const std::string& swap_remove_name);
|
||||
void SendLeaderMessage(Client* leader_client, uint16_t chat_type, uint32_t string_id, const std::initializer_list<std::string>& parameters = {});
|
||||
void SendLeaderMessage(Client* leader_client, uint16_t chat_type, uint32_t string_id,
|
||||
const std::initializer_list<std::string>& args = {});
|
||||
void SendUpdatesToZoneMembers(bool clear = false, bool message_on_clear = true);
|
||||
void SendWorldDzLocationUpdate(uint16_t server_opcode, const DynamicZoneLocation& location);
|
||||
void SendWorldExpeditionUpdate(uint16_t server_opcode);
|
||||
|
||||
@@ -285,11 +285,11 @@ bool ExpeditionRequest::CheckMembersForConflicts(const std::vector<std::string>&
|
||||
}
|
||||
|
||||
void ExpeditionRequest::SendLeaderMessage(
|
||||
uint16_t chat_type, uint32_t string_id, const std::initializer_list<std::string>& parameters)
|
||||
uint16_t chat_type, uint32_t string_id, const std::initializer_list<std::string>& args)
|
||||
{
|
||||
if (!m_disable_messages)
|
||||
{
|
||||
Client::SendCrossZoneMessageString(m_leader, m_leader_name, chat_type, string_id, parameters);
|
||||
Client::SendCrossZoneMessageString(m_leader, m_leader_name, chat_type, string_id, args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ private:
|
||||
void SendLeaderMemberInExpedition(const std::string& member_name, bool is_solo);
|
||||
void SendLeaderMemberReplayLockout(const std::string& member_name, const ExpeditionLockoutTimer& lockout, bool is_solo);
|
||||
void SendLeaderMemberEventLockout(const std::string& member_name, const ExpeditionLockoutTimer& lockout);
|
||||
void SendLeaderMessage(uint16_t chat_type, uint32_t string_id, const std::initializer_list<std::string>& parameters = {});
|
||||
void SendLeaderMessage(uint16_t chat_type, uint32_t string_id, const std::initializer_list<std::string>& args = {});
|
||||
|
||||
Client* m_requester = nullptr;
|
||||
Client* m_leader = nullptr;
|
||||
|
||||
+1
-10
@@ -2881,18 +2881,9 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_CZClientMessage:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerCZClientMessage_Struct*>(pack->pBuffer);
|
||||
Client* client = entity_list.GetClientByName(buf->character_name);
|
||||
if (client) {
|
||||
client->Message(buf->chat_type, buf->message);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_CZClientMessageString:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerCZClientMessageString_Struct*>(pack->pBuffer);
|
||||
auto buf = reinterpret_cast<CZClientMessageString_Struct*>(pack->pBuffer);
|
||||
Client* client = entity_list.GetClientByName(buf->character_name);
|
||||
if (client) {
|
||||
client->MessageString(buf);
|
||||
|
||||
Reference in New Issue
Block a user