Fix initial connection state

This commit is contained in:
momo5502 2022-10-25 21:09:38 +02:00
parent 1517005793
commit 1679c6dacd

View File

@ -83,10 +83,13 @@ namespace network
server_addr.sin_addr.s_addr = address;
server_addr.sin_port = port;
if (bind(s, reinterpret_cast<sockaddr*>(&server_addr), sizeof(server_addr)) ==
int retries = 0;
while (bind(s, reinterpret_cast<sockaddr*>(&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<uint8_t>(0x142332E55_g, 0); // clear local net id
utils::hook::jump(0x142332E72_g, 0x142332E8E_g); // skip checksum parsing
utils::hook::set<uint32_t>(0x14134C6E0_g, 4); // set initial connection state to "connecting"
// Fix netadr types
//utils::hook::set<uint32_t>(0x142332DE5_g, game::NA_RAWIP); // raw socket type
//utils::hook::set<uint32_t>(0x142332E00_g, game::NA_IP); // dw socket type