diff --git a/modules/corelib/ui/uiminiwindow.lua b/modules/corelib/ui/uiminiwindow.lua index d0ba1bcf..972ed789 100644 --- a/modules/corelib/ui/uiminiwindow.lua +++ b/modules/corelib/ui/uiminiwindow.lua @@ -314,6 +314,10 @@ function UIMiniWindow:disableResize() self:getChildById('bottomResizeBorder'):disable() end +function UIMiniWindow:enableResize() + self:getChildById('bottomResizeBorder'):enable() +end + function UIMiniWindow:fitOnParent() local parent = self:getParent() if self:isVisible() and parent and parent:getClassName() == 'UIMiniWindowContainer' then diff --git a/modules/game_containers/containers.lua b/modules/game_containers/containers.lua index bd0bd923..5d5cdda9 100644 --- a/modules/game_containers/containers.lua +++ b/modules/game_containers/containers.lua @@ -22,7 +22,7 @@ end function reloadContainers() clean() - for containerid,container in pairs(g_game.getContainers()) do + for _,container in pairs(g_game.getContainers()) do onContainerOpen(container) end end @@ -91,7 +91,7 @@ function onContainerOpen(container, previousContainer) local layout = containerPanel:getLayout() local cellSize = layout:getCellSize() - containerWindow:setContentMinimumHeight(cellSize.height*1) + containerWindow:setContentMinimumHeight(cellSize.height) containerWindow:setContentMaximumHeight(cellSize.height*layout:getNumLines()) if not previousContainer then diff --git a/modules/game_interface/widgets/uigamemap.lua b/modules/game_interface/widgets/uigamemap.lua index 03469054..51ebeecf 100644 --- a/modules/game_interface/widgets/uigamemap.lua +++ b/modules/game_interface/widgets/uigamemap.lua @@ -56,15 +56,13 @@ function UIGameMap:onMouseRelease(mousePosition, mouseButton) self.cancelNextRelease = false return true end - - local tile = self:getTile(mousePosition) - - local localPlayerPos = g_game.getLocalPlayer():getPosition() + local autoWalkPos = self:getPosition(mousePosition) - + -- happens when clicking outside of map boundaries if not autoWalkPos then return false end - + + local localPlayerPos = g_game.getLocalPlayer():getPosition() if autoWalkPos.z ~= localPlayerPos.z then local dz = autoWalkPos.z - localPlayerPos.z autoWalkPos.x = autoWalkPos.x + dz @@ -77,6 +75,7 @@ function UIGameMap:onMouseRelease(mousePosition, mouseButton) local creatureThing local multiUseThing + local tile = self:getTile(mousePosition) if tile then lookThing = tile:getTopLookThing() useThing = tile:getTopUseThing() diff --git a/modules/game_market/market.lua b/modules/game_market/market.lua index 9dbf0e97..4a1f0b1b 100644 --- a/modules/game_market/market.lua +++ b/modules/game_market/market.lua @@ -19,8 +19,6 @@ * Extend information features - Hover over offers for purchase information (balance after transaction, etc) - Display out of trend market offers based on their previous statistics (like cipsoft does) - - * Make compatible with cipsoft 9.61 (has the protocol changed? creating offer not working) ]] Market = {} @@ -1005,8 +1003,18 @@ function Market.createNewOffer() local amount = amountEdit:getValue() local anonymous = anonymous:isChecked() and 1 or 0 - -- error check offer + -- error checking local errorMsg = '' + if type == MarketAction.Buy then + if information.balance < ((piecePrice * amount) + fee) then + errorMsg = errorMsg..'Not enough balance to create this offer.\n' + end + elseif type == MarketAction.Sell then + if Market.depotContains(spriteId) < amount then + errorMsg = errorMsg..'Not enough items in your depot to create this offer.\n' + end + end + if piecePrice > piecePriceEdit.maximum then errorMsg = errorMsg..'Price is too high.\n' elseif piecePrice < piecePriceEdit.minimum then @@ -1017,9 +1025,10 @@ function Market.createNewOffer() elseif amount < amountEdit.minimum then errorMsg = errorMsg..'Amount is too low.\n' end + local timeCheck = os.time() - lastCreatedOffer if timeCheck < offerExhaust[type] then - local waitTime = math.ceil((offerExhaust[type] - timeCheck)) + local waitTime = math.ceil(offerExhaust[type] - timeCheck) errorMsg = errorMsg..'You must wait '.. waitTime ..' seconds before creating a new offer.\n' end diff --git a/modules/game_skills/skills.lua b/modules/game_skills/skills.lua index a70778ae..aa47e8db 100644 --- a/modules/game_skills/skills.lua +++ b/modules/game_skills/skills.lua @@ -268,7 +268,7 @@ function onStaminaChange(localPlayer, stamina) if minutes < 10 then minutes = '0' .. minutes end - local percent = 100 * stamina / (42 * 60) -- max is 42 hours + local percent = math.floor(100 * stamina / (42 * 60)) -- max is 42 hours setSkillValue('stamina', hours .. ":" .. minutes) setSkillPercent('stamina', percent, tr('You have %s percent', percent)) @@ -293,13 +293,13 @@ function onRegenerationChange(localPlayer, regenerationTime) if not g_game.getFeature(GamePlayerRegenerationTime) or regenerationTime < 0 then return end - local hours = math.floor(regenerationTime / 60) - local minutes = regenerationTime % 60 - if minutes < 10 then - minutes = '0' .. minutes + local minutes = math.floor(regenerationTime / 60) + local seconds = regenerationTime % 60 + if seconds < 10 then + seconds = '0' .. seconds end - setSkillValue('regenerationTime', hours .. ":" .. minutes) + setSkillValue('regenerationTime', minutes .. ":" .. seconds) checkAlert('regenerationTime', regenerationTime, false, 300) end diff --git a/modules/game_textwindow/textwindow.lua b/modules/game_textwindow/textwindow.lua index 4380b01c..bde2dd08 100644 --- a/modules/game_textwindow/textwindow.lua +++ b/modules/game_textwindow/textwindow.lua @@ -67,6 +67,7 @@ function onGameEditText(id, itemId, maxLength, text, writter, time) if writeable then g_game.editText(id, textEdit:getText()) end + textEdit = nil destroy() end diff --git a/src/otclient/creature.cpp b/src/otclient/creature.cpp index f3e2494f..a8155a7e 100644 --- a/src/otclient/creature.cpp +++ b/src/otclient/creature.cpp @@ -521,7 +521,7 @@ void Creature::setOutfit(const Outfit& outfit) m_outfit.setAuxId(outfit.getAuxId()); m_outfit.setCategory(outfit.getCategory()); } else { - if(!g_things.isValidDatId(outfit.getId(), ThingCategoryCreature)) + if(outfit.getId() > 0 && !g_things.isValidDatId(outfit.getId(), ThingCategoryCreature)) return; m_outfit = outfit; } diff --git a/src/otclient/game.cpp b/src/otclient/game.cpp index 00fb34cd..b2de7007 100644 --- a/src/otclient/game.cpp +++ b/src/otclient/game.cpp @@ -325,11 +325,15 @@ void Game::processOpenOutfitWindow(const Outfit& currentOufit, const std::vector { virtualMountCreature = CreaturePtr(new Creature); virtualMountCreature->setDirection(Otc::South); - if(currentOufit.getMount() > 0) { - Outfit mountOutfit; - mountOutfit.setId(currentOufit.getMount()); - virtualMountCreature->setOutfit(mountOutfit); - } + + Outfit mountOutfit; + mountOutfit.setId(0); + + int mount = currentOufit.getMount(); + if(mount > 0) + mountOutfit.setId(mount); + + virtualMountCreature->setOutfit(mountOutfit); } g_lua.callGlobalField("g_game", "onOpenOutfitWindow", virtualOutfitCreature, outfitList, virtualMountCreature, mountList);