From 93647873de327ec2edec97215d00a6892068e5a1 Mon Sep 17 00:00:00 2001 From: AJ Martinez Date: Mon, 23 May 2022 23:12:24 -0500 Subject: [PATCH 1/4] Add warning and reset flow for non-default masterserver address --- src/m_menu.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 15a61987..59bb064e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -260,6 +260,10 @@ static menu_t SP_TimeAttackDef, SP_ReplayDef, SP_GuestReplayDef, SP_GhostDef; // Multiplayer #ifndef NONET +static void M_PreStartServerMenu(INT32 choice); +static void M_PreStartServerMenuChoice(event_t *ev); +static void M_PreConnectMenu(INT32 choice); +static void M_PreConnectMenuChoice(event_t *ev); static void M_StartServerMenu(INT32 choice); static void M_ConnectMenu(INT32 choice); static void M_ConnectMenuModChecks(INT32 choice); @@ -994,7 +998,7 @@ static menuitem_t MP_MainMenu[] = {IT_HEADER, NULL, "Host a game", NULL, 100-24}, #ifndef NONET - {IT_STRING|IT_CALL, NULL, "Internet/LAN...", M_StartServerMenu, 110-24}, + {IT_STRING|IT_CALL, NULL, "Internet/LAN...", M_PreStartServerMenu, 110-24}, #else {IT_GRAYEDOUT, NULL, "Internet/LAN...", NULL, 110-24}, #endif @@ -1002,7 +1006,7 @@ static menuitem_t MP_MainMenu[] = {IT_HEADER, NULL, "Join a game", NULL, 132-24}, #ifndef NONET - {IT_STRING|IT_CALL, NULL, "Internet server browser...",M_ConnectMenuModChecks, 142-24}, + {IT_STRING|IT_CALL, NULL, "Internet server browser...",M_PreConnectMenu, 142-24}, {IT_STRING|IT_KEYHANDLER, NULL, "Specify IPv4 address:", M_HandleConnectIP, 150-24}, #else {IT_GRAYEDOUT, NULL, "Internet server browser...",NULL, 142-24}, @@ -8797,6 +8801,60 @@ static void M_ConnectMenuModChecks(INT32 choice) M_ConnectMenu(-1); } + +static void M_HandleMasterServerResetChoice(event_t *ev) +{ + INT32 choice = -1; + + choice = ev->data1; + + if (ev->type == ev_keydown) + { + if (choice == ' ' || choice == 'y' || choice == KEY_ENTER || choice == gamecontrol[gc_accelerate][0] || choice == gamecontrol[gc_accelerate][1]) + { + CV_Set(&cv_masterserver, cv_masterserver.defaultvalue); + S_StartSound(NULL, sfx_s221); + } + } +} + +static void M_PreStartServerMenu(INT32 choice) +{ + (void)choice; + + if (!CV_IsSetToDefault(&cv_masterserver)) + { + M_StartMessage(M_GetText("Hey! You've changed the Server Browser address.\n\nYou won't be able to host games on the official Server Browser.\nUnless you're from the future, this probably isn't what you want.\n\n\x83Press Accel\x80 to fix this and continue.\x80\nPress any other key to continue anyway.\n"),M_PreStartServerMenuChoice,MM_EVENTHANDLER); + return; + } + + M_StartServerMenu(-1); +} + +static void M_PreConnectMenu(INT32 choice) +{ + (void)choice; + + if (!CV_IsSetToDefault(&cv_masterserver)) + { + M_StartMessage(M_GetText("Hey! You've changed the Server Browser address.\n\nYou won't be able to see games from the official Server Browser.\nUnless you're from the future, this probably isn't what you want.\n\n\x83Press Accel\x80 to fix this and continue.\x80\nPress any other key to continue anyway.\n"),M_PreConnectMenuChoice,MM_EVENTHANDLER); + return; + } + + M_ConnectMenuModChecks(-1); +} + +static void M_PreStartServerMenuChoice(event_t *ev) +{ + M_HandleMasterServerResetChoice(ev); + M_StartServerMenu(-1); +} + +static void M_PreConnectMenuChoice(event_t *ev) +{ + M_HandleMasterServerResetChoice(ev); + M_ConnectMenuModChecks(-1); +} #endif //NONET //=========================================================================== From 8548d441099f8c4a030cf1f9d1fb35effd45f135 Mon Sep 17 00:00:00 2001 From: AJ Martinez Date: Tue, 24 May 2022 18:25:18 -0500 Subject: [PATCH 2/4] Futureproofing mserv address conveyance --- src/m_menu.c | 33 +++++++++++++++++++++++++++++++-- src/mserv.c | 3 +++ src/mserv.h | 2 ++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 59bb064e..9b95d79b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8565,6 +8565,15 @@ static void M_DrawConnectMenu(void) // Page num V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + MP_ConnectMenu[mp_connect_page].alphaKey, highlightflags, va("%u of %d", serverlistpage+1, numPages)); + + // Did you change the Server Browser address? Have a little reminder. + int mservflags = V_ALLOWLOWERCASE; + if (CV_IsSetToDefault(&cv_masterserver)) + mservflags = mservflags|highlightflags|V_30TRANS; + else + mservflags = mservflags|warningflags; + V_DrawRightAlignedThinString(BASEVIDWIDTH - currentMenu->x, currentMenu->y+10 + MP_ConnectMenu[mp_connect_page].alphaKey, + mservflags, cv_masterserver.string); // Horizontal line! V_DrawFill(1, currentMenu->y+32, 318, 1, 0); @@ -8802,6 +8811,8 @@ static void M_ConnectMenuModChecks(INT32 choice) M_ConnectMenu(-1); } +boolean firstDismissedNagThisBoot = true; + static void M_HandleMasterServerResetChoice(event_t *ev) { INT32 choice = -1; @@ -8813,7 +8824,16 @@ static void M_HandleMasterServerResetChoice(event_t *ev) if (choice == ' ' || choice == 'y' || choice == KEY_ENTER || choice == gamecontrol[gc_accelerate][0] || choice == gamecontrol[gc_accelerate][1]) { CV_Set(&cv_masterserver, cv_masterserver.defaultvalue); + CV_Set(&cv_masterserver_nagattempts, cv_masterserver_nagattempts.defaultvalue); S_StartSound(NULL, sfx_s221); + } else + { + if (firstDismissedNagThisBoot) { + if (cv_masterserver_nagattempts.value > 0) { + CV_SetValue(&cv_masterserver_nagattempts, cv_masterserver_nagattempts.value - 1); + } + firstDismissedNagThisBoot = false; + } } } } @@ -8822,7 +8842,7 @@ static void M_PreStartServerMenu(INT32 choice) { (void)choice; - if (!CV_IsSetToDefault(&cv_masterserver)) + if (!CV_IsSetToDefault(&cv_masterserver) && cv_masterserver_nagattempts.value > 0) { M_StartMessage(M_GetText("Hey! You've changed the Server Browser address.\n\nYou won't be able to host games on the official Server Browser.\nUnless you're from the future, this probably isn't what you want.\n\n\x83Press Accel\x80 to fix this and continue.\x80\nPress any other key to continue anyway.\n"),M_PreStartServerMenuChoice,MM_EVENTHANDLER); return; @@ -8835,7 +8855,7 @@ static void M_PreConnectMenu(INT32 choice) { (void)choice; - if (!CV_IsSetToDefault(&cv_masterserver)) + if (!CV_IsSetToDefault(&cv_masterserver) && cv_masterserver_nagattempts.value > 0) { M_StartMessage(M_GetText("Hey! You've changed the Server Browser address.\n\nYou won't be able to see games from the official Server Browser.\nUnless you're from the future, this probably isn't what you want.\n\n\x83Press Accel\x80 to fix this and continue.\x80\nPress any other key to continue anyway.\n"),M_PreConnectMenuChoice,MM_EVENTHANDLER); return; @@ -9069,6 +9089,15 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) static void M_DrawServerMenu(void) { M_DrawLevelSelectOnly(false, false); + if (currentMenu == &MP_ServerDef && cv_advertise.value) // Remind players where they're hosting. + { + int mservflags = V_ALLOWLOWERCASE; + if (CV_IsSetToDefault(&cv_masterserver)) + mservflags = mservflags|highlightflags|V_30TRANS; + else + mservflags = mservflags|warningflags; + V_DrawCenteredThinString(BASEVIDWIDTH/2, BASEVIDHEIGHT-12, mservflags, cv_masterserver.string); + } M_DrawGenericMenu(); } diff --git a/src/mserv.c b/src/mserv.c index ab615711..33128c76 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -75,6 +75,8 @@ consvar_t cv_masterserver_update_rate = {"masterserver_update_rate", "15", CV_SA consvar_t cv_advertise = {"advertise", "No", CV_NETVAR|CV_CALL|CV_NOINIT, CV_YesNo, Advertise_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_masterserver_nagattempts = {"masterserver_nagattempts", "5", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; + #if defined (MASTERSERVER) && defined (HAVE_THREADS) int ms_QueryId; I_mutex ms_QueryId_mutex; @@ -98,6 +100,7 @@ void AddMServCommands(void) CV_RegisterVar(&cv_masterserver_timeout); CV_RegisterVar(&cv_masterserver_debug); CV_RegisterVar(&cv_masterserver_token); + CV_RegisterVar(&cv_masterserver_nagattempts); CV_RegisterVar(&cv_advertise); CV_RegisterVar(&cv_servername); CV_RegisterVar(&cv_server_contact); diff --git a/src/mserv.h b/src/mserv.h index 02aaf367..ef401aba 100644 --- a/src/mserv.h +++ b/src/mserv.h @@ -61,6 +61,8 @@ extern consvar_t cv_masterserver_token; extern consvar_t cv_advertise; +extern consvar_t cv_masterserver_nagattempts; + #ifdef HAVE_THREADS extern int ms_QueryId; extern I_mutex ms_QueryId_mutex; From 1441fda8384633b678ab0482f159ae76f5241abe Mon Sep 17 00:00:00 2001 From: AJ Martinez Date: Tue, 24 May 2022 18:44:49 -0500 Subject: [PATCH 3/4] Clearly mark MS reminder + formatting touchup --- src/m_menu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 9b95d79b..28f71aa9 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8572,8 +8572,8 @@ static void M_DrawConnectMenu(void) mservflags = mservflags|highlightflags|V_30TRANS; else mservflags = mservflags|warningflags; - V_DrawRightAlignedThinString(BASEVIDWIDTH - currentMenu->x, currentMenu->y+10 + MP_ConnectMenu[mp_connect_page].alphaKey, - mservflags, cv_masterserver.string); + V_DrawRightAlignedSmallString(BASEVIDWIDTH - currentMenu->x, currentMenu->y+14 + MP_ConnectMenu[mp_connect_page].alphaKey, + mservflags, va("MS: %s", cv_masterserver.string)); // Horizontal line! V_DrawFill(1, currentMenu->y+32, 318, 1, 0); @@ -9096,7 +9096,7 @@ static void M_DrawServerMenu(void) mservflags = mservflags|highlightflags|V_30TRANS; else mservflags = mservflags|warningflags; - V_DrawCenteredThinString(BASEVIDWIDTH/2, BASEVIDHEIGHT-12, mservflags, cv_masterserver.string); + V_DrawCenteredThinString(BASEVIDWIDTH/2, BASEVIDHEIGHT-12, mservflags, va("Master Server: %s", cv_masterserver.string)); } M_DrawGenericMenu(); } From 129fc2bbb1814617500a5302b626d3f99dc65a3f Mon Sep 17 00:00:00 2001 From: AJ Martinez Date: Wed, 25 May 2022 18:22:43 -0500 Subject: [PATCH 4/4] Style cleanup --- src/m_menu.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 28f71aa9..6c04c933 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8826,10 +8826,13 @@ static void M_HandleMasterServerResetChoice(event_t *ev) CV_Set(&cv_masterserver, cv_masterserver.defaultvalue); CV_Set(&cv_masterserver_nagattempts, cv_masterserver_nagattempts.defaultvalue); S_StartSound(NULL, sfx_s221); - } else + } + else { - if (firstDismissedNagThisBoot) { - if (cv_masterserver_nagattempts.value > 0) { + if (firstDismissedNagThisBoot) + { + if (cv_masterserver_nagattempts.value > 0) + { CV_SetValue(&cv_masterserver_nagattempts, cv_masterserver_nagattempts.value - 1); } firstDismissedNagThisBoot = false;