From 0b6796cad9a4794444d18556cbd351608e864bcf Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 27 Feb 2024 20:18:10 +0300 Subject: [PATCH 1/2] Add cvar joinrefusemessage for custom messages when allowjoin is Off --- src/d_clisrv.c | 4 +++- src/d_clisrv.h | 2 +- src/d_netcmd.c | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1749d9aea..e3edcd962 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3959,6 +3959,8 @@ consvar_t cv_netticbuffer = {"netticbuffer", "1", CV_SAVE, netticbuffer_cons_t, static void Joinable_OnChange(void); +consvar_t cv_joinrefusemessage = {"joinrefusemessage", "The server is not accepting\njoins for the moment.", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_allownewplayer = {"allowjoin", "On", CV_SAVE|CV_CALL, CV_OnOff, Joinable_OnChange, 0, NULL, NULL, 0, 0, NULL}; #ifdef VANILLAJOINNEXTROUND @@ -4586,7 +4588,7 @@ static void HandleConnect(SINT8 node) } else if (!cv_allownewplayer.value && node) { - SV_SendRefuse(node, M_GetText("The server is not accepting\njoins for the moment.")); + SV_SendRefuse(node, M_GetText(cv_joinrefusemessage.string)); } else if (connectedplayers >= maxplayers) { diff --git a/src/d_clisrv.h b/src/d_clisrv.h index b1bc9ffcc..a314057a2 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -567,7 +567,7 @@ extern consvar_t #ifdef VANILLAJOINNEXTROUND cv_joinnextround, #endif - cv_netticbuffer, cv_allownewplayer, cv_maxplayers, cv_resynchattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; + cv_netticbuffer, cv_allownewplayer, cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; extern consvar_t cv_connectawaittime; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 21f60b7cd..46fe4509e 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -778,6 +778,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_httpsource); #ifndef NONET CV_RegisterVar(&cv_allownewplayer); + CV_RegisterVar(&cv_joinrefusemessage); CV_RegisterVar(&cv_chatlogsize); #ifdef VANILLAJOINNEXTROUND CV_RegisterVar(&cv_joinnextround); From 0ef51011d40cfbd244582b649897dcd5b554f5c0 Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 27 Feb 2024 20:26:18 +0300 Subject: [PATCH 2/2] Change default value for joinrefusemessage because cvars don't support newline characters --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e3edcd962..06670e729 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3959,7 +3959,7 @@ consvar_t cv_netticbuffer = {"netticbuffer", "1", CV_SAVE, netticbuffer_cons_t, static void Joinable_OnChange(void); -consvar_t cv_joinrefusemessage = {"joinrefusemessage", "The server is not accepting\njoins for the moment.", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_joinrefusemessage = {"joinrefusemessage", "The server is not accepting joins for the moment.", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_allownewplayer = {"allowjoin", "On", CV_SAVE|CV_CALL, CV_OnOff, Joinable_OnChange, 0, NULL, NULL, 0, 0, NULL};