]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - lhnet.c
now shows status messages in join game menu when a server is typed in manually (it...
[xonotic/darkplaces.git] / lhnet.c
diff --git a/lhnet.c b/lhnet.c
index 267dc462ee8a497b766fb1f3f7edbbeccf7d90d9..4b33180bb31b179ed9336f6892b0807c06435d16 100644 (file)
--- a/lhnet.c
+++ b/lhnet.c
@@ -24,6 +24,8 @@
 #include "sys.h"
 #include "netconn.h"
 #else
+#define Con_Print printf
+#define Con_Printf printf
 #define Z_Malloc malloc
 #define Z_Free free
 #endif
@@ -457,9 +459,15 @@ lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address)
                                        if (ioctl(lhnetsocket->inetsocket, FIONBIO, &_true) != -1)
 #endif
                                        {
-                                               if (bind(lhnetsocket->inetsocket, (void *)&lhnetsocket->address.addressdata, address->addresstype == LHNETADDRESSTYPE_INET6 ? sizeof(lhnetsocket->address.addressdata.inet6) : sizeof(lhnetsocket->address.addressdata.inet4)) != -1)
+#ifdef WIN32
+                                               int namelen;
+#else
+                                               socklen_t namelen;
+#endif
+                                               namelen = address->addresstype == LHNETADDRESSTYPE_INET6 ? sizeof(lhnetsocket->address.addressdata.inet6) : sizeof(lhnetsocket->address.addressdata.inet4);
+                                               if (bind(lhnetsocket->inetsocket, (void *)&lhnetsocket->address.addressdata, namelen) != -1)
                                                {
-                                                       getsockname(lhnetsocket->inetsocket, (void *)&lhnetsocket->address.addressdata, address->addresstype == LHNETADDRESSTYPE_INET6 ? sizeof(lhnetsocket->address.addressdata.inet6) : sizeof(lhnetsocket->address.addressdata.inet4));
+                                                       getsockname(lhnetsocket->inetsocket, (void *)&lhnetsocket->address.addressdata, &namelen);
                                                        lhnetsocket->next = &lhnet_socketlist;
                                                        lhnetsocket->prev = lhnetsocket->next->prev;
                                                        lhnetsocket->next->prev = lhnetsocket;
@@ -557,7 +565,7 @@ int LHNET_Read(lhnetsocket_t *lhnetsocket, void *content, int maxcontentlength,
                                continue;
                        }
 #ifndef STANDALONETEST
-                       if (p->sentdoubletime && Sys_DoubleTime() < p->sentdoubletime)
+                       if (cl_netlocalping.value && (Sys_DoubleTime() - cl_netlocalping.value * 1000.0) < p->sentdoubletime)
                                continue;
 #endif
                        if (value == 0 && p->destinationport == lhnetsocket->address.addressdata.loop.port)
@@ -673,8 +681,7 @@ int LHNET_Write(lhnetsocket_t *lhnetsocket, const void *content, int contentleng
                p->next->prev = p;
                p->prev->next = p;
 #ifndef STANDALONETEST
-               if (cl_fakelocalping_min.value || cl_fakelocalping_max.value)
-                       p->sentdoubletime = Sys_DoubleTime() + lhrandom(cl_fakelocalping_min.value, cl_fakelocalping_max.value) * (0.5 / 1000.0);
+               p->sentdoubletime = Sys_DoubleTime();
 #endif
                value = contentlength;
        }