Skip to content

Commit 86a3c29

Browse files
authored
fix: prevent task flood caused by double OTSYS_TIME() subtraction in action delay (#3591)
Fixes a bug where `Game::playerEquipItem` incorrectly subtracted `OTSYS_TIME()` from a delay that had already been normalized inside `Player::getNextActionTime()`. This caused negative or extremely large delay values (up to ~28 days), which led to the Dispatcher scheduling massive amounts of future tasks that would never execute. Over time, this behavior caused exponential growth in the `Dispatcher::scheduledTasks` queue, consuming memory and degrading server performance.
1 parent 1173f95 commit 86a3c29

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/game/game.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3422,7 +3422,7 @@ void Game::playerEquipItem(uint32_t playerId, uint16_t itemId, bool hasTier /* =
34223422
return;
34233423
}
34243424
} else if (!player->canDoAction()) {
3425-
uint32_t delay = player->getNextActionTime() - OTSYS_TIME();
3425+
uint32_t delay = player->getNextActionTime();
34263426
if (delay > 0) {
34273427
const auto &task = createPlayerTask(
34283428
delay,

0 commit comments

Comments
 (0)