Windows libraries for getaddrinfo
authorhgn <hgodden00@gmail.com>
Wed, 10 Apr 2024 15:50:36 +0000 (16:50 +0100)
committerhgn <hgodden00@gmail.com>
Wed, 10 Apr 2024 15:50:36 +0000 (16:50 +0100)
build.c
network.c
skaterift.c

diff --git a/build.c b/build.c
index 5a078218b92914fd18cc3ff7bb10b04a8892f526..3cb9299dbe0b4d4cd9d86a7c54137d4fce465751 100644 (file)
--- a/build.c
+++ b/build.c
@@ -178,6 +178,11 @@ void build_game_bin( struct vg_project *proj )
             .custom_shaders = 1
          });
 
             .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 );
    vg_add_source( proj, "skaterift.c " );
    vg_add_controller_database( proj );
    vg_compile_project( proj );
index 4c9c61afd7424fb9e5d9fd66da47cacc3851e390..fdec386ccd62f0e884414ea860f5f28c4df67612 100644 (file)
--- a/network.c
+++ b/network.c
 #include "ent_region.h"
 #include "vg/vg_loader.h"
 
 #include "ent_region.h"
 #include "vg/vg_loader.h"
 
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netdb.h>
+#ifdef _WIN32
+ #include <winsock2.h>
+ #include <ws2tcpip.h>
+#else
+ #include <sys/socket.h>
+ #include <sys/types.h>
+ #include <netdb.h>
+#endif
 
 struct network_client network_client =
 {
 
 struct network_client network_client =
 {
@@ -613,7 +618,22 @@ static void network_resolve_host_thread( void *_ )
                         &hints, &result);
    if( s != 0 ) 
    {
                         &hints, &result);
    if( s != 0 ) 
    {
+#ifndef _WIN32
       vg_error( "getaddrinfo: %s\n", gai_strerror(s) );
       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;
    }
 
       goto end;
    }
 
index 27af1d10b9885d275a465fec250f3181b387a89b..756fcfe891c0cf9494f3e8b928afeade5939e119 100644 (file)
 
 #define SR_ALLOW_REWIND_HUB
 
 
 #define SR_ALLOW_REWIND_HUB
 
+#ifdef _WIN32
+ #include <winsock2.h>
+#endif
+
 /* 
  *     system headers
  * --------------------- */
 /* 
  *     system headers
  * --------------------- */