Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

MuteCountMap Player::muteCountMap;

Player::Player(std::shared_ptr<ProtocolGame> p) :

Check warning on line 65 in src/creatures/players/player.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-24.04-linux-debug

when initialized here [-Wreorder]

Check warning on line 65 in src/creatures/players/player.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-debug

when initialized here [-Wreorder]
lastPing(OTSYS_TIME()),
lastPong(lastPing),
inbox(std::make_shared<Inbox>(ITEM_INBOX)),
Expand Down Expand Up @@ -4604,16 +4604,21 @@
while (i < containers.size()) {
std::shared_ptr<Container> tmpContainer = containers[i++];
if (!autoStack || !isStackable) {
// we need to find first empty container as fast as we can for non-stackable items
uint32_t n = tmpContainer->capacity() - tmpContainer->size();
while (n) {
if (tmpContainer->queryAdd(tmpContainer->capacity() - n, item, item->getItemCount(), flags) == RETURNVALUE_NOERROR) {
index = tmpContainer->capacity() - n;
const uint32_t containerCapacity = tmpContainer->capacity();
const uint32_t containerSize = tmpContainer->size();

// Avoid underflow in the loop below
if (containerSize >= containerCapacity) {
continue;
}

for (uint32_t pos = 0; pos < containerCapacity; ++pos) {
auto rv = tmpContainer->queryAdd(pos, item, item->getItemCount(), flags);
if (rv == RETURNVALUE_NOERROR) {
index = pos;
destItem = nullptr;
return tmpContainer;
}

n--;
}

for (const auto &tmpContainerItem : tmpContainer->getItemList()) {
Expand Down Expand Up @@ -8884,7 +8889,7 @@
}

void Player::stowItem(const std::shared_ptr<Item> &item, uint32_t count, bool allItems) {
if (!item || !item->isItemStorable() && item->getID() != ITEM_GOLD_POUCH) {

Check warning on line 8892 in src/creatures/players/player.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-24.04-linux-debug

suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]

Check warning on line 8892 in src/creatures/players/player.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-debug

suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
sendCancelMessage("This item cannot be stowed here.");
return;
}
Expand Down
Loading