mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-10 07:52:26 +00:00
[Performance] Re-use OP_SendFindableNPCs packet memory (#4623)
This commit is contained in:
parent
95c6560e7c
commit
401f1038f3
@ -5319,15 +5319,12 @@ void EntityList::SendFindableNPCList(Client *c)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto outapp = new EQApplicationPacket(OP_SendFindableNPCs, sizeof(FindableNPC_Struct));
|
static EQApplicationPacket p(OP_SendFindableNPCs, sizeof(FindableNPC_Struct));
|
||||||
|
auto b = (FindableNPC_Struct*) p.pBuffer;
|
||||||
FindableNPC_Struct *fnpcs = (FindableNPC_Struct *)outapp->pBuffer;
|
b->Unknown109 = 0x16;
|
||||||
|
b->Unknown110 = 0x06;
|
||||||
fnpcs->Unknown109 = 0x16;
|
b->Unknown111 = 0x24;
|
||||||
fnpcs->Unknown110 = 0x06;
|
b->Action = 0;
|
||||||
fnpcs->Unknown111 = 0x24;
|
|
||||||
|
|
||||||
fnpcs->Action = 0;
|
|
||||||
|
|
||||||
auto it = npc_list.begin();
|
auto it = npc_list.begin();
|
||||||
while (it != npc_list.end()) {
|
while (it != npc_list.end()) {
|
||||||
@ -5335,50 +5332,47 @@ void EntityList::SendFindableNPCList(Client *c)
|
|||||||
NPC *n = it->second;
|
NPC *n = it->second;
|
||||||
|
|
||||||
if (n->IsFindable()) {
|
if (n->IsFindable()) {
|
||||||
fnpcs->EntityID = n->GetID();
|
b->EntityID = n->GetID();
|
||||||
strn0cpy(fnpcs->Name, n->GetCleanName(), sizeof(fnpcs->Name));
|
strn0cpy(b->Name, n->GetCleanName(), sizeof(b->Name));
|
||||||
strn0cpy(fnpcs->LastName, n->GetLastName(), sizeof(fnpcs->LastName));
|
strn0cpy(b->LastName, n->GetLastName(), sizeof(b->LastName));
|
||||||
fnpcs->Race = n->GetRace();
|
b->Race = n->GetRace();
|
||||||
fnpcs->Class = n->GetClass();
|
b->Class = n->GetClass();
|
||||||
|
|
||||||
c->QueuePacket(outapp);
|
c->QueuePacket(&p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
safe_delete(outapp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityList::UpdateFindableNPCState(NPC *n, bool Remove)
|
void EntityList::UpdateFindableNPCState(NPC *n, bool Remove)
|
||||||
{
|
{
|
||||||
if (!n || !n->IsFindable())
|
if (!n || !n->IsFindable()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto outapp = new EQApplicationPacket(OP_SendFindableNPCs, sizeof(FindableNPC_Struct));
|
static EQApplicationPacket p(OP_SendFindableNPCs, sizeof(FindableNPC_Struct));
|
||||||
|
auto b = (FindableNPC_Struct *) p.pBuffer;
|
||||||
|
b->Unknown109 = 0x16;
|
||||||
|
b->Unknown110 = 0x06;
|
||||||
|
b->Unknown111 = 0x24;
|
||||||
|
|
||||||
FindableNPC_Struct *fnpcs = (FindableNPC_Struct *)outapp->pBuffer;
|
b->Action = Remove ? 1 : 0;
|
||||||
|
b->EntityID = n->GetID();
|
||||||
fnpcs->Unknown109 = 0x16;
|
strn0cpy(b->Name, n->GetCleanName(), sizeof(b->Name));
|
||||||
fnpcs->Unknown110 = 0x06;
|
strn0cpy(b->LastName, n->GetLastName(), sizeof(b->LastName));
|
||||||
fnpcs->Unknown111 = 0x24;
|
b->Race = n->GetRace();
|
||||||
|
b->Class = n->GetClass();
|
||||||
fnpcs->Action = Remove ? 1: 0;
|
|
||||||
fnpcs->EntityID = n->GetID();
|
|
||||||
strn0cpy(fnpcs->Name, n->GetCleanName(), sizeof(fnpcs->Name));
|
|
||||||
strn0cpy(fnpcs->LastName, n->GetLastName(), sizeof(fnpcs->LastName));
|
|
||||||
fnpcs->Race = n->GetRace();
|
|
||||||
fnpcs->Class = n->GetClass();
|
|
||||||
|
|
||||||
auto it = client_list.begin();
|
auto it = client_list.begin();
|
||||||
while (it != client_list.end()) {
|
while (it != client_list.end()) {
|
||||||
Client *c = it->second;
|
Client *c = it->second;
|
||||||
if (c && (c->ClientVersion() >= EQ::versions::ClientVersion::SoD))
|
if (c && (c->ClientVersion() >= EQ::versions::ClientVersion::SoD)) {
|
||||||
c->QueuePacket(outapp);
|
c->QueuePacket(&p);
|
||||||
|
}
|
||||||
|
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_delete(outapp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityList::HideCorpses(Client *c, uint8 CurrentMode, uint8 NewMode)
|
void EntityList::HideCorpses(Client *c, uint8 CurrentMode, uint8 NewMode)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user