Bug fix: Failed to detect out_of_funds when placing buy order.

This commit is contained in:
Jesse McDonald 2017-06-03 18:24:37 -05:00
parent 5cfb580545
commit b52e813d45

View File

@ -885,7 +885,7 @@ function ex_methods.buy(self, p_name, ex_name, item_name, wear, amount, rate)
if poster ~= p_name then if poster ~= p_name then
local can_afford = math.floor(balance / row_rate) local can_afford = math.floor(balance / row_rate)
last_row_rate = row_rate last_row_rate = row_rate
out_of_funds = row_bought < can_afford out_of_funds = can_afford < row_bought
row_bought = math.min(row_bought, can_afford) row_bought = math.min(row_bought, can_afford)
-- asking prices can only increase from here -- asking prices can only increase from here
if row_bought == 0 then break end if row_bought == 0 then break end
@ -1057,14 +1057,7 @@ function ex_methods.sell(self, p_name, ex_name, item_name, wear, amount, rate)
local out_of_funds = false local out_of_funds = false
if poster ~= p_name then if poster ~= p_name then
local bal = self:get_balance(poster) local bal = self:get_balance(poster) or 0
if not bal then
search_stmt:reset()
db:exec("ROLLBACK;")
return false, poster .. " does not have an account."
end
local can_afford = math.floor(bal / row_rate) local can_afford = math.floor(bal / row_rate)
out_of_funds = can_afford < row_sold out_of_funds = can_afford < row_sold
row_sold = math.min(row_sold, can_afford) row_sold = math.min(row_sold, can_afford)