//=============================================================================
/* SLIST MENU */
-static int slist_cursor;
+static unsigned slist_cursor;
void M_Menu_ServerList_f(cmd_state_t *cmd)
{
static void M_ServerList_Draw (void)
{
- int n, y, visible, start, end, statnumplayers, statmaxplayers;
+ unsigned n, y, visible, start, end, statnumplayers, statmaxplayers;
cachepic_t *p;
const char *s;
char vabuf[1024];
M_Background(640, vid_conheight.integer);
// scroll the list as the cursor moves
ServerList_GetPlayerStatistics(&statnumplayers, &statmaxplayers);
- s = va(vabuf, sizeof(vabuf), "%i/%i masters %i/%i servers %i/%i players", masterreplycount, masterquerycount, serverreplycount, serverquerycount, statnumplayers, statmaxplayers);
+ s = va(vabuf, sizeof(vabuf), "%u/%u masters %u/%u servers %u/%u players", masterreplycount, masterquerycount, serverreplycount, serverquerycount, statnumplayers, statmaxplayers);
M_PrintRed((640 - strlen(s) * 8) / 2, 32, s);
if (*m_return_reason)
M_Print(16, menu_height - 8, m_return_reason);
y = 48;
- visible = (int)((menu_height - 16 - y) / 8 / 2);
- start = bound(0, slist_cursor - (visible >> 1), serverlist_viewcount - visible);
+ visible = (menu_height - 16 - y) / 8 / 2;
+ start = min(slist_cursor - min(slist_cursor, visible >> 1), serverlist_viewcount - min(serverlist_viewcount, visible));
end = min(start + visible, serverlist_viewcount);
p = Draw_CachePic ("gfx/p_multi");
case K_LEFTARROW:
S_LocalSound ("sound/misc/menu1.wav");
slist_cursor--;
- if (slist_cursor < 0)
+ if (slist_cursor >= serverlist_viewcount)
slist_cursor = serverlist_viewcount - 1;
break;
extern cvar_t rcon_secure_challengetimeout;
double masterquerytime = -1000;
-int masterquerycount = 0;
-int masterreplycount = 0;
-int serverquerycount = 0;
-int serverreplycount = 0;
+unsigned masterquerycount = 0;
+unsigned masterreplycount = 0;
+unsigned serverquerycount = 0;
+unsigned serverreplycount = 0;
challenge_t challenges[MAX_CHALLENGES];
static double serverlist_querywaittime = 0;
#endif
-static int cl_numsockets;
+static unsigned cl_numsockets;
static lhnetsocket_t *cl_sockets[16];
-static int sv_numsockets;
+static unsigned sv_numsockets;
static lhnetsocket_t *sv_sockets[16];
netconn_t *netconn_list = NULL;
cvar_t net_address_ipv6 = {CF_CLIENT | CF_SERVER, "net_address_ipv6", "", "network address to open ipv6 ports on (if empty, use default interfaces)"};
char cl_net_extresponse[NET_EXTRESPONSE_MAX][1400];
-int cl_net_extresponse_count = 0;
-int cl_net_extresponse_last = 0;
+unsigned cl_net_extresponse_count = 0;
+unsigned cl_net_extresponse_last = 0;
char sv_net_extresponse[NET_EXTRESPONSE_MAX][1400];
-int sv_net_extresponse_count = 0;
-int sv_net_extresponse_last = 0;
+unsigned sv_net_extresponse_count = 0;
+unsigned sv_net_extresponse_last = 0;
#ifdef CONFIG_MENU
// ServerList interface
serverlist_mask_t serverlist_ormasks[SERVERLIST_ORMASKCOUNT];
serverlist_infofield_t serverlist_sortbyfield;
-int serverlist_sortflags;
+unsigned serverlist_sortflags;
-int serverlist_viewcount = 0;
-unsigned short serverlist_viewlist[SERVERLIST_VIEWLISTSIZE];
+unsigned serverlist_viewcount = 0;
+uint16_t serverlist_viewlist[SERVERLIST_VIEWLISTSIZE];
-int serverlist_maxcachecount = 0;
-int serverlist_cachecount = 0;
+unsigned serverlist_maxcachecount = 0;
+unsigned serverlist_cachecount = 0;
serverlist_entry_t *serverlist_cache = NULL;
qbool serverlist_consoleoutput;
-static int nFavorites = 0;
+static unsigned nFavorites = 0;
static lhnetaddress_t favorites[MAX_FAVORITESERVERS];
-static int nFavorites_idfp = 0;
+static unsigned nFavorites_idfp = 0;
static char favorites_idfp[MAX_FAVORITESERVERS][FP64_SIZE+1];
void NetConn_UpdateFavorites_c(cvar_t *var)
/// helper function to insert a value into the viewset
/// spare entries will be removed
-static void _ServerList_ViewList_Helper_InsertBefore( int index, serverlist_entry_t *entry )
+static void _ServerList_ViewList_Helper_InsertBefore(unsigned index, serverlist_entry_t *entry)
{
- int i;
+ unsigned i;
+
if( serverlist_viewcount < SERVERLIST_VIEWLISTSIZE ) {
i = serverlist_viewcount++;
} else {
}
/// we suppose serverlist_viewcount to be valid, ie > 0
-static void _ServerList_ViewList_Helper_Remove( int index )
+static inline void _ServerList_ViewList_Helper_Remove(unsigned index)
{
serverlist_viewcount--;
for( ; index < serverlist_viewcount ; index++ )
static void ServerList_ViewList_Insert( serverlist_entry_t *entry )
{
- int start, end, mid, i;
+ unsigned start, end, mid, i;
lhnetaddress_t addr;
// reject incompatible servers
static void ServerList_ViewList_Remove( serverlist_entry_t *entry )
{
- int i;
+ unsigned i;
+
for( i = 0; i < serverlist_viewcount; i++ )
{
if (ServerList_GetViewEntry(i) == entry)
void ServerList_RebuildViewList(void)
{
- int i;
+ unsigned i;
serverlist_viewcount = 0;
for( i = 0 ; i < serverlist_cachecount ; i++ ) {
serverlist_ormasks[i].info.numbots = -1;
}
-void ServerList_GetPlayerStatistics(int *numplayerspointer, int *maxplayerspointer)
+void ServerList_GetPlayerStatistics(unsigned *numplayerspointer, unsigned *maxplayerspointer)
{
- int i;
- int numplayers = 0, maxplayers = 0;
+ unsigned i;
+ unsigned numplayers = 0, maxplayers = 0;
+
for (i = 0;i < serverlist_cachecount;i++)
{
if (serverlist_cache[i].query == SQS_QUERIED)
void ServerList_QueryList(qbool resetcache, qbool querydp, qbool queryqw, qbool consoleoutput)
{
+ unsigned i;
+
masterquerytime = host.realtime;
masterquerycount = 0;
masterreplycount = 0;
else
{
// refresh all entries
- int n;
- for (n = 0; n < serverlist_cachecount; ++n)
+ for (i = 0; i < serverlist_cachecount; ++i)
{
- serverlist_entry_t *entry = &serverlist_cache[n];
+ serverlist_entry_t *entry = &serverlist_cache[i];
entry->query = SQS_REFRESHING;
entry->querycounter = 0;
}
int NetConn_Read(lhnetsocket_t *mysocket, void *data, int maxlength, lhnetaddress_t *peeraddress)
{
int length;
- int i;
+ unsigned i;
+
if (mysocket->address.addresstype == LHNETADDRESSTYPE_LOOP && netconn_mutex)
Thread_LockMutex(netconn_mutex);
length = LHNET_Read(mysocket, data, maxlength, peeraddress);
int NetConn_Write(lhnetsocket_t *mysocket, const void *data, int length, const lhnetaddress_t *peeraddress)
{
int ret;
- int i;
+ unsigned i;
+
if (net_fakeloss_send.integer)
for (i = 0;i < cl_numsockets;i++)
if (cl_sockets[i] == mysocket && (rand() % 100) < net_fakeloss_send.integer)
lhnetsocket_t *NetConn_ChooseClientSocketForAddress(lhnetaddress_t *address)
{
- int i, a = LHNETADDRESS_GetAddressType(address);
+ unsigned i;
+ lhnetaddresstype_t a = LHNETADDRESS_GetAddressType(address);
+
for (i = 0;i < cl_numsockets;i++)
if (cl_sockets[i] && LHNETADDRESS_GetAddressType(LHNET_AddressFromSocket(cl_sockets[i])) == a)
return cl_sockets[i];
lhnetsocket_t *NetConn_ChooseServerSocketForAddress(lhnetaddress_t *address)
{
- int i, a = LHNETADDRESS_GetAddressType(address);
+ unsigned i;
+ lhnetaddresstype_t a = LHNETADDRESS_GetAddressType(address);
+
for (i = 0;i < sv_numsockets;i++)
if (sv_sockets[i] && LHNETADDRESS_GetAddressType(LHNET_AddressFromSocket(sv_sockets[i])) == a)
return sv_sockets[i];
#ifdef CONFIG_MENU
static int NetConn_ClientParsePacket_ServerList_ProcessReply(const char *addressstring)
{
- int n;
+ unsigned n;
int pingtime;
serverlist_entry_t *entry = NULL;
// returns true, if it's sensible to continue the processing
static qbool NetConn_ClientParsePacket_ServerList_PrepareQuery(int protocol, const char *ipstring, qbool isfavorite)
{
- int n;
+ unsigned n;
serverlist_entry_t *entry;
// ignore the rest of the message if the serverlist is full
#ifdef CONFIG_MENU
void NetConn_QueryQueueFrame(void)
{
- int index;
- int queries;
- int maxqueries;
+ unsigned index;
+ unsigned queries, maxqueries;
double timeouttime;
static double querycounter = 0;
// each time querycounter reaches 1.0 issue a query
querycounter += cl.realframetime * net_slist_queriespersecond.value;
- maxqueries = (int)querycounter;
- maxqueries = bound(0, maxqueries, net_slist_queriesperframe.integer);
+ maxqueries = bound(0, (int)querycounter, net_slist_queriesperframe.integer);
querycounter -= maxqueries;
if (maxqueries == 0)
if (entry->querycounter != (unsigned)net_slist_maxtries.integer)
{
lhnetaddress_t address;
- int socket;
+ unsigned socket;
LHNETADDRESS_FromString(&address, entry->info.cname, 0);
if (entry->protocol == PROTOCOL_QUAKEWORLD)
void NetConn_ClientFrame(void)
{
- int i, length;
+ unsigned i;
+ int length;
lhnetaddress_t peeraddress;
unsigned char readbuffer[NET_HEADERSIZE+NET_MAXMESSAGE];
+
NetConn_UpdateSockets();
if (cls.connect_trying && cls.connect_nextsendtime < host.realtime)
{
void NetConn_ServerFrame(void)
{
- int i, length;
+ unsigned i;
+ int length;
lhnetaddress_t peeraddress;
unsigned char readbuffer[NET_HEADERSIZE+NET_MAXMESSAGE];
+
for (i = 0;i < sv_numsockets;i++)
while (sv_sockets[i] && (length = NetConn_Read(sv_sockets[i], readbuffer, sizeof(readbuffer), &peeraddress)) > 0)
NetConn_ServerParsePacket(sv_sockets[i], readbuffer, length, &peeraddress);
#ifdef CONFIG_MENU
void NetConn_QueryMasters(qbool querydp, qbool queryqw)
{
- int i, j;
- int masternum;
+ unsigned i, j;
+ unsigned masternum;
lhnetaddress_t masteraddress;
lhnetaddress_t broadcastaddress;
char request[256];
if (cl_sockets[i])
{
const char *cmdname, *extraoptions;
- int af = LHNETADDRESS_GetAddressType(LHNET_AddressFromSocket(cl_sockets[i]));
+ lhnetaddresstype_t af = LHNETADDRESS_GetAddressType(LHNET_AddressFromSocket(cl_sockets[i]));
if(LHNETADDRESS_GetAddressType(&broadcastaddress) == af)
{
{
if (cl_sockets[i])
{
- int af = LHNETADDRESS_GetAddressType(LHNET_AddressFromSocket(cl_sockets[i]));
+ lhnetaddresstype_t af = LHNETADDRESS_GetAddressType(LHNET_AddressFromSocket(cl_sockets[i]));
if(LHNETADDRESS_GetAddressType(&broadcastaddress) == af)
{
extern serverlist_mask_t serverlist_ormasks[SERVERLIST_ORMASKCOUNT];
extern serverlist_infofield_t serverlist_sortbyfield;
-extern int serverlist_sortflags; // not using the enum, as it is a bitmask
+extern unsigned serverlist_sortflags; // not using the enum, as it is a bitmask
#if SERVERLIST_TOTALSIZE > 65536
#error too many servers, change type of index array
#endif
-extern int serverlist_viewcount;
-extern unsigned short serverlist_viewlist[SERVERLIST_VIEWLISTSIZE];
+extern unsigned serverlist_viewcount;
+extern uint16_t serverlist_viewlist[SERVERLIST_VIEWLISTSIZE];
-extern int serverlist_cachecount;
+extern unsigned serverlist_cachecount;
extern serverlist_entry_t *serverlist_cache;
extern const serverlist_entry_t *serverlist_callbackentry;
-extern qbool serverlist_consoleoutput;
-
-void ServerList_GetPlayerStatistics(int *numplayerspointer, int *maxplayerspointer);
+void ServerList_GetPlayerStatistics(unsigned *numplayerspointer, unsigned *maxplayerspointer);
#endif
//============================================================================
//============================================================================
extern char cl_net_extresponse[NET_EXTRESPONSE_MAX][1400];
-extern int cl_net_extresponse_count;
-extern int cl_net_extresponse_last;
+extern unsigned cl_net_extresponse_count;
+extern unsigned cl_net_extresponse_last;
extern char sv_net_extresponse[NET_EXTRESPONSE_MAX][1400];
-extern int sv_net_extresponse_count;
-extern int sv_net_extresponse_last;
+extern unsigned sv_net_extresponse_count;
+extern unsigned sv_net_extresponse_last;
#ifdef CONFIG_MENU
extern double masterquerytime;
-extern int masterquerycount;
-extern int masterreplycount;
-extern int serverquerycount;
-extern int serverreplycount;
+extern unsigned masterquerycount;
+extern unsigned masterreplycount;
+extern unsigned serverquerycount;
+extern unsigned serverreplycount;
#endif
extern sizebuf_t cl_message;