]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - lhnet.c
made CL_ExpandEntities cause an error if called before cl_entities is initialized
[xonotic/darkplaces.git] / lhnet.c
diff --git a/lhnet.c b/lhnet.c
index 4b33180bb31b179ed9336f6892b0807c06435d16..8c9c845562355afcd9700d09b0ff12dc77d69510 100644 (file)
--- a/lhnet.c
+++ b/lhnet.c
@@ -8,13 +8,13 @@
 #ifdef WIN32
 #include <winsock.h>
 #else
-#include <netdb.h>
-#include <netinet/in.h>
-//#include <arpa/inet.h>
 #include <unistd.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <errno.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
 #endif
 
 // for Z_Malloc/Z_Free in quake
@@ -347,9 +347,9 @@ static const char *LHNETPRIVATE_StrError(void)
        int i = WSAGetLastError();
        switch (i)
        {
-               case WSAEINTR:           return "WSAEINTR";                                     
+               case WSAEINTR:           return "WSAEINTR";
                case WSAEBADF:           return "WSAEBADF";
-               case WSAEACCES:          return "WSAEACCES";          
+               case WSAEACCES:          return "WSAEACCES";
                case WSAEFAULT:          return "WSAEFAULT";
                case WSAEINVAL:          return "WSAEINVAL";
                case WSAEMFILE:          return "WSAEMFILE";
@@ -392,7 +392,7 @@ static const char *LHNETPRIVATE_StrError(void)
                case WSAEREMOTE:         return "WSAEREMOTE";
                case WSAEDISCON:         return "WSAEDISCON";
                case 0:                  return "no error";
-               default:                 return "unknown WSAE error";  
+               default:                 return "unknown WSAE error";
        }
 #else
        return strerror(errno);
@@ -467,7 +467,10 @@ lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address)
                                                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)
                                                {
+                                                       int i = 1;
                                                        getsockname(lhnetsocket->inetsocket, (void *)&lhnetsocket->address.addressdata, &namelen);
+                                                       // enable broadcast on this socket
+                                                       setsockopt(lhnetsocket->inetsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i));
                                                        lhnetsocket->next = &lhnet_socketlist;
                                                        lhnetsocket->prev = lhnetsocket->next->prev;
                                                        lhnetsocket->next->prev = lhnetsocket;
@@ -565,7 +568,7 @@ int LHNET_Read(lhnetsocket_t *lhnetsocket, void *content, int maxcontentlength,
                                continue;
                        }
 #ifndef STANDALONETEST
-                       if (cl_netlocalping.value && (Sys_DoubleTime() - cl_netlocalping.value * 1000.0) < p->sentdoubletime)
+                       if (cl_netlocalping.value && (Sys_DoubleTime() - cl_netlocalping.value * (1.0 / 1000.0)) < p->sentdoubletime)
                                continue;
 #endif
                        if (value == 0 && p->destinationport == lhnetsocket->address.addressdata.loop.port)