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>
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_t * | selectedServer |
static char | serverText [1024] |
static int | serverListLength |
static int | serverListPos |
static cvar_t * | cl_serverlist |
static char | serverInfoText [1024] |
static char | userInfoText [256] |
static SDL_Thread * | masterServerQueryThread |
static qboolean | serversAlreadyQueried = qfalse |
static int | lastServerQuery = 0 |
Serverlist management for multiplayer.
Serverlist management headers for multiplayer.
Definition in file mp_serverlist.c.
#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().
enum serverListStatus_t |
Definition at line 85 of file mp_serverlist.c.
static void CL_AddServerToList | ( | const char * | node, | |
const char * | service | |||
) | [static] |
Adds a server to the serverlist cache.
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 | |||
) |
Serverbrowser text.
Definition at line 271 of file mp_serverlist.c.
References _, COLORED_GREEN, Com_DPrintf(), Com_Parse(), Com_Printf(), Com_sprintf(), Cvar_Set(), DEBUG_CLIENT, FS_CheckFile(), Info_BoolForKey(), Info_ValueForKey(), MAX_INFO_STRING, NET_ReadString(), Q_strncpyz(), serverInfoText, TEXT_LIST, TEXT_STANDARD, UI_PushWindow(), UI_RegisterText(), userInfoText, and va().
Referenced by CL_ServerInfoCallback().
void CL_ParseTeamInfoMessage | ( | struct dbuffer * | msg | ) |
Team selection text.
This function fills the multiplayer_selectteam menu with content
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] |
Pings all servers in serverList.
Definition at line 145 of file mp_serverlist.c.
References CL_PingServerCallback(), Com_DPrintf(), Com_Printf(), DEBUG_CLIENT, NET_Connect(), NET_OOB_Printf(), NET_StreamSetCallback(), NET_StreamSetData(), serverList_s::node, PROTOCOL_VERSION, and serverList_s::service.
Referenced by CL_AddServerToList().
static void CL_PingServerCallback | ( | struct net_stream * | s | ) | [static] |
CL_PingServer.
Definition at line 111 of file mp_serverlist.c.
References CL_ProcessPingReply(), CL_ShowServer(), clc_oob, serverList_s::clients, Com_sprintf(), serverList_s::gametype, serverList_s::mapname, MAX_INFO_STRING, NET_ReadByte(), NET_ReadMsg(), NET_ReadString(), NET_ReadStringLine(), NET_StreamFree(), NET_StreamGetData(), Q_strcat(), serverListPos, serverList_s::serverListPos, serverText, serverList_s::sv_hostname, and serverList_s::sv_maxclients.
Referenced by CL_PingServer().
void CL_PingServers_f | ( | void | ) |
The first function called when entering the multiplayer menu, then CL_Frame takes over.
Definition at line 546 of file mp_serverlist.c.
References CL_Milliseconds(), CL_QueryMasterServer(), CL_ServerListDiscoveryCallback(), cls, Cmd_Argc(), Cmd_Argv(), Com_DPrintf(), DEBUG_CLIENT, DOUBLEQUOTE, i, lastServerQuery, Mem_Free, NET_DatagramBroadcast(), NET_DatagramSocketNew(), client_static_s::netDatagramSocket, PORT_CLIENT, PORT_SERVER, qfalse, qtrue, serverListLength, serverListPos, SERVERQUERYTIMEOUT, serversAlreadyQueried, serverText, TEXT_LIST, and UI_RegisterText().
Referenced by MP_CallbacksInit().
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.
[out] | server | The server data to store the parsed information in |
[in] | msg | The ping response with the server information to parse |
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] |
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] |
Definition at line 370 of file mp_serverlist.c.
References CL_AddServerToList(), Com_DPrintf(), Com_Parse(), Com_Printf(), DEBUG_CLIENT, HTTP_GetURL(), i, masterserver_url, MAX_SERVERLIST, MAX_VAR, Mem_Free, Q_strncpyz(), cvar_s::string, and va().
Referenced by CL_QueryMasterServer().
static void CL_ServerInfo_f | ( | void | ) | [static] |
Definition at line 475 of file mp_serverlist.c.
References CL_ServerInfoCallback(), Cmd_Argc(), Cmd_Argv(), Com_Printf(), Cvar_GetString(), DOUBLEQUOTE, NET_Connect(), NET_OOB_Printf(), NET_StreamSetCallback(), serverList_s::node, port, PORT_SERVER, PROTOCOL_VERSION, and serverList_s::service.
Referenced by MP_ServerListInit().
static void CL_ServerInfoCallback | ( | struct net_stream * | s | ) | [static] |
Definition at line 351 of file mp_serverlist.c.
References CL_ParseServerInfoMessage(), clc_oob, NET_ReadByte(), NET_ReadMsg(), NET_ReadStringLine(), NET_StreamFree(), NET_StreamPeerToName(), and qtrue.
Referenced by CL_ServerInfo_f().
static void CL_ServerListClick_f | ( | void | ) | [static] |
Callback for bookmark nodes in multiplayer menu (mp_bookmarks).
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] |
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.
[in] | server | The server data |
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 | ) |
Definition at line 594 of file mp_serverlist.c.
References CL_BookmarkAdd_f(), CL_PrintServerList_f(), CL_ServerInfo_f(), CL_ServerListClick_f(), Cmd_AddCommand(), CVAR_ARCHIVE, Cvar_Get(), i, MAX_BOOKMARKS, and va().
Referenced by GAME_MP_InitStartup().
void MP_ServerListShutdown | ( | void | ) |
Definition at line 610 of file mp_serverlist.c.
References Cmd_RemoveCommand(), and masterServerQueryThread.
Referenced by GAME_MP_Shutdown().
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] |
Definition at line 41 of file mp_serverlist.c.
Referenced by CL_AddServerToList(), CL_PingServers_f(), CL_PrintServerList_f(), and CL_ServerListClick_f().
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().