From 2a69ae42ee36853bfa13f9685cdd72ab699234c3 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sun, 1 Nov 2015 17:02:52 -0600 Subject: [PATCH] (Performance) Rate limit the rate in which signals are processed for NPC's --- common/features.h | 1 + zone/mob.h | 1 + zone/mob_ai.cpp | 7 ++++++- zone/net.cpp | 8 ++++---- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/common/features.h b/common/features.h index 44f83c648..2ede4b4be 100644 --- a/common/features.h +++ b/common/features.h @@ -159,6 +159,7 @@ enum { //timer settings, all in milliseconds AItarget_check_duration = 500, AIClientScanarea_delay = 750, //used in REVERSE_AGGRO AIassistcheck_delay = 3000, //now often a fighting NPC will yell for help + AI_check_signal_timer_delay = 500, // How often EVENT_SIGNAL checks are processed ClientProximity_interval = 150, CombatEventTimer_expire = 12000, Tribute_duration = 600000, diff --git a/zone/mob.h b/zone/mob.h index 7fff5a1c4..a45dd464d 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -1262,6 +1262,7 @@ protected: std::unique_ptr AIscanarea_timer; std::unique_ptr AIwalking_timer; std::unique_ptr AIfeignremember_timer; + std::unique_ptr AI_check_signal_timer; uint32 pLastFightingDelayMoving; HateList hate_list; std::set feign_memory_list; diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 4ac408055..fca550499 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -429,6 +429,8 @@ void Mob::AI_Init() AItarget_check_timer.reset(nullptr); AIfeignremember_timer.reset(nullptr); AIscanarea_timer.reset(nullptr); + AI_check_signal_timer.reset(nullptr); + minLastFightingDelayMoving = RuleI(NPC, LastFightingDelayMovingMin); maxLastFightingDelayMoving = RuleI(NPC, LastFightingDelayMovingMax); @@ -479,6 +481,8 @@ void Mob::AI_Start(uint32 iMoveDelay) { AItarget_check_timer = std::unique_ptr(new Timer(AItarget_check_duration)); AIfeignremember_timer = std::unique_ptr(new Timer(AIfeignremember_delay)); AIscanarea_timer = std::unique_ptr(new Timer(AIscanarea_delay)); + AI_check_signal_timer = std::unique_ptr(new Timer(AI_check_signal_timer_delay)); + #ifdef REVERSE_AGGRO if(IsNPC() && !CastToNPC()->WillAggroNPCs()) AIscanarea_timer->Disable(); @@ -544,6 +548,7 @@ void Mob::AI_Stop() { AItarget_check_timer.reset(nullptr); AIscanarea_timer.reset(nullptr); AIfeignremember_timer.reset(nullptr); + AI_check_signal_timer.reset(nullptr); hate_list.WipeHateList(); } @@ -998,7 +1003,7 @@ void Mob::AI_Process() { } // trigger EVENT_SIGNAL if required - if(IsNPC()) { + if (AI_check_signal_timer->Check() && IsNPC()) { CastToNPC()->CheckSignal(); } diff --git a/zone/net.cpp b/zone/net.cpp index d950fc15a..0d5d546d6 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -393,10 +393,10 @@ int main(int argc, char** argv) { worldserver.Process(); - if (!eqsf.IsOpen() && Config->ZonePort!=0) { - Log.Out(Logs::General, Logs::Zone_Server, "Starting EQ Network server on port %d",Config->ZonePort); + if (!eqsf.IsOpen() && Config->ZonePort != 0) { + Log.Out(Logs::General, Logs::Zone_Server, "Starting EQ Network server on port %d", Config->ZonePort); if (!eqsf.Open(Config->ZonePort)) { - Log.Out(Logs::General, Logs::Error, "Failed to open port %d",Config->ZonePort); + Log.Out(Logs::General, Logs::Error, "Failed to open port %d", Config->ZonePort); ZoneConfig::SetZonePort(0); worldserver.Disconnect(); worldwasconnected = false; @@ -410,7 +410,7 @@ int main(int argc, char** argv) { //structures and opcodes for that patch. struct in_addr in; in.s_addr = eqss->GetRemoteIP(); - Log.Out(Logs::Detail, Logs::World_Server, "New connection from %s:%d", inet_ntoa(in),ntohs(eqss->GetRemotePort())); + Log.Out(Logs::Detail, Logs::World_Server, "New connection from %s:%d", inet_ntoa(in), ntohs(eqss->GetRemotePort())); stream_identifier.AddStream(eqss); //takes the stream }