From 670feb452ccdd23da5fa4768fe7bb1d1637f9e8d Mon Sep 17 00:00:00 2001 From: sleepyyapril Date: Wed, 25 Dec 2024 15:30:53 -0400 Subject: [PATCH] I fixed it! --- Content.Server/Database/UserDbDataManager.cs | 11 +++++++---- .../Preferences/Managers/ServerPreferencesManager.cs | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Content.Server/Database/UserDbDataManager.cs b/Content.Server/Database/UserDbDataManager.cs index 50759008c3c..af246831cbf 100644 --- a/Content.Server/Database/UserDbDataManager.cs +++ b/Content.Server/Database/UserDbDataManager.cs @@ -67,13 +67,16 @@ private async Task Load(ICommonSession session, CancellationToken cancel) // As such, this task must NOT throw a non-cancellation error! try { - await Task.WhenAll( - _prefs.LoadData(session, cancel), - _playTimeTracking.LoadData(session, cancel)); + var tasks = new List(); + foreach (var action in _onLoadPlayer) + tasks.Add(action(session, cancel)); + await Task.WhenAll(tasks); cancel.ThrowIfCancellationRequested(); - _prefs.SanitizeData(session); + foreach (var action in _onFinishLoad) + action(session); + _prefs.SanitizeData(session); _sawmill.Verbose($"Load complete for user {session}"); } catch (OperationCanceledException) diff --git a/Content.Server/Preferences/Managers/ServerPreferencesManager.cs b/Content.Server/Preferences/Managers/ServerPreferencesManager.cs index e12359fb729..929586d735e 100644 --- a/Content.Server/Preferences/Managers/ServerPreferencesManager.cs +++ b/Content.Server/Preferences/Managers/ServerPreferencesManager.cs @@ -54,7 +54,7 @@ private async void HandleSelectCharacterMessage(MsgSelectCharacter message) if (!_cachedPlayerPrefs.TryGetValue(userId, out var prefsData) || !prefsData.PrefsLoaded) { - Logger.WarningS("prefs", $"User {userId} tried to modify preferences before they loaded."); + _sawmill.Error($"User {userId} tried to modify preferences before they loaded."); return; } @@ -231,6 +231,7 @@ public void SanitizeData(ICommonSession session) var data = _cachedPlayerPrefs[session.UserId]; DebugTools.Assert(data.Prefs != null); data.Prefs = SanitizePreferences(session, data.Prefs, _dependencies); + _sawmill.Debug("here"); } public void OnClientDisconnected(ICommonSession session)