- 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

@ -100,6 +100,8 @@ cvar_t *cl_guidServerUniq;
cvar_t *cl_consoleKeys;
cvar_t *cl_gamename;
clientActive_t cl;
clientConnection_t clc;
clientStatic_t cls;
@ -3169,6 +3171,8 @@ void CL_Init( void ) {
// ~ and `, as keys and characters
cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60", CVAR_ARCHIVE);
cl_gamename = Cvar_Get("cl_gamename", GAMENAME_FOR_MASTER, CVAR_TEMP);
// userinfo
Cvar_Get ("name", "UnnamedPlayer", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("rate", "25000", CVAR_USERINFO | CVAR_ARCHIVE );
@ -3715,7 +3719,6 @@ void CL_GlobalServers_f( void ) {
netadr_t to;
int count, i, masterNum;
char command[1024], *masteraddress;
char *cmdname;
if ((count = Cmd_Argc()) < 3 || (masterNum = atoi(Cmd_Argv(1))) < 0 || masterNum > MAX_MASTER_SERVERS - 1)
{
@ -3753,14 +3756,24 @@ void CL_GlobalServers_f( void ) {
// Use the extended query for IPv6 masters
if (to.type == NA_IP6 || to.type == NA_MULTICAST6)
{
cmdname = "getserversExt " GAMENAME_FOR_MASTER;
int v4enabled = Cvar_VariableIntegerValue("net_enabled") & NET_ENABLEV4;
if(v4enabled)
{
Com_sprintf(command, sizeof(command), "getserversExt %s %s ipv6",
cl_gamename->string, Cmd_Argv(2));
}
else
{
Com_sprintf(command, sizeof(command), "getserversExt %s %s",
cl_gamename->string, Cmd_Argv(2));
}
// TODO: test if we only have an IPv6 connection. If it's the case,
// request IPv6 servers only by appending " ipv6" to the command
}
else
cmdname = "getservers";
Com_sprintf( command, sizeof(command), "%s %s", cmdname, Cmd_Argv(2) );
Com_sprintf(command, sizeof(command), "getservers %s", Cmd_Argv(2));
for (i=3; i < count; i++)
{

View file

@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define CLIENT_WINDOW_MIN_TITLE "changeme2"
#define GAMENAME_FOR_MASTER "iofoo3" // must NOT contain whitespaces
#define HEARTBEAT_FOR_MASTER GAMENAME_FOR_MASTER
#define FLATLINE_FOR_MASTER GAMENAME_FOR_MASTER "dead"
#else
#define PRODUCT_NAME "ioq3"
#define BASEGAME "baseq3"
@ -41,6 +42,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define CLIENT_WINDOW_MIN_TITLE "ioq3"
#define GAMENAME_FOR_MASTER "Quake3Arena"
#define HEARTBEAT_FOR_MASTER "QuakeArena-1"
#define FLATLINE_FOR_MASTER HEARTBEAT_FOR_MASTER
#endif
#ifdef _MSC_VER

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);
}
//============================================================================