From 91a80017b4d8cdb8e717cc2a356d3eab68ab7fac Mon Sep 17 00:00:00 2001 From: 4drik <4drik@users.noreply.github.com> Date: Wed, 20 Nov 2019 10:23:39 +0100 Subject: [PATCH] Fix for moving creatures/items far out of reach Fix to https://github.com/edubart/otclient/issues/1055 --- modules/game_interface/widgets/uiitem.lua | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/modules/game_interface/widgets/uiitem.lua b/modules/game_interface/widgets/uiitem.lua index bc5ea741..ee4b8775 100644 --- a/modules/game_interface/widgets/uiitem.lua +++ b/modules/game_interface/widgets/uiitem.lua @@ -20,15 +20,26 @@ function UIItem:onDragLeave(droppedWidget, mousePos) end function UIItem:onDrop(widget, mousePos) - if not self:canAcceptDrop(widget, mousePos) then return false end + + if not self:canAcceptDrop(widget, mousePos) then + return false + end local item = widget.currentDragThing - if not item:isItem() then return false end - - local toPos = self.position + if not item:isItem() then + return false + end local itemPos = item:getPosition() - if itemPos.x == toPos.x and itemPos.y == toPos.y and itemPos.z == toPos.z then return false end + local itemTile = item:getTile() + if itemPos.x ~= 65535 and not itemTile then + return false + end + + local toPos = self.position + if itemPos.x == toPos.x and itemPos.y == toPos.y and itemPos.z == toPos.z then + return false + end if item:getCount() > 1 then modules.game_interface.moveStackableItem(item, toPos)