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