Skip to content

feat: configurable multi-user session mode#344

Open
kirre-bylund wants to merge 5 commits into
devfrom
feat/1521-configurable-multi-user-mode
Open

feat: configurable multi-user session mode#344
kirre-bylund wants to merge 5 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 ELootLockerMultiUserSessionMode UENUM to ULootLockerConfig 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

The setting appears in Project Settings → Plugins → LootLockerSDK → LootLocker | Multi User.

Backwards compatibility

A NotSet sentinel value (hidden from the editor dropdown via UMETA(Hidden)) handles the pre-migration case. PostInitProperties() calls MigrateSettingsIfNeeded() which:

  • Uses GConfig->GetString(...) to check whether MultiUserSessionMode has ever been written to DefaultGame.ini
  • If absent (pre-migration): API key present → Hotseat; API key absent → SingleSession
  • Persists the result via TryUpdateDefaultConfigFile() / UpdateDefaultConfigFile() so subsequent loads skip the check

Changes

  • LootLockerSDK/Source/LootLockerSDK/Public/LootLockerConfig.h

    • New ELootLockerMultiUserSessionMode UENUM with UMETA tooltips (NotSet hidden)
    • New MultiUserSessionMode UPROPERTY in "LootLocker|Multi User" category
    • MigrateSettingsIfNeeded() declaration; call added to PostInitProperties()
  • LootLockerSDK/Source/LootLockerSDK/Private/LootLockerConfig.cpp

    • #include "Misc/ConfigCacheIni.h" added
    • MigrateSettingsIfNeeded() implementation
  • LootLockerSDK/Source/LootLockerSDK/Private/LootLockerStateData.cpp

    • #include "LootLockerConfig.h" added
    • SavePlayerData() branches on the configured mode:
      • SingleSession: calls ClearAllSavedStates() before saving
      • ProfileSwitching: calls SetAllPlayersToInactiveExceptForPlayer(), sets new player as default
      • Hotseat / NotSet: preserves the previous first-auth-is-default behaviour

- Add ELootLockerMultiUserSessionMode UENUM (Hotseat/SingleSession/ProfileSwitching/NotSet)
  with full UMETA tooltips in LootLockerConfig.h
- Add MultiUserSessionMode UPROPERTY in LootLocker|Multi User category with descriptive tooltip
- Add MigrateSettingsIfNeeded() called from PostInitProperties(): checks GConfig for key presence;
  if absent (pre-migration), sets Hotseat (existing projects) or SingleSession (new installs)
  and persists to DefaultGame.ini via TryUpdateDefaultConfigFile/UpdateDefaultConfigFile
- Add #include Misc/ConfigCacheIni.h to LootLockerConfig.cpp
- Modify SavePlayerData() to apply session mode:
  - SingleSession: calls ClearAllSavedStates() before saving, always sets new player as default
  - ProfileSwitching: calls SetAllPlayersToInactiveExceptForPlayer(), sets new player as default
  - Hotseat (default/NotSet): preserves existing behaviour
Copy link
Copy Markdown

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 configurable multi-user session handling mode to the LootLocker Unreal SDK so the “default player” behavior on new authentications is explicit and less surprising across sessions.

Changes:

  • Introduces ELootLockerMultiUserSessionMode and a MultiUserSessionMode config property on ULootLockerConfig, including a one-time migration path for existing projects.
  • Implements settings migration logic that selects an initial mode and persists it to config.
  • Updates persisted player-state saving to branch behavior based on the configured multi-user mode (wipe-on-auth, profile switching, or legacy hotseat behavior).

Reviewed changes

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

File Description
LootLockerSDK/Source/LootLockerSDK/Public/LootLockerConfig.h Adds the new UENUM + config UPROPERTY and triggers migration from PostInitProperties().
LootLockerSDK/Source/LootLockerSDK/Private/LootLockerConfig.cpp Implements MigrateSettingsIfNeeded() using ini inspection and config persistence.
LootLockerSDK/Source/LootLockerSDK/Private/LootLockerStateData.cpp Adjusts SavePlayerData() behavior based on the configured multi-user session mode.

Comment thread LootLockerSDK/Source/LootLockerSDK/Private/LootLockerStateData.cpp Outdated
Comment thread LootLockerSDK/Source/LootLockerSDK/Private/LootLockerConfig.cpp Outdated
Comment thread LootLockerSDK/Source/LootLockerSDK/Private/LootLockerConfig.cpp
Comment on lines +143 to +147
const ELootLockerMultiUserSessionMode Mode = GetDefault<ULootLockerConfig>()->MultiUserSessionMode;

if (Mode == ELootLockerMultiUserSessionMode::SingleSession)
{
// Wipe all existing player state before saving the new player.
- SingleSession: save new player first, then wipe others via ClearAllSavedStatesExceptForPlayer to prevent data loss on IO failure
- MigrateSettingsIfNeeded: use GetDefaultConfigFilename() so read/write targets always match
- MigrateSettingsIfNeeded: gate on-disk persistence to WITH_EDITOR contexts to avoid startup IO on read-only packaged installs
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.

2 participants