From b52e813d452c7e98e7b89aa859c784d6f5248097 Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Sat, 3 Jun 2017 18:24:37 -0500 Subject: [PATCH] Bug fix: Failed to detect out_of_funds when placing buy order. --- exchange.lua | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/exchange.lua b/exchange.lua index 82c1c8b..19e850a 100644 --- a/exchange.lua +++ b/exchange.lua @@ -885,7 +885,7 @@ function ex_methods.buy(self, p_name, ex_name, item_name, wear, amount, rate) if poster ~= p_name then local can_afford = math.floor(balance / 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) -- asking prices can only increase from here 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 if poster ~= p_name then - local bal = self:get_balance(poster) - - if not bal then - search_stmt:reset() - db:exec("ROLLBACK;") - return false, poster .. " does not have an account." - end - + local bal = self:get_balance(poster) or 0 local can_afford = math.floor(bal / row_rate) out_of_funds = can_afford < row_sold row_sold = math.min(row_sold, can_afford)