{
for (n = start;n < end;n++)
{
+ serverlist_entry_t *entry = ServerList_GetViewEntry(n);
DrawQ_Fill(menu_x, menu_y + y, 640, 16, n == slist_cursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
- M_PrintColored(0, y, serverlist_viewlist[n]->line1);y += 8;
- M_PrintColored(0, y, serverlist_viewlist[n]->line2);y += 8;
+ M_PrintColored(0, y, entry->line1);y += 8;
+ M_PrintColored(0, y, entry->line2);y += 8;
}
}
else if (realtime - masterquerytime > 10)
case K_ENTER:
S_LocalSound ("sound/misc/menu2.wav");
if (serverlist_viewcount)
- Cbuf_AddText(va("connect \"%s\"\n", serverlist_viewlist[slist_cursor]->info.cname));
+ Cbuf_AddText(va("connect \"%s\"\n", ServerList_GetViewEntry(slist_cursor)->info.cname));
break;
default:
Con_Print("VM_M_getserverliststring: bad hostnr passed!\n");
return;
}
- cache = serverlist_viewlist[hostnr];
+ cache = ServerList_GetViewEntry(hostnr);
switch( (int) PRVM_G_FLOAT(OFS_PARM0) ) {
case SLIF_CNAME:
PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString( cache->info.cname );
Con_Print("VM_M_getserverliststring: bad hostnr passed!\n");
return;
}
- cache = serverlist_viewlist[hostnr];
+ cache = ServerList_GetViewEntry(hostnr);
switch( (int) PRVM_G_FLOAT(OFS_PARM0) ) {
case SLIF_MAXPLAYERS:
PRVM_G_FLOAT( OFS_RETURN ) = cache->info.maxplayers;
int serverlist_sortflags;
int serverlist_viewcount = 0;
-serverlist_entry_t *serverlist_viewlist[SERVERLIST_VIEWLISTSIZE];
+unsigned short serverlist_viewlist[SERVERLIST_VIEWLISTSIZE];
int serverlist_maxcachecount = 0;
int serverlist_cachecount = 0;
for( ; i > index ; i-- )
serverlist_viewlist[ i ] = serverlist_viewlist[ i - 1 ];
- serverlist_viewlist[index] = entry;
+ serverlist_viewlist[index] = (int)(entry - serverlist_cache);
}
/// we suppose serverlist_viewcount to be valid, ie > 0
// two special cases
// check whether to insert it as new first item
- if( _ServerList_Entry_Compare( entry, serverlist_viewlist[0] ) ) {
+ if( _ServerList_Entry_Compare( entry, ServerList_GetViewEntry(0) ) ) {
_ServerList_ViewList_Helper_InsertBefore( 0, entry );
return;
} // check whether to insert it as new last item
- else if( !_ServerList_Entry_Compare( entry, serverlist_viewlist[serverlist_viewcount - 1] ) ) {
+ else if( !_ServerList_Entry_Compare( entry, ServerList_GetViewEntry(serverlist_viewcount - 1) ) ) {
_ServerList_ViewList_Helper_InsertBefore( serverlist_viewcount, entry );
return;
}
{
mid = (start + end) / 2;
// test the item that lies in the middle between start and end
- if( _ServerList_Entry_Compare( entry, serverlist_viewlist[mid] ) )
+ if( _ServerList_Entry_Compare( entry, ServerList_GetViewEntry(mid) ) )
// the item has to be in the upper half
end = mid;
else
int i;
for( i = 0; i < serverlist_viewcount; i++ )
{
- if (serverlist_viewlist[i] == entry)
+ if (ServerList_GetViewEntry(i) == entry)
{
_ServerList_ViewList_Helper_Remove(i);
break;
serverlist_info_t info;
} serverlist_mask_t;
+#define ServerList_GetCacheEntry(x) (&serverlist_cache[(x)])
+#define ServerList_GetViewEntry(x) (ServerList_GetCacheEntry(serverlist_viewlist[(x)]))
+
extern serverlist_mask_t serverlist_andmasks[SERVERLIST_ANDMASKCOUNT];
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
+#if SERVERLIST_TOTALSIZE > 65536
+#error too many servers, change type of index array
+#endif
extern int serverlist_viewcount;
-extern serverlist_entry_t *serverlist_viewlist[SERVERLIST_VIEWLISTSIZE];
+extern unsigned short serverlist_viewlist[SERVERLIST_VIEWLISTSIZE];
extern int serverlist_cachecount;
+extern serverlist_entry_t *serverlist_cache;
extern qboolean serverlist_consoleoutput;