mp_serverlist.c File Reference

Serverlist management for multiplayer. More...

#include "../cl_shared.h"
#include "../cl_game.h"
#include "../ui/ui_main.h"
#include "../ui/ui_popup.h"
#include "../../shared/infostring.h"
#include "../../shared/parse.h"
#include "mp_serverlist.h"
#include "mp_callbacks.h"
#include <SDL_thread.h>
Include dependency graph for mp_serverlist.c:

Go to the source code of this file.

Defines

#define MAX_SERVERLIST   128
#define SERVERQUERYTIMEOUT   40000

Enumerations

enum  serverListStatus_t { SERVERLIST_SHOWALL, SERVERLIST_HIDEFULL, SERVERLIST_HIDEEMPTY }

Functions

static qboolean CL_ProcessPingReply (serverList_t *server, const char *msg)
 Parsed the server ping response.
static qboolean CL_ShowServer (const serverList_t *server)
 Perform the server filtering.
static void CL_PingServerCallback (struct net_stream *s)
 CL_PingServer.
static void CL_PingServer (serverList_t *server)
 Pings all servers in serverList.
void CL_PrintServerList_f (void)
 Prints all the servers on the list to game console.
static void CL_AddServerToList (const char *node, const char *service)
 Adds a server to the serverlist cache.
void CL_ParseTeamInfoMessage (struct dbuffer *msg)
 Team selection text.
void CL_ParseServerInfoMessage (struct dbuffer *msg, const char *hostname)
 Serverbrowser text.
static void CL_ServerInfoCallback (struct net_stream *s)
static int CL_QueryMasterServerThread (void *data)
static void CL_QueryMasterServer (void)
static void CL_ServerListDiscoveryCallback (struct datagram_socket *s, const char *buf, int len, struct sockaddr *from)
static void CL_BookmarkAdd_f (void)
 Add a new bookmark.
static void CL_ServerInfo_f (void)
static void CL_ServerListClick_f (void)
 Callback for bookmark nodes in multiplayer menu (mp_bookmarks).
void CL_PingServers_f (void)
 The first function called when entering the multiplayer menu, then CL_Frame takes over.
void MP_ServerListInit (void)
void MP_ServerListShutdown (void)

Variables

static serverList_t serverList [MAX_SERVERLIST]
serverList_tselectedServer
static char serverText [1024]
static int serverListLength
static int serverListPos
static cvar_tcl_serverlist
static char serverInfoText [1024]
static char userInfoText [256]
static SDL_Thread * masterServerQueryThread
static qboolean serversAlreadyQueried = qfalse
static int lastServerQuery = 0

Detailed Description

Serverlist management for multiplayer.

Serverlist management headers for multiplayer.

Definition in file mp_serverlist.c.


Define Documentation

#define MAX_SERVERLIST   128

Definition at line 36 of file mp_serverlist.c.

Referenced by CL_AddServerToList(), and CL_QueryMasterServerThread().

#define SERVERQUERYTIMEOUT   40000

ms until the server query timed out

Definition at line 539 of file mp_serverlist.c.

Referenced by CL_PingServers_f().


Enumeration Type Documentation

Enumerator:
SERVERLIST_SHOWALL 
SERVERLIST_HIDEFULL 
SERVERLIST_HIDEEMPTY 

Definition at line 85 of file mp_serverlist.c.


Function Documentation

static void CL_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 178 of file mp_serverlist.c.

References cl_genericPool, CL_PingServer(), i, MAX_SERVERLIST, Mem_PoolStrDup, serverList_s::node, serverListLength, and serverList_s::service.

Referenced by CL_QueryMasterServerThread(), and CL_ServerListDiscoveryCallback().

static void CL_BookmarkAdd_f ( void   )  [static]

Add a new bookmark.

bookmarks are saved in cvar adr[0-15]

Definition at line 447 of file mp_serverlist.c.

References _, Cmd_Argc(), Cmd_Argv(), Com_Printf(), Cvar_GetString(), Cvar_Set(), i, MAX_BOOKMARKS, UI_Popup(), and va().

Referenced by MP_ServerListInit().

void CL_ParseServerInfoMessage ( struct dbuffer msg,
const char *  hostname 
)
void CL_ParseTeamInfoMessage ( struct dbuffer msg  ) 

Team selection text.

This function fills the multiplayer_selectteam menu with content

See also:
NET_OOB_Printf
SVC_TeamInfo
CL_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 204 of file mp_serverlist.c.

References _, Com_DPrintf(), Cvar_SetValue(), DEBUG_CLIENT, Info_IntegerForKey(), Info_ValueForKey(), LIST_AddString(), MAX_TEAMS, teamData_s::maxPlayersPerTeam, teamData_s::maxteams, NET_ReadString(), TEAM_NO_ACTIVE, teamData_s::teamCount, teamData, TEXT_MULTIPLAYER_USERLIST, TEXT_MULTIPLAYER_USERTEAM, UI_ExecuteConfunc(), UI_RegisterLinkedListText(), UI_ResetData(), and va().

Referenced by CL_ConnectionlessPacket().

static void CL_PingServer ( serverList_t server  )  [static]
static void CL_PingServerCallback ( struct net_stream s  )  [static]
void CL_PingServers_f ( void   ) 
void CL_PrintServerList_f ( void   ) 

Prints all the servers on the list to game console.

Definition at line 162 of file mp_serverlist.c.

References Com_Printf(), i, and serverListLength.

Referenced by MP_ServerListInit().

static qboolean CL_ProcessPingReply ( serverList_t server,
const char *  msg 
) [static]

Parsed the server ping response.

Parameters:
[out] server The server data to store the parsed information in
[in] msg The 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 54 of file mp_serverlist.c.

References serverList_s::clients, Com_DPrintf(), DEBUG_CLIENT, serverList_s::gametype, Info_ValueForKey(), serverList_s::mapname, serverList_s::pinged, PROTOCOL_VERSION, Q_strncpyz(), qfalse, qtrue, serverList_s::sv_dedicated, serverList_s::sv_hostname, serverList_s::sv_maxclients, UFO_VERSION, and serverList_s::version.

Referenced by CL_PingServerCallback().

static void CL_QueryMasterServer ( void   )  [static]
See also:
CL_PingServers_f

Definition at line 420 of file mp_serverlist.c.

References CL_QueryMasterServerThread(), and masterServerQueryThread.

Referenced by CL_PingServers_f().

static int CL_QueryMasterServerThread ( void *  data  )  [static]
static void CL_ServerInfo_f ( void   )  [static]
static void CL_ServerInfoCallback ( struct net_stream s  )  [static]
static void CL_ServerListClick_f ( void   )  [static]

Callback for bookmark nodes in multiplayer menu (mp_bookmarks).

See also:
CL_ParseServerInfoMessage

Definition at line 512 of file mp_serverlist.c.

References Cbuf_AddText(), Cmd_Argc(), Cmd_Argv(), Com_Printf(), i, serverInfoText, serverListLength, serverListPos, TEXT_STANDARD, UI_RegisterText(), and va().

Referenced by MP_ServerListInit().

static void CL_ServerListDiscoveryCallback ( struct datagram_socket s,
const char *  buf,
int  len,
struct sockaddr *  from 
) [static]
See also:
SV_DiscoveryCallback

Definition at line 431 of file mp_serverlist.c.

References CL_AddServerToList(), match(), MAX_VAR, and NET_SockaddrToStrings().

Referenced by CL_PingServers_f().

static qboolean CL_ShowServer ( const serverList_t server  )  [inline, static]

Perform the server filtering.

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

Definition at line 96 of file mp_serverlist.c.

References serverList_s::clients, cvar_s::integer, qfalse, qtrue, SERVERLIST_HIDEEMPTY, SERVERLIST_HIDEFULL, SERVERLIST_SHOWALL, and serverList_s::sv_maxclients.

Referenced by CL_PingServerCallback().

void MP_ServerListInit ( void   ) 
void MP_ServerListShutdown ( void   ) 

Definition at line 610 of file mp_serverlist.c.

References Cmd_RemoveCommand(), and masterServerQueryThread.

Referenced by GAME_MP_Shutdown().


Variable Documentation

cvar_t* cl_serverlist [static]

Definition at line 43 of file mp_serverlist.c.

int lastServerQuery = 0 [static]

Definition at line 537 of file mp_serverlist.c.

Referenced by CL_PingServers_f().

SDL_Thread* masterServerQueryThread [static]

Definition at line 368 of file mp_serverlist.c.

Referenced by CL_QueryMasterServer(), and MP_ServerListShutdown().

Definition at line 39 of file mp_serverlist.c.

Referenced by CL_Connect_f().

char serverInfoText[1024] [static]

Definition at line 260 of file mp_serverlist.c.

Referenced by CL_ParseServerInfoMessage(), and CL_ServerListClick_f().

serverList_t serverList[MAX_SERVERLIST] [static]

Definition at line 38 of file mp_serverlist.c.

int serverListLength [static]
int serverListPos [static]

Definition at line 42 of file mp_serverlist.c.

Referenced by CL_PingServerCallback(), CL_PingServers_f(), and CL_ServerListClick_f().

qboolean serversAlreadyQueried = qfalse [static]

this is true if pingservers was already executed

Definition at line 536 of file mp_serverlist.c.

Referenced by CL_PingServers_f().

char serverText[1024] [static]

Definition at line 40 of file mp_serverlist.c.

Referenced by CL_PingServerCallback(), and CL_PingServers_f().

char userInfoText[256] [static]

Definition at line 261 of file mp_serverlist.c.

Referenced by CL_ParseServerInfoMessage().


Generated by  doxygen 1.6.2