]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added NetConn_SleepMicroseconds function, and LHNET_SleepUntilPacket_Microseconds...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 29 Mar 2007 00:33:16 +0000 (00:33 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 29 Mar 2007 00:33:16 +0000 (00:33 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7016 d7cf8633-e32d-0410-b094-e92efae38249

lhnet.c
lhnet.h
netconn.c
netconn.h

diff --git a/lhnet.c b/lhnet.c
index 4f820099e2e6e2efe3e6707a359fa6ea064d9552..b3f392d85e4a0280b750cb2e4fce40f525d6d169 100644 (file)
--- a/lhnet.c
+++ b/lhnet.c
@@ -495,6 +495,28 @@ static const char *LHNETPRIVATE_StrError(void)
 #endif
 }
 
+void LHNET_SleepUntilPacket_Microseconds(int microseconds)
+{
+       fd_set fdreadset;
+       struct timeval tv;
+       int lastfd;
+       lhnetsocket_t *s;
+       FD_ZERO(&fdreadset);
+       lastfd = 0;
+       for (s = lhnet_socketlist.next;s != &lhnet_socketlist;s = s->next)
+       {
+               if (s->address.addresstype == LHNETADDRESSTYPE_INET4 || s->address.addresstype == LHNETADDRESSTYPE_INET6)
+               {
+                       if (lastfd < s->inetsocket)
+                               lastfd = s->inetsocket;
+                       FD_SET(s->inetsocket, &fdreadset);
+               }
+       }
+       tv.tv_sec = microseconds / 1000000;
+       tv.tv_usec = microseconds % 1000000;
+       select(lastfd + 1, &fdreadset, NULL, NULL, &tv);
+}
+
 lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address)
 {
        lhnetsocket_t *lhnetsocket, *s;
diff --git a/lhnet.h b/lhnet.h
index 1d0de942b5d12651e8a6a6d6bb0a964931dc5e2e..c865f9a9835f51b0a2766fc67af9ed22914116f4 100644 (file)
--- a/lhnet.h
+++ b/lhnet.h
@@ -74,6 +74,7 @@ lhnetsocket_t;
 
 void LHNET_Init(void);
 void LHNET_Shutdown(void);
+void LHNET_SleepUntilPacket_Microseconds(int microseconds);
 lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address);
 void LHNET_CloseSocket(lhnetsocket_t *lhnetsocket);
 lhnetaddress_t *LHNET_AddressFromSocket(lhnetsocket_t *sock);
index cac6d1ad36074accfbdc3b531376f3c374e23353..8dec08692a15c9189f61edabb1b45eee055cdc08 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -2294,6 +2294,11 @@ void NetConn_ServerFrame(void)
        }
 }
 
+void NetConn_SleepMicroseconds(int microseconds)
+{
+       LHNET_SleepUntilPacket_Microseconds(microseconds);
+}
+
 void NetConn_QueryMasters(qboolean querydp, qboolean queryqw)
 {
        int i;
index f158e359eff47f0fe04f4878e636bb096000d175..9b54313d94599d13bf4eb1a35d71dbcba7edf94a 100755 (executable)
--- a/netconn.h
+++ b/netconn.h
@@ -350,6 +350,7 @@ int NetConn_WriteString(lhnetsocket_t *mysocket, const char *string, const lhnet
 int NetConn_IsLocalGame(void);
 void NetConn_ClientFrame(void);
 void NetConn_ServerFrame(void);
+void NetConn_SleepMicroseconds(int microseconds);
 void NetConn_QueryMasters(qboolean querydp, qboolean queryqw);
 void NetConn_Heartbeat(int priority);
 void NetConn_QueryQueueFrame(void);