diff --git a/src/player.cpp b/src/player.cpp index d284204a0a..1a61059e9f 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -3407,7 +3407,7 @@ void Player::doAttacking(uint32_t) } SchedulerTask_ptr task = createSchedulerTask(std::max(SCHEDULER_MINTICKS, delay), - [id = getID()]() { g_game.checkCreatureAttack(id); }); + [id = getID()]() { g_game.checkCreatureAttack(id); }); if (!classicSpeed) { setNextActionTask(std::move(task), false); } else { diff --git a/src/player.h b/src/player.h index 4ef9172b0e..c1b97d27c4 100644 --- a/src/player.h +++ b/src/player.h @@ -13,9 +13,9 @@ #include "guild.h" #include "inbox.h" #include "protocolgame.h" +#include "scheduler.h" #include "town.h" #include "vocation.h" -#include "scheduler.h" class House; struct Mount; diff --git a/src/scheduler.cpp b/src/scheduler.cpp index bb2eb7d89b..ad9e7b898d 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -19,16 +19,17 @@ uint32_t Scheduler::addEvent(SchedulerTask_ptr task) auto& timer = it.first->second; timer.expires_after(std::chrono::milliseconds(scheduledTask->getDelay())); - timer.async_wait([this, scheduledTask = std::move(scheduledTask)](const boost::system::error_code& error) mutable { - eventIdTimerMap.erase(scheduledTask->getEventId()); + timer.async_wait( + [this, scheduledTask = std::move(scheduledTask)](const boost::system::error_code& error) mutable { + eventIdTimerMap.erase(scheduledTask->getEventId()); - if (error == boost::asio::error::operation_aborted || getState() == THREAD_STATE_TERMINATED) { - // The timer was manually canceled or Scheduler::shutdown was called - return; - } + if (error == boost::asio::error::operation_aborted || getState() == THREAD_STATE_TERMINATED) { + // The timer was manually canceled or Scheduler::shutdown was called + return; + } - g_dispatcher.addTask(std::move(scheduledTask)); - }); + g_dispatcher.addTask(std::move(scheduledTask)); + }); }); return eventId; @@ -62,4 +63,7 @@ void Scheduler::shutdown() }); } -SchedulerTask_ptr createSchedulerTask(uint32_t delay, TaskFunc&& f) { return SchedulerTask_ptr(new SchedulerTask(delay, std::move(f))); } +SchedulerTask_ptr createSchedulerTask(uint32_t delay, TaskFunc&& f) +{ + return SchedulerTask_ptr(new SchedulerTask(delay, std::move(f))); +} diff --git a/src/tasks.cpp b/src/tasks.cpp index e72f231712..e73b2b19d9 100644 --- a/src/tasks.cpp +++ b/src/tasks.cpp @@ -30,7 +30,7 @@ void Dispatcher::threadMain() tmpTaskList.swap(taskList); taskLockUnique.unlock(); - for (auto &task : tmpTaskList) { + for (auto& task : tmpTaskList) { if (!task->hasExpired()) { ++dispatcherCycle; // execute it diff --git a/src/tasks.h b/src/tasks.h index 56f27f5273..87292d68a2 100644 --- a/src/tasks.h +++ b/src/tasks.h @@ -53,7 +53,7 @@ class Dispatcher : public ThreadHolder public: void addTask(Task_ptr task); - void addTask(TaskFunc&& f) { addTask( std::make_unique(std::move(f))); } + void addTask(TaskFunc&& f) { addTask(std::make_unique(std::move(f))); } void addTask(uint32_t expiration, TaskFunc&& f) { addTask(make_unique(expiration, std::move(f))); }