]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - lhnet.c
CREDITS: Add name
[xonotic/darkplaces.git] / lhnet.c
diff --git a/lhnet.c b/lhnet.c
index 20781f820af82ef0c2b83eaf0da8cf32e8c8ac76..d043f81cf7cb9e69d3e1610a9ef6fcce6829567a 100644 (file)
--- a/lhnet.c
+++ b/lhnet.c
@@ -1,5 +1,5 @@
 
-// Written by Forest Hale 2003-06-15 and placed into public domain.
+// Written by Ashley Rose Hale (LadyHavoc) 2003-06-15 and placed into public domain.
 
 #ifdef WIN32
 #ifdef _MSC_VER
@@ -17,7 +17,7 @@
 #endif
 
 #ifndef STANDALONETEST
-#include "quakedef.h"
+#include "darkplaces.h"
 #endif
 
 #include <stdlib.h>
@@ -57,6 +57,9 @@
 #include "lhnet.h"
 
 #if defined(WIN32)
+// as of Visual Studio 2015, EWOULDBLOCK and ECONNREFUSED are real things, with different values than we want when talking to WinSock, so we have to undef them here or change the rest of the code.
+#undef EWOULDBLOCK
+#undef ECONNREFUSED
 #define EWOULDBLOCK WSAEWOULDBLOCK
 #define ECONNREFUSED WSAECONNREFUSED
 
@@ -311,7 +314,7 @@ int LHNETADDRESS_FromString(lhnetaddress_t *vaddress, const char *string, int de
 #ifdef STANDALONETEST
        if (i < MAX_NAMECACHE)
 #else
-       if (i < MAX_NAMECACHE && realtime < namecache[i].expirationtime)
+       if (i < MAX_NAMECACHE && host.realtime < namecache[i].expirationtime)
 #endif
        {
                *address = namecache[i].address;
@@ -333,7 +336,7 @@ int LHNETADDRESS_FromString(lhnetaddress_t *vaddress, const char *string, int de
                namecache[namecacheposition].name[i] = name[i];
        namecache[namecacheposition].name[i] = 0;
 #ifndef STANDALONETEST
-       namecache[namecacheposition].expirationtime = realtime + 12 * 3600; // 12 hours
+       namecache[namecacheposition].expirationtime = host.realtime + 12 * 3600; // 12 hours
 #endif
 
        // try resolving the address (handles dns and other ip formats)
@@ -446,7 +449,7 @@ int LHNETADDRESS_FromString(lhnetaddress_t *vaddress, const char *string, int de
 #ifdef STANDALONETEST
        if (i < MAX_NAMECACHE)
 #else
-       if (i < MAX_NAMECACHE && realtime < namecache[i].expirationtime)
+       if (i < MAX_NAMECACHE && host.realtime < namecache[i].expirationtime)
 #endif
        {
                *address = namecache[i].address;
@@ -482,7 +485,7 @@ int LHNETADDRESS_FromString(lhnetaddress_t *vaddress, const char *string, int de
                                namecache[namecacheposition].name[i] = name[i];
                        namecache[namecacheposition].name[i] = 0;
 #ifndef STANDALONETEST
-                       namecache[namecacheposition].expirationtime = realtime + 12 * 3600; // 12 hours
+                       namecache[namecacheposition].expirationtime = host.realtime + 12 * 3600; // 12 hours
 #endif
                        namecache[namecacheposition].address = *address;
                        namecacheposition = (namecacheposition + 1) % MAX_NAMECACHE;
@@ -505,7 +508,7 @@ int LHNETADDRESS_FromString(lhnetaddress_t *vaddress, const char *string, int de
                                namecache[namecacheposition].name[i] = name[i];
                        namecache[namecacheposition].name[i] = 0;
 #ifndef STANDALONETEST
-                       namecache[namecacheposition].expirationtime = realtime + 12 * 3600; // 12 hours
+                       namecache[namecacheposition].expirationtime = host.realtime + 12 * 3600; // 12 hours
 #endif
                        namecache[namecacheposition].address = *address;
                        namecacheposition = (namecacheposition + 1) % MAX_NAMECACHE;
@@ -523,7 +526,7 @@ int LHNETADDRESS_FromString(lhnetaddress_t *vaddress, const char *string, int de
                namecache[namecacheposition].name[i] = name[i];
        namecache[namecacheposition].name[i] = 0;
 #ifndef STANDALONETEST
-       namecache[namecacheposition].expirationtime = realtime + 12 * 3600; // 12 hours
+       namecache[namecacheposition].expirationtime = host.realtime + 12 * 3600; // 12 hours
 #endif
        namecache[namecacheposition].address.addresstype = LHNETADDRESSTYPE_NONE;
        namecacheposition = (namecacheposition + 1) % MAX_NAMECACHE;
@@ -966,9 +969,9 @@ lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address)
                                                                int rfc1149only = 0;
                                                                int rfc1149enabled = 0;
                                                                if(setsockopt(lhnetsocket->inetsocket, SOL_RFC1149, RFC1149_1149ONLY, &rfc1149only))
-                                                                       Con_Printf("LHNET_OpenSocket_Connectionless: warning: setsockopt(RFC1149_1149ONLY) returned error: %s\n", LHNETPRIVATE_StrError());
+                                                                       Con_Printf(CON_ERROR "LHNET_OpenSocket_Connectionless: warning: setsockopt(RFC1149_1149ONLY) returned error: %s\n", LHNETPRIVATE_StrError());
                                                                if(setsockopt(lhnetsocket->inetsocket, SOL_RFC1149, RFC1149_ENABLED, &rfc1149enabled))
-                                                                       Con_Printf("LHNET_OpenSocket_Connectionless: warning: setsockopt(RFC1149_ENABLED) returned error: %s\n", LHNETPRIVATE_StrError());
+                                                                       Con_Printf(CON_ERROR "LHNET_OpenSocket_Connectionless: warning: setsockopt(RFC1149_ENABLED) returned error: %s\n", LHNETPRIVATE_StrError());
                                                        }
 #endif
 
@@ -1107,7 +1110,7 @@ int LHNET_Read(lhnetsocket_t *lhnetsocket, void *content, int maxcontentlength,
                                continue;
                        }
 #ifndef STANDALONETEST
-                       if (cl_netlocalping.value && (realtime - cl_netlocalping.value * (1.0 / 2000.0)) < p->sentdoubletime)
+                       if (net_fakelag.value && (host.realtime - net_fakelag.value * (1.0 / 2000.0)) < p->sentdoubletime)
                                continue;
 #endif
                        if (value == 0 && p->destinationport == lhnetsocket->address.port)
@@ -1209,7 +1212,7 @@ int LHNET_Write(lhnetsocket_t *lhnetsocket, const void *content, int contentleng
                p->next->prev = p;
                p->prev->next = p;
 #ifndef STANDALONETEST
-               p->sentdoubletime = realtime;
+               p->sentdoubletime = host.realtime;
 #endif
                value = contentlength;
        }