Fixes money being debitted multiple times (#4078)

This commit is contained in:
esguard
2021-05-30 07:19:14 +02:00
committed by GitHub
parent 5fad2123d9
commit 0ef61ba47a
3 changed files with 32 additions and 11 deletions

View File

@@ -84,20 +84,23 @@ namespace Content.Server.Cargo
/// Approves an order in the database.
/// </summary>
/// <param name="order">The order to be approved.</param>
public void ApproveOrder(int orderNumber)
public bool ApproveOrder(int orderNumber)
{
if (CurrentOrderSize == MaxOrderSize)
return;
return false;
if (!_orders.TryGetValue(orderNumber, out var order))
return;
return false;
if (order.Approved)
return false;
else if (CurrentOrderSize + order.Amount > MaxOrderSize)
{
AddOrder(order.Requester, Loc.GetString("{0} (Overflow)", order.Reason.Replace(" (Overflow)","")), order.ProductId,
AddOrder(order.Requester, Loc.GetString("{0} (Overflow)", order.Reason.Replace(" (Overflow)", "")), order.ProductId,
order.Amount - MaxOrderSize - CurrentOrderSize, order.PayingAccountId);
order.Amount = MaxOrderSize - CurrentOrderSize;
}
order.Approved = true;
CurrentOrderSize += order.Amount;
return true;
}
/// <summary>