increase timeouts
This commit is contained in:
@@ -195,16 +195,15 @@ namespace MareSynchronos.Utils
|
||||
return await _framework.RunOnFrameworkThread(func);
|
||||
}
|
||||
|
||||
public unsafe void WaitWhileCharacterIsDrawing(string name, IntPtr characterAddress, CancellationToken? ct = null)
|
||||
public unsafe void WaitWhileCharacterIsDrawing(string name, IntPtr characterAddress, int timeOut = 5000, CancellationToken? ct = null)
|
||||
{
|
||||
if (!_clientState.IsLoggedIn || characterAddress == IntPtr.Zero) return;
|
||||
|
||||
var obj = (GameObject*)characterAddress;
|
||||
const int maxWaitTime = 5000;
|
||||
const int tick = 250;
|
||||
int curWaitTime = 0;
|
||||
// ReSharper disable once LoopVariableIsNeverChangedInsideLoop
|
||||
while ((obj->RenderFlags & 0b100000000000) == 0b100000000000 && (!ct?.IsCancellationRequested ?? true) && curWaitTime < maxWaitTime) // 0b100000000000 is "still rendering" or something
|
||||
while ((obj->RenderFlags & 0b100000000000) == 0b100000000000 && (!ct?.IsCancellationRequested ?? true) && curWaitTime < timeOut) // 0b100000000000 is "still rendering" or something
|
||||
{
|
||||
Logger.Verbose($"Waiting for {name} to finish drawing");
|
||||
curWaitTime += tick;
|
||||
@@ -216,8 +215,6 @@ namespace MareSynchronos.Utils
|
||||
Thread.Sleep(tick);
|
||||
}
|
||||
|
||||
public void WaitWhileSelfIsDrawing(CancellationToken? token) => WaitWhileCharacterIsDrawing("self", _clientState.LocalPlayer?.Address ?? IntPtr.Zero, token);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_clientState.Login -= ClientStateOnLogin;
|
||||
|
||||
Reference in New Issue
Block a user