Skip to content

feat: configurable multi-user session mode#468

Merged
kirre-bylund merged 10 commits into
devfrom
feat/1521-configurable-multi-user-mode
May 29, 2026
Merged

feat: configurable multi-user session mode#468
kirre-bylund merged 10 commits into
devfrom
feat/1521-configurable-multi-user-mode

Conversation

@kirre-bylund
Copy link
Copy Markdown
Contributor

Summary

Resolves lootlocker/index#1521

Adds a configurable LootLockerMultiUserSessionMode enum to LootLockerConfig that controls how the SDK handles new authentications with respect to the active/default player. This addresses the common developer confusion where requests go to the "wrong player" because a previously-cached default persists across sessions.

New setting: Multi User Session Mode

Three modes are available:

Mode Active sessions Cache Default rule Best for
Hotseat (previous default) Multiple All retained First auth in session Local multiplayer / couch co-op
Single Session (new install default) One Previous wiped on new auth Always latest auth Standard single-player games
Profile Switching One Historic retained in cold cache Always latest auth Games with account selection screens

Backwards compatibility

A NotSet sentinel value handles the pre-migration case:

  • On first editor load after upgrading, [InitializeOnLoadMethod] checks whether an API key is already configured:
    • API key present (existing project) → resolves to Hotseat — no behaviour change
    • API key absent (new install) → resolves to SingleSession
  • The resolved value is persisted to the config asset immediately so subsequent loads skip the check

Changes

  • Runtime/Game/Resources/LootLockerConfig.cs

    • New LootLockerMultiUserSessionMode enum at namespace scope (NotSet, Hotseat, SingleSession, ProfileSwitching)
    • New multiUserSessionMode config field with detailed [Tooltip] explaining each mode
    • Pre-migration logic in [InitializeOnLoadMethod]
  • Runtime/Client/LootLockerStateData.cs

    • _SetPlayerData() branches on the configured mode:
      • SingleSession: clears all previous state before saving the new player
      • ProfileSwitching: deactivates all other players (cold cache kept), sets new player as default
      • Hotseat / NotSet: preserves the previous first-auth-is-default behaviour

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new configuration setting (LootLockerMultiUserSessionMode) to control how the SDK treats “default/active player” selection when multiple authentications occur, aiming to reduce confusion from previously-cached default players.

Changes:

  • Introduces LootLockerMultiUserSessionMode and adds multiUserSessionMode to LootLockerConfig, including editor-time pre-migration persistence from NotSet.
  • Updates LootLockerStateData._SetPlayerData() to branch player cache/default behavior based on the configured session mode.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
Runtime/Game/Resources/LootLockerConfig.cs Adds the multi-user session mode enum + config field, and editor-time migration/persistence for existing projects/new installs.
Runtime/Client/LootLockerStateData.cs Alters player state persistence/default-player rules based on the configured multi-user session mode.

Comment thread Runtime/Client/LootLockerStateData.cs Outdated
Comment thread Runtime/Client/LootLockerStateData.cs Outdated
Comment thread Runtime/Game/Resources/LootLockerConfig.cs
@kirre-bylund kirre-bylund force-pushed the feat/1521-configurable-multi-user-mode branch from 85d3b4e to eae0735 Compare May 21, 2026 10:18
@kirre-bylund kirre-bylund requested a review from JohannesLoot May 25, 2026 08:13
- Add LootLockerMultiUserSessionMode enum (Hotseat/SingleSession/ProfileSwitching/NotSet)
  at namespace scope in LootLockerConfig.cs
- Add multiUserSessionMode config field with detailed inspector tooltip
- Add [InitializeOnLoadMethod] pre-migration: NotSet resolves to Hotseat (existing
  projects with API key) or SingleSession (new installs) and is persisted to the asset
- Modify _SetPlayerData to apply session mode:
  - SingleSession: clears all previous state before saving, always sets new player as default
  - ProfileSwitching: deactivates other players (keeps cold cache), sets new player as default
  - Hotseat (default): preserves existing behaviour, first auth in session is default
- SingleSession: save new player first, then wipe others via _ClearAllSavedStatesExceptForPlayer to prevent data loss on IO failure
- ExternalFileConfig: add multi_user_session_mode field
- Config.Get(): apply multi_user_session_mode from external file config (only if != NotSet)
- CheckForSettingOverrides: add -multiusersessionmode command-line override
NotSet is now resolved the same way migration does: no API key → SingleSession, otherwise Hotseat.
@kirre-bylund kirre-bylund force-pushed the feat/1521-configurable-multi-user-mode branch from 5580e5b to d609d1a Compare May 28, 2026 06:21
Copy link
Copy Markdown
Contributor

@JohannesLoot JohannesLoot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, merge away!

@JohannesLoot
Copy link
Copy Markdown
Contributor

From previous discussion:
Some of the remote/connect methods will require Hotseat mode.
Add a warning/error to those methods when the wrong user mode is enabled.

@kirre-bylund
Copy link
Copy Markdown
Contributor Author

From previous discussion: Some of the remote/connect methods will require Hotseat mode. Add a warning/error to those methods when the wrong user mode is enabled.

Fixed

@kirre-bylund kirre-bylund merged commit 8597219 into dev May 29, 2026
58 checks passed
@kirre-bylund kirre-bylund deleted the feat/1521-configurable-multi-user-mode branch May 29, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants