Fix market issue with non stackable items.
This commit is contained in:
parent
f4641333f4
commit
82bfdc566f
|
@ -358,6 +358,7 @@ local function updateDepotItemCount(itemId, amount)
|
||||||
if depotItem and itemId == depotItem.ptr:getId() then
|
if depotItem and itemId == depotItem.ptr:getId() then
|
||||||
local depotItemCount = depotItem.ptr:getCount()
|
local depotItemCount = depotItem.ptr:getCount()
|
||||||
|
|
||||||
|
if depotItem.ptr:isStackable() then
|
||||||
if depotItemCount <= 100 and depotItemCount >= amount then
|
if depotItemCount <= 100 and depotItemCount >= amount then
|
||||||
if (depotItemCount - amount) <= 0 then
|
if (depotItemCount - amount) <= 0 then
|
||||||
table.remove(information.depotItems, i)
|
table.remove(information.depotItems, i)
|
||||||
|
@ -372,8 +373,8 @@ local function updateDepotItemCount(itemId, amount)
|
||||||
if remainder > 0 then
|
if remainder > 0 then
|
||||||
removeCount = removeCount + 1
|
removeCount = removeCount + 1
|
||||||
end
|
end
|
||||||
for i = 1, removeCount do
|
for j = 1, removeCount do
|
||||||
if i == removeCount and remainder > 0 then
|
if j == removeCount and remainder > 0 then
|
||||||
updateDepotItemCount(itemId, remainder)
|
updateDepotItemCount(itemId, remainder)
|
||||||
else
|
else
|
||||||
updateDepotItemCount(itemId, 100)
|
updateDepotItemCount(itemId, 100)
|
||||||
|
@ -381,8 +382,15 @@ local function updateDepotItemCount(itemId, amount)
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
if amount > 0 then
|
||||||
|
table.remove(information.depotItems, i)
|
||||||
|
amount = amount - 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function updateFee(price, amount)
|
local function updateFee(price, amount)
|
||||||
|
@ -873,6 +881,8 @@ function Market.loadDepotItems(depotItems)
|
||||||
local data = depotItems[i]
|
local data = depotItems[i]
|
||||||
local id, count = data[1], data[2]
|
local id, count = data[1], data[2]
|
||||||
|
|
||||||
|
local tmpItem = Item.create(id)
|
||||||
|
if tmpItem:isStackable() then
|
||||||
if count > 100 then
|
if count > 100 then
|
||||||
local createCount = math.floor(count/100)
|
local createCount = math.floor(count/100)
|
||||||
local remainder = count % 100
|
local remainder = count % 100
|
||||||
|
@ -893,6 +903,11 @@ function Market.loadDepotItems(depotItems)
|
||||||
newItem:setCount(count)
|
newItem:setCount(count)
|
||||||
table.insert(items, newItem)
|
table.insert(items, newItem)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
for i = 1, count do
|
||||||
|
table.insert(items, Item.create(id))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, newItem in pairs(items) do
|
for _, newItem in pairs(items) do
|
||||||
|
|
Loading…
Reference in New Issue