#include "lhnet.h"
-#define NET_NAMELEN 128
-
-#define NET_MAXMESSAGE 65536
#define NET_HEADERSIZE (2 * sizeof(unsigned int))
-#define NET_DATAGRAMSIZE (MAX_DATAGRAM + NET_HEADERSIZE)
// NetHeader flags
#define NETFLAG_LENGTH_MASK 0x0000ffff
lhnetsocket_t *mysocket;
lhnetaddress_t peeraddress;
-
+
// this is mostly identical to qsocket_t from quake
// if this time is reached, kick off peer
int receiveMessageLength;
qbyte receiveMessage[NET_MAXMESSAGE];
- char address[NET_NAMELEN];
+ char address[128];
} netconn_t;
extern netconn_t *netconn_list;
extern char playername[];
extern int playercolor;
-#define HOSTCACHESIZE 128
+#define HOSTCACHE_TOTALSIZE 2048
+#define HOSTCACHE_VIEWCACHESIZE 128
+#define HOSTCACHE_ANDMASKCOUNT 5
+#define HOSTCACHE_ORMASKCOUNT 5
+typedef enum
+{
+ // HCMO_CONTAINS is the default for strings
+ // HCMO_GREATEREQUAL is the default for numbers (also used when OP == CONTAINS or NOTCONTAINS
+ HCMO_CONTAINS,
+ HCMO_NOTCONTAIN,
+
+ HCMO_LESSEQUAL,
+ HCMO_LESS,
+ HCMO_EQUAL,
+ HCMO_GREATER,
+ HCMO_GREATEREQUAL,
+ HCMO_NOTEQUAL
+} hostcache_maskop_t;
+
+// struct with all fields that you can search for or sort by
typedef struct
{
- // ping time for sorting servers
- double ping;
// address for connecting
char cname[128];
- // description (seen by user)
+ // ping time for sorting servers
+ int ping;
+ // name of the game
+ char game[32];
+ // name of the mod
+ char mod[32];
+ // name of the map
+ char map[32];
+ // name of the session
+ char name[128];
+ // max client number
+ int maxplayers;
+ // number of currently connected players
+ int numplayers;
+ // protocol version
+ int protocol;
+} hostcache_info_t;
+
+typedef enum
+{
+ HCIF_CNAME,
+ HCIF_PING,
+ HCIF_GAME,
+ HCIF_MOD,
+ HCIF_MAP,
+ HCIF_NAME,
+ HCIF_MAXPLAYERS,
+ HCIF_NUMPLAYERS,
+ HCIF_PROTOCOL,
+ HCIF_COUNT
+} hostcache_infofield_t;
+
+typedef struct
+{
+ // used to determine whether this entry should be included into the final view
+ qboolean finished;
+ // used to calculate ping when update comes in
+ double querytime;
+
+ hostcache_info_t info;
+
+ // legacy stuff
char line1[128];
char line2[128];
} hostcache_t;
-extern int hostCacheCount;
-extern hostcache_t hostcache[HOSTCACHESIZE];
+typedef struct
+{
+ qboolean active;
+ hostcache_maskop_t tests[HCIF_COUNT];
+ hostcache_info_t info;
+} hostcache_mask_t;
+
+extern hostcache_mask_t hostcache_andmasks[HOSTCACHE_ANDMASKCOUNT];
+extern hostcache_mask_t hostcache_ormasks[HOSTCACHE_ORMASKCOUNT];
+
+extern hostcache_infofield_t hostcache_sortbyfield;
+extern qboolean hostcache_sortdescending;
+
+extern int hostcache_viewcount;
+extern hostcache_t *hostcache_viewset[HOSTCACHE_VIEWCACHESIZE];
+
+extern int hostcache_cachecount;
+
+extern qboolean hostcache_consoleoutput;
#if !defined(_WIN32 ) && !defined (__linux__) && !defined (__sun__)
#ifndef htonl
//
//============================================================================
+extern double masterquerytime;
+extern int masterquerycount;
+extern int masterreplycount;
+extern int serverquerycount;
+extern int serverreplycount;
+
extern sizebuf_t net_message;
-extern cvar_t cl_fakelocalping_min;
-extern cvar_t cl_fakelocalping_max;
+extern cvar_t cl_netlocalping;
int NetConn_SendReliableMessage(netconn_t *conn, sizebuf_t *data);
//void NetConn_SendMessageNext(netconn_t *conn);
void Net_Stats_f(void);
void Net_Slist_f(void);
+// Hostcache interface
+// manually refresh the view set, do this after having changed the mask or any other flag
+void HostCache_RebuildViewSet(void);
+void HostCache_ResetMasks(void);
+void HostCache_QueryList(void);
+
#endif