Skip to content

Commit

Permalink
fix: exhaustion to playerEquipItem
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Dec 2, 2024
1 parent 34b6fa8 commit b9c7af4
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 @@ -3380,6 +3380,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 @@ -3477,6 +3492,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 b9c7af4

Please sign in to comment.