[Performance] Clear Wearchange Deduplication Cache

This commit is contained in:
Chris Miles 2025-06-30 13:36:00 -05:00
parent 07d484597d
commit b784d40620
3 changed files with 6 additions and 0 deletions

View File

@ -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();

View File

@ -211,6 +211,7 @@ public:
uint16 m_last_wearchange_race_id = 0;
// client_id -> slot_id -> key
std::unordered_map<uint32_t, std::unordered_map<uint8_t, uint64_t>> m_last_seen_wearchange;
Timer m_clear_wearchange_cache_timer;
// Bot attack flag
Timer bot_attack_flag_timer;

View File

@ -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();