Skip to content

Commit

Permalink
fix formating
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturKnopik committed Dec 24, 2024
1 parent abdf6c5 commit 32d01a9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3407,7 +3407,7 @@ void Player::doAttacking(uint32_t)
}

SchedulerTask_ptr task = createSchedulerTask(std::max<uint32_t>(SCHEDULER_MINTICKS, delay),
[id = getID()]() { g_game.checkCreatureAttack(id); });
[id = getID()]() { g_game.checkCreatureAttack(id); });
if (!classicSpeed) {
setNextActionTask(std::move(task), false);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 13 additions & 9 deletions src/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)));
}
2 changes: 1 addition & 1 deletion src/tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Dispatcher : public ThreadHolder<Dispatcher>
public:
void addTask(Task_ptr task);

void addTask(TaskFunc&& f) { addTask( std::make_unique<Task>(std::move(f))); }
void addTask(TaskFunc&& f) { addTask(std::make_unique<Task>(std::move(f))); }

void addTask(uint32_t expiration, TaskFunc&& f) { addTask(make_unique<Task>(expiration, std::move(f))); }

Expand Down

0 comments on commit 32d01a9

Please sign in to comment.