Fix for moving creatures/items far out of reach

Fix to https://github.com/edubart/otclient/issues/1055
This commit is contained in:
4drik 2019-11-20 10:21:04 +01:00 committed by diath
parent 11b006c356
commit 656dff45f1

View File

@ -30,16 +30,30 @@ function UIGameMap:onDragLeave(droppedWidget, mousePos)
end end
function UIGameMap:onDrop(widget, mousePos) function UIGameMap:onDrop(widget, mousePos)
if not self:canAcceptDrop(widget, mousePos) then return false end if not self:canAcceptDrop(widget, mousePos) then
return false
end
local tile = self:getTile(mousePos) local tile = self:getTile(mousePos)
if not tile then return false end if not tile then
return false
end
local thing = widget.currentDragThing local thing = widget.currentDragThing
local toPos = tile:getPosition()
local thingPos = thing:getPosition() local thingPos = thing:getPosition()
if thingPos.x == toPos.x and thingPos.y == toPos.y and thingPos.z == toPos.z then return false end if not thingPos then
return false
end
local thingTile = thing:getTile()
if thingPos.x ~= 65535 and not thingTile then
return false
end
local toPos = tile:getPosition()
if thingPos.x == toPos.x and thingPos.y == toPos.y and thingPos.z == toPos.z then
return false
end
if thing:isItem() and thing:getCount() > 1 then if thing:isItem() and thing:getCount() > 1 then
modules.game_interface.moveStackableItem(thing, toPos) modules.game_interface.moveStackableItem(thing, toPos)