mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-15 07:44:16 +01:00
fix receiving chara data while initilaization, fix glamourer not applying after glamplate or material extraction, potentially fix more zoning issues
This commit is contained in:
parent
8f9421c349
commit
83f0905232
3 changed files with 42 additions and 14 deletions
|
|
@ -19,6 +19,7 @@ public class Pair
|
|||
private readonly ILogger<Pair> _logger;
|
||||
private readonly MareMediator _mediator;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private CancellationTokenSource _applicationCts = new CancellationTokenSource();
|
||||
private OnlineUserIdentDto? _onlineUserIdentDto = null;
|
||||
|
||||
public Pair(ILogger<Pair> logger, CachedPlayerFactory cachedPlayerFactory,
|
||||
|
|
@ -73,10 +74,32 @@ public class Pair
|
|||
|
||||
public void ApplyData(OnlineUserCharaDataDto data)
|
||||
{
|
||||
if (CachedPlayer == null) throw new InvalidOperationException("CachedPlayer not initialized");
|
||||
|
||||
_applicationCts = _applicationCts.CancelRecreate();
|
||||
LastReceivedCharacterData = data.CharaData;
|
||||
|
||||
if (CachedPlayer == null)
|
||||
{
|
||||
_logger.LogDebug("Received Data for {uid} but CachedPlayer does not exist, waiting", data.User.UID);
|
||||
Task.Run(async () =>
|
||||
{
|
||||
using var timeoutCts = new CancellationTokenSource();
|
||||
timeoutCts.CancelAfter(TimeSpan.FromSeconds(120));
|
||||
var appToken = _applicationCts.Token;
|
||||
using var combined = CancellationTokenSource.CreateLinkedTokenSource(timeoutCts.Token, appToken);
|
||||
while (CachedPlayer == null && !combined.Token.IsCancellationRequested)
|
||||
{
|
||||
await Task.Delay(250, combined.Token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (!combined.IsCancellationRequested)
|
||||
{
|
||||
_logger.LogDebug("Applying delayed data for {uid}", data.User.UID);
|
||||
ApplyLastReceivedData();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
ApplyLastReceivedData();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue