diff --git a/Content.Server/_NF/Bank/BankSystem.cs b/Content.Server/_NF/Bank/BankSystem.cs index 54ab026d0bf..d2ad4d25248 100644 --- a/Content.Server/_NF/Bank/BankSystem.cs +++ b/Content.Server/_NF/Bank/BankSystem.cs @@ -1,5 +1,4 @@ using System.Threading; -using System.Threading.Tasks; using Content.Server.Database; using Content.Server.Preferences.Managers; using Content.Server.GameTicking; @@ -9,6 +8,7 @@ using Robust.Shared.Network; using Content.Shared._NF.Bank.Events; using Robust.Server.Player; +using Content.Server.Cargo.Components; using Content.Shared.Preferences.Loadouts; using Robust.Shared.Prototypes; using Content.Shared.Roles; @@ -22,9 +22,6 @@ public sealed partial class BankSystem : EntitySystem [Dependency] private readonly IServerPreferencesManager _prefsManager = default!; [Dependency] private readonly IServerDbManager _dbManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; - - [Dependency] private readonly IDependencyCollection _dependencies = default!; // Corvax-Frontier-Changes - private ISawmill _log = default!; public override void Initialize() @@ -42,9 +39,6 @@ public override void Initialize() // TODO: stop it from running 5 times every time private void OnBankAccountChanged(EntityUid mobUid, BankAccountComponent bank, ref ComponentGetState args) { - if (args.Player is null) - return; - var user = args.Player?.UserId; if (user == null || args.Player?.AttachedEntity != mobUid) @@ -77,29 +71,15 @@ private void OnBankAccountChanged(EntityUid mobUid, BankAccountComponent bank, r new HashSet>(profile.TraitPreferences), // Frontier Merge new Dictionary(profile.Loadouts)); - newProfile.EnsureValid(args.Player, _dependencies, []); - args.State = new BankAccountComponentState { Balance = bank.Balance, }; - // idk if it works as i want - Task.Run(() => SaveCharSlot((NetUserId) user, profile, index)).Wait(300); // Corvax-Frontier-Changes + + _dbManager.SaveCharacterSlotAsync((NetUserId) user, newProfile, index); _log.Info($"Character {profile.Name} saved"); } - // Corvax-Frontier-Changes-Start - private async Task SaveCharSlot(NetUserId userId, HumanoidCharacterProfile profile, int index) - { - try - { - await _dbManager.SaveCharacterSlotAsync(userId, profile, index); - } - catch (Exception ex) - { - _log.Error($"Caught exception while saving bank account to database: {ex.Message}. Stack Trace: {ex.StackTrace}"); - } - } - // Corvax-Frontier-Changes-End + /// /// Attempts to remove money from a character's bank account. This should always be used instead of attempting to modify the bankaccountcomponent directly ///