From 95a79ec8151909c90de4d28b3ccf7fbe2c177c4b Mon Sep 17 00:00:00 2001 From: dongresource Date: Tue, 22 Sep 2020 21:31:08 +0200 Subject: [PATCH] Switched MobManager::step() to the timer. It doesn't really need to run on every shard step. This makes it a lot less hot. --- src/CNShardServer.cpp | 2 -- src/MobManager.cpp | 4 +++- src/MobManager.hpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CNShardServer.cpp b/src/CNShardServer.cpp index e6bc59a..8f99d12 100644 --- a/src/CNShardServer.cpp +++ b/src/CNShardServer.cpp @@ -87,6 +87,4 @@ void CNShardServer::onStep() { event.scheduledEvent = currTime + event.delta; } } - - MobManager::step(currTime); } diff --git a/src/MobManager.cpp b/src/MobManager.cpp index f4d3242..2305a7c 100644 --- a/src/MobManager.cpp +++ b/src/MobManager.cpp @@ -9,6 +9,8 @@ std::map MobManager::Mobs; void MobManager::init() { + REGISTER_SHARD_TIMER(step, 200); + REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_ATTACK_NPCs, pcAttackNpcs); REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_COMBAT_BEGIN, combatBegin); @@ -207,7 +209,7 @@ void MobManager::roamingStep(Mob *mob, time_t currTime) { } } -void MobManager::step(time_t currTime) { +void MobManager::step(CNServer *serv, time_t currTime) { for (auto& pair : Mobs) { int x = pair.second->appearanceData.iX; int y = pair.second->appearanceData.iY; diff --git a/src/MobManager.hpp b/src/MobManager.hpp index c295847..cd770b0 100644 --- a/src/MobManager.hpp +++ b/src/MobManager.hpp @@ -56,7 +56,7 @@ namespace MobManager { extern std::map Mobs; void init(); - void step(time_t); + void step(CNServer*, time_t); void deadStep(Mob*, time_t); void roamingStep(Mob*, time_t);