Skip to content

Commit 6894388

Browse files
committed
fix: Set the first ulid being used each play session as the default for
requests
1 parent c219af1 commit 6894388

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Runtime/Client/LootLockerStateData.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ public static LootLockerPlayerData GetStateForPlayerOrDefaultStateOrEmpty(string
195195
}
196196
string playerULIDToGetDataFor = string.IsNullOrEmpty(playerULID) ? ActiveMetaData.DefaultPlayer : playerULID;
197197

198+
// Make this player the default for requests if there is no default yet or if the current default is not currently active
199+
bool shouldBeMadeDefault = !playerULID.Equals(ActiveMetaData.DefaultPlayer, StringComparison.OrdinalIgnoreCase) && ActivePlayerData.Count == 0;
200+
198201
if (ActivePlayerData.TryGetValue(playerULIDToGetDataFor, out var data))
199202
{
200203
return data;
@@ -204,6 +207,10 @@ public static LootLockerPlayerData GetStateForPlayerOrDefaultStateOrEmpty(string
204207
{
205208
if (ActivePlayerData.TryGetValue(playerULIDToGetDataFor, out var data2))
206209
{
210+
if (shouldBeMadeDefault)
211+
{
212+
SetDefaultPlayerULID(data2.ULID);
213+
}
207214
return data2;
208215
}
209216
}
@@ -264,7 +271,7 @@ public static bool SetPlayerData(LootLockerPlayerData updatedPlayerData)
264271
{
265272
ActiveMetaData.WhiteLabelEmailToPlayerUlidMap[updatedPlayerData.WhiteLabelEmail] = updatedPlayerData.ULID;
266273
}
267-
if (string.IsNullOrEmpty(ActiveMetaData.DefaultPlayer))
274+
if (string.IsNullOrEmpty(ActiveMetaData.DefaultPlayer) || !ActivePlayerData.ContainsKey(ActiveMetaData.DefaultPlayer))
268275
{
269276
SetDefaultPlayerULID(updatedPlayerData.ULID);
270277
}

0 commit comments

Comments
 (0)