🐛 fixed

This commit is contained in:
EntireTwix 2023-01-09 18:37:40 -08:00
parent 779ab90b8f
commit 8fea062a3f

View file

@ -191,7 +191,7 @@ BankResponse Bank::SetBal(const std::string &name, int64_t amount) noexcept
amount -= u.balance; amount -= u.balance;
u.balance += amount; u.balance += amount;
#if MAX_LOG_SIZE > 0 #if MAX_LOG_SIZE > 0
u.log.AddTrans("Ω", (amount > 0), amount, time(NULL)); u.log.AddTrans("Ω", (amount > 0), std::abs(amount), time(NULL));
#endif #endif
})) }))
{ {
@ -211,10 +211,10 @@ BankResponse Bank::ImpactBal(const std::string &name, int64_t amount) noexcept
} }
uint32_t bal; uint32_t bal;
if (ValidUsername(name) && Bank::users.modify_if(name, [&bal, &amount](User &u) { if (ValidUsername(name) && Bank::users.modify_if(name, [&bal, &amount](User &u) {
amount += (u.balance < (amount * -1)) * (amount + u.balance); if (u.balance < (amount * -1)) { amount = -u.balance; };
bal = u.balance += amount; bal = u.balance += amount;
#if MAX_LOG_SIZE > 0 #if MAX_LOG_SIZE > 0
u.log.AddTrans("Ω", (amount > 0), amount, time(NULL)); u.log.AddTrans("Ω", (amount > 0), std::abs(amount), time(NULL));
#endif #endif
})) }))
{ {