mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-28 05:11:34 +00:00
Register/unregister server by changing cv_advertise
This commit is contained in:
parent
901ea3c18b
commit
93d3808307
1 changed files with 33 additions and 8 deletions
41
src/mserv.c
41
src/mserv.c
|
@ -59,6 +59,8 @@ static void Update_parameters (void);
|
||||||
|
|
||||||
static void MasterServer_OnChange(void);
|
static void MasterServer_OnChange(void);
|
||||||
|
|
||||||
|
static void Advertise_OnChange(void);
|
||||||
|
|
||||||
static CV_PossibleValue_t masterserver_update_rate_cons_t[] = {
|
static CV_PossibleValue_t masterserver_update_rate_cons_t[] = {
|
||||||
{2, "MIN"},
|
{2, "MIN"},
|
||||||
{60, "MAX"},
|
{60, "MAX"},
|
||||||
|
@ -71,7 +73,7 @@ consvar_t cv_server_contact = {"server_contact", "", CV_SAVE|CV_CALL|CV_NOINIT,
|
||||||
|
|
||||||
consvar_t cv_masterserver_update_rate = {"masterserver_update_rate", "15", CV_SAVE|CV_CALL|CV_NOINIT, masterserver_update_rate_cons_t, Update_parameters, 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, Update_parameters, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
consvar_t cv_advertise = {"advertise", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_advertise = {"advertise", "Yes", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, Advertise_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
|
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
|
||||||
int ms_QueryId;
|
int ms_QueryId;
|
||||||
|
@ -263,6 +265,9 @@ Finish_unlist (void)
|
||||||
Lock_state();
|
Lock_state();
|
||||||
{
|
{
|
||||||
registered = MSRegistered;
|
registered = MSRegistered;
|
||||||
|
|
||||||
|
if (MSId == MSRegisteredId)
|
||||||
|
MSId++;
|
||||||
}
|
}
|
||||||
Unlock_state();
|
Unlock_state();
|
||||||
|
|
||||||
|
@ -284,13 +289,6 @@ Finish_unlist (void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Lock_state();
|
|
||||||
{
|
|
||||||
if (MSId == MSRegisteredId)
|
|
||||||
MSId++;
|
|
||||||
}
|
|
||||||
Unlock_state();
|
|
||||||
|
|
||||||
#ifdef HAVE_DISCORDRPC
|
#ifdef HAVE_DISCORDRPC
|
||||||
DRPC_UpdatePresence();
|
DRPC_UpdatePresence();
|
||||||
#endif
|
#endif
|
||||||
|
@ -540,3 +538,30 @@ static void MasterServer_OnChange(void)
|
||||||
RegisterServer();
|
RegisterServer();
|
||||||
#endif/*MASTERSERVER*/
|
#endif/*MASTERSERVER*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
Advertise_OnChange(void)
|
||||||
|
{
|
||||||
|
int different;
|
||||||
|
|
||||||
|
if (cv_advertise.value)
|
||||||
|
{
|
||||||
|
if (serverrunning)
|
||||||
|
{
|
||||||
|
Lock_state();
|
||||||
|
{
|
||||||
|
different = ( MSId != MSRegisteredId );
|
||||||
|
}
|
||||||
|
Unlock_state();
|
||||||
|
|
||||||
|
if (different)
|
||||||
|
{
|
||||||
|
RegisterServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UnregisterServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue