diff --git a/data-otservbr-global/startup/others/functions.lua b/data-otservbr-global/startup/others/functions.lua index 8624dc8b268..362e2a38b97 100644 --- a/data-otservbr-global/startup/others/functions.lua +++ b/data-otservbr-global/startup/others/functions.lua @@ -28,7 +28,7 @@ function loadLuaMapAction(tablename) if not value.itemId == false and tile:getItemCountById(value.itemId) == 0 then logger.error("[loadLuaMapAction] - Wrong item id {} found", value.itemId) logger.warn("Action id: {}, position {}", index, tile:getPosition():toString()) - break + goto continue end if value.itemId ~= false and tile:getItemCountById(value.itemId) > 0 then @@ -49,6 +49,7 @@ function loadLuaMapAction(tablename) tile:getGround():setAttribute(ITEM_ATTRIBUTE_ACTIONID, index) end end + ::continue:: end end end @@ -64,12 +65,12 @@ function loadLuaMapUnique(tablename) if not value.itemId == false and tile:getItemCountById(value.itemId) == 0 then logger.error("[loadLuaMapUnique] - Wrong item id {} found", value.itemId) logger.warn("Unique id: {}, position {}", index, tile:getPosition():toString()) - break + goto continue end if tile:getItemCountById(value.itemId) < 1 or value.itemId == false then logger.warn("[loadLuaMapUnique] - Wrong item id {} found", value.itemId) logger.warn("Unique id: {}, position {}, item id: wrong", index, tile:getPosition():toString()) - break + goto continue end item = tile:getItemById(value.itemId) -- If he found the item, add the unique id @@ -77,6 +78,8 @@ function loadLuaMapUnique(tablename) item:setAttribute(ITEM_ATTRIBUTE_UNIQUEID, index) end end + + ::continue:: end end @@ -91,7 +94,7 @@ function loadLuaMapSign(tablename) if tile:getItemCountById(value.itemId) == 0 then logger.error("[loadLuaMapSign] - Wrong item id {} found", value.itemId) logger.warn("Sign id: {}, position {}, item id: wrong", index, tile:getPosition():toString()) - break + goto continue end if tile:getItemCountById(value.itemId) == 1 then item = tile:getItemById(value.itemId) @@ -101,6 +104,7 @@ function loadLuaMapSign(tablename) item:setAttribute(ITEM_ATTRIBUTE_TEXT, value.text) end end + ::continue:: end end @@ -137,17 +141,18 @@ function loadLuaMapBookDocument(tablename) totals[2] = totals[2] + 1 else logger.warn("[loadLuaMapBookDocument] - Item not found! Index: {}, itemId: {}", index, value.itemId) - break + goto continue end else logger.warn("[loadLuaMapBookDocument] - Container not found! Index: {}, containerId: {}", index, value.containerId) - break + goto continue end else logger.warn("[loadLuaMapBookDocument] - Tile not found! Index: {}, position: x: {} y: {} z: {}", index, value.position.x, value.position.y, value.position.z) - break + goto continue end end + ::continue:: end if totals[1] == totals[2] then logger.debug("Loaded {} books and documents in the map", totals[2]) diff --git a/src/creatures/npcs/npc.cpp b/src/creatures/npcs/npc.cpp index 18ca0dd0758..6d38524aef3 100644 --- a/src/creatures/npcs/npc.cpp +++ b/src/creatures/npcs/npc.cpp @@ -234,8 +234,8 @@ void Npc::onPlayerBuyItem(std::shared_ptr player, uint16_t itemId, uint8 return; } - // Check if the player not have empty slots - if (!ignore && player->getFreeBackpackSlots() == 0) { + // Check if the player not have empty slots or the item is not a container + if (!ignore && (player->getFreeBackpackSlots() == 0 && (player->getInventoryItem(CONST_SLOT_BACKPACK) || (!Item::items[itemId].isContainer() || !(Item::items[itemId].slotPosition & SLOTP_BACKPACK))))) { player->sendCancelMessage(RETURNVALUE_NOTENOUGHROOM); return; }