UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
mp_serverlist.cpp File Reference

Serverlist management for multiplayer. More...

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. More...
 
static bool GAME_MP_ShowServer (const serverList_t *server)
 Perform the server filtering. More...
 
static void GAME_MP_PingServerCallback (struct net_stream *s)
 
static void GAME_MP_PingServer (serverList_t *server)
 Pings all servers in serverList. More...
 
static void GAME_MP_PrintServerList_f (void)
 Prints all the servers on the list to game console. More...
 
static void GAME_MP_AddServerToList (const char *node, const char *service)
 Adds a server to the serverlist cache. More...
 
void GAME_MP_ParseTeamInfoMessage (dbuffer *msg)
 Team selection text. More...
 
static void GAME_MP_ParseServerInfoMessage (dbuffer *msg, const char *hostname)
 Serverbrowser text. More...
 
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. More...
 
static void GAME_MP_ServerInfo_f (void)
 
static void GAME_MP_ServerListClick_f (void)
 Callback for bookmark nodes in multiplayer menu (mp_bookmarks) More...
 
void GAME_MP_PingServers_f (void)
 The first function called when entering the multiplayer menu, then CL_Frame takes over. More...
 
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

#define MAX_SERVERLIST   128

Definition at line 34 of file mp_serverlist.cpp.

Referenced by GAME_MP_AddServerToList(), and GAME_MP_QueryMasterServerThread().

#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

Enumerator
SERVERLIST_SHOWALL 
SERVERLIST_HIDEFULL 
SERVERLIST_HIDEEMPTY 

Definition at line 86 of file mp_serverlist.cpp.

Function Documentation

static 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 GAME_MP_PingServer(), cgame_import_s::GAME_StrDup(), i, MAX_SERVERLIST, serverList_s::node, OBJZERO, Q_streq, serverListLength, and serverList_s::service.

Referenced by GAME_MP_QueryMasterServerThread(), and GAME_MP_ServerListDiscoveryCallback().

static 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 _, cgame_import_s::Cmd_Argv(), cgame_import_s::Cvar_GetString(), cgame_import_s::Cvar_Set(), i, MAX_BOOKMARKS, and va().

static 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 _, Com_Parse(), Com_sprintf(), cgame_import_s::Cvar_Set(), 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().

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 _, DEBUG_CLIENT, Info_IntegerForKey(), Info_ValueForKey(), MAX_TEAMS, teamData_s::maxPlayersPerTeam, teamData_s::maxteams, OBJZERO, TEAM_NO_ACTIVE, teamData_s::teamCount, teamData, TEXT_MULTIPLAYER_USERLIST, TEXT_MULTIPLAYER_USERTEAM, user, and va().

Referenced by GAME_MP_HandleServerCommand().

static void GAME_MP_PingServer ( serverList_t server)
static
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 cgame_import_s::Cmd_Argv(), DEBUG_CLIENT, DOUBLEQUOTE, GAME_MP_QueryMasterServerThread(), GAME_MP_ServerListDiscoveryCallback(), i, lastServerQuery, cgame_import_s::NET_DatagramSocketNew(), OBJZERO, PORT_CLIENT, PORT_SERVER, Q_streq, serverListLength, serverListPos, SERVERQUERYTIMEOUT, serversAlreadyQueried, serverText, and TEXT_LIST.

static 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 i, serverList_s::node, serverList_s::pinged, serverListLength, and serverList_s::service.

static 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_s::clients, Com_DPrintf(), DEBUG_CLIENT, serverList_s::gametype, Info_IntegerForKey(), Info_ValueForKey(), serverList_s::mapname, serverList_s::pinged, PROTOCOL_VERSION, Q_streq, Q_strncpyz(), serverList_s::sv_dedicated, serverList_s::sv_hostname, serverList_s::sv_maxclients, UFO_VERSION, and serverList_s::version.

Referenced by GAME_MP_PingServerCallback().

static void GAME_MP_QueryMasterServerThread ( const char *  responseBuf,
void userdata 
)
static
static 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 cgame_import_s::Cmd_Argv(), i, serverInfoText, serverListLength, serverListPos, and TEXT_STANDARD.

static 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 GAME_MP_AddServerToList(), and MAX_VAR.

Referenced by GAME_MP_PingServers_f().

void GAME_MP_ServerListInit ( const cgame_import_t import)

Definition at line 586 of file mp_serverlist.cpp.

References CVAR_ARCHIVE, cgame_import_s::Cvar_Get(), i, MAX_BOOKMARKS, and va().

Referenced by GAME_MP_InitStartup().

void GAME_MP_ServerListShutdown ( void  )

Definition at line 597 of file mp_serverlist.cpp.

Referenced by GAME_MP_Shutdown().

static 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 serverList_s::clients, cvar_s::integer, SERVERLIST_HIDEEMPTY, SERVERLIST_HIDEFULL, SERVERLIST_SHOWALL, and serverList_s::sv_maxclients.

Referenced by GAME_MP_PingServerCallback().

Variable Documentation

const cgame_import_t* cgi
static

Definition at line 36 of file mp_serverlist.cpp.

cvar_t* cl_serverlist
static

Definition at line 43 of file mp_serverlist.cpp.

int lastServerQuery = 0
static

Definition at line 522 of file mp_serverlist.cpp.

Referenced by GAME_MP_PingServers_f().

struct datagram_socket* netDatagramSocket
static

Definition at line 44 of file mp_serverlist.cpp.

serverList_t* selectedServer

Definition at line 39 of file mp_serverlist.cpp.

Referenced by GAME_MP_Connect_f().

char serverInfoText[1024]
static

Definition at line 264 of file mp_serverlist.cpp.

Referenced by GAME_MP_ParseServerInfoMessage(), and GAME_MP_ServerListClick_f().

serverList_t serverList[MAX_SERVERLIST]
static

Definition at line 38 of file mp_serverlist.cpp.

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_PrintServerList_f(void)
Prints all the servers on the list to game console.
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_BookmarkAdd_f(void)
Add a new bookmark.

Definition at line 578 of file mp_serverlist.cpp.

int serverListPos
static
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().

char serverText[1024]
static

Definition at line 40 of file mp_serverlist.cpp.

Referenced by GAME_MP_PingServerCallback(), and GAME_MP_PingServers_f().

char userInfoText[256]
static

Definition at line 265 of file mp_serverlist.cpp.

Referenced by GAME_MP_ParseServerInfoMessage().