summaryrefslogtreecommitdiff
path: root/src/server/sv_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/sv_main.c')
-rw-r--r--src/server/sv_main.c56
1 files changed, 38 insertions, 18 deletions
diff --git a/src/server/sv_main.c b/src/server/sv_main.c
index fa009b62..014c3a96 100644
--- a/src/server/sv_main.c
+++ b/src/server/sv_main.c
@@ -31,17 +31,17 @@ serverStatic_t svs; // persistant server info
server_t sv; // local server
vm_t *gvm = NULL; // game virtual machine
-cvar_t *sv_fps; // time rate for running non-clients
+cvar_t *sv_fps = NULL; // time rate for running non-clients
cvar_t *sv_timeout; // seconds without any message
cvar_t *sv_zombietime; // seconds to sink messages after disconnect
cvar_t *sv_rconPassword; // password for remote server commands
-cvar_t *sv_privatePassword; // password for the privateClient slots
+cvar_t *sv_privatePassword; // password for the privateClient slots
cvar_t *sv_allowDownload;
cvar_t *sv_maxclients;
cvar_t *sv_privateClients; // number of clients reserved for password
cvar_t *sv_hostname;
-cvar_t *sv_master[MAX_MASTER_SERVERS]; // master server ip address
+cvar_t *sv_master[MAX_MASTER_SERVERS]; // master server ip address
cvar_t *sv_reconnectlimit; // minimum seconds between connect messages
cvar_t *sv_showloss; // report when usercmds are lost
cvar_t *sv_padPackets; // add nop bytes to messages
@@ -56,6 +56,9 @@ cvar_t *sv_maxPing;
cvar_t *sv_pure;
cvar_t *sv_lanForceRate; // dedicated 1 (LAN) server forces local client rates to 99999 (bug #491)
cvar_t *sv_dequeuePeriod;
+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
/*
=============================================================================
@@ -221,8 +224,8 @@ but not on every player enter or exit.
================
*/
#define HEARTBEAT_MSEC 300*1000
-#define HEARTBEAT_GAME "Tremulous"
-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;
@@ -303,9 +306,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_GAME );
+ 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_GAME );
+ NET_OutOfBandPrint( NS_SERVER, adr[i][1], "heartbeat %s\n", message);
}
}
@@ -319,11 +322,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
@@ -460,7 +463,8 @@ static leakyBucket_t *SVC_BucketForAddress( netadr_t address, int burst, int per
interval = now - bucket->lastTime;
// Reclaim expired buckets
- if ( bucket->lastTime > 0 && interval > ( burst * period ) ) {
+ if ( bucket->lastTime > 0 && ( interval > ( burst * period ) ||
+ interval < 0 ) ) {
if ( bucket->prev != NULL ) {
bucket->prev->next = bucket->next;
} else {
@@ -1003,6 +1007,29 @@ static qboolean SV_CheckPaused( void ) {
/*
==================
+SV_FrameMsec
+Return time in millseconds until processing of the next server frame.
+==================
+*/
+int SV_FrameMsec()
+{
+ if(sv_fps)
+ {
+ int frameMsec;
+
+ frameMsec = 1000.0f / sv_fps->value;
+
+ if(frameMsec < sv.timeResidual)
+ return 0;
+ else
+ return frameMsec - sv.timeResidual;
+ }
+ else
+ return 1;
+}
+
+/*
+==================
SV_Frame
Player movement occurs as a result of packet events, which
@@ -1051,13 +1078,6 @@ void SV_Frame( int msec ) {
sv.timeResidual += msec;
- if ( com_dedicated->integer && sv.timeResidual < frameMsec ) {
- // NET_Sleep will give the OS time slices until either get a packet
- // or time enough for a server frame has gone by
- NET_Sleep(frameMsec - sv.timeResidual);
- return;
- }
-
// if time is about to hit the 32nd bit, kick all clients
// and clear sv.time, rather
// than checking for negative time wraparound everywhere.
@@ -1120,7 +1140,7 @@ void SV_Frame( int msec ) {
SV_SendClientMessages();
// send a heartbeat to the master if needed
- SV_MasterHeartbeat();
+ SV_MasterHeartbeat(sv_heartbeat->string);
}
//============================================================================