From b784d406203751f173a2027ab36a327afee567f2 Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Mon, 30 Jun 2025 13:36:00 -0500 Subject: [PATCH] [Performance] Clear Wearchange Deduplication Cache --- zone/mob.cpp | 1 + zone/mob.h | 1 + zone/mob_appearance.cpp | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/zone/mob.cpp b/zone/mob.cpp index 97c2d17e5..16774bfbc 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -133,6 +133,7 @@ Mob::Mob( m_see_close_mobs_timer(1000), m_mob_check_moving_timer(1000), bot_attack_flag_timer(10000), + m_clear_wearchange_cache_timer(60 * 10 * 1000), // 10 minutes m_destroying(false) { mMovementManager = &MobMovementManager::Get(); diff --git a/zone/mob.h b/zone/mob.h index 18541857e..193d8aae2 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -211,6 +211,7 @@ public: uint16 m_last_wearchange_race_id = 0; // client_id -> slot_id -> key std::unordered_map> m_last_seen_wearchange; + Timer m_clear_wearchange_cache_timer; // Bot attack flag Timer bot_attack_flag_timer; diff --git a/zone/mob_appearance.cpp b/zone/mob_appearance.cpp index 430247443..7a21a9be3 100644 --- a/zone/mob_appearance.cpp +++ b/zone/mob_appearance.cpp @@ -395,6 +395,10 @@ void Mob::SendWearChange(uint8 material_slot, Client *one_client) w->wear_slot_id = material_slot; + if (m_clear_wearchange_cache_timer.Check()) { + m_last_seen_wearchange.clear(); + } + if (GetRace() != m_last_wearchange_race_id) { m_last_seen_wearchange.clear(); m_last_wearchange_race_id = GetRace();