From 8ec4bce1bf041b00ae3fbf84ce7d9c686a854090 Mon Sep 17 00:00:00 2001 From: spherallic Date: Thu, 27 Jun 2024 00:25:56 +0200 Subject: [PATCH] Rename idlespectate to idleaction for future expansion --- src/netcode/d_clisrv.c | 12 +++++++----- src/netcode/d_clisrv.h | 2 +- src/netcode/d_netcmd.c | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/netcode/d_clisrv.c b/src/netcode/d_clisrv.c index d46e75c3f..03668d0f0 100644 --- a/src/netcode/d_clisrv.c +++ b/src/netcode/d_clisrv.c @@ -113,9 +113,11 @@ consvar_t cv_blamecfail = CVAR_INIT ("blamecfail", "Off", CV_SAVE|CV_NETVAR, CV_ static CV_PossibleValue_t playbackspeed_cons_t[] = {{1, "MIN"}, {10, "MAX"}, {0, NULL}}; consvar_t cv_playbackspeed = CVAR_INIT ("playbackspeed", "1", 0, playbackspeed_cons_t, NULL); -consvar_t cv_idletime = CVAR_INIT ("idletime", "0", CV_SAVE, CV_Unsigned, NULL); -consvar_t cv_idlespectate = CVAR_INIT ("idlespectate", "On", CV_SAVE, CV_OnOff, NULL); -consvar_t cv_dedicatedidletime = CVAR_INIT ("dedicatedidletime", "10", CV_SAVE, CV_Unsigned, NULL); +consvar_t cv_dedicatedidletime = CVAR_INIT ("dedicatedidletime", "10", CV_SAVE|CV_NETVAR, CV_Unsigned, NULL); + +static CV_PossibleValue_t idleaction_cons_t[] = {{1, "Kick"}, {2, "Spectate"}, {0, NULL}}; +consvar_t cv_idleaction = CVAR_INIT ("idleaction", "Spectate", CV_SAVE|CV_NETVAR, idleaction_cons_t, NULL); +consvar_t cv_idletime = CVAR_INIT ("idletime", "3", CV_SAVE|CV_NETVAR, CV_Unsigned, NULL); consvar_t cv_httpsource = CVAR_INIT ("http_source", "", CV_SAVE, NULL, NULL); @@ -1373,7 +1375,7 @@ static void IdleUpdate(void) if (players[i].lastinputtime > (tic_t)cv_idletime.value * TICRATE * 60) { players[i].lastinputtime = 0; - if (cv_idlespectate.value && G_GametypeHasSpectators()) + if (cv_idleaction.value == 2 && G_GametypeHasSpectators()) { changeteam_union NetPacket; UINT16 usvalue; @@ -1384,7 +1386,7 @@ static void IdleUpdate(void) usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); } - else + else if (cv_idleaction.value == 1) { SendKick(i, KICK_MSG_IDLE | KICK_MSG_KEEP_BODY); } diff --git a/src/netcode/d_clisrv.h b/src/netcode/d_clisrv.h index 342173dff..86af61e9e 100644 --- a/src/netcode/d_clisrv.h +++ b/src/netcode/d_clisrv.h @@ -73,7 +73,7 @@ extern UINT32 realpingtable[MAXPLAYERS]; extern UINT32 playerpingtable[MAXPLAYERS]; extern tic_t servermaxping; -extern consvar_t cv_netticbuffer, cv_resynchattempts, cv_blamecfail, cv_playbackspeed, cv_idletime, cv_idlespectate, cv_dedicatedidletime; +extern consvar_t cv_netticbuffer, cv_resynchattempts, cv_blamecfail, cv_playbackspeed, cv_idletime, cv_idleaction, cv_dedicatedidletime; extern consvar_t cv_httpsource; // Used in d_net, the only dependence diff --git a/src/netcode/d_netcmd.c b/src/netcode/d_netcmd.c index 4134c633e..b0f872d86 100644 --- a/src/netcode/d_netcmd.c +++ b/src/netcode/d_netcmd.c @@ -620,7 +620,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_blamecfail); CV_RegisterVar(&cv_dedicatedidletime); CV_RegisterVar(&cv_idletime); - CV_RegisterVar(&cv_idlespectate); + CV_RegisterVar(&cv_idleaction); CV_RegisterVar(&cv_httpsource); COM_AddCommand("ping", Command_Ping_f, COM_LUA);