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);
{
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)