Skip to content

Commit

Permalink
Merge branch 'main' into fix-daily-reward
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel authored Mar 28, 2024
2 parents aca6d6d + 8dec6f9 commit 26a33bf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
12 changes: 11 additions & 1 deletion src/creatures/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,17 @@ bool Creature::dropCorpse(std::shared_ptr<Creature> lastHitCreature, std::shared
player->sendLootMessage(lootMessage.str());
}

if (player->checkAutoLoot(monster->isRewardBoss()) && corpseContainer && mostDamageCreature->getPlayer()) {
stdext::arraylist<Direction> dirList(128);
FindPathParams fpp;
fpp.minTargetDist = 0;
fpp.maxTargetDist = 1;
fpp.fullPathSearch = true;
fpp.clearSight = true;
fpp.maxSearchDist = 0;

auto isReachable = g_game().map.getPathMatching(player->getPosition(), dirList, FrozenPathingConditionCall(corpse->getPosition()), fpp);

if (player->checkAutoLoot(monster->isRewardBoss()) && corpseContainer && mostDamageCreature->getPlayer() && isReachable) {
g_dispatcher().addEvent([player, corpseContainer, corpsePosition = corpse->getPosition()] {
g_game().playerQuickLootCorpse(player, corpseContainer, corpsePosition);
},
Expand Down
8 changes: 4 additions & 4 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6452,7 +6452,7 @@ void Player::stowItem(std::shared_ptr<Item> item, uint32_t count, bool allItems)
// Stow locker items
std::shared_ptr<DepotLocker> depotLocker = getDepotLocker(getLastDepotId());
auto [itemVector, itemMap] = requestLockerItems(depotLocker);
for (auto lockerItem : itemVector) {
for (const auto &lockerItem : itemVector) {
if (lockerItem == nullptr) {
break;
}
Expand All @@ -6463,7 +6463,7 @@ void Player::stowItem(std::shared_ptr<Item> item, uint32_t count, bool allItems)
}
} else if (item->getContainer()) {
itemDict = item->getContainer()->getStowableItems();
for (std::shared_ptr<Item> containerItem : item->getContainer()->getItems(true)) {
for (const std::shared_ptr<Item> &containerItem : item->getContainer()->getItems(true)) {
uint32_t depotChest = g_configManager().getNumber(DEPOTCHEST, __FUNCTION__);
bool validDepot = depotChest > 0 && depotChest < 21;
if (g_configManager().getBoolean(STASH_MOVING, __FUNCTION__) && containerItem && !containerItem->isStackable() && validDepot) {
Expand All @@ -6473,10 +6473,10 @@ void Player::stowItem(std::shared_ptr<Item> item, uint32_t count, bool allItems)
}
}
} else {
itemDict.push_back(std::pair<std::shared_ptr<Item>, uint32_t>(item, count));
itemDict.emplace_back(item, count);
}

if (itemDict.size() == 0) {
if (itemDict.empty()) {
sendCancelMessage("There is no stowable items on this container.");
return;
}
Expand Down
14 changes: 7 additions & 7 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1518,11 +1518,6 @@ void Game::playerMoveItem(std::shared_ptr<Player> player, const Position &fromPo
return;
}

if (!item->isPushable() || item->hasAttribute(ItemAttribute_t::UNIQUEID)) {
player->sendCancelMessage(RETURNVALUE_NOTMOVABLE);
return;
}

const Position &playerPos = player->getPosition();
auto cylinderTile = fromCylinder->getTile();
const Position &mapFromPos = cylinderTile ? cylinderTile->getPosition() : item->getPosition();
Expand Down Expand Up @@ -1649,12 +1644,17 @@ void Game::playerMoveItem(std::shared_ptr<Player> player, const Position &fromPo
return;
}
}

if (isTryingToStow(toPos, toCylinder)) {
player->stowItem(item, count, false);
return;
}


if (!item->isPushable() || item->hasAttribute(ItemAttribute_t::UNIQUEID)) {
player->sendCancelMessage(RETURNVALUE_NOTMOVABLE);
return;
}

ReturnValue ret = internalMoveItem(fromCylinder, toCylinder, toIndex, item, count, nullptr, 0, player);
if (ret != RETURNVALUE_NOERROR) {
player->sendCancelMessage(ret);
Expand Down

0 comments on commit 26a33bf

Please sign in to comment.