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.
25 lines
926 B
C#
25 lines
926 B
C#
using System.Diagnostics.CodeAnalysis;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Content.Shared.Preferences;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Server.Preferences.Managers
|
|
{
|
|
public interface IServerPreferencesManager
|
|
{
|
|
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);
|
|
PlayerPreferences GetPreferences(NetUserId userId);
|
|
PlayerPreferences? GetPreferencesOrNull(NetUserId? userId);
|
|
IEnumerable<KeyValuePair<NetUserId, ICharacterProfile>> GetSelectedProfilesForPlayers(List<NetUserId> userIds);
|
|
bool HavePreferencesLoaded(ICommonSession session);
|
|
}
|
|
}
|