[Performance] Reworked how client to NPC aggro checks are made

- Before when reverse aggro checks were done (client to NPC), checks would happen every 750 millseconds where a client would
		check an entire entity list with distance calcs and other checks for aggro, with many clients in a zone and many NPC's this would
		add a lot of unecessary overhead. A temporary adjustment on 3/25 was made and upped the check to 6 seconds.
	- Now, there is a new methodology to scanning. The client will build a cache list of NPC's within close range as defined in new rule:
		RULE_INT(Range, ClientNPCScan, 300) and will also get any NPC that has an aggro range beyond that defined range to use in
		the frequent checks for aggro, the result is far less overhead
	- Client scanning changes when moving versus not moving, the client will scan aggro every 500 milliseconds while moving, and
		3000 millseconds aggro check when not moving, with a 6000ms re-fetch for close NPC's
	- A demo of these changes can be found here:
		https://youtu.be/aGroiwLSTVU
This commit is contained in:
Akkadius
2017-03-28 01:30:42 -05:00
parent 940f3b03e8
commit 4b6ce1c19e
9 changed files with 191 additions and 105 deletions
+15
View File
@@ -2288,10 +2288,15 @@ bool EntityList::RemoveNPC(uint16 delete_id)
{
auto it = npc_list.find(delete_id);
if (it != npc_list.end()) {
NPC *npc = it->second;
// make sure its proximity is removed
RemoveProximity(delete_id);
// remove from client close lists
RemoveNPCFromClientCloseLists(npc);
// remove from the list
npc_list.erase(it);
// remove from limit list if needed
if (npc_limit_list.count(delete_id))
npc_limit_list.erase(delete_id);
@@ -2300,6 +2305,16 @@ bool EntityList::RemoveNPC(uint16 delete_id)
return false;
}
bool EntityList::RemoveNPCFromClientCloseLists(NPC *npc)
{
auto it = client_list.begin();
while (it != client_list.end()) {
it->second->close_npcs.erase(npc);
++it;
}
return false;
}
bool EntityList::RemoveMerc(uint16 delete_id)
{
auto it = merc_list.find(delete_id);