- Add cvars cl_gamename, sv_heartbeat, sv_flatline so standalone games can customise their messages to the master server

This commit is contained in:
Thilo Schulz 2011-02-04 13:25:51 +00:00
parent 0eb5d1720c
commit 67a8b273c2
6 changed files with 60 additions and 18 deletions

View file

@ -276,6 +276,8 @@ extern cvar_t *sv_floodProtect;
extern cvar_t *sv_lanForceRate;
extern cvar_t *sv_strictAuth;
extern cvar_t *sv_banFile;
extern cvar_t *sv_heartbeat;
extern cvar_t *sv_flatline;
extern serverBan_t serverBans[SERVER_MAXBANS];
extern int serverBansCount;
@ -298,12 +300,10 @@ void SV_AddOperatorCommands (void);
void SV_RemoveOperatorCommands (void);
void SV_MasterHeartbeat (void);
void SV_MasterShutdown (void);
//
// sv_init.c
//

View file

@ -684,6 +684,8 @@ void SV_Init (void)
sv_lanForceRate = Cvar_Get ("sv_lanForceRate", "1", CVAR_ARCHIVE );
sv_strictAuth = Cvar_Get ("sv_strictAuth", "1", CVAR_ARCHIVE );
sv_banFile = Cvar_Get("sv_banFile", "serverbans.dat", CVAR_ARCHIVE);
sv_heartbeat = Cvar_Get("sv_heartbeat", HEARTBEAT_FOR_MASTER, CVAR_INIT);
sv_flatline = Cvar_Get("sv_flatline", FLATLINE_FOR_MASTER, CVAR_INIT);
// initialize bot cvars so they are listed and can be set before loading the botlib
SV_BotInitCvars();

View file

@ -58,6 +58,9 @@ cvar_t *sv_floodProtect;
cvar_t *sv_lanForceRate; // dedicated 1 (LAN) server forces local client rates to 99999 (bug #491)
cvar_t *sv_strictAuth;
cvar_t *sv_banFile;
cvar_t *sv_heartbeat; // Heartbeat string that is sent to the master
cvar_t *sv_flatline; // If the master server supports it we can send a flatline
// when server is killed
serverBan_t serverBans[SERVER_MAXBANS];
int serverBansCount = 0;
@ -232,7 +235,8 @@ but not on every player enter or exit.
================
*/
#define HEARTBEAT_MSEC 300*1000
void SV_MasterHeartbeat( void ) {
void SV_MasterHeartbeat(const char *message)
{
static netadr_t adr[MAX_MASTER_SERVERS][2]; // [2] for v4 and v6 address for the same address string.
int i;
int res;
@ -315,9 +319,9 @@ void SV_MasterHeartbeat( void ) {
// ever incompatably changes
if(adr[i][0].type != NA_BAD)
NET_OutOfBandPrint( NS_SERVER, adr[i][0], "heartbeat %s\n", HEARTBEAT_FOR_MASTER );
NET_OutOfBandPrint( NS_SERVER, adr[i][0], "heartbeat %s\n", message);
if(adr[i][1].type != NA_BAD)
NET_OutOfBandPrint( NS_SERVER, adr[i][1], "heartbeat %s\n", HEARTBEAT_FOR_MASTER );
NET_OutOfBandPrint( NS_SERVER, adr[i][1], "heartbeat %s\n", message);
}
}
@ -331,11 +335,11 @@ Informs all masters that this server is going down
void SV_MasterShutdown( void ) {
// send a hearbeat right now
svs.nextHeartbeatTime = -9999;
SV_MasterHeartbeat();
SV_MasterHeartbeat(sv_flatline->string);
// send it again to minimize chance of drops
svs.nextHeartbeatTime = -9999;
SV_MasterHeartbeat();
SV_MasterHeartbeat(sv_flatline->string);
// when the master tries to poll the server, it won't respond, so
// it will be removed from the list
@ -1139,7 +1143,7 @@ void SV_Frame( int msec ) {
SV_SendClientMessages();
// send a heartbeat to the master if needed
SV_MasterHeartbeat();
SV_MasterHeartbeat(sv_heartbeat->string);
}
//============================================================================