Compare commits

...

6 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 d3daa6621c Add delay between handshake attempts 2026-08-12 04:26:44 +02:00
Tixx d38d8ffce3 Add t to TCP packets 2026-08-02 21:36:54 +02:00
2 changed files with 23 additions and 4 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ void ServerSend(std::string Data, bool Rel) {
C = Data.at(0);
if (C == 'O' || C == 'T')
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;
if (compressBound(Data.size()) > 1024)
Rel = true;
+21 -2
View File
@@ -7,6 +7,7 @@
#include "Network/network.hpp"
#include "Zlib/Compressor.h"
#include <stdexcept>
#include <thread>
#if defined(_WIN32)
#include <ws2tcpip.h>
@@ -21,12 +22,17 @@
#include "Logger.h"
#include <array>
#include <future>
#include <mutex>
#include <string>
SOCKET UDPSock = -1;
sockaddr_in* ToServer = nullptr;
std::mutex UDPSendMutex;
void UDPSend(std::string Data) {
std::scoped_lock lock(UDPSendMutex);
if (ClientID == -1 || UDPSock == -1)
return;
if (Data.length() > 400) {
@@ -78,6 +84,7 @@ void UDPRcv() {
Ret[Rcv] = 0;
UDPParser(std::string_view(Ret.data(), Rcv));
}
void UDPClientMain(const std::string& IP, int Port) {
#ifdef _WIN32
WSADATA data;
@@ -93,9 +100,16 @@ void UDPClientMain(const std::string& IP, int Port) {
ToServer->sin_port = htons(Port);
inet_pton(AF_INET, IP.c_str(), &ToServer->sin_addr);
UDPSock = socket(AF_INET, SOCK_DGRAM, 0);
if (!magic.empty())
for (int i = 0; i < 10; i++)
std::future<void> magicSend;
if (!magic.empty()) {
magicSend = std::async(std::launch::async, ([](){
for (int i = 0; i < 10; i++) {
UDPSend(magic);
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
}));
}
GameSend("P" + std::to_string(ClientID));
TCPSend("H", TCPSock);
UDPSend("p");
@@ -104,6 +118,11 @@ void UDPClientMain(const std::string& IP, int Port) {
UDPRcv();
}
debug("UDP receive loop done");
if (magicSend.valid()) {
magicSend.get();
}
KillSocket(UDPSock);
WSACleanup();
}