2018-08-04 19:00:19 +00:00
# ifndef CL_MASTER_H
# define CL_MASTER_H
2017-12-11 02:55:06 +00:00
enum masterprotocol_e
{
MP_UNSPECIFIED ,
MP_QUAKEWORLD ,
# if defined(Q2CLIENT) || defined(Q2SERVER)
MP_QUAKE2 ,
# endif
# if defined(Q3CLIENT) || defined(Q3SERVER)
MP_QUAKE3 ,
# endif
# ifdef NQPROT
MP_NETQUAKE ,
# endif
MP_DPMASTER
} ;
2004-08-23 00:15:46 +00:00
2018-12-28 00:04:36 +00:00
# if defined(CL_MASTER) && defined(HAVE_CLIENT)
2014-12-23 15:26:42 +00:00
# define SS_PROTOCOLMASK 0xf
# define SS_UNKNOWN 0
# define SS_QUAKEWORLD 1
# define SS_NETQUAKE 2
# define SS_DARKPLACES 3
# define SS_QUAKE2 4
# define SS_QUAKE3 5
//#define SS_UNUSED 6
//#define SS_UNUSED 7
# define SS_LOCAL (1<<3u) //local servers are ones we detected without being listed on a master server (masters will report public ips, so these may appear as dupes if they're also public)
# define SS_FTESERVER (1<<4u) //hehehe...
# define SS_FAVORITE (1<<5u) //filter all others.
# define SS_KEEPINFO (1<<6u)
# define SS_PROXY (1<<7u)
2004-08-23 00:15:46 +00:00
2018-04-15 02:48:23 +00:00
# define PING_DEAD 0xffff //default ping value to denote servers that are not responding.
2020-02-11 18:06:10 +00:00
# define PING_UNKNOWN 0xfffe //these servers are considered up, but we can't query them directly so can't determine the final ping from here.
# define PING_MAX 0xfffd //highest 'valid' ping value.
2018-04-15 02:48:23 +00:00
2004-08-23 00:15:46 +00:00
//despite not supporting nq or q2, we still load them. We just filter them. This is to make sure we properly write the listing files.
2013-10-29 17:38:22 +00:00
enum mastertype_e
{
2005-05-17 02:36:54 +00:00
MT_BAD , //this would be an error
2020-02-11 18:06:10 +00:00
// MT_MASTERHTTPJSON,
2013-10-29 17:38:22 +00:00
MT_MASTERHTTP ,
MT_MASTERUDP ,
MT_BCAST ,
MT_SINGLE ,
} ;
2004-08-23 00:15:46 +00:00
2018-05-21 13:47:53 +00:00
typedef enum hostcachekey_e
2013-10-29 17:38:22 +00:00
{
2005-05-13 10:42:48 +00:00
SLKEY_PING ,
SLKEY_MAP ,
SLKEY_NAME ,
SLKEY_ADDRESS ,
SLKEY_NUMPLAYERS ,
SLKEY_MAXPLAYERS ,
SLKEY_GAMEDIR ,
2006-02-28 00:46:04 +00:00
SLKEY_FREEPLAYERS ,
SLKEY_BASEGAME ,
2014-12-23 15:26:42 +00:00
SLKEY_FLAGS ,
2006-03-14 01:18:47 +00:00
SLKEY_TIMELIMIT ,
SLKEY_FRAGLIMIT ,
2006-02-28 00:46:04 +00:00
2008-11-09 22:29:28 +00:00
SLKEY_MOD ,
SLKEY_PROTOCOL ,
2015-06-22 11:49:15 +00:00
SLKEY_NUMBOTS , //uninteresting bots that will presumably get kicked if people join.
SLKEY_NUMSPECTATORS , //spectators
SLKEY_NUMHUMANS , //actual players
2008-11-09 22:29:28 +00:00
SLKEY_QCSTATUS ,
2018-09-29 17:31:58 +00:00
SLKEY_CATEGORY , //urgh, hideous shite.
2008-11-09 22:29:28 +00:00
// SLKEY_PLAYERS, //eep!
SLKEY_ISFAVORITE , //eep!
2014-12-23 15:26:42 +00:00
SLKEY_ISLOCAL ,
SLKEY_ISPROXY ,
2015-04-27 06:19:33 +00:00
SLKEY_SERVERINFO ,
2008-11-09 22:29:28 +00:00
2005-05-13 10:42:48 +00:00
SLKEY_TOOMANY ,
2015-04-27 06:19:33 +00:00
SLKEY_PLAYER0 ,
SLKEY_CUSTOM = SLKEY_PLAYER0 + MAX_CLIENTS
2005-05-13 10:42:48 +00:00
} hostcachekey_t ;
2018-05-21 13:47:53 +00:00
typedef enum slist_test_e
2013-10-29 17:38:22 +00:00
{
2005-05-13 10:42:48 +00:00
SLIST_TEST_CONTAINS ,
SLIST_TEST_NOTCONTAIN ,
SLIST_TEST_LESSEQUAL ,
SLIST_TEST_LESS ,
SLIST_TEST_EQUAL ,
SLIST_TEST_GREATER ,
SLIST_TEST_GREATEREQUAL ,
2013-03-12 22:35:33 +00:00
SLIST_TEST_NOTEQUAL ,
SLIST_TEST_STARTSWITH ,
SLIST_TEST_NOTSTARTSWITH
2005-05-13 10:42:48 +00:00
} slist_test_t ;
2004-08-23 00:15:46 +00:00
//contains info about a server in greater detail. Could be too mem intensive.
2013-10-29 17:38:22 +00:00
typedef struct serverdetailedinfo_s
{
2004-08-23 00:15:46 +00:00
char info [ MAX_SERVERINFO_STRING ] ;
int numplayers ;
2015-06-22 11:49:15 +00:00
struct serverdetailedplayerinfo_s
2013-10-29 17:38:22 +00:00
{
2004-08-23 00:15:46 +00:00
int userid ;
int frags ;
float time ;
int ping ;
char name [ 64 ] ;
2015-06-22 11:49:15 +00:00
char skin [ 16 ] ; //is this even useful?
2015-06-18 22:11:30 +00:00
char team [ 16 ] ;
2004-08-23 00:15:46 +00:00
char topc ;
2015-06-18 22:11:30 +00:00
char botc ;
2015-06-22 11:49:15 +00:00
qbyte isspec ;
2004-08-23 00:15:46 +00:00
} players [ MAX_CLIENTS ] ;
} serverdetailedinfo_t ;
//hold minimum info.
2013-10-29 17:38:22 +00:00
typedef struct serverinfo_s
{
2020-06-12 23:29:58 +00:00
char name [ 80 ] ; //hostname.
2004-08-23 00:15:46 +00:00
netadr_t adr ;
2020-02-11 18:06:10 +00:00
char brokerid [ 64 ] ; //'rtc[s]://adr//brokerid'
2004-08-23 00:15:46 +00:00
2015-05-03 19:57:46 +00:00
short special ; //flags
short protocol ;
2015-06-22 11:49:15 +00:00
qbyte players ;
qbyte maxplayers ;
2005-05-13 10:42:48 +00:00
qbyte sends ;
2018-12-28 00:04:36 +00:00
qbyte status ;
# define SRVSTATUS_ALIVE 1u //server is responding to pings
# define SRVSTATUS_DISPLAYED 2u //server passed all filters
# define SRVSTATUS_GLOBAL 4u //server was reported by one of the master servers (ie: global and not local)
2005-05-13 10:42:48 +00:00
2015-06-22 11:49:15 +00:00
qbyte numspectators ;
2008-11-09 22:29:28 +00:00
qbyte numhumans ;
qbyte numbots ;
qbyte freeslots ;
2018-09-29 17:31:58 +00:00
int qccategory ; //urgh
char qcstatus [ 128 ] ;
2008-11-09 22:29:28 +00:00
char modname [ 8 + 1 ] ;
char gamedir [ 8 + 1 ] ;
char map [ 16 ] ;
2020-08-13 08:39:48 +00:00
// unsigned short gameversion;
2005-05-13 10:42:48 +00:00
unsigned short ping ;
2004-08-23 00:15:46 +00:00
short tl ;
short fl ;
float refreshtime ;
serverdetailedinfo_t * moreinfo ;
2015-07-07 02:03:31 +00:00
struct serverinfo_s * prevpeer ;
unsigned short cost ;
unsigned short numpeers ;
struct peers_s
{
struct serverinfo_s * peer ;
unsigned short ping ;
} * peers ;
2004-08-23 00:15:46 +00:00
struct serverinfo_s * next ;
} serverinfo_t ;
2013-10-29 17:38:22 +00:00
typedef struct master_s
{
2004-08-23 00:15:46 +00:00
struct master_s * next ;
netadr_t adr ;
2012-11-27 03:23:19 +00:00
char * address ; //text based address (http servers)
struct dl_download * dl ;
2014-12-23 15:26:42 +00:00
qbyte nosave ;
2013-10-29 17:38:22 +00:00
qbyte mastertype ;
qbyte protocoltype ;
2011-06-16 02:03:57 +00:00
int sends ; /*needs to resend?*/
2004-08-23 00:15:46 +00:00
char name [ 1 ] ;
} master_t ;
2013-10-29 17:38:22 +00:00
extern struct selectedserver_s
{
2004-08-23 00:15:46 +00:00
qboolean inuse ;
netadr_t adr ;
2020-02-11 18:06:10 +00:00
char brokerid [ 64 ] ;
2015-06-28 03:43:10 +00:00
float refreshtime ;
2016-09-08 19:04:35 +00:00
int lastplayer ;
char lastrule [ 64 ] ;
2004-08-23 00:15:46 +00:00
serverdetailedinfo_t * detail ;
int linenum ;
} selectedserver ;
2013-10-29 17:38:22 +00:00
typedef struct player_s
{
2004-08-23 00:15:46 +00:00
char name [ 16 ] ;
int frags ;
int colour ;
char skin [ 8 ] ;
2015-06-18 22:11:30 +00:00
char team [ 8 ] ;
2004-08-23 00:15:46 +00:00
netadr_t adr ;
struct player_s * next ;
} player_t ;
void SListOptionChanged ( serverinfo_t * newserver ) ;
extern serverinfo_t * firstserver ;
extern master_t * master ;
extern player_t * mplayers ;
2017-12-09 21:22:46 +00:00
extern qboolean sb_favouriteschanged ;
2004-08-23 00:15:46 +00:00
2006-02-11 14:51:36 +00:00
void Master_SetupSockets ( void ) ;
2015-06-18 22:11:30 +00:00
qboolean CL_QueryServers ( void ) ;
2012-04-09 19:12:12 +00:00
int Master_CheckPollSockets ( void ) ;
2012-11-27 03:23:19 +00:00
void MasterInfo_Shutdown ( void ) ;
2017-12-09 21:22:46 +00:00
void MasterInfo_WriteServers ( void ) ;
2020-02-11 18:06:10 +00:00
serverinfo_t * Master_InfoForServer ( netadr_t * addr , const char * brokerid ) ;
2004-08-23 00:15:46 +00:00
serverinfo_t * Master_InfoForNum ( int num ) ;
2011-06-16 02:03:57 +00:00
unsigned int Master_TotalCount ( void ) ;
2016-07-12 00:40:13 +00:00
unsigned int Master_NumPolled ( void ) ; //progress indicator
unsigned int Master_NumAlive ( void ) ;
2005-10-07 16:27:20 +00:00
void Master_SetupSockets ( void ) ;
2018-05-06 16:09:07 +00:00
void MasterInfo_Refresh ( qboolean doreset ) ;
2004-08-23 00:15:46 +00:00
void Master_QueryServer ( serverinfo_t * server ) ;
2004-08-31 09:15:24 +00:00
void MasterInfo_WriteServers ( void ) ;
2020-02-11 18:06:10 +00:00
char * Master_ServerToString ( char * s , int len , serverinfo_t * a ) ; //like NET_AdrToString, but handles more complex addresses.
2005-05-13 10:42:48 +00:00
2018-05-21 13:47:53 +00:00
hostcachekey_t Master_KeyForName ( const char * keyname ) ;
float Master_ReadKeyFloat ( serverinfo_t * server , hostcachekey_t keynum ) ;
char * Master_ReadKeyString ( serverinfo_t * server , hostcachekey_t keynum ) ;
2005-05-13 10:42:48 +00:00
2018-05-21 13:47:53 +00:00
int Master_SortServers ( void ) ;
2005-05-13 10:42:48 +00:00
void Master_SetSortField ( hostcachekey_t field , qboolean descending ) ;
hostcachekey_t Master_GetSortField ( void ) ;
qboolean Master_GetSortDescending ( void ) ;
int Master_NumSorted ( void ) ;
void Master_ClearMasks ( void ) ;
serverinfo_t * Master_SortedServer ( int idx ) ;
2018-08-04 19:00:19 +00:00
void Master_SetMaskString ( qboolean or_ , hostcachekey_t field , const char * param , slist_test_t testop ) ;
void Master_SetMaskInteger ( qboolean or_ , hostcachekey_t field , int param , slist_test_t testop ) ;
2015-07-07 02:03:31 +00:00
serverinfo_t * Master_FindRoute ( netadr_t target ) ;
2017-12-11 02:55:06 +00:00
# endif
2018-08-04 19:00:19 +00:00
# endif