Skip to content

Commit

Permalink
- added delayed registration for client updates for new characters th…
Browse files Browse the repository at this point in the history
…at do not exist but are being created
  • Loading branch information
mfoltz committed Sep 20, 2024
1 parent 2bbf3ad commit 832067e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Services/EclipseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ internal class EclipseService
static readonly bool Classes = ConfigService.SoftSynergies || ConfigService.HardSynergies;

static readonly WaitForSeconds Delay = new(2.5f);
static readonly WaitForSeconds NewUserDelay = new(15f);

const int Attempts = 20;
static readonly Regex regex = new(@"^\[(\d+)\]:");

public readonly static HashSet<ulong> RegisteredUsers = [];
Expand Down Expand Up @@ -61,6 +63,32 @@ static void RegisterUser(ulong steamId)
SendClientConfig(playerInfo.User);
SendClientProgress(playerInfo.CharEntity, steamId);
}
else // delayed registration, wait for cache to update/player to make character...
{
Core.StartCoroutine(DelayedRegistration(steamId));
}
}
static IEnumerator DelayedRegistration(ulong steamId)
{
int tries = 0;

while (tries <= Attempts)
{
yield return NewUserDelay;

if (steamId.TryGetPlayerInfo(out PlayerInfo playerInfo) && playerInfo.CharEntity.Exists())
{
Core.Log.LogInfo($"User {steamId} registered for Eclipse updates from PlayerCache...");
RegisteredUsers.Add(steamId);
SendClientConfig(playerInfo.User);
SendClientProgress(playerInfo.CharEntity, steamId);
yield break;
}
else
{
tries++;
}
}
}
public static void SendClientConfig(User user)
{
Expand Down

0 comments on commit 832067e

Please sign in to comment.