diff --git a/src/cvars.cpp b/src/cvars.cpp index 416ed70f9..e1dbbc8af 100644 --- a/src/cvars.cpp +++ b/src/cvars.cpp @@ -502,6 +502,7 @@ consvar_t cv_kicktime = Server("kicktime", "20").values(CV_Unsigned); void MasterServer_OnChange(void); consvar_t cv_masterserver = Server("masterserver", "https://ms.kartkrew.org/ms/api").onchange(MasterServer_OnChange); +consvar_t cv_masterserver_nagattempts = Server("masterserver_nagattempts", "5").values(CV_Unsigned); void MasterServer_Debug_OnChange (void); consvar_t cv_masterserver_debug = Server("masterserver_debug", "Off").on_off().onchange(MasterServer_Debug_OnChange); diff --git a/src/k_menudraw.c b/src/k_menudraw.c index bc0233f1d..8fef30a7b 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -3086,6 +3086,23 @@ void M_DrawTimeAttack(void) // NOTE: This is pretty rigid and only intended for use with the multiplayer options menu which has *3* choices. +static void M_DrawMasterServerReminder(void) +{ + // Did you change the Server Browser address? Have a little reminder. + + INT32 mservflags = 0; + if (CV_IsSetToDefault(&cv_masterserver)) + mservflags = highlightflags; + else + mservflags = warningflags; + + INT32 y = BASEVIDHEIGHT - 24; + + V_DrawFadeFill(0, y-1, BASEVIDWIDTH, 10+1, 0, 31, 5); + V_DrawCenteredThinString(BASEVIDWIDTH/2, y, + mservflags, va("List via \"%s\"", cv_masterserver.string)); +} + static void M_MPOptDrawer(menu_t *m, INT16 extend[3][3]) { // This is a copypaste of the generic gamemode menu code with a few changes. @@ -3149,6 +3166,7 @@ void M_DrawMPOptSelect(void) M_DrawEggaChannel(); M_DrawMenuTooltips(); M_MPOptDrawer(&PLAY_MP_OptSelectDef, mpmenu.modewinextend); + M_DrawMasterServerReminder(); } // Multiplayer mode option select: HOST GAME! @@ -3468,20 +3486,6 @@ static void M_DrawServerCountAndHorizontalBar(void) va("%c", throbber[throbindex]) ); } - - // Did you change the Server Browser address? Have a little reminder. - - INT32 mservflags = 0; - if (CV_IsSetToDefault(&cv_masterserver)) - mservflags = highlightflags; - else - mservflags = warningflags; - - y = BASEVIDHEIGHT - 24; - - V_DrawFadeFill(0, y-1, BASEVIDWIDTH, 10+1, 0, 31, 5); - V_DrawCenteredThinString(BASEVIDWIDTH/2, y, - mservflags, va("List from \"%s\"", cv_masterserver.string)); } void M_DrawMPServerBrowser(void) @@ -3586,6 +3590,7 @@ void M_DrawMPServerBrowser(void) // And finally, the overlay bar! M_DrawServerCountAndHorizontalBar(); + M_DrawMasterServerReminder(); } // OPTIONS MENU diff --git a/src/menus/play-online-1.c b/src/menus/play-online-1.c index 7f9a9c294..e58490187 100644 --- a/src/menus/play-online-1.c +++ b/src/menus/play-online-1.c @@ -4,6 +4,7 @@ #include "../k_menu.h" #include "../m_cond.h" #include "../s_sound.h" +#include "../mserv.h" // cv_masterserver #if defined (TESTERS) #define IT_STRING_CALL_NOTESTERS IT_DISABLED @@ -11,13 +12,74 @@ #define IT_STRING_CALL_NOTESTERS (IT_STRING | IT_CALL) #endif // TESTERS +static boolean firstDismissedNagThisBoot = true; + +static void M_HandleMasterServerResetChoice(INT32 ch) +{ + if (ch == MA_YES) + { + 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; + } + } +} + +static void M_PreMPHostInitChoice(INT32 ch) +{ + M_HandleMasterServerResetChoice(ch); + M_MPHostInit(0); +} + +static void M_PreMPHostInit(INT32 choice) +{ + (void)choice; + + if (!CV_IsSetToDefault(&cv_masterserver) && cv_masterserver_nagattempts.value > 0) + { + M_StartMessage("Server Browser Alert", M_GetText("Hey! You've changed the game's\naddress for the Server Browser.\n\nYou won't be able to host games on\nthe official Server Browser.\n\nUnless you're from the future, this\nprobably isn't what you want.\n"), &M_PreMPHostInitChoice, MM_YESNO, "Fix and continue", "I changed the URL intentionally"); + return; + } + + M_MPHostInit(0); +} + +static void M_PreMPRoomSelectInitChoice(INT32 ch) +{ + M_HandleMasterServerResetChoice(ch); + M_MPRoomSelectInit(0); +} + +static void M_PreMPRoomSelectInit(INT32 choice) +{ + (void)choice; + + if (!CV_IsSetToDefault(&cv_masterserver) && cv_masterserver_nagattempts.value > 0) + { + M_StartMessage("Server Browser Alert", M_GetText("Hey! You've changed the game's\naddress for the Server Browser.\n\nYou won't be able to see games from\nthe official Server Browser.\n\nUnless you're from the future, this\nprobably isn't what you want.\n"), &M_PreMPRoomSelectInitChoice, MM_YESNO, "Fix and continue", "I changed the URL intentionally"); + return; + } + + M_MPRoomSelectInit(0); +} + menuitem_t PLAY_MP_OptSelect[] = { {IT_STRING_CALL_NOTESTERS, "Host Game", "Start your own online game!", - NULL, {.routine = M_MPHostInit}, 0, 0}, + NULL, {.routine = M_PreMPHostInit}, 0, 0}, {IT_STRING_CALL_NOTESTERS, "Server Browser", "Search for game servers to play in.", - NULL, {.routine = M_MPRoomSelectInit}, 0, 0}, + NULL, {.routine = M_PreMPRoomSelectInit}, 0, 0}, {IT_STRING | IT_CALL, "Join by IP", "Join an online game by its IP address.", NULL, {.routine = M_MPJoinIPInit}, 0, 0}, diff --git a/src/mserv.h b/src/mserv.h index dd9a548fd..6fe9a77c4 100644 --- a/src/mserv.h +++ b/src/mserv.h @@ -57,6 +57,7 @@ struct msg_ban_t // ================================ GLOBALS =============================== extern consvar_t cv_masterserver, cv_servername; +extern consvar_t cv_masterserver_nagattempts; extern consvar_t cv_server_contact; extern consvar_t cv_masterserver_update_rate; extern consvar_t cv_masterserver_timeout;