From 1679c6dacd678a5fbf912a970c812db990ea6745 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Tue, 25 Oct 2022 21:09:38 +0200 Subject: [PATCH] Fix initial connection state --- src/client/component/network.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/client/component/network.cpp b/src/client/component/network.cpp index 1e0bf26b..80f45f90 100644 --- a/src/client/component/network.cpp +++ b/src/client/component/network.cpp @@ -83,10 +83,13 @@ namespace network server_addr.sin_addr.s_addr = address; server_addr.sin_port = port; - if (bind(s, reinterpret_cast(&server_addr), sizeof(server_addr)) == + int retries = 0; + while (bind(s, reinterpret_cast(&server_addr), sizeof(server_addr)) == SOCKET_ERROR) { - throw std::runtime_error("Failed to bind socket"); + if (++retries > 10) return; + server_addr.sin_port = htons(ntohs(server_addr.sin_port) + 1); + } } } } @@ -131,6 +134,8 @@ namespace network utils::hook::set(0x142332E55_g, 0); // clear local net id utils::hook::jump(0x142332E72_g, 0x142332E8E_g); // skip checksum parsing + utils::hook::set(0x14134C6E0_g, 4); // set initial connection state to "connecting" + // Fix netadr types //utils::hook::set(0x142332DE5_g, game::NA_RAWIP); // raw socket type //utils::hook::set(0x142332E00_g, game::NA_IP); // dw socket type