diff --git a/src/creatures/npcs/npc.cpp b/src/creatures/npcs/npc.cpp index e3fed54ce1b..928d56ec04e 100644 --- a/src/creatures/npcs/npc.cpp +++ b/src/creatures/npcs/npc.cpp @@ -222,18 +222,18 @@ void Npc::onThink(uint32_t interval) void Npc::onPlayerBuyItem(Player* player, uint16_t itemId, uint8_t subType, uint8_t amount, bool ignore, bool inBackpacks) { - if (!player) { + if (player == nullptr) { + SPDLOG_ERROR("[Npc::onPlayerBuyItem] - Player is nullptr"); return; } - // Check if the player not have empty slots - if (player->getFreeBackpackSlots() == 0) { + const ItemType& itemType = Item::items[itemId]; + if (!itemType.stackable && player->getFreeBackpackSlots() < amount || player->getFreeBackpackSlots() == 0) { player->sendCancelMessage(RETURNVALUE_NOTENOUGHROOM); return; } uint32_t buyPrice = 0; - const ItemType& itemType = Item::items[itemId]; const std::vector &shopVector = getShopItemVector(); for (ShopBlock shopBlock : shopVector) {