Skip to content

Commit

Permalink
fix: container:addItem missing return (opentibiabr#2857)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreoam authored Sep 6, 2024
1 parent d4b1b61 commit dec6ad0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ monster.loot = {
{ name = "two-headed turtle heads", chance = 8700 },
{ name = "strong mana potion", chance = 13373 },
{ name = "hydrophytes", chance = 11000 },
{ id = 1047, chance = 6388 }, -- bone
{ id = 3115, chance = 6388 }, -- bone
{ name = "glacier shoes", chance = 4650 },
{ id = 281, chance = 3582 }, -- giant shimmering pearl (green)
{ name = "small tropical fish", chance = 3582 },
Expand Down
6 changes: 3 additions & 3 deletions data/libs/functions/container.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ function Container:addLoot(loot)
local countToAdd = math.min(remainingCount, stackSize)
local tmpItem = self:addItem(itemId, countToAdd, INDEX_WHEREEVER, FLAG_NOLIMIT)
if not tmpItem then
logger.warn("Container:addLoot: failed to add stackable item: {}, to corpse {} with id {}", ItemType(itemId):getName(), self:getName(), self:getId())
logger.warn("Container:addLoot: failed to add stackable item: {} with id {}, to corpse {} with id {}", ItemType(itemId):getName(), itemId, self:getName(), self:getId())
goto continue
end
remainingCount = remainingCount - countToAdd
end
elseif iType:getCharges() ~= 0 then
local tmpItem = self:addItem(itemId, item.count, INDEX_WHEREEVER, FLAG_NOLIMIT)
if not tmpItem then
logger.warn("Container:addLoot: failed to add charge item: {}, to corpse {} with id {}", ItemType(itemId):getName(), self:getName(), self:getId())
logger.warn("Container:addLoot: failed to add charge item: {} with id {}, to corpse {} with id {}", ItemType(itemId):getName(), itemId, self:getName(), self:getId())
end
else
for i = 1, item.count do
local tmpItem = self:addItem(itemId, 1, INDEX_WHEREEVER, FLAG_NOLIMIT)
if not tmpItem then
logger.warn("Container:addLoot: failed to add item: {}, to corpse {} with id {}", ItemType(itemId):getName(), self:getName(), self:getId())
logger.warn("Container:addLoot: failed to add item: {} with id {}, to corpse {} with id {}", ItemType(itemId):getName(), itemId, self:getName(), self:getId())
goto continue
end

Expand Down
1 change: 1 addition & 0 deletions src/lua/functions/items/container_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ int ContainerFunctions::luaContainerAddItem(lua_State* L) {
setItemMetatable(L, -1, item);
} else {
reportErrorFunc(fmt::format("Cannot add item to container, error code: '{}'", getReturnMessage(ret)));
pushBoolean(L, false);
}
return 1;
}
Expand Down

0 comments on commit dec6ad0

Please sign in to comment.