Skip to content

Commit 2a8631c

Browse files
committed
Fix matches preemptively starting
1 parent 36056e0 commit 2a8631c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

RLBotCS/Main.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
if (args.Length > 0 && args[0] == "--version")
1010
{
11-
Console.WriteLine("RLBotServer v5.beta.6.9");
11+
Console.WriteLine("RLBotServer v5.beta.6.10");
1212
Environment.Exit(0);
1313
}
1414

RLBotCS/Server/BridgeHandler.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,20 @@ MatchStarter matchStarter
2323

2424
private async Task HandleInternalMessages()
2525
{
26+
bool isFirstTick = true;
27+
2628
await foreach (IBridgeMessage message in _context.Reader.ReadAllAsync())
2729
{
2830
lock (_context)
2931
{
32+
if (isFirstTick)
33+
{
34+
// Don't start reading messages until we receive the first message from Rocket League
35+
isFirstTick = false;
36+
Monitor.Wait(_context);
37+
_context.Logger.LogDebug("Started reading internal messages");
38+
}
39+
3040
try
3141
{
3242
message.HandleMessage(_context);
@@ -47,6 +57,8 @@ private async Task HandleServer()
4757

4858
_context.Logger.LogInformation("Connected to Rocket League");
4959

60+
bool isFirstTick = true;
61+
5062
await foreach (var messageClump in _context.Messenger.ReadAllAsync())
5163
{
5264
lock (_context)
@@ -147,6 +159,13 @@ private async Task HandleServer()
147159
}
148160

149161
_context.RenderingMgmt.SendRenderClears();
162+
163+
if (isFirstTick)
164+
{
165+
isFirstTick = false;
166+
// Trigger HandleInternalMessages to start processing messages
167+
Monitor.Pulse(_context);
168+
}
150169
}
151170
}
152171
}

0 commit comments

Comments
 (0)