]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - netconn.h
Cleaned up alot more memory leaks. (still get 720 leaks just running demo1.dem)
[xonotic/darkplaces.git] / netconn.h
index 9586fdcd65ba0abc54d8a328d7202f2963b46e6e..e5ab5e6e30e42426f6e27bce177c0311b0307e33 100755 (executable)
--- a/netconn.h
+++ b/netconn.h
@@ -24,11 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #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
@@ -120,7 +116,7 @@ typedef struct netconn_s
 
        lhnetsocket_t *mysocket;
        lhnetaddress_t peeraddress;
-
+       
        // this is mostly identical to qsocket_t from quake
 
        // if this time is reached, kick off peer
@@ -143,7 +139,7 @@ typedef struct netconn_s
        int receiveMessageLength;
        qbyte receiveMessage[NET_MAXMESSAGE];
 
-       char address[NET_NAMELEN];
+       char address[128];
 } netconn_t;
 
 extern netconn_t *netconn_list;
@@ -154,21 +150,96 @@ extern cvar_t developer_networking;
 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
@@ -191,8 +262,16 @@ extern unsigned short ntohs (unsigned short netshort);
 //
 //============================================================================
 
+extern double masterquerytime;
+extern int masterquerycount;
+extern int masterreplycount;
+extern int serverquerycount;
+extern int serverreplycount;
+
 extern sizebuf_t net_message;
 
+extern cvar_t cl_netlocalping;
+
 int NetConn_SendReliableMessage(netconn_t *conn, sizebuf_t *data);
 //void NetConn_SendMessageNext(netconn_t *conn);
 //void NetConn_ReSendMessage(netconn_t *conn);
@@ -221,5 +300,11 @@ int NetConn_SendToAll(sizebuf_t *data, double blocktime);
 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