This commit is contained in:
Akkadius 2024-11-19 01:28:20 -06:00
parent 8f54abec61
commit 34b3a3fc88
8 changed files with 32 additions and 24 deletions

View File

@ -679,7 +679,7 @@ int ZoneStore::GetZoneNPCMaximumAggroDistance(uint32 zone_id, int version)
uint32 ZoneStore::GetZoneMaximumMovementUpdateRange(uint32 zone_id, int version) uint32 ZoneStore::GetZoneMaximumMovementUpdateRange(uint32 zone_id, int version)
{ {
const auto& z = GetZoneVersionWithFallback(zone_id, version); const auto& z = GetZoneVersionWithFallback(zone_id, version);
return z ? z->max_movement_update_range : DEFAULT_ZONE_MAX_MOVEMENT_UPDATE_RANGE; return z ? z->npc_update_range : DEFAULT_ZONE_MAX_MOVEMENT_UPDATE_RANGE;
} }
int8 ZoneStore::GetZoneMinimumExpansion(uint32 zone_id, int version) int8 ZoneStore::GetZoneMinimumExpansion(uint32 zone_id, int version)

View File

@ -1122,7 +1122,7 @@ void EntityList::AESpell(
LogAoeCast( LogAoeCast(
"Close scan distance [{}] cast distance [{}]", "Close scan distance [{}] cast distance [{}]",
zone->GetMaxUpdateRange(), zone->GetMaxNpcUpdateRange(),
distance distance
); );

View File

@ -1733,7 +1733,7 @@ void EntityList::QueueCloseClients(
} }
if (distance <= 0) { if (distance <= 0) {
distance = zone->GetMaxUpdateRange(); distance = zone->GetMaxClientUpdateRange();
} }
float distance_squared = distance * distance; float distance_squared = distance * distance;
@ -2940,7 +2940,7 @@ void EntityList::ScanCloseMobs(Mob *scanning_mob)
g_scan_bench_timer.reset(); g_scan_bench_timer.reset();
float scan_range = zone->GetMaxUpdateRange(); float scan_range = std::max(zone->GetMaxNpcUpdateRange(), zone->GetMaxClientUpdateRange());
// Reserve memory in m_close_mobs to avoid frequent re-allocations if not already reserved. // Reserve memory in m_close_mobs to avoid frequent re-allocations if not already reserved.
// Assuming mob_list.size() as an upper bound for reservation. // Assuming mob_list.size() as an upper bound for reservation.
@ -3002,7 +3002,7 @@ void EntityList::UpdateVisibility(Mob *scanning_mob) {
int8_t scanning_visibility = (it_scanning_visible != scanning_mob->m_can_see_mob.end()) int8_t scanning_visibility = (it_scanning_visible != scanning_mob->m_can_see_mob.end())
? it_scanning_visible->second : 0; ? it_scanning_visible->second : 0;
if (scanning_mob->CalculateDistance(mob) <= zone->GetMaxUpdateRange()) { if (scanning_mob->CalculateDistance(mob) <= mob->GetUpdateRange()) {
if (scanning_visibility != STATE_VISIBLE) { // Become visible if (scanning_visibility != STATE_VISIBLE) { // Become visible
if (scanning_mob->IsClient()) { if (scanning_mob->IsClient()) {
scanning_mob->CastToClient()->SetVisibility(mob, true); scanning_mob->CastToClient()->SetVisibility(mob, true);
@ -5815,7 +5815,7 @@ void EntityList::ReloadMerchants() {
*/ */
std::unordered_map<uint16, Mob *> &EntityList::GetCloseMobList(Mob *mob, float distance) std::unordered_map<uint16, Mob *> &EntityList::GetCloseMobList(Mob *mob, float distance)
{ {
if (distance <= zone->GetMaxUpdateRange()) { if (distance <= zone->GetMaxNpcUpdateRange()) {
return mob->m_close_mobs; return mob->m_close_mobs;
} }

View File

@ -8631,3 +8631,7 @@ void Mob::ClearDataBucketCache()
DataBucket::DeleteFromCache(id, t); DataBucket::DeleteFromCache(id, t);
} }
} }
float Mob::GetUpdateRange() {
return IsClient() ? zone->GetMaxClientUpdateRange() : zone->GetMaxNpcUpdateRange();
}

View File

@ -1493,6 +1493,7 @@ public:
std::unordered_map<uint16, Mob *> &GetCloseMobList(float distance = 0.0f); std::unordered_map<uint16, Mob *> &GetCloseMobList(float distance = 0.0f);
void CheckScanCloseMobsMovingTimer(); void CheckScanCloseMobsMovingTimer();
float GetUpdateRange();
void ClearDataBucketCache(); void ClearDataBucketCache();

View File

@ -859,7 +859,7 @@ void MobMovementManager::SendCommandToClients(
} }
else { else {
float short_range = RuleR(Pathing, ShortMovementUpdateRange); float short_range = RuleR(Pathing, ShortMovementUpdateRange);
float long_range = zone->GetMaxUpdateRange(); float long_range = zone->GetMaxNpcUpdateRange();
for (auto &c : _impl->Clients) { for (auto &c : _impl->Clients) {
if (single_client && c != single_client) { if (single_client && c != single_client) {

View File

@ -1379,7 +1379,8 @@ bool Zone::LoadZoneCFG(const char* filename, uint16 instance_version)
can_levitate = z->canlevitate != 0; can_levitate = z->canlevitate != 0;
can_castoutdoor = z->castoutdoor != 0; can_castoutdoor = z->castoutdoor != 0;
is_hotzone = z->hotzone != 0; is_hotzone = z->hotzone != 0;
max_movement_update_range = z->max_movement_update_range; m_npc_update_range = z->npc_update_range;
m_client_update_range = z->client_update_range;
default_ruleset = z->ruleset; default_ruleset = z->ruleset;
allow_mercs = true; allow_mercs = true;
m_graveyard_id = z->graveyard_id; m_graveyard_id = z->graveyard_id;

View File

@ -414,7 +414,8 @@ public:
SendDiscordMessage(webhook_id, message_prefix + Discord::FormatDiscordMessage(log_category, message)); SendDiscordMessage(webhook_id, message_prefix + Discord::FormatDiscordMessage(log_category, message));
}; };
double GetMaxUpdateRange() const { return max_movement_update_range; } double GetMaxNpcUpdateRange() const { return m_npc_update_range; }
double GetMaxClientUpdateRange() const { return m_client_update_range; }
void SetIsHotzone(bool is_hotzone); void SetIsHotzone(bool is_hotzone);
@ -466,7 +467,8 @@ private:
bool staticzone; bool staticzone;
bool zone_has_current_time; bool zone_has_current_time;
bool quest_hot_reload_queued; bool quest_hot_reload_queued;
double max_movement_update_range; double m_npc_update_range;
double m_client_update_range;
char *long_name; char *long_name;
char *map_name; char *map_name;
char *short_name; char *short_name;