diff --git a/rehlds/common/enums.h b/rehlds/common/enums.h index 4f6021d..72f525c 100644 --- a/rehlds/common/enums.h +++ b/rehlds/common/enums.h @@ -16,12 +16,13 @@ #ifndef ENUMS_H #define ENUMS_H +// Used as array indexer typedef enum netsrc_s { - NS_CLIENT, + NS_CLIENT = 0, NS_SERVER, - NS_MULTICAST // xxxMO + NS_MULTICAST, // xxxMO + NS_MAX } netsrc_t; #endif - diff --git a/rehlds/engine/net_ws.cpp b/rehlds/engine/net_ws.cpp index 5774393..b074077 100644 --- a/rehlds/engine/net_ws.cpp +++ b/rehlds/engine/net_ws.cpp @@ -35,7 +35,7 @@ CRITICAL_SECTION net_cs; qboolean net_thread_initialized; loopback_t loopbacks[2]; -packetlag_t g_pLagData[3]; // List of lag structures, if fakelag is set. +packetlag_t g_pLagData[NS_MAX]; // List of lag structures, if fakelag is set. float gFakeLag; int net_configured; #ifdef _WIN32 @@ -63,21 +63,21 @@ netadr_t in_from; #endif #ifndef HOOK_ENGINE -SOCKET ip_sockets[3] = { INV_SOCK, INV_SOCK, INV_SOCK }; +SOCKET ip_sockets[NS_MAX] = { INV_SOCK, INV_SOCK, INV_SOCK }; #else -SOCKET ip_sockets[3]; +SOCKET ip_sockets[NS_MAX]; #endif #ifdef _WIN32 #ifndef HOOK_ENGINE -SOCKET ipx_sockets[3] = { INV_SOCK, INV_SOCK, INV_SOCK }; +SOCKET ipx_sockets[NS_MAX] = { INV_SOCK, INV_SOCK, INV_SOCK }; #else -SOCKET ipx_sockets[3]; +SOCKET ipx_sockets[NS_MAX]; #endif #endif // _WIN32 LONGPACKET gNetSplit; -net_messages_t *messages[3]; +net_messages_t *messages[NS_MAX]; net_messages_t *normalqueue; //void *hNetThread; //int32 dwNetThreadId; @@ -775,7 +775,7 @@ qboolean NET_LagPacket(qboolean newdata, netsrc_t sock, netadr_t *from, sizebuf_ packetlag_t *pPacket; float curtime; int ninterval; - static int losscount[3]; + static int losscount[NS_MAX]; if (gFakeLag <= 0.0) { @@ -1087,7 +1087,7 @@ DLL_EXPORT int NET_Sleep_Timeout(void) { SOCKET number = 0; - for (int sock = 0; sock < 3; sock++) + for (int sock = 0; sock < NS_MAX; sock++) { SOCKET net_socket = ip_sockets[sock]; if (net_socket != INV_SOCK) @@ -1108,12 +1108,12 @@ DLL_EXPORT int NET_Sleep_Timeout(void) number = net_socket; } #endif // _WIN32 - } - res = select((int)(number + 1), &fdset, 0, 0, &tv); + } + res = select((int)(number + 1), &fdset, NULL, NULL, &tv); } else { - res = select(0, 0, 0, 0, &tv); + res = select(0, NULL, NULL, NULL, &tv); } --numFrames; return res; @@ -1128,7 +1128,7 @@ int NET_Sleep(void) FD_ZERO(&fdset); number = 0; - for (int sock = 0; sock < 3; sock++) + for (int sock = 0; sock < NS_MAX; sock++) { SOCKET net_socket = ip_sockets[sock]; if (net_socket != INV_SOCK) @@ -1154,7 +1154,7 @@ int NET_Sleep(void) tv.tv_sec = 0; tv.tv_usec = 20 * 1000; - return select((int)(number + 1), &fdset, 0, 0, net_sleepforever == 0 ? &tv : NULL); + return select((int)(number + 1), &fdset, NULL, NULL, net_sleepforever == 0 ? &tv : NULL); } void NET_StartThread(void) @@ -1306,7 +1306,7 @@ void NET_AllocateQueues(void) void NET_FlushQueues(void) { - for (int i = 0; i < 3; i++) + for (int i = 0; i < NS_MAX; i++) { net_messages_t *p = messages[i]; while (p) @@ -1919,7 +1919,7 @@ void NET_Config(qboolean multiplayer) { NET_ThreadLock(); - for (int sock = 0; sock < 3; sock++) + for (int sock = 0; sock < NS_MAX; sock++) { if (ip_sockets[sock] != INV_SOCK) { @@ -2041,7 +2041,7 @@ void NET_Init(void) in_message.flags = 0; in_message.buffername = "in_message"; - for (int i = 0; i < 3; i++) + for (int i = 0; i < NS_MAX; i++) { g_pLagData[i].pPrev = &g_pLagData[i]; g_pLagData[i].pNext = &g_pLagData[i];