Skip to content

Commit

Permalink
synced punch packets
Browse files Browse the repository at this point in the history
  • Loading branch information
Dazegambler committed Nov 15, 2024
1 parent 5360bbf commit fbeb48b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions th155r/Netcode/lobby.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,14 @@ int fastcall lobby_send_string_udp_send_hook_WELCOME2(
inet_pton(AF_INET, host, &((sockaddr_in*)&client_addr)->sin_addr);

DWORD idc;
auto now = std::chrono::high_resolution_clock::now();
auto duration = now.time_since_epoch();
auto now_ms = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
while(now_ms % 1000 != 0){
now = std::chrono::high_resolution_clock::now();
duration = now.time_since_epoch();
now_ms = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
}
for (size_t i = 0; i < 30; ++i) {
WSASendTo_log(sock, &PUNCH_BUF, 1, &idc, 0, (const sockaddr*)&client_addr, sizeof(sockaddr), NULL, NULL);
}
Expand Down Expand Up @@ -561,6 +569,14 @@ msvc_string* fastcall lobby_recv_welcome_hook(
inet_pton(AF_INET, host, &((sockaddr_in*)&client_addr)->sin_addr);

DWORD idc;
auto now = std::chrono::high_resolution_clock::now();
auto duration = now.time_since_epoch();
auto now_ms = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
while(now_ms % 1000 != 0){
now = std::chrono::high_resolution_clock::now();
duration = now.time_since_epoch();
now_ms = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
}
for (size_t i = 0; i < 30; ++i) {
WSASendTo_log(sock, &PUNCH_BUF, 1, &idc, 0, (const sockaddr*)&client_addr, sizeof(sockaddr), NULL, NULL);
}
Expand Down

0 comments on commit fbeb48b

Please sign in to comment.