Fix currency duplication bug (#32524)
This commit is contained in:
@@ -283,6 +283,9 @@ public sealed partial class StoreSystem
|
||||
/// </remarks>
|
||||
private void OnRequestWithdraw(EntityUid uid, StoreComponent component, StoreRequestWithdrawMessage msg)
|
||||
{
|
||||
if (msg.Amount <= 0)
|
||||
return;
|
||||
|
||||
//make sure we have enough cash in the bank and we actually support this currency
|
||||
if (!component.Balance.TryGetValue(msg.Currency, out var currentAmount) || currentAmount < msg.Amount)
|
||||
return;
|
||||
@@ -306,7 +309,8 @@ public sealed partial class StoreSystem
|
||||
var cashId = proto.Cash[value];
|
||||
var amountToSpawn = (int) MathF.Floor((float) (amountRemaining / value));
|
||||
var ents = _stack.SpawnMultiple(cashId, amountToSpawn, coordinates);
|
||||
_hands.PickupOrDrop(buyer, ents.First());
|
||||
if (ents.FirstOrDefault() is {} ent)
|
||||
_hands.PickupOrDrop(buyer, ent);
|
||||
amountRemaining -= value * amountToSpawn;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user