From bfb3149e165f6f652b6f3e5361e36a0c92633697 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Sat, 22 Jun 2024 22:22:26 -0300 Subject: [PATCH] fix: correction in checking inbox:getMaxCapacity() (#2679) --- data-otservbr-global/npc/emael.lua | 2 +- data-otservbr-global/npc/emperor_kruzak.lua | 2 +- data-otservbr-global/npc/hireling.lua | 2 +- data-otservbr-global/npc/king_tibianus.lua | 2 +- data-otservbr-global/npc/queen_eloise.lua | 2 +- data-otservbr-global/npc/walter_jaeger.lua | 2 +- data/libs/systems/hireling.lua | 4 ++-- data/modules/scripts/daily_reward/daily_reward.lua | 2 +- data/scripts/talkactions/player/reward.lua | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/data-otservbr-global/npc/emael.lua b/data-otservbr-global/npc/emael.lua index 79111f8f324..4fff95b1b95 100644 --- a/data-otservbr-global/npc/emael.lua +++ b/data-otservbr-global/npc/emael.lua @@ -69,7 +69,7 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("Ah, I see you killed a lot of dangerous creatures. Here's your podium of vigour!", npc, creature) local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() - if inbox and #inboxItems <= inbox:getMaxCapacity() then + if inbox and #inboxItems < inbox:getMaxCapacity() then local decoKit = inbox:addItem(ITEM_DECORATION_KIT, 1) if decoKit then decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "Unwrap it in your own house to create a <" .. ItemType(38707):getName() .. ">.") diff --git a/data-otservbr-global/npc/emperor_kruzak.lua b/data-otservbr-global/npc/emperor_kruzak.lua index 4f838396df0..daf0742f615 100644 --- a/data-otservbr-global/npc/emperor_kruzak.lua +++ b/data-otservbr-global/npc/emperor_kruzak.lua @@ -82,7 +82,7 @@ local function creatureSayCallback(npc, creature, type, message) if player:getMoney() + player:getBankBalance() >= 500000000 then local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() - if inbox and #inboxItems <= inbox:getMaxCapacity() then + if inbox and #inboxItems < inbox:getMaxCapacity() then local decoKit = inbox:addItem(ITEM_DECORATION_KIT, 1) local decoItemName = ItemType(31510):getName() decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "You bought this item in the Store.\nUnwrap it in your own house to create a " .. decoItemName .. ".") diff --git a/data-otservbr-global/npc/hireling.lua b/data-otservbr-global/npc/hireling.lua index aad7785079d..6897bafdcf7 100644 --- a/data-otservbr-global/npc/hireling.lua +++ b/data-otservbr-global/npc/hireling.lua @@ -521,7 +521,7 @@ function createHirelingType(HirelingName) local inboxItems = inbox:getItems() if player:getFreeCapacity() < itType:getWeight(1) then npcHandler:say("Sorry, but you don't have enough capacity.", npc, creature) - elseif not inbox or #inboxItems > inbox:getMaxCapacity() then + elseif not inbox or #inboxItems >= inbox:getMaxCapacity() then player:getPosition():sendMagicEffect(CONST_ME_POFF) npcHandler:say("Sorry, you don't have enough room on your inbox", npc, creature) elseif not player:removeMoneyBank(15000) then diff --git a/data-otservbr-global/npc/king_tibianus.lua b/data-otservbr-global/npc/king_tibianus.lua index de47e45acca..d9968357fa1 100644 --- a/data-otservbr-global/npc/king_tibianus.lua +++ b/data-otservbr-global/npc/king_tibianus.lua @@ -87,7 +87,7 @@ local function creatureSayCallback(npc, creature, type, message) if player:getMoney() + player:getBankBalance() >= 500000000 then local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() - if inbox and #inboxItems <= inbox:getMaxCapacity() then + if inbox and #inboxItems < inbox:getMaxCapacity() then local decoKit = inbox:addItem(ITEM_DECORATION_KIT, 1) local decoItemName = ItemType(31510):getName() decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "Unwrap it in your own house to create a " .. decoItemName .. ".") diff --git a/data-otservbr-global/npc/queen_eloise.lua b/data-otservbr-global/npc/queen_eloise.lua index a9397061a56..0467bb6e74a 100644 --- a/data-otservbr-global/npc/queen_eloise.lua +++ b/data-otservbr-global/npc/queen_eloise.lua @@ -77,7 +77,7 @@ local function creatureSayCallback(npc, creature, type, message) if player:getMoney() + player:getBankBalance() >= 500000000 then local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() - if inbox and #inboxItems <= inbox:getMaxCapacity() then + if inbox and #inboxItems < inbox:getMaxCapacity() then local decoKit = inbox:addItem(ITEM_DECORATION_KIT, 1) local decoItemName = ItemType(31510):getName() decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "You bought this item in the Store.\nUnwrap it in your own house to create a " .. decoItemName .. ".") diff --git a/data-otservbr-global/npc/walter_jaeger.lua b/data-otservbr-global/npc/walter_jaeger.lua index 6911d7ed323..6b0e26075d6 100644 --- a/data-otservbr-global/npc/walter_jaeger.lua +++ b/data-otservbr-global/npc/walter_jaeger.lua @@ -283,7 +283,7 @@ local function processItemInboxPurchase(player, name, id) local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() - if inbox and #inboxItems <= inbox:getMaxCapacity() then + if inbox and #inboxItems < inbox:getMaxCapacity() then local decoKit = inbox:addItem(ITEM_DECORATION_KIT, 1) if decoKit then decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "You bought this item with the Walter Jaeger.\nUnwrap it in your own house to create a <" .. name .. ">.") diff --git a/data/libs/systems/hireling.lua b/data/libs/systems/hireling.lua index 8b5784759fa..30134cd7cd0 100644 --- a/data/libs/systems/hireling.lua +++ b/data/libs/systems/hireling.lua @@ -361,7 +361,7 @@ function Hireling:returnToLamp(player_id) local inbox = owner:getStoreInbox() local inboxItems = inbox:getItems() - if not inbox or #inboxItems > inbox:getMaxCapacity() then + if not inbox or #inboxItems >= inbox:getMaxCapacity() then owner:getPosition():sendMagicEffect(CONST_ME_POFF) return owner:sendTextMessage(MESSAGE_FAILURE, "You don't have enough room in your inbox.") end @@ -556,7 +556,7 @@ function Player:addNewHireling(name, sex) local inbox = self:getStoreInbox() local inboxItems = inbox:getItems() - if not inbox or #inboxItems > inbox:getMaxCapacity() then + if not inbox or #inboxItems >= inbox:getMaxCapacity() then self:getPosition():sendMagicEffect(CONST_ME_POFF) self:sendTextMessage(MESSAGE_FAILURE, "You don't have enough room in your inbox.") return false diff --git a/data/modules/scripts/daily_reward/daily_reward.lua b/data/modules/scripts/daily_reward/daily_reward.lua index 09b927cedda..b6a7c16993a 100644 --- a/data/modules/scripts/daily_reward/daily_reward.lua +++ b/data/modules/scripts/daily_reward/daily_reward.lua @@ -454,7 +454,7 @@ function Player.selectDailyReward(self, msg) -- Adding items to store inbox local inbox = self:getStoreInbox() local inboxItems = inbox:getItems() - if not inbox or #inboxItems > inbox:getMaxCapacity() then + if not inbox or #inboxItems >= inbox:getMaxCapacity() then self:sendError("You do not have enough space in your store inbox.") return false end diff --git a/data/scripts/talkactions/player/reward.lua b/data/scripts/talkactions/player/reward.lua index 3f4cc3787de..a05dab3a933 100644 --- a/data/scripts/talkactions/player/reward.lua +++ b/data/scripts/talkactions/player/reward.lua @@ -26,7 +26,7 @@ local function sendExerciseRewardModal(player) local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() - if inbox and #inboxItems <= inbox:getMaxCapacity() and player:getFreeCapacity() >= iType:getWeight() then + if inbox and #inboxItems < inbox:getMaxCapacity() and player:getFreeCapacity() >= iType:getWeight() then local item = inbox:addItem(it.id, it.charges) if item then item:setActionId(IMMOVABLE_ACTION_ID)