UFO: Alien Invasion
Loading...
Searching...
No Matches
mp_serverlist.cpp File Reference

Serverlist management for multiplayer. More...

Include dependency graph for mp_serverlist.cpp:

Go to the source code of this file.

Macros

#define MAX_SERVERLIST   128
#define SERVERQUERYTIMEOUT   40000

Enumerations

enum  serverListStatus_t { SERVERLIST_SHOWALL , SERVERLIST_HIDEFULL , SERVERLIST_HIDEEMPTY }

Functions

static bool GAME_MP_ProcessPingReply (serverList_t *server, const char *msg)
 Parsed the server ping response.
static bool GAME_MP_ShowServer (const serverList_t *server)
 Perform the server filtering.
static void GAME_MP_PingServerCallback (struct net_stream *s)
static void GAME_MP_PingServer (serverList_t *server)
 Pings all servers in serverList.
static void GAME_MP_PrintServerList_f (void)
 Prints all the servers on the list to game console.
static void GAME_MP_AddServerToList (const char *node, const char *service)
 Adds a server to the serverlist cache.
void GAME_MP_ParseTeamInfoMessage (dbuffer *msg)
 Team selection text.
static void GAME_MP_ParseServerInfoMessage (dbuffer *msg, const char *hostname)
 Serverbrowser text.
static void GAME_MP_ServerInfoCallback (struct net_stream *s)
static void GAME_MP_QueryMasterServerThread (const char *responseBuf, void *userdata)
static void GAME_MP_ServerListDiscoveryCallback (struct datagram_socket *s, const char *buf, int len, struct sockaddr *from)
static void GAME_MP_BookmarkAdd_f (void)
 Add a new bookmark.
static void GAME_MP_ServerInfo_f (void)
static void GAME_MP_ServerListClick_f (void)
 Callback for bookmark nodes in multiplayer menu (mp_bookmarks).
void GAME_MP_PingServers_f (void)
 The first function called when entering the multiplayer menu, then CL_Frame takes over.
void GAME_MP_ServerListInit (const cgame_import_t *import)
void GAME_MP_ServerListShutdown (void)

Variables

static const cgame_import_tcgi
static serverList_t serverList [MAX_SERVERLIST]
serverList_tselectedServer
static char serverText [1024]
static int serverListLength
static int serverListPos
static cvar_tcl_serverlist
static struct datagram_socketnetDatagramSocket
static char serverInfoText [1024]
static char userInfoText [256]
static bool serversAlreadyQueried = false
static int lastServerQuery = 0
static const cmdList_t serverListCmds []

Detailed Description

Serverlist management for multiplayer.

Definition in file mp_serverlist.cpp.

Macro Definition Documentation

◆ MAX_SERVERLIST

#define MAX_SERVERLIST   128

Definition at line 34 of file mp_serverlist.cpp.

Referenced by GAME_MP_AddServerToList(), and GAME_MP_QueryMasterServerThread().

◆ SERVERQUERYTIMEOUT

#define SERVERQUERYTIMEOUT   40000

ms until the server query timed out

Definition at line 524 of file mp_serverlist.cpp.

Referenced by GAME_MP_PingServers_f().

Enumeration Type Documentation

◆ serverListStatus_t

Enumerator
SERVERLIST_SHOWALL 
SERVERLIST_HIDEFULL 
SERVERLIST_HIDEEMPTY 

Definition at line 86 of file mp_serverlist.cpp.

Function Documentation

◆ GAME_MP_AddServerToList()

void GAME_MP_AddServerToList ( const char * node,
const char * service )
static

Adds a server to the serverlist cache.

Returns
false if it is no valid address or server already exists
See also
CL_ParseStatusMessage

Definition at line 184 of file mp_serverlist.cpp.

References cgi, GAME_MP_PingServer(), i, MAX_SERVERLIST, OBJZERO, Q_streq, serverList, and serverListLength.

Referenced by GAME_MP_QueryMasterServerThread(), and GAME_MP_ServerListDiscoveryCallback().

◆ GAME_MP_BookmarkAdd_f()

void GAME_MP_BookmarkAdd_f ( void )
static

Add a new bookmark.

bookmarks are saved in cvar adr[0-15]

Definition at line 433 of file mp_serverlist.cpp.

References _, cgi, i, MAX_BOOKMARKS, and va().

◆ GAME_MP_ParseServerInfoMessage()

void GAME_MP_ParseServerInfoMessage ( dbuffer * msg,
const char * hostname )
static

Serverbrowser text.

See also
CL_PingServer
CL_PingServers_f
Note
This function fills the network browser server information with text
See also
NET_OOB_Printf
CL_ServerInfoCallback
SVC_Info

Definition at line 275 of file mp_serverlist.cpp.

References _, cgi, Com_Parse(), Com_sprintf(), DEBUG_CLIENT, Info_BoolForKey(), Info_ValueForKey(), MAX_INFO_STRING, Q_strcat(), Q_strncpyz(), Q_strnull(), S_COLOR_GREEN, serverInfoText, TEXT_LIST, TEXT_STANDARD, and userInfoText.

Referenced by GAME_MP_ServerInfoCallback().

◆ GAME_MP_ParseTeamInfoMessage()

void GAME_MP_ParseTeamInfoMessage ( dbuffer * msg)

Team selection text.

This function fills the multiplayer_selectteam menu with content

See also
NET_OOB_Printf
SVC_TeamInfo
GAME_MP_SelectTeam_Init_f
Todo
warning must not be into the player list. if we see this we are the first player that would be connected to the server

Definition at line 208 of file mp_serverlist.cpp.

References _, cgi, DEBUG_CLIENT, Info_IntegerForKey(), Info_ValueForKey(), MAX_TEAMS, OBJZERO, TEAM_NO_ACTIVE, teamData, TEXT_MULTIPLAYER_USERLIST, TEXT_MULTIPLAYER_USERTEAM, user, and va().

Referenced by GAME_MP_HandleServerCommand().

◆ GAME_MP_PingServer()

void GAME_MP_PingServer ( serverList_t * server)
static

Pings all servers in serverList.

See also
CL_AddServerToList
GAME_MP_ParseServerInfoMessage

Definition at line 153 of file mp_serverlist.cpp.

References cgi, DEBUG_CLIENT, GAME_MP_PingServerCallback(), serverList_t::node, PROTOCOL_VERSION, serverList_t::service, and SV_CMD_INFO.

Referenced by GAME_MP_AddServerToList().

◆ GAME_MP_PingServerCallback()

◆ GAME_MP_PingServers_f()

void GAME_MP_PingServers_f ( void )

The first function called when entering the multiplayer menu, then CL_Frame takes over.

See also
GAME_MP_ParseServerInfoMessage
Note
Use a parameter for pingservers to update the current serverlist

Definition at line 531 of file mp_serverlist.cpp.

References cgi, DEBUG_CLIENT, DOUBLEQUOTE, GAME_MP_QueryMasterServerThread(), GAME_MP_ServerListDiscoveryCallback(), i, lastServerQuery, netDatagramSocket, OBJZERO, PORT_CLIENT, PORT_SERVER, Q_streq, selectedServer, serverList, serverListLength, serverListPos, SERVERQUERYTIMEOUT, serversAlreadyQueried, serverText, and TEXT_LIST.

◆ GAME_MP_PrintServerList_f()

void GAME_MP_PrintServerList_f ( void )
static

Prints all the servers on the list to game console.

Definition at line 169 of file mp_serverlist.cpp.

References cgi, i, serverList_t::node, serverList_t::pinged, serverList, serverListLength, and serverList_t::service.

◆ GAME_MP_ProcessPingReply()

bool GAME_MP_ProcessPingReply ( serverList_t * server,
const char * msg )
static

Parsed the server ping response.

Parameters
[out]serverThe server data to store the parsed information in
[in]msgThe ping response with the server information to parse
See also
CL_PingServerCallback
SVC_Info
Returns
true if the server is compatible, msg is not null and the server wasn't pinged already, false otherwise

Definition at line 55 of file mp_serverlist.cpp.

References serverList_t::clients, Com_DPrintf(), DEBUG_CLIENT, serverList_t::gametype, Info_IntegerForKey(), Info_ValueForKey(), serverList_t::mapname, serverList_t::pinged, PROTOCOL_VERSION, Q_streq, Q_strncpyz(), serverList_t::sv_dedicated, serverList_t::sv_hostname, serverList_t::sv_maxclients, UFO_VERSION, and serverList_t::version.

Referenced by GAME_MP_PingServerCallback().

◆ GAME_MP_QueryMasterServerThread()

void GAME_MP_QueryMasterServerThread ( const char * responseBuf,
void * userdata )
static

◆ GAME_MP_ServerInfo_f()

void GAME_MP_ServerInfo_f ( void )
static
See also
CL_ServerInfoCallback

Definition at line 461 of file mp_serverlist.cpp.

References cgi, DOUBLEQUOTE, GAME_MP_ServerInfoCallback(), port, PORT_SERVER, PROTOCOL_VERSION, selectedServer, and SV_CMD_STATUS.

◆ GAME_MP_ServerInfoCallback()

void GAME_MP_ServerInfoCallback ( struct net_stream * s)
static

◆ GAME_MP_ServerListClick_f()

void GAME_MP_ServerListClick_f ( void )
static

Callback for bookmark nodes in multiplayer menu (mp_bookmarks).

See also
GAME_MP_ParseServerInfoMessage

Definition at line 498 of file mp_serverlist.cpp.

References cgi, i, selectedServer, serverInfoText, serverList, serverListLength, serverListPos, and TEXT_STANDARD.

◆ GAME_MP_ServerListDiscoveryCallback()

void GAME_MP_ServerListDiscoveryCallback ( struct datagram_socket * s,
const char * buf,
int len,
struct sockaddr * from )
static
See also
SV_DiscoveryCallback

Definition at line 417 of file mp_serverlist.cpp.

References cgi, GAME_MP_AddServerToList(), len, and MAX_VAR.

Referenced by GAME_MP_PingServers_f().

◆ GAME_MP_ServerListInit()

void GAME_MP_ServerListInit ( const cgame_import_t * import)

Definition at line 586 of file mp_serverlist.cpp.

References cgi, cl_serverlist, CVAR_ARCHIVE, i, MAX_BOOKMARKS, serverListCmds, and va().

Referenced by GAME_MP_InitStartup().

◆ GAME_MP_ServerListShutdown()

void GAME_MP_ServerListShutdown ( void )

Definition at line 597 of file mp_serverlist.cpp.

References cgi, netDatagramSocket, and serverListCmds.

Referenced by GAME_MP_Shutdown().

◆ GAME_MP_ShowServer()

bool GAME_MP_ShowServer ( const serverList_t * server)
inlinestatic

Perform the server filtering.

Parameters
[in]serverThe server data
Returns
true if the server should be visible for the current filter settings, false otherwise

Definition at line 97 of file mp_serverlist.cpp.

References cl_serverlist, serverList_t::clients, SERVERLIST_HIDEEMPTY, SERVERLIST_HIDEFULL, SERVERLIST_SHOWALL, and serverList_t::sv_maxclients.

Referenced by GAME_MP_PingServerCallback().

Variable Documentation

◆ cgi

const cgame_import_t* cgi
static

Definition at line 36 of file mp_serverlist.cpp.

◆ cl_serverlist

cvar_t* cl_serverlist
static

Definition at line 43 of file mp_serverlist.cpp.

Referenced by GAME_MP_ServerListInit(), and GAME_MP_ShowServer().

◆ lastServerQuery

int lastServerQuery = 0
static

Definition at line 522 of file mp_serverlist.cpp.

Referenced by GAME_MP_PingServers_f().

◆ netDatagramSocket

struct datagram_socket* netDatagramSocket
static

Definition at line 44 of file mp_serverlist.cpp.

Referenced by GAME_MP_PingServers_f(), and GAME_MP_ServerListShutdown().

◆ selectedServer

◆ serverInfoText

char serverInfoText[1024]
static

Definition at line 264 of file mp_serverlist.cpp.

Referenced by GAME_MP_ParseServerInfoMessage(), and GAME_MP_ServerListClick_f().

◆ serverList

◆ serverListCmds

const cmdList_t serverListCmds[]
static
Initial value:
= {
{"bookmark_add", GAME_MP_BookmarkAdd_f, "Add a new bookmark - see adrX cvars"},
{"server_info", GAME_MP_ServerInfo_f, nullptr},
{"serverlist", GAME_MP_PrintServerList_f, nullptr},
{"servers_click", GAME_MP_ServerListClick_f, nullptr},
{nullptr, nullptr, nullptr}
}
static void GAME_MP_BookmarkAdd_f(void)
Add a new bookmark.
static void GAME_MP_ServerListClick_f(void)
Callback for bookmark nodes in multiplayer menu (mp_bookmarks).
static void GAME_MP_ServerInfo_f(void)
static void GAME_MP_PrintServerList_f(void)
Prints all the servers on the list to game console.

Definition at line 578 of file mp_serverlist.cpp.

Referenced by GAME_MP_ServerListInit(), and GAME_MP_ServerListShutdown().

◆ serverListLength

◆ serverListPos

int serverListPos
static

◆ serversAlreadyQueried

bool serversAlreadyQueried = false
static

this is true if pingservers was already executed

Definition at line 521 of file mp_serverlist.cpp.

Referenced by GAME_MP_PingServers_f().

◆ serverText

char serverText[1024]
static

Definition at line 40 of file mp_serverlist.cpp.

Referenced by GAME_MP_PingServerCallback(), and GAME_MP_PingServers_f().

◆ userInfoText

char userInfoText[256]
static

Definition at line 265 of file mp_serverlist.cpp.

Referenced by GAME_MP_ParseServerInfoMessage().