- 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

33
README
View file

@ -110,7 +110,8 @@ New cvars
cl_mouseAccelStyle - Set to 1 for QuakeLive mouse acceleration cl_mouseAccelStyle - Set to 1 for QuakeLive mouse acceleration
behaviour, 0 for standard q3 behaviour, 0 for standard q3
cl_mouseAccelOffset - Tuning the acceleration curve, see below cl_mouseAccelOffset - Tuning the acceleration curve, see below
cl_gamename - Gamename sent to master server in
getserversExt query
s_useOpenAL - use the OpenAL sound backend if available s_useOpenAL - use the OpenAL sound backend if available
s_alPrecache - cache OpenAL sounds before use s_alPrecache - cache OpenAL sounds before use
s_alGain - the value of AL_GAIN for each source s_alGain - the value of AL_GAIN for each source
@ -142,24 +143,27 @@ New cvars
com_ansiColor - enable use of ANSI escape codes in the tty com_ansiColor - enable use of ANSI escape codes in the tty
com_altivec - enable use of altivec on PowerPC systems com_altivec - enable use of altivec on PowerPC systems
com_standalone (read only) - If set to 1, quake3 is running in com_standalone (read only) - If set to 1, quake3 is running in
standalone mode. standalone mode
com_basegame - Use a different base than baseq3. If no com_basegame - Use a different base than baseq3. If no
original Quake3 or TeamArena pak files original Quake3 or TeamArena pak files
are found, this will enable running in are found, this will enable running in
standalone mode. standalone mode
com_homepath - Specify name that is to be appended to the com_homepath - Specify name that is to be appended to the
home path home path
com_maxfpsUnfocused - Maximum frames per second when unfocused com_maxfpsUnfocused - Maximum frames per second when unfocused
com_maxfpsMinimized - Maximum frames per second when minimized com_maxfpsMinimized - Maximum frames per second when minimized
com_busyWait - Will use a busy loop to wait for rendering com_busyWait - Will use a busy loop to wait for rendering
next frame when set to non-zero value. next frame when set to non-zero value
in_joystickNo - select which joystick to use in_joystickNo - select which joystick to use
in_keyboardDebug - print keyboard debug info in_keyboardDebug - print keyboard debug info
sv_dlURL - the base of the HTTP or FTP site that sv_dlURL - the base of the HTTP or FTP site that
holds custom pk3 files for your server holds custom pk3 files for your server
sv_banFile - Name of the file that is used for storing sv_banFile - Name of the file that is used for storing
the server bans. the server bans
sv_heartbeat - Heartbeat string sent to master server
sv_flatline - Heartbeat string sent to master server
when server is killed
net_ip6 - IPv6 address to bind to net_ip6 - IPv6 address to bind to
net_port6 - port to bind to using the ipv6 address net_port6 - port to bind to using the ipv6 address
@ -354,9 +358,26 @@ Creating standalone games
+set com_homepath <homedirname> +set com_homepath <homedirname>
to the command line. Example line: to the command line. Then you can control which kind of messages to send to
the master server:
+set sv_heartbeat <heartbeat> +set sv_flatline <flatline>
+set cl_gamename <gamename>
The <heartbeat> and <flatline> message can be specific to your game. The
flatline message is sent to signal the master server that the game server is
quitting. Vanilla quake3 uses "QuakeArena-1" both for the heartbeat and
flatline messages.
The cl_gamename message is for dpmaster to specify which game the client
wants a server list for. It is only used in the new ipv6 based getServersExt
query.
Example line:
+set com_basegame basefoo +set com_homepath .foo +set com_basegame basefoo +set com_homepath .foo
+set sv_heartbeat fooalive +set sv_flatline foodead
+set cl_gamename foo
If you really changed parts that would make vanilla ioquake3 incompatible with If you really changed parts that would make vanilla ioquake3 incompatible with
your mod, we have included another way to conveniently build a stand-alone your mod, we have included another way to conveniently build a stand-alone

View file

@ -100,6 +100,8 @@ cvar_t *cl_guidServerUniq;
cvar_t *cl_consoleKeys; cvar_t *cl_consoleKeys;
cvar_t *cl_gamename;
clientActive_t cl; clientActive_t cl;
clientConnection_t clc; clientConnection_t clc;
clientStatic_t cls; clientStatic_t cls;
@ -3169,6 +3171,8 @@ void CL_Init( void ) {
// ~ and `, as keys and characters // ~ and `, as keys and characters
cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60", CVAR_ARCHIVE); cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60", CVAR_ARCHIVE);
cl_gamename = Cvar_Get("cl_gamename", GAMENAME_FOR_MASTER, CVAR_TEMP);
// userinfo // userinfo
Cvar_Get ("name", "UnnamedPlayer", CVAR_USERINFO | CVAR_ARCHIVE ); Cvar_Get ("name", "UnnamedPlayer", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("rate", "25000", CVAR_USERINFO | CVAR_ARCHIVE ); Cvar_Get ("rate", "25000", CVAR_USERINFO | CVAR_ARCHIVE );
@ -3715,7 +3719,6 @@ void CL_GlobalServers_f( void ) {
netadr_t to; netadr_t to;
int count, i, masterNum; int count, i, masterNum;
char command[1024], *masteraddress; char command[1024], *masteraddress;
char *cmdname;
if ((count = Cmd_Argc()) < 3 || (masterNum = atoi(Cmd_Argv(1))) < 0 || masterNum > MAX_MASTER_SERVERS - 1) 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 // Use the extended query for IPv6 masters
if (to.type == NA_IP6 || to.type == NA_MULTICAST6) 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, // TODO: test if we only have an IPv6 connection. If it's the case,
// request IPv6 servers only by appending " ipv6" to the command // request IPv6 servers only by appending " ipv6" to the command
} }
else else
cmdname = "getservers"; Com_sprintf(command, sizeof(command), "getservers %s", Cmd_Argv(2));
Com_sprintf( command, sizeof(command), "%s %s", cmdname, Cmd_Argv(2) );
for (i=3; i < count; i++) 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 CLIENT_WINDOW_MIN_TITLE "changeme2"
#define GAMENAME_FOR_MASTER "iofoo3" // must NOT contain whitespaces #define GAMENAME_FOR_MASTER "iofoo3" // must NOT contain whitespaces
#define HEARTBEAT_FOR_MASTER GAMENAME_FOR_MASTER #define HEARTBEAT_FOR_MASTER GAMENAME_FOR_MASTER
#define FLATLINE_FOR_MASTER GAMENAME_FOR_MASTER "dead"
#else #else
#define PRODUCT_NAME "ioq3" #define PRODUCT_NAME "ioq3"
#define BASEGAME "baseq3" #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 CLIENT_WINDOW_MIN_TITLE "ioq3"
#define GAMENAME_FOR_MASTER "Quake3Arena" #define GAMENAME_FOR_MASTER "Quake3Arena"
#define HEARTBEAT_FOR_MASTER "QuakeArena-1" #define HEARTBEAT_FOR_MASTER "QuakeArena-1"
#define FLATLINE_FOR_MASTER HEARTBEAT_FOR_MASTER
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER

View file

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

View file

@ -684,6 +684,8 @@ void SV_Init (void)
sv_lanForceRate = Cvar_Get ("sv_lanForceRate", "1", CVAR_ARCHIVE ); sv_lanForceRate = Cvar_Get ("sv_lanForceRate", "1", CVAR_ARCHIVE );
sv_strictAuth = Cvar_Get ("sv_strictAuth", "1", CVAR_ARCHIVE ); sv_strictAuth = Cvar_Get ("sv_strictAuth", "1", CVAR_ARCHIVE );
sv_banFile = Cvar_Get("sv_banFile", "serverbans.dat", 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 // initialize bot cvars so they are listed and can be set before loading the botlib
SV_BotInitCvars(); 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_lanForceRate; // dedicated 1 (LAN) server forces local client rates to 99999 (bug #491)
cvar_t *sv_strictAuth; cvar_t *sv_strictAuth;
cvar_t *sv_banFile; 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]; serverBan_t serverBans[SERVER_MAXBANS];
int serverBansCount = 0; int serverBansCount = 0;
@ -232,7 +235,8 @@ but not on every player enter or exit.
================ ================
*/ */
#define HEARTBEAT_MSEC 300*1000 #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. static netadr_t adr[MAX_MASTER_SERVERS][2]; // [2] for v4 and v6 address for the same address string.
int i; int i;
int res; int res;
@ -315,9 +319,9 @@ void SV_MasterHeartbeat( void ) {
// ever incompatably changes // ever incompatably changes
if(adr[i][0].type != NA_BAD) 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) 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 ) { void SV_MasterShutdown( void ) {
// send a hearbeat right now // send a hearbeat right now
svs.nextHeartbeatTime = -9999; svs.nextHeartbeatTime = -9999;
SV_MasterHeartbeat(); SV_MasterHeartbeat(sv_flatline->string);
// send it again to minimize chance of drops // send it again to minimize chance of drops
svs.nextHeartbeatTime = -9999; svs.nextHeartbeatTime = -9999;
SV_MasterHeartbeat(); SV_MasterHeartbeat(sv_flatline->string);
// when the master tries to poll the server, it won't respond, so // when the master tries to poll the server, it won't respond, so
// it will be removed from the list // it will be removed from the list
@ -1139,7 +1143,7 @@ void SV_Frame( int msec ) {
SV_SendClientMessages(); SV_SendClientMessages();
// send a heartbeat to the master if needed // send a heartbeat to the master if needed
SV_MasterHeartbeat(); SV_MasterHeartbeat(sv_heartbeat->string);
} }
//============================================================================ //============================================================================