From 053a57cf4d1543e304b3fd99e8cb0b8d994792eb Mon Sep 17 00:00:00 2001 From: hgn Date: Wed, 10 Apr 2024 16:50:36 +0100 Subject: [PATCH 1/1] Windows libraries for getaddrinfo --- build.c | 5 +++++ network.c | 26 +++++++++++++++++++++++--- skaterift.c | 4 ++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/build.c b/build.c index 5a07821..3cb9299 100644 --- a/build.c +++ b/build.c @@ -178,6 +178,11 @@ void build_game_bin( struct vg_project *proj ) .custom_shaders = 1 }); + if( proj->env->platform == k_platform_windows ) + { + vg_link( proj, "-lws2_32 " ); + } + vg_add_source( proj, "skaterift.c " ); vg_add_controller_database( proj ); vg_compile_project( proj ); diff --git a/network.c b/network.c index 4c9c61a..fdec386 100644 --- a/network.c +++ b/network.c @@ -16,9 +16,14 @@ #include "ent_region.h" #include "vg/vg_loader.h" -#include -#include -#include +#ifdef _WIN32 + #include + #include +#else + #include + #include + #include +#endif struct network_client network_client = { @@ -613,7 +618,22 @@ static void network_resolve_host_thread( void *_ ) &hints, &result); if( s != 0 ) { +#ifndef _WIN32 vg_error( "getaddrinfo: %s\n", gai_strerror(s) ); +#endif + + if( !strcmp( network_client.host_adress, "skaterift.com" ) ) + { + vg_warn( "getaddrinfo failed for skaterift.com;\n " + "falling back to a hardcoded IPv4\n" ); + strcpy( network_client.host_adress, "46.101.34.155" ); + SteamAPI_SteamNetworkingIPAddr_ParseString( + &network_client.ip, + network_client.host_adress ); + network_client.ip.m_port = NETWORK_PORT; + *status = 1; + } + goto end; } diff --git a/skaterift.c b/skaterift.c index 27af1d1..756fcfe 100644 --- a/skaterift.c +++ b/skaterift.c @@ -13,6 +13,10 @@ #define SR_ALLOW_REWIND_HUB +#ifdef _WIN32 + #include +#endif + /* * system headers * --------------------- */ -- 2.25.1