diff --git a/Content.Server/Preferences/Managers/ServerPreferencesManager.cs b/Content.Server/Preferences/Managers/ServerPreferencesManager.cs index 7b434110cfa..de71304f953 100644 --- a/Content.Server/Preferences/Managers/ServerPreferencesManager.cs +++ b/Content.Server/Preferences/Managers/ServerPreferencesManager.cs @@ -3,9 +3,11 @@ using System.Threading; using System.Threading.Tasks; using Content.Corvax.Interfaces.Server; +using Content.Server.Administration.Logs; using Content.Server.Database; using Content.Server.Humanoid; using Content.Shared.CCVar; +using Content.Shared.Database; using Content.Shared.Humanoid.Prototypes; using Content.Shared.Preferences; using Content.Shared.Roles; @@ -31,6 +33,7 @@ public sealed class ServerPreferencesManager : IServerPreferencesManager [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IDependencyCollection _dependencies = default!; [Dependency] private readonly IPrototypeManager _protos = default!; + [Dependency] private readonly IAdminLogManager _log = default!; private IServerSponsorsManager? _sponsors; // Corvax-Sponsors // Cache player prefs on the server so we don't need as much async hell related to them. @@ -111,10 +114,22 @@ private async void HandleUpdateCharacterMessage(MsgUpdateCharacter message) if (curPrefs.Characters.TryGetValue(slot, out var storedProfile) && storedProfile is HumanoidCharacterProfile storedHumanoid) { if (humanoid.BankBalance != storedHumanoid.BankBalance) + { + _log.Add(LogType.UpdateCharacter, LogImpact.High, + $"Character update with wrong balance from {message.MsgChannel.UserName}, current balance: {storedHumanoid.BankBalance}, tried to set: {humanoid.BankBalance}"); + return; + } } else if (humanoid.BankBalance != HumanoidCharacterProfile.DefaultBalance) + { + _log.Add(LogType.UpdateCharacter, LogImpact.High, + $"Character creation with wrong balance from {message.MsgChannel.UserName}, default balance: {HumanoidCharacterProfile.DefaultBalance}, tried to set: {humanoid.BankBalance}"); + return; + } + + _log.Add(LogType.UpdateCharacter, LogImpact.Low, $"Successful character update from {message.MsgChannel.UserName}"); // Corvax-Sponsors-Start: Ensure removing sponsor markings if client somehow bypassed client filtering // WARN! It's not removing markings from DB! diff --git a/Content.Server/_NF/Bank/BankSystem.cs b/Content.Server/_NF/Bank/BankSystem.cs index f04586de0c3..b8106203e46 100644 --- a/Content.Server/_NF/Bank/BankSystem.cs +++ b/Content.Server/_NF/Bank/BankSystem.cs @@ -10,6 +10,7 @@ using Content.Shared._NF.Bank.Events; using Robust.Server.Player; using Content.Shared.Preferences.Loadouts; +using Content.Shared.Database; namespace Content.Server.Bank; @@ -103,6 +104,8 @@ public bool TryBankWithdraw(EntityUid mobUid, int amount) return false; } + _adminLogger.Add(LogType.Balance, LogImpact.Medium, $"Balance change from {ToPrettyString(mobUid)}, old balance: {bank.Balance}, withdrew: {amount}"); + bank.Balance -= amount; _log.Info($"{mobUid} withdrew {amount}"); if (_playerManager.TryGetSessionByEntity(mobUid, out var player)) @@ -133,6 +136,8 @@ public bool TryBankDeposit(EntityUid mobUid, int amount) return false; } + _adminLogger.Add(LogType.Balance, LogImpact.Medium, $"Balance change from {ToPrettyString(mobUid)}, old balance: {bank.Balance}, deposited: {amount}"); + bank.Balance += amount; _log.Info($"{mobUid} deposited {amount}"); if (_playerManager.TryGetSessionByEntity(mobUid, out var player)) diff --git a/Content.Shared.Database/LogType.cs b/Content.Shared.Database/LogType.cs index 5422646c139..0fa8c64c5e2 100644 --- a/Content.Shared.Database/LogType.cs +++ b/Content.Shared.Database/LogType.cs @@ -101,4 +101,7 @@ public enum LogType // Frontier Station Spesific ATMUsage = 200, ShipYardUsage = 201, + + UpdateCharacter = 300, + Balance = 301 }