// for Z_Malloc/Z_Free in quake
#ifndef STANDALONETEST
+#include "quakedef.h"
#include "zone.h"
+#include "sys.h"
+#include "netconn.h"
#else
#define Z_Malloc malloc
#define Z_Free free
int sourceport;
int destinationport;
time_t timeout;
+#ifndef STANDALONETEST
+ double sentdoubletime;
+#endif
struct lhnetpacket_s *next, *prev;
}
lhnetpacket_t;
for (p = lhnet_packetlist.next;p != &lhnet_packetlist;p = pnext)
{
pnext = p->next;
+ if (p->timeout < currenttime)
+ {
+ // unlink and free
+ p->next->prev = p->prev;
+ p->prev->next = p->next;
+ Z_Free(p);
+ continue;
+ }
+#ifndef STANDALONETEST
+ if (p->sentdoubletime && Sys_DoubleTime() < p->sentdoubletime)
+ continue;
+#endif
if (value == 0 && p->destinationport == lhnetsocket->address.addressdata.loop.port)
{
if (p->length <= maxcontentlength)
p->prev->next = p->next;
Z_Free(p);
}
- else if (p->timeout < currenttime)
- {
- // unlink and free
- p->next->prev = p->prev;
- p->prev->next = p->next;
- Z_Free(p);
- }
}
}
else if (lhnetsocket->address.addresstype == LHNETADDRESSTYPE_INET4)
{
#ifdef WIN32
int e = WSAGetLastError();
- if (e == WSAEWOULDBLOCK || e == WSAECONNREFUSED)
+ if (e == WSAEWOULDBLOCK)
return 0;
+ switch (e)
+ {
+ case WSAECONNREFUSED:
+ Con_Printf("Connection refused\n");
+ return 0;
+ }
#else
- if (errno == EWOULDBLOCK || errno == ECONNREFUSED)
+ if (errno == EWOULDBLOCK)
return 0;
+ switch (errno)
+ {
+ case ECONNREFUSED:
+ Con_Printf("Connection refused\n");
+ return 0;
+ }
#endif
}
}
{
#ifdef WIN32
int e = WSAGetLastError();
- if (e == WSAEWOULDBLOCK || e == WSAECONNREFUSED)
+ if (e == WSAEWOULDBLOCK)
return 0;
+ switch (e)
+ {
+ case WSAECONNREFUSED:
+ Con_Printf("Connection refused\n");
+ return 0;
+ }
#else
- if (errno == EWOULDBLOCK || errno == ECONNREFUSED)
+ if (errno == EWOULDBLOCK)
return 0;
+ switch (errno)
+ {
+ case ECONNREFUSED:
+ Con_Printf("Connection refused\n");
+ return 0;
+ }
#endif
}
}
p->prev = p->next->prev;
p->next->prev = p;
p->prev->next = p;
+#ifndef STANDALONETEST
+ if (cl_fakelocalping_min.integer || cl_fakelocalping_max.integer)
+ p->sentdoubletime = Sys_DoubleTime() + (cl_fakelocalping_min.integer + ((cl_fakelocalping_max.integer - cl_fakelocalping_min.integer) * (rand() & 255) / 256)) / 1000.0;
+#endif
value = contentlength;
}
else if (lhnetsocket->address.addresstype == LHNETADDRESSTYPE_INET4)