]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - libs/l_net/l_net_berkley.c
Wean off #define
[xonotic/netradiant.git] / libs / l_net / l_net_berkley.c
index 7e5a50e0045310caa3a4417238e701b33e7e33c2..f53f37e82bcd30c05c2c17ea31abb5f361c0dbc6 100644 (file)
 #include <unistd.h>
 #include <stdarg.h>
 #include <stdio.h>
-#define SOCKET_ERROR -1
-#define INVALID_SOCKET -1
+const int SOCKET_ERROR = -1;
+const int INVALID_SOCKET = -1;
 
 #define WinError WinPrint
 
-#define qtrue   1
-#define qfalse  0
-
 #define ioctlsocket ioctl
 #define closesocket close
 
@@ -80,9 +77,9 @@ typedef struct tag_error_struct
 
 static char my_tcpip_address[NET_NAMELEN];
 
-#define DEFAULTnet_hostport 26000
+const int DEFAULTnet_hostport = 26000;
 
-#define MAXHOSTNAMELEN      256
+const int MAXHOSTNAMELEN = 256;
 
 static int net_acceptsocket = -1;       // socket for fielding new connections
 static int net_controlsocket;
@@ -173,7 +170,10 @@ int WINS_Init( void ){
        // determine my name & address
        gethostname( buff, MAXHOSTNAMELEN );
        local = gethostbyname( buff );
-       myAddr = *(int *)local->h_addr_list[0];
+       if(local && local->h_addr_list && local->h_addr_list[0])
+               myAddr = *(int *)local->h_addr_list[0];
+       else
+               myAddr = inet_addr("127.0.0.1");
 
        // if the quake hostname isn't set, set it to the machine name
 //     if (Q_strcmp(hostname.string, "UNNAMED") == 0)