-using System.Threading;
using Content.Server.GameTicking;
using Content.Server.RoundEnd;
using Content.Shared.CCVar;
private void OnRoundEnd(RoundEndSystemChangedEvent ev)
{
- Interlocked.Increment(ref RoundCount);
+ RoundCount += 1;
}
}
async Task WaitForEvent()
{
- var timeout = Task.Delay(TimeSpan.FromSeconds(10));
- var currentCount = Thread.VolatileRead(ref sys.RoundCount);
- while (currentCount == Thread.VolatileRead(ref sys.RoundCount) && !timeout.IsCompleted)
+ const int maxTicks = 60;
+ var currentCount = sys.RoundCount;
+ for (var i = 0; i < maxTicks; i++)
{
- await pair.RunTicksSync(5);
+ if (currentCount != sys.RoundCount)
+ return;
+
+ await pair.RunTicksSync(1);
}
- if (timeout.IsCompleted) throw new TimeoutException("Event took too long to trigger");
+
+ throw new TimeoutException("Event took too long to trigger");
}
// Need to clean self up