mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
[Performance] Send Smarter Emote Packets (#4818)
This commit is contained in:
parent
950cc4a325
commit
c8a7066d0e
@ -1886,3 +1886,36 @@ std::vector<uint32_t> ClientList::GetGuildZoneServers(uint32 guild_id)
|
||||
|
||||
return zone_server_ids;
|
||||
}
|
||||
|
||||
std::vector<uint32_t> ClientList::GetZoneServersWithGMs()
|
||||
{
|
||||
std::vector<uint32_t> zone_server_ids;
|
||||
std::unordered_set<uint32_t> seen_ids;
|
||||
LinkedListIterator<ClientListEntry *> iterator(clientlist);
|
||||
|
||||
iterator.Reset();
|
||||
while (iterator.MoreElements()) {
|
||||
ClientListEntry *cle = iterator.GetData();
|
||||
|
||||
if (cle->Online() != CLE_Status::InZone) {
|
||||
iterator.Advance();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!cle->Server()) {
|
||||
iterator.Advance();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cle->Admin() > 0) {
|
||||
uint32_t id = cle->Server()->GetID();
|
||||
if (seen_ids.insert(id).second) {
|
||||
zone_server_ids.emplace_back(id);
|
||||
}
|
||||
}
|
||||
|
||||
iterator.Advance();
|
||||
}
|
||||
|
||||
return zone_server_ids;
|
||||
}
|
||||
|
||||
@ -61,6 +61,7 @@ public:
|
||||
void CLEKeepAlive(uint32 numupdates, uint32* wid);
|
||||
void CLEAdd(uint32 login_server_id, const char* login_server_name, const char* login_name, const char* login_key, int16 world_admin = AccountStatus::Player, uint32 ip_address = 0, uint8 is_local=0);
|
||||
std::vector<uint32_t> GetGuildZoneServers(uint32 guild_id);
|
||||
std::vector<uint32_t> GetZoneServersWithGMs();
|
||||
void UpdateClientGuild(uint32 char_id, uint32 guild_id);
|
||||
bool IsAccountInGame(uint32 iLSID);
|
||||
|
||||
|
||||
@ -517,19 +517,27 @@ void ZSList::SendEmoteMessage(const char* to, uint32 to_guilddbid, int16 to_mins
|
||||
SendEmoteMessageRaw(to, to_guilddbid, to_minstatus, type, buffer);
|
||||
}
|
||||
|
||||
void ZSList::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message) {
|
||||
if (!message)
|
||||
void ZSList::SendEmoteMessageRaw(
|
||||
const char *to,
|
||||
uint32 to_guilddbid,
|
||||
int16 to_minstatus,
|
||||
uint32 type,
|
||||
const char *message
|
||||
)
|
||||
{
|
||||
if (!message) {
|
||||
return;
|
||||
}
|
||||
auto pack = new ServerPacket;
|
||||
|
||||
pack->opcode = ServerOP_EmoteMessage;
|
||||
pack->size = sizeof(ServerEmoteMessage_Struct) + strlen(message) + 1;
|
||||
pack->opcode = ServerOP_EmoteMessage;
|
||||
pack->size = sizeof(ServerEmoteMessage_Struct) + strlen(message) + 1;
|
||||
pack->pBuffer = new uchar[pack->size];
|
||||
memset(pack->pBuffer, 0, pack->size);
|
||||
ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*)pack->pBuffer;
|
||||
ServerEmoteMessage_Struct *sem = (ServerEmoteMessage_Struct *) pack->pBuffer;
|
||||
|
||||
if (to) {
|
||||
strcpy((char *)sem->to, to);
|
||||
strcpy((char *) sem->to, to);
|
||||
}
|
||||
else {
|
||||
sem->to[0] = 0;
|
||||
@ -537,22 +545,37 @@ void ZSList::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_m
|
||||
|
||||
sem->guilddbid = to_guilddbid;
|
||||
sem->minstatus = to_minstatus;
|
||||
sem->type = type;
|
||||
sem->type = type;
|
||||
strcpy(&sem->message[0], message);
|
||||
char tempto[64] = { 0 };
|
||||
if (to)
|
||||
char tempto[64] = {0};
|
||||
if (to) {
|
||||
strn0cpy(tempto, to, 64);
|
||||
}
|
||||
|
||||
if (tempto[0] == 0) {
|
||||
SendPacket(pack);
|
||||
if (to_guilddbid > 0) {
|
||||
SendPacketToZonesWithGuild(to_guilddbid, pack);
|
||||
}
|
||||
else if (to_minstatus > 0) {
|
||||
SendPacketToZonesWithGMs(pack);
|
||||
} else {
|
||||
SendPacket(pack);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ZoneServer* zs = FindByName(to);
|
||||
|
||||
if (zs != 0)
|
||||
ZoneServer *zs = FindByName(to);
|
||||
if (zs) {
|
||||
zs->SendPacket(pack);
|
||||
else
|
||||
}
|
||||
else if (to_guilddbid > 0) {
|
||||
SendPacketToZonesWithGuild(to_guilddbid, pack);
|
||||
}
|
||||
else if (to_minstatus > 0) {
|
||||
SendPacketToZonesWithGMs(pack);
|
||||
}
|
||||
else {
|
||||
SendPacket(pack);
|
||||
}
|
||||
}
|
||||
delete pack;
|
||||
}
|
||||
@ -887,6 +910,19 @@ bool ZSList::SendPacketToZonesWithGuild(uint32 guild_id, ServerPacket* pack)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ZSList::SendPacketToZonesWithGMs(ServerPacket* pack)
|
||||
{
|
||||
for (auto const &z: zone_server_list) {
|
||||
for (auto const &server_id: client_list.GetZoneServersWithGMs()) {
|
||||
if (z->GetID() == server_id && z->GetZoneID() > 0) {
|
||||
z->SendPacket(pack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ZSList::SendServerReload(ServerReload::Type type, uchar *packet)
|
||||
{
|
||||
static auto pack = ServerPacket(ServerOP_ServerReloadRequest, sizeof(ServerReload::Request));
|
||||
|
||||
@ -30,6 +30,7 @@ public:
|
||||
bool SendPacket(uint32 zoneid, ServerPacket *pack);
|
||||
bool SendPacket(uint32 zoneid, uint16 instanceid, ServerPacket *pack);
|
||||
bool SendPacketToZonesWithGuild(uint32 guild_id, ServerPacket *pack);
|
||||
bool SendPacketToZonesWithGMs(ServerPacket *pack);
|
||||
bool SendPacketToBootedZones(ServerPacket* pack);
|
||||
bool SetLockedZone(uint16 iZoneID, bool iLock);
|
||||
|
||||
|
||||
@ -571,7 +571,13 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
|
||||
);
|
||||
}
|
||||
}
|
||||
zoneserver_list.SendPacket(pack);
|
||||
if (scm->guilddbid > 0) {
|
||||
zoneserver_list.SendPacketToZonesWithGuild(scm->guilddbid, pack);
|
||||
} else if (scm->chan_num == ChatChannel_GMSAY) {
|
||||
zoneserver_list.SendPacketToZonesWithGMs(pack);
|
||||
} else {
|
||||
zoneserver_list.SendPacket(pack);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user