From 75e9c52ce850a6e919cc39274ac24d307c2ef151 Mon Sep 17 00:00:00 2001 From: SaltySnail Date: Sat, 28 Mar 2026 16:23:29 +0100 Subject: [PATCH] Rewrite accept code to not use continue --- src/TNetwork.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/TNetwork.cpp b/src/TNetwork.cpp index 6e5f51f..9c88dea 100644 --- a/src/TNetwork.cpp +++ b/src/TNetwork.cpp @@ -241,12 +241,14 @@ void TNetwork::TCPServerMain() { } ip::tcp::endpoint ClientEp; ip::tcp::socket ClientSocket = Acceptor.accept(ClientEp, ec); - if (ec) { + if (!ec) { + TConnection Conn { std::move(ClientSocket), ClientEp }; + std::thread ID(&TNetwork::Identify, this, std::move(Conn)); + ID.detach(); // TODO: Add to a queue and attempt to join periodically + } + else { beammp_errorf("Failed to accept() new client: {}", ec.message()); } - TConnection Conn { std::move(ClientSocket), ClientEp }; - std::thread ID(&TNetwork::Identify, this, std::move(Conn)); - ID.detach(); // TODO: Add to a queue and attempt to join periodically } catch (const std::exception& e) { beammp_errorf("Exception in accept routine: {}", e.what()); }