]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix preferences sent to client not being sanitized (#27789)
authorPieter-Jan Briers <pieterjan.briers+git@gmail.com>
Wed, 8 May 2024 02:24:54 +0000 (04:24 +0200)
committerGitHub <noreply@github.com>
Wed, 8 May 2024 02:24:54 +0000 (04:24 +0200)
Fucking whoops

In #27742 I made it so sanitization of character profiles was moved to be *after* database load. Except that means I moved it to be after the copy of all character profiles got sent to the client.

Move the sending to *also* be in that second load stage, and rename it. Fixes the issue.

Content.Server/Database/UserDbDataManager.cs
Content.Server/Preferences/Managers/IServerPreferencesManager.cs
Content.Server/Preferences/Managers/ServerPreferencesManager.cs

index 3f6659840adb6b020a582ad60eb3fe013504b17e..c58c594dbad00e21caa3c2163dc44f69e7eca4a5 100644 (file)
@@ -67,7 +67,7 @@ public sealed class UserDbDataManager : IPostInjectInit
                 _playTimeTracking.LoadData(session, cancel));
 
             cancel.ThrowIfCancellationRequested();
-            _prefs.SanitizeData(session);
+            _prefs.FinishLoad(session);
 
             _sawmill.Verbose($"Load complete for user {session}");
         }
index 92e7adf22ad20a2ca73699faaa46f094abe59938..63c267f154acc09894072475f92f6d97c2cab4fb 100644 (file)
@@ -12,7 +12,7 @@ namespace Content.Server.Preferences.Managers
         void Init();
 
         Task LoadData(ICommonSession session, CancellationToken cancel);
-        void SanitizeData(ICommonSession session);
+        void FinishLoad(ICommonSession session);
         void OnClientDisconnected(ICommonSession session);
 
         bool TryGetCachedPreferences(NetUserId userId, [NotNullWhen(true)] out PlayerPreferences? playerPreferences);
index 55532f1ff5b6bd5a0e3f882e43c485f5970cfb0f..7a80757435e7303cc243e68bb8c511a31ea87d9a 100644 (file)
@@ -199,27 +199,28 @@ namespace Content.Server.Preferences.Managers
                 {
                     var prefs = await GetOrCreatePreferencesAsync(session.UserId, cancel);
                     prefsData.Prefs = prefs;
-                    prefsData.PrefsLoaded = true;
-
-                    var msg = new MsgPreferencesAndSettings();
-                    msg.Preferences = prefs;
-                    msg.Settings = new GameSettings
-                    {
-                        MaxCharacterSlots = MaxCharacterSlots
-                    };
-                    _netManager.ServerSendMessage(msg, session.Channel);
                 }
             }
         }
 
-        public void SanitizeData(ICommonSession session)
+        public void FinishLoad(ICommonSession session)
         {
             // This is a separate step from the actual database load.
             // Sanitizing preferences requires play time info due to loadouts.
             // And play time info is loaded concurrently from the DB with preferences.
-            var data = _cachedPlayerPrefs[session.UserId];
-            DebugTools.Assert(data.Prefs != null);
-            data.Prefs = SanitizePreferences(session, data.Prefs, _dependencies);
+            var prefsData = _cachedPlayerPrefs[session.UserId];
+            DebugTools.Assert(prefsData.Prefs != null);
+            prefsData.Prefs = SanitizePreferences(session, prefsData.Prefs, _dependencies);
+
+            prefsData.PrefsLoaded = true;
+
+            var msg = new MsgPreferencesAndSettings();
+            msg.Preferences = prefsData.Prefs;
+            msg.Settings = new GameSettings
+            {
+                MaxCharacterSlots = MaxCharacterSlots
+            };
+            _netManager.ServerSendMessage(msg, session.Channel);
         }
 
         public void OnClientDisconnected(ICommonSession session)