From 93647873de327ec2edec97215d00a6892068e5a1 Mon Sep 17 00:00:00 2001 From: AJ Martinez Date: Mon, 23 May 2022 23:12:24 -0500 Subject: [PATCH] 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 //===========================================================================