Skip to content

Commit

Permalink
perf: fixes exhaustion to 'playerEquipItem' (#3165)
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas authored Jan 5, 2025
1 parent cc3a246 commit 0e188a9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3383,6 +3383,21 @@ void Game::playerEquipItem(uint32_t playerId, uint16_t itemId, bool hasTier /* =
return;
}

if (!player->canDoAction()) {
uint32_t delay = player->getNextActionTime() - OTSYS_TIME();
if (delay > 0) {
const auto &task = createPlayerTask(
delay,
[this, playerId, itemId, hasTier, tier] {
playerEquipItem(playerId, itemId, hasTier, tier);
},
__FUNCTION__
);
player->setNextActionTask(task);
}
return;
}

if (player->hasCondition(CONDITION_FEARED)) {
/*
* When player is feared the player can´t equip any items.
Expand Down Expand Up @@ -3480,6 +3495,8 @@ void Game::playerEquipItem(uint32_t playerId, uint16_t itemId, bool hasTier /* =
if (ret != RETURNVALUE_NOERROR) {
player->sendCancelMessage(ret);
}

player->setNextAction(OTSYS_TIME() + g_configManager().getNumber(ACTIONS_DELAY_INTERVAL));
}

void Game::playerMove(uint32_t playerId, Direction direction) {
Expand Down

0 comments on commit 0e188a9

Please sign in to comment.