sv_main.c File Reference

Main server code? More...

#include "server.h"
#include "../ports/system.h"
Include dependency graph for sv_main.c:

Go to the source code of this file.

Defines

#define SV_OUTPUTBUF_LENGTH   1024
#define HEARTBEAT_SECONDS   300

Functions

char * SV_GetConfigString (int index)
int SV_GetConfigStringInteger (int index)
char * SV_SetConfigString (int index,...)
client_tSV_GetNextClient (client_t *lastClient)
 Iterates through clients.
client_tSV_GetClient (int index)
void SV_DropClient (client_t *drop, const char *message)
 Called when the player is totally leaving the server, either willingly or unwillingly. This is NOT called if the entire server is quitting or crashing.
static void SVC_TeamInfo (struct net_stream *s)
 Responds with teaminfo such as free team num.
static void SVC_Status (struct net_stream *s)
 Responds with all the info that the server browser can see.
static void SVC_Info (struct net_stream *s)
 Responds with short info for broadcast scans.
static void SVC_DirectConnect (struct net_stream *stream)
 A connection request that did not come from the master.
static qboolean Rcon_Validate (const char *password)
 Checks whether the remote connection is allowed (rcon_password must be set on the server) - and verify the user given password with the cvar value.
static void SVC_RemoteCommand (struct net_stream *stream)
 A client issued an rcon command. Shift down the remaining args. Redirect all printfs.
static void SV_ConnectionlessPacket (struct net_stream *stream, struct dbuffer *msg)
 Handles a connectionless message from a client.
void SV_ReadPacket (struct net_stream *s)
static int Master_HeartbeatThread (void *data)
 Send a message to the master every few minutes to let it know we are alive, and log information.
static void Master_Heartbeat (void)
static void SV_CheckGameStart (void)
 If all connected clients have set their ready flag the server will spawn the clients and that change the client state.
void SV_Frame (int now, void *data)
static void Master_Shutdown (void)
 Informs all masters that this server is going down.
void SV_UserinfoChanged (client_t *cl)
 Pull specific info from a newly changed userinfo string into a more C friendly form.
static qboolean SV_CheckMaxSoldiersPerPlayer (cvar_t *cvar)
mapData_tSV_GetMapData (void)
mapTiles_tSV_GetMapTiles (void)
void SV_Init (void)
 Only called once at startup, not for each game.
static void SV_FinalMessage (const char *message, qboolean reconnect)
 Used by SV_Shutdown to send a final message to all connected clients before the server goes down.
void SV_Clear (void)
 Cleanup when the whole game process is shutting down.
void SV_Shutdown (const char *finalmsg, qboolean reconnect)
 Called when each game quits, before Sys_Quit or Sys_Error.
void SV_ShutdownWhenEmpty (void)
 Will eventually shutdown the server once all clients have disconnected.
int SV_CountPlayers (void)
 Returns the number of spawned players.

Variables

static cvar_trcon_password
static cvar_tsv_http_downloadserver
static cvar_tsv_enablemorale
static cvar_tsv_maxsoldiersperteam
static cvar_tsv_maxsoldiersperplayer
static cvar_tsv_hostname
static cvar_tsv_reconnect_limit
cvar_tsv_maxclients = NULL
cvar_tsv_dumpmapassembly
cvar_tsv_threads
cvar_tsv_public
cvar_tsv_mapname
memPool_tsv_genericPool
static char sv_outputbuf [SV_OUTPUTBUF_LENGTH]
static SDL_Thread * masterServerHeartBeatThread

Detailed Description

Main server code?

Definition in file sv_main.c.


Define Documentation

#define HEARTBEAT_SECONDS   300

Definition at line 513 of file sv_main.c.

Referenced by Master_Heartbeat().

#define SV_OUTPUTBUF_LENGTH   1024

Definition at line 416 of file sv_main.c.

Referenced by SVC_RemoteCommand().


Function Documentation

static void Master_Heartbeat ( void   )  [static]
static int Master_HeartbeatThread ( void *  data  )  [static]

Send a message to the master every few minutes to let it know we are alive, and log information.

Definition at line 521 of file sv_main.c.

References Com_DPrintf(), Com_Printf(), DEBUG_SERVER, HTTP_GetURL(), masterserver_url, masterServerHeartBeatThread, Mem_Free, port, cvar_s::string, and va().

Referenced by Master_Heartbeat().

static void Master_Shutdown ( void   )  [static]

Informs all masters that this server is going down.

Definition at line 646 of file sv_main.c.

References Com_DPrintf(), DEBUG_SERVER, HTTP_GetURL(), cvar_s::integer, masterserver_url, Mem_Free, port, cvar_s::string, sv_dedicated, and va().

Referenced by SV_Shutdown().

static qboolean Rcon_Validate ( const char *  password  )  [inline, static]

Checks whether the remote connection is allowed (rcon_password must be set on the server) - and verify the user given password with the cvar value.

Definition at line 403 of file sv_main.c.

References qfalse, qtrue, and cvar_s::string.

Referenced by SVC_RemoteCommand().

static void SV_CheckGameStart ( void   )  [static]

If all connected clients have set their ready flag the server will spawn the clients and that change the client state.

See also:
SV_Spawn_f

Definition at line 568 of file sv_main.c.

References cl, cs_began, cs_free, cvar_s::integer, player_s::isReady, client_s::player, qtrue, serverInstanceGame_t::started, client_s::state, sv, SV_ClientCommand(), SV_GetClient(), and SV_GetNextClient().

Referenced by SV_Frame().

static qboolean SV_CheckMaxSoldiersPerPlayer ( cvar_t cvar  )  [static]

Definition at line 691 of file sv_main.c.

References Cvar_AssertValue(), MAX_ACTIVETEAM, and qtrue.

Referenced by SV_Init().

void SV_Clear ( void   ) 

Cleanup when the whole game process is shutting down.

See also:
SV_Shutdown
Com_Quit

Definition at line 781 of file sv_main.c.

References SV_MapcycleClear().

Referenced by Com_Quit().

static void SV_ConnectionlessPacket ( struct net_stream stream,
struct dbuffer msg 
) [static]

Handles a connectionless message from a client.

See also:
NET_OOB_Printf
Parameters:
[out] stream The stream to write to
msg The message buffer to read the connectionless data from

Definition at line 462 of file sv_main.c.

References Cmd_Argv(), Cmd_TokenizeString(), Com_DPrintf(), Com_Printf(), DEBUG_SERVER, NET_ReadStringLine(), NET_StreamPeerToName(), qfalse, qtrue, SVC_DirectConnect(), SVC_Info(), SVC_RemoteCommand(), SVC_Status(), and SVC_TeamInfo().

Referenced by SV_ReadPacket().

int SV_CountPlayers ( void   ) 

Returns the number of spawned players.

See also:
SV_ShutdownWhenEmpty

Definition at line 851 of file sv_main.c.

References cl, count, cs_spawned, serverInstanceStatic_t::initialized, client_s::state, SV_GetNextClient(), and svs.

Referenced by Sys_ConsoleProc().

void SV_DropClient ( client_t drop,
const char *  message 
)
static void SV_FinalMessage ( const char *  message,
qboolean  reconnect 
) [static]

Used by SV_Shutdown to send a final message to all connected clients before the server goes down.

See also:
SV_Shutdown

Definition at line 751 of file sv_main.c.

References cl, cs_connected, free_dbuffer(), NET_StreamFinished(), NET_Wait(), NET_WriteByte(), NET_WriteConstMsg(), NET_WriteString(), new_dbuffer(), client_s::state, client_s::stream, SV_GetNextClient(), svc_disconnect, and svc_reconnect.

Referenced by SV_Shutdown().

void SV_Frame ( int  now,
void *  data 
)
client_t* SV_GetClient ( int  index  ) 

Definition at line 126 of file sv_main.c.

References serverInstanceStatic_t::clients, and svs.

Referenced by SV_CheckGameStart(), SV_New_f(), SV_PlayerPrintf(), and SVC_DirectConnect().

char* SV_GetConfigString ( int  index  ) 
int SV_GetConfigStringInteger ( int  index  ) 

Definition at line 58 of file sv_main.c.

References Com_Error(), serverInstanceGame_t::configstrings, ERR_FATAL, MAX_CONFIGSTRINGS, and sv.

Referenced by SV_Map(), and SV_Status_f().

mapData_t* SV_GetMapData ( void   ) 

Definition at line 697 of file sv_main.c.

References serverInstanceGame_t::mapData, and sv.

Referenced by CL_RequestNextDownload().

mapTiles_t* SV_GetMapTiles ( void   ) 

Definition at line 702 of file sv_main.c.

References serverInstanceGame_t::mapTiles, and sv.

Referenced by CL_RequestNextDownload().

client_t* SV_GetNextClient ( client_t lastClient  ) 

Iterates through clients.

Parameters:
[in] lastClient Pointer of the client to iterate from. call with NULL to get the first one.

Definition at line 104 of file sv_main.c.

References serverInstanceStatic_t::clients, cvar_s::integer, and svs.

Referenced by SV_BroadcastPrintf(), SV_CheckGameStart(), SV_CountPlayers(), SV_DropClient(), SV_FinalMessage(), SV_GetPlayerClientStructure(), SV_Map(), SV_Multicast(), SV_StartGame_f(), SV_Status_f(), SVC_DirectConnect(), SVC_Info(), SVC_Status(), and SVC_TeamInfo().

void SV_Init ( void   ) 
void SV_ReadPacket ( struct net_stream s  ) 
char* SV_SetConfigString ( int  index,
  ... 
)
void SV_Shutdown ( const char *  finalmsg,
qboolean  reconnect 
)

Called when each game quits, before Sys_Quit or Sys_Error.

Parameters:
[in] finalmsg The message all clients get as server shutdown message
[in] reconnect True if this is only a restart (new map or map restart), false if the server shutdown completely and you also want to disconnect all clients

Definition at line 792 of file sv_main.c.

References serverInstanceStatic_t::clients, Com_Printf(), CVAR_LATCH, CVAR_NOSET, cvar_s::flags, i, serverInstanceStatic_t::initialized, Master_Shutdown(), Mem_Free, sv_model_s::name, NET_DatagramSocketClose(), serverInstanceStatic_t::netDatagramSocket, serverInstanceGame_t::numSVModels, serverInstanceStatic_t::serverMutex, sv, SV_FinalMessage(), SV_ShutdownGameProgs(), SV_Stop(), serverInstanceGame_t::svModels, and svs.

void SV_ShutdownWhenEmpty ( void   ) 

Will eventually shutdown the server once all clients have disconnected.

See also:
SV_CountPlayers

Definition at line 840 of file sv_main.c.

References serverInstanceStatic_t::abandon, Com_SetServerState(), qtrue, ss_dead, and svs.

Referenced by CL_Disconnect_f().

void SV_UserinfoChanged ( client_t cl  ) 

Pull specific info from a newly changed userinfo string into a more C friendly form.

Definition at line 667 of file sv_main.c.

References Com_DPrintf(), DEBUG_SERVER, serverInstanceStatic_t::ge, i, Info_ValueForKey(), client_s::messagelevel, client_s::name, client_s::player, serverInstanceStatic_t::serverMutex, svs, and client_s::userinfo.

Referenced by SV_ExecuteClientMessage(), and SVC_DirectConnect().

static void SVC_DirectConnect ( struct net_stream stream  )  [static]
static void SVC_Info ( struct net_stream s  )  [static]

Responds with short info for broadcast scans.

Note:
The second parameter should be the current protocol version number.
Only a short server description - the user can determine whether he is interested in a full status
See also:
CL_ParseStatusMessage
CL_ProcessPingReply

Definition at line 249 of file sv_main.c.

References cl, Cmd_Argv(), Com_DPrintf(), Com_sprintf(), count, cs_spawning, DEBUG_SERVER, DOUBLEQUOTE, Info_SetValueForKey(), Info_SetValueForKeyAsInteger(), cvar_s::integer, MAX_INFO_STRING, MAX_VAR, serverInstanceGame_t::name, NET_OOB_Printf(), PROTOCOL_VERSION, client_s::state, cvar_s::string, sv, sv_dedicated, sv_gametype, SV_GetNextClient(), and UFO_VERSION.

Referenced by SV_ConnectionlessPacket().

static void SVC_RemoteCommand ( struct net_stream stream  )  [static]

A client issued an rcon command. Shift down the remaining args. Redirect all printfs.

Definition at line 423 of file sv_main.c.

References Cmd_Argc(), Cmd_Argv(), Cmd_ExecuteString(), Com_BeginRedirect(), Com_EndRedirect(), Com_Printf(), i, NET_StreamPeerToName(), Q_strcat(), qfalse, Rcon_Validate(), sv_outputbuf, and SV_OUTPUTBUF_LENGTH.

Referenced by SV_ConnectionlessPacket().

static void SVC_Status ( struct net_stream s  )  [static]

Responds with all the info that the server browser can see.

See also:
SV_StatusString

Definition at line 219 of file sv_main.c.

References cl, clc_oob, Com_sprintf(), cs_free, Cvar_Serverinfo(), serverInstanceStatic_t::ge, client_s::name, NET_WriteByte(), NET_WriteMsg(), NET_WriteRawString(), new_dbuffer(), client_s::player, client_s::state, SV_GetNextClient(), and svs.

Referenced by SV_ConnectionlessPacket().

static void SVC_TeamInfo ( struct net_stream s  )  [static]

Variable Documentation

SDL_Thread* masterServerHeartBeatThread [static]

Definition at line 515 of file sv_main.c.

Referenced by Master_Heartbeat(), and Master_HeartbeatThread().

cvar_t* rcon_password [static]

password for remote server commands

Definition at line 33 of file sv_main.c.

Definition at line 43 of file sv_main.c.

Definition at line 35 of file sv_main.c.

Definition at line 49 of file sv_main.c.

Referenced by SV_InitGame(), and SV_MapcycleAdd().

cvar_t* sv_hostname [static]

Definition at line 38 of file sv_main.c.

Definition at line 34 of file sv_main.c.

Definition at line 47 of file sv_main.c.

Referenced by SV_Map().

Definition at line 37 of file sv_main.c.

Definition at line 36 of file sv_main.c.

char sv_outputbuf[SV_OUTPUTBUF_LENGTH] [static]

Definition at line 418 of file sv_main.c.

Referenced by SVC_RemoteCommand().

should heartbeats be sent

Definition at line 46 of file sv_main.c.

Referenced by SV_InitGame().

minimum seconds between connect messages

Definition at line 40 of file sv_main.c.

run the game lib threaded

Definition at line 44 of file sv_main.c.


Generated by  doxygen 1.6.2