masterserver_update_rate cvar determines wait between updates in minutes

The new default is 15 minutes as well. And if you think that's too long, I have
confirmed that the Master Server delists inactive servers after a whopping 40
minutes, at least.
This commit is contained in:
James R 2020-04-13 23:10:06 -07:00
parent bb8b279cd4
commit 4fcd24d848
2 changed files with 13 additions and 1 deletions

View file

@ -34,15 +34,25 @@ int HMS_compare_mod_version (char *buffer, size_t size_of_buffer);
static time_t MSLastPing; static time_t MSLastPing;
static inline void SendPingToMasterServer(void);
#ifndef NONET #ifndef NONET
static void Command_Listserv_f(void); static void Command_Listserv_f(void);
#endif #endif
static void MasterServer_OnChange(void); static void MasterServer_OnChange(void);
static void ServerName_OnChange(void); static void ServerName_OnChange(void);
static CV_PossibleValue_t masterserver_update_rate_cons_t[] = {
{2, "MIN"},
{60, "MAX"},
{0}
};
consvar_t cv_masterserver = {"masterserver", "https://mb.srb2.org/MS/0", CV_SAVE|CV_CALL, NULL, MasterServer_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_masterserver = {"masterserver", "https://mb.srb2.org/MS/0", CV_SAVE|CV_CALL, NULL, MasterServer_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_servername = {"servername", "SRB2Kart server", CV_SAVE|CV_CALL|CV_NOINIT, NULL, ServerName_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_servername = {"servername", "SRB2Kart server", CV_SAVE|CV_CALL|CV_NOINIT, NULL, ServerName_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_masterserver_update_rate = {"masterserver_update_rate", "15", CV_SAVE|CV_CALL|CV_NOINIT, masterserver_update_rate_cons_t, SendPingToMasterServer, 0, NULL, NULL, 0, 0, NULL};
char *ms_API; char *ms_API;
INT16 ms_RoomId = -1; INT16 ms_RoomId = -1;
@ -63,6 +73,7 @@ void AddMServCommands(void)
{ {
#ifndef NONET #ifndef NONET
CV_RegisterVar(&cv_masterserver); CV_RegisterVar(&cv_masterserver);
CV_RegisterVar(&cv_masterserver_update_rate);
CV_RegisterVar(&cv_masterserver_debug); CV_RegisterVar(&cv_masterserver_debug);
CV_RegisterVar(&cv_servername); CV_RegisterVar(&cv_servername);
COM_AddCommand("listserv", Command_Listserv_f); COM_AddCommand("listserv", Command_Listserv_f);
@ -171,7 +182,7 @@ static void UpdateServer(void)
static inline void SendPingToMasterServer(void) static inline void SendPingToMasterServer(void)
{ {
// Here, have a simpler MS Ping... - Cue // Here, have a simpler MS Ping... - Cue
if(time(NULL) > (MSLastPing+(60*2)) && con_state != MSCS_NONE) if(time(NULL) > (MSLastPing+(60*cv_masterserver_update_rate.value)) && con_state != MSCS_NONE)
{ {
UpdateServer(); UpdateServer();
} }

View file

@ -65,6 +65,7 @@ typedef struct
// ================================ GLOBALS =============================== // ================================ GLOBALS ===============================
extern consvar_t cv_masterserver, cv_servername; extern consvar_t cv_masterserver, cv_servername;
extern consvar_t cv_masterserver_update_rate;
extern consvar_t cv_masterserver_debug; extern consvar_t cv_masterserver_debug;
extern char *ms_API; extern char *ms_API;