(Performance) Rate limit the rate in which signals are processed for NPC's

This commit is contained in:
Akkadius 2015-11-01 17:02:52 -06:00
parent e5ad5e13db
commit 2a69ae42ee
4 changed files with 12 additions and 5 deletions

View File

@ -159,6 +159,7 @@ enum { //timer settings, all in milliseconds
AItarget_check_duration = 500, AItarget_check_duration = 500,
AIClientScanarea_delay = 750, //used in REVERSE_AGGRO AIClientScanarea_delay = 750, //used in REVERSE_AGGRO
AIassistcheck_delay = 3000, //now often a fighting NPC will yell for help 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, ClientProximity_interval = 150,
CombatEventTimer_expire = 12000, CombatEventTimer_expire = 12000,
Tribute_duration = 600000, Tribute_duration = 600000,

View File

@ -1262,6 +1262,7 @@ protected:
std::unique_ptr<Timer> AIscanarea_timer; std::unique_ptr<Timer> AIscanarea_timer;
std::unique_ptr<Timer> AIwalking_timer; std::unique_ptr<Timer> AIwalking_timer;
std::unique_ptr<Timer> AIfeignremember_timer; std::unique_ptr<Timer> AIfeignremember_timer;
std::unique_ptr<Timer> AI_check_signal_timer;
uint32 pLastFightingDelayMoving; uint32 pLastFightingDelayMoving;
HateList hate_list; HateList hate_list;
std::set<uint32> feign_memory_list; std::set<uint32> feign_memory_list;

View File

@ -429,6 +429,8 @@ void Mob::AI_Init()
AItarget_check_timer.reset(nullptr); AItarget_check_timer.reset(nullptr);
AIfeignremember_timer.reset(nullptr); AIfeignremember_timer.reset(nullptr);
AIscanarea_timer.reset(nullptr); AIscanarea_timer.reset(nullptr);
AI_check_signal_timer.reset(nullptr);
minLastFightingDelayMoving = RuleI(NPC, LastFightingDelayMovingMin); minLastFightingDelayMoving = RuleI(NPC, LastFightingDelayMovingMin);
maxLastFightingDelayMoving = RuleI(NPC, LastFightingDelayMovingMax); maxLastFightingDelayMoving = RuleI(NPC, LastFightingDelayMovingMax);
@ -479,6 +481,8 @@ void Mob::AI_Start(uint32 iMoveDelay) {
AItarget_check_timer = std::unique_ptr<Timer>(new Timer(AItarget_check_duration)); AItarget_check_timer = std::unique_ptr<Timer>(new Timer(AItarget_check_duration));
AIfeignremember_timer = std::unique_ptr<Timer>(new Timer(AIfeignremember_delay)); AIfeignremember_timer = std::unique_ptr<Timer>(new Timer(AIfeignremember_delay));
AIscanarea_timer = std::unique_ptr<Timer>(new Timer(AIscanarea_delay)); AIscanarea_timer = std::unique_ptr<Timer>(new Timer(AIscanarea_delay));
AI_check_signal_timer = std::unique_ptr<Timer>(new Timer(AI_check_signal_timer_delay));
#ifdef REVERSE_AGGRO #ifdef REVERSE_AGGRO
if(IsNPC() && !CastToNPC()->WillAggroNPCs()) if(IsNPC() && !CastToNPC()->WillAggroNPCs())
AIscanarea_timer->Disable(); AIscanarea_timer->Disable();
@ -544,6 +548,7 @@ void Mob::AI_Stop() {
AItarget_check_timer.reset(nullptr); AItarget_check_timer.reset(nullptr);
AIscanarea_timer.reset(nullptr); AIscanarea_timer.reset(nullptr);
AIfeignremember_timer.reset(nullptr); AIfeignremember_timer.reset(nullptr);
AI_check_signal_timer.reset(nullptr);
hate_list.WipeHateList(); hate_list.WipeHateList();
} }
@ -998,7 +1003,7 @@ void Mob::AI_Process() {
} }
// trigger EVENT_SIGNAL if required // trigger EVENT_SIGNAL if required
if(IsNPC()) { if (AI_check_signal_timer->Check() && IsNPC()) {
CastToNPC()->CheckSignal(); CastToNPC()->CheckSignal();
} }