Compare commits

..

5 Commits

Author SHA1 Message Date
Tixx 92cf7a9c67 Add parallel udp initialization (#269)
By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
2026-08-22 22:05:16 +02:00
Tixx 89f564f09d Add parallel udp initialization 2026-08-18 23:13:59 +02:00
Tixx 2bb5686c68 Add t to TCP packets (#266)
By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
2026-08-13 23:41:27 +02:00
SaltySnail f8c9fd7992 Add delay between handshake attempts (#268)
By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
2026-08-12 22:38:30 +02:00
Tixx d38d8ffce3 Add t to TCP packets 2026-08-02 21:36:54 +02:00
2 changed files with 20 additions and 5 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ void ServerSend(std::string Data, bool Rel) {
C = Data.at(0); C = Data.at(0);
if (C == 'O' || C == 'T') if (C == 'O' || C == 'T')
Ack = true; Ack = true;
if (C == 'N' || C == 'W' || C == 'Y' || C == 'V' || C == 'E' || C == 'C') if (C == 'N' || C == 'W' || C == 'Y' || C == 'V' || C == 'E' || C == 'C' || C == 't')
Rel = true; Rel = true;
if (compressBound(Data.size()) > 1024) if (compressBound(Data.size()) > 1024)
Rel = true; Rel = true;
+19 -4
View File
@@ -22,12 +22,17 @@
#include "Logger.h" #include "Logger.h"
#include <array> #include <array>
#include <future>
#include <mutex>
#include <string> #include <string>
SOCKET UDPSock = -1; SOCKET UDPSock = -1;
sockaddr_in* ToServer = nullptr; sockaddr_in* ToServer = nullptr;
std::mutex UDPSendMutex;
void UDPSend(std::string Data) { void UDPSend(std::string Data) {
std::scoped_lock lock(UDPSendMutex);
if (ClientID == -1 || UDPSock == -1) if (ClientID == -1 || UDPSock == -1)
return; return;
if (Data.length() > 400) { if (Data.length() > 400) {
@@ -79,6 +84,7 @@ void UDPRcv() {
Ret[Rcv] = 0; Ret[Rcv] = 0;
UDPParser(std::string_view(Ret.data(), Rcv)); UDPParser(std::string_view(Ret.data(), Rcv));
} }
void UDPClientMain(const std::string& IP, int Port) { void UDPClientMain(const std::string& IP, int Port) {
#ifdef _WIN32 #ifdef _WIN32
WSADATA data; WSADATA data;
@@ -94,11 +100,15 @@ void UDPClientMain(const std::string& IP, int Port) {
ToServer->sin_port = htons(Port); ToServer->sin_port = htons(Port);
inet_pton(AF_INET, IP.c_str(), &ToServer->sin_addr); inet_pton(AF_INET, IP.c_str(), &ToServer->sin_addr);
UDPSock = socket(AF_INET, SOCK_DGRAM, 0); UDPSock = socket(AF_INET, SOCK_DGRAM, 0);
std::future<void> magicSend;
if (!magic.empty()) { if (!magic.empty()) {
for (int i = 0; i < 10; i++) { magicSend = std::async(std::launch::async, ([](){
std::this_thread::sleep_for(std::chrono::milliseconds(10)); for (int i = 0; i < 10; i++) {
UDPSend(magic); UDPSend(magic);
} std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
}));
} }
GameSend("P" + std::to_string(ClientID)); GameSend("P" + std::to_string(ClientID));
TCPSend("H", TCPSock); TCPSend("H", TCPSock);
@@ -108,6 +118,11 @@ void UDPClientMain(const std::string& IP, int Port) {
UDPRcv(); UDPRcv();
} }
debug("UDP receive loop done"); debug("UDP receive loop done");
if (magicSend.valid()) {
magicSend.get();
}
KillSocket(UDPSock); KillSocket(UDPSock);
WSACleanup(); WSACleanup();
} }