Scanning optimization work from over a year ago from EZ - cleaned up a bit

This commit is contained in:
Akkadius
2019-12-25 03:16:14 -06:00
parent 07fd803d41
commit 8cb51eb253
14 changed files with 393 additions and 222 deletions
+11 -7
View File
@@ -251,17 +251,21 @@ bool Client::Process() {
}
}
/* Build a close range list of NPC's */
/**
* Scan close range mobs
*
* Used in aggro checks
*/
if (npc_close_scan_timer.Check()) {
close_mobs.clear();
//Force spawn updates when traveled far
bool force_spawn_updates = false;
float client_update_range = (RuleI(Range, ClientForceSpawnUpdateRange) * RuleI(Range, ClientForceSpawnUpdateRange));
float scan_range = (RuleI(Range, ClientNPCScan) * RuleI(Range, ClientNPCScan));
auto &mob_list = entity_list.GetMobList();
for (auto itr = mob_list.begin(); itr != mob_list.end(); ++itr) {
Mob* mob = itr->second;
auto &mob_list = entity_list.GetMobList();
for (auto itr : mob_list) {
Mob *mob = itr.second;
float distance = DistanceSquared(m_Position, mob->GetPosition());
if (mob->IsNPC()) {
if (distance <= scan_range) {
close_mobs.insert(std::pair<Mob *, float>(mob, distance));