fix: Fixes empty/missing bank box prevent withdraw from account gold (#2219)

This commit is contained in:
Kamron Batman 2025-06-24 10:37:59 -07:00 • committed by GitHub
parent d3e4606050
commit 7d748491d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -12,7 +12,7 @@ namespace Server.Mobiles;
[SerializationGenerator(0, false)] [SerializationGenerator(0, false)]
public partial class Banker : BaseVendor public partial class Banker : BaseVendor
{ {
private readonly List<SBInfo> m_SBInfos = new(); private readonly List<SBInfo> m_SBInfos = [];
[Constructible] [Constructible]
public Banker() : base("the banker") public Banker() : base("the banker")
@ -41,7 +41,7 @@ public partial class Banker : BaseVendor
} }
} }
Container bank = m.FindBankNoCreate(); var bank = m.FindBankNoCreate();
if (bank != null) if (bank != null)
{ {
@ -80,11 +80,11 @@ public partial class Banker : BaseVendor
} }
} }
Container bank = m.FindBankNoCreate(); var bank = m.FindBankNoCreate();
if (bank != null) if (bank != null)
{ {
gold = new List<Gold>(); gold = [];
foreach (var g in bank.FindItemsByType<Gold>()) foreach (var g in bank.FindItemsByType<Gold>())
{ {
@ -97,7 +97,7 @@ public partial class Banker : BaseVendor
return int.MaxValue; return int.MaxValue;
} }
checks = new List<BankCheck>(); checks = [];
foreach (var bc in bank.FindItemsByType<BankCheck>()) foreach (var bc in bank.FindItemsByType<BankCheck>())
{ {
@ -111,7 +111,7 @@ public partial class Banker : BaseVendor
private static bool HasRequiredBalance(int requiredBalance, Mobile m, out PooledRefList<Gold> gold, out PooledRefList<BankCheck> checks) private static bool HasRequiredBalance(int requiredBalance, Mobile m, out PooledRefList<Gold> gold, out PooledRefList<BankCheck> checks)
{ {
Container bank = m.FindBankNoCreate(); var bank = m.FindBankNoCreate();
if (bank == null) if (bank == null)
{ {
@ -380,11 +380,9 @@ public partial class Banker : BaseVendor
{ {
Say(1048147); // Your backpack can't hold anything else. Say(1048147); // Your backpack can't hold anything else.
} }
else if (amount > 0) else if (amount <= 0)
{ {
var box = e.Mobile.FindBankNoCreate(); if (!Withdraw(e.Mobile, amount))
if (box == null || !Withdraw(e.Mobile, amount))
{ {
Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold! Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold!
} }