Skip to content

Commit 1efc6dd

Browse files
committed
fix: expiration update
1 parent 110fc87 commit 1efc6dd

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/creatures/players/player.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12113,10 +12113,10 @@ void Player::addScheduledUpdates(uint32_t flags) {
1211312113
scheduledUpdates |= flags;
1211412114

1211512115
if (shouldSchedule) {
12116-
g_dispatcher().addEvent(
12116+
g_dispatcher().scheduleEvent(
12117+
SCHEDULER_MINTICKS,
1211712118
[playerId = getID()]() { g_game().updatePlayerEvent(playerId); },
12118-
__FUNCTION__,
12119-
PLAYER_UPDATE_TICKS
12119+
__FUNCTION__
1212012120
);
1212112121

1212212122
scheduledUpdate = true;

src/game/scheduling/dispatcher.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
static constexpr uint16_t DISPATCHER_TASK_EXPIRATION = 2000;
2424
static constexpr uint16_t SCHEDULER_MINTICKS = 50;
2525
static constexpr uint16_t NPC_SELL_TICKS = 150;
26-
static constexpr uint16_t PLAYER_UPDATE_TICKS = 1000;
2726

2827
enum class TaskGroup : int8_t {
2928
ThreadPool = -1,

src/game/scheduling/task.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
std::atomic_uint_fast64_t Task::LAST_EVENT_ID = 0;
2525

2626
Task::Task(uint32_t expiresAfterMs, std::function<void(void)> &&f, std::string_view context) :
27-
func(std::move(f)), context(context), utime(OTSYS_TIME()),
28-
expiration(expiresAfterMs > 0 ? OTSYS_TIME() + expiresAfterMs : 0) {
27+
func(std::move(f)), context(context),
28+
utime(OTSYS_TIME(true)),
29+
expiration(expiresAfterMs > 0 ? OTSYS_TIME(true) + expiresAfterMs : 0) {
2930
if (this->context.empty()) {
3031
g_logger().error("[{}]: task context cannot be empty!", __FUNCTION__);
3132
return;
@@ -46,7 +47,7 @@ Task::Task(std::function<void(void)> &&f, std::string_view context, uint32_t del
4647
}
4748

4849
[[nodiscard]] bool Task::hasExpired() const {
49-
return expiration != 0 && expiration < OTSYS_TIME();
50+
return expiration != 0 && expiration < OTSYS_TIME(true);
5051
}
5152

5253
bool Task::execute() const {

0 commit comments

Comments
 (0)