Fix preference loading bugs (#27742)

First bug: if an error occured during pref loading code, it would fail. If the person then readied up, it would likely cause the round to fail to start.

Why could they ready up? The code only checks that the prefs finished loading, not that they finished loading *successfully*. Whoops.

Anyways, now people get kicked if their prefs fail to load. And I improved the error handling.

Second bug: if a user disconnected while their prefs were loading, it would cause an exception. This exception would go unobserved on lobby servers or raise through gameticker on non-lobby servers.

This happened even on a live server once and then triggered the first bug, but idk how.

Fixed this by properly plumbing through cancellation into the preferences loading code. The stuff is now cancelled properly.

Third bug: if somebody has a loadout item with a playtime requirement active, load-time sanitization of player prefs could run into a race condition because the sanitization can happen *before* play time was loaded.

Fixed by moving pref sanitizations to a later stage in the load process.
This commit is contained in:
Pieter-Jan Briers
2024-05-07 06:21:03 +02:00
committed by GitHub
parent 61c1aeddf3
commit 7a38b22ddb
9 changed files with 154 additions and 54 deletions

View File

@@ -12,6 +12,7 @@ namespace Content.Server.Preferences.Managers
void Init();
Task LoadData(ICommonSession session, CancellationToken cancel);
void SanitizeData(ICommonSession session);
void OnClientDisconnected(ICommonSession session);
bool TryGetCachedPreferences(NetUserId userId, [NotNullWhen(true)] out PlayerPreferences? playerPreferences);