diff --git a/zone/client.cpp b/zone/client.cpp index a1b89a064..5b2ec15b0 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -12968,6 +12968,18 @@ void Client::CheckSendBulkClientPositionUpdate() } } + // if we have seen this mob before and it hasn't moved, skip it + if (m_last_seen_mob_position.contains(mob->GetID())) { + if (m_last_seen_mob_position[mob->GetID()] == mob->GetPosition()) { + LogVisibilityDetail( + "Mob [{}] has already been sent to client [{}] at this position, skipping", + mob->GetCleanName(), + GetCleanName() + ); + continue; + } + } + mob_movement_manager.SendCommandToClients( mob, 0.0, diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 8ad5f2c02..96a34bda1 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -971,6 +971,8 @@ void Client::CompleteConnect() RecordStats(); AutoGrantAAPoints(); + m_last_seen_mob_position.reserve(entity_list.GetMobList().size()); + // enforce some rules.. if (!CanEnterZone()) { LogInfo("Kicking character [{}] from zone, not allowed here (missing requirements)", GetCleanName()); diff --git a/zone/entity.cpp b/zone/entity.cpp index 0518d78a5..3c5762836 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -2870,6 +2870,7 @@ bool EntityList::RemoveMobFromCloseLists(Mob *mob) it->second->m_close_mobs.erase(entity_id); it->second->m_can_see_mob.erase(entity_id); + it->second->m_last_seen_mob_position.erase(entity_id); ++it; } @@ -2975,7 +2976,7 @@ void EntityList::ScanCloseMobs(Mob *scanning_mob) } BenchTimer g_vis_bench_timer; -#define STATE_HIDDEN -1 +#define STATE_HIDDEN (-1) #define STATE_VISIBLE 1 void EntityList::UpdateVisibility(Mob *scanning_mob) { diff --git a/zone/entity.h b/zone/entity.h index b897eb704..1a85bd33c 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -571,6 +571,7 @@ public: void SendAlternateAdvancementStats(); void ScanCloseMobs(Mob *scanning_mob); void UpdateVisibility(Mob *scanning_mob); + void UpdateKnownPositions(Mob *scanning_mob); void GetTrapInfo(Client* c); bool IsTrapGroupSpawned(uint32 trap_id, uint8 group); diff --git a/zone/mob.h b/zone/mob.h index 353307d8b..2e20ef710 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -201,11 +201,12 @@ public: void DisplayInfo(Mob *mob); - std::unordered_map m_close_mobs; - std::unordered_map m_can_see_mob; - Timer m_scan_close_mobs_timer; - Timer m_see_close_mobs_timer; - Timer m_mob_check_moving_timer; + std::unordered_map m_close_mobs; + std::unordered_map m_can_see_mob; + std::unordered_map m_last_seen_mob_position; + Timer m_scan_close_mobs_timer; + Timer m_see_close_mobs_timer; + Timer m_mob_check_moving_timer; // Bot attack flag Timer bot_attack_flag_timer; diff --git a/zone/mob_movement_manager.cpp b/zone/mob_movement_manager.cpp index 7f21ff07c..b2e5e8a82 100644 --- a/zone/mob_movement_manager.cpp +++ b/zone/mob_movement_manager.cpp @@ -852,6 +852,7 @@ void MobMovementManager::SendCommandToClients( } c->QueuePacket(&outapp, false); + c->m_last_seen_mob_position[mob->GetID()] = mob->GetPosition(); } } else { @@ -902,6 +903,7 @@ void MobMovementManager::SendCommandToClients( } c->QueuePacket(&outapp, false); + c->m_last_seen_mob_position[mob->GetID()] = mob->GetPosition(); } } }