Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RLBotCS/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

if (args.Length > 0 && args[0] == "--version")
{
Console.WriteLine("RLBotServer v5.beta.6.9");
Console.WriteLine("RLBotServer v5.beta.6.10");
Environment.Exit(0);
}

Expand Down
20 changes: 20 additions & 0 deletions RLBotCS/Server/BridgeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,20 @@ class BridgeHandler(
MatchStarter matchStarter
)
{
private ManualResetEvent startReadingInternalMsgs = new ManualResetEvent(false);

private const int MAX_TICK_SKIP = 1;
private readonly BridgeContext _context = new(writer, reader, messenger, matchStarter);

private async Task HandleInternalMessages()
{
// if Rocket League is already running,
// we wait for it to connect to us first
if (LaunchManager.IsRocketLeagueRunningWithArgs())
startReadingInternalMsgs.WaitOne();

_context.Logger.LogDebug("Started reading internal messages");

await foreach (IBridgeMessage message in _context.Reader.ReadAllAsync())
{
lock (_context)
Expand All @@ -47,10 +56,21 @@ private async Task HandleServer()

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

bool isFirstTick = true;

await foreach (var messageClump in _context.Messenger.ReadAllAsync())
{
lock (_context)
{
if (isFirstTick)
{
isFirstTick = false;
// Trigger HandleInternalMessages to start processing messages
// it will still wait until we're done,
// since we have a lock on _context
startReadingInternalMsgs.Set();
}

// reset the counter that lets us know if we're sending too many bytes
// technically this resets every time Rocket League renders a frame,
// but we don't know when that is. Since every message from the game
Expand Down
1 change: 1 addition & 0 deletions RLBotCS/Server/ServerMessage/StartMatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public ServerAction Execute(ServerContext context)
Debug.Assert(ConfigValidator.Validate(MatchConfig));

context.Bridge.TryWrite(new ClearRenders());
context.Bridge.TryWrite(new EndMatch());

foreach (var (writer, _) in context.Sessions.Values)
writer.TryWrite(new SessionMessage.StopMatch(false));
Expand Down