From 4b8bc463581a179d53ef5ca9d7267f1b88c5491f Mon Sep 17 00:00:00 2001 From: NepDisk Date: Tue, 14 Nov 2023 03:10:37 -0500 Subject: [PATCH] Master server 'b gone. Makes disabling the define actually alone the compile to work --- src/d_clisrv.c | 5 ++++- src/doomdef.h | 2 +- src/i_tcp.c | 4 ++++ src/m_menu.c | 40 ++++++++++++++++++++++++++++++++++------ src/mserv.c | 16 +++++++++++++++- src/mserv.h | 13 +++++++++---- 6 files changed, 67 insertions(+), 13 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 6e56d3ac4..68206d485 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1939,12 +1939,13 @@ static void CL_LoadReceivedSavegame(void) static void SendAskInfo(INT32 node) { tic_t asktime; - + #ifdef MASTERSERVER if (node != 0 && node != BROADCASTADDR && cv_rendezvousserver.string[0]) { I_NetRequestHolePunch(node); } + #endif MASTERSERVER asktime = I_GetTime(); @@ -6155,6 +6156,7 @@ static void UpdatePingTable(void) static void RenewHolePunch(void) { +#ifdef MASTERSERVER if (cv_rendezvousserver.string[0]) { static time_t past; @@ -6167,6 +6169,7 @@ static void RenewHolePunch(void) past = now; } } +#endif } // Handle timeouts to prevent definitive freezes from happenning diff --git a/src/doomdef.h b/src/doomdef.h index f41a02782..e05265ed5 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -638,7 +638,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #define GL_SHADERS #if defined (HAVE_CURL) && ! defined (NONET) -#define MASTERSERVER +//#define MASTERSERVER #else #undef UPDATE_ALERT #endif diff --git a/src/i_tcp.c b/src/i_tcp.c index 9162d61ae..ca2e5ea26 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -611,6 +611,7 @@ is_external_address (UINT32 p) static boolean hole_punch(ssize_t c) { +#ifdef MASTERSERVER /* See ../doc/Holepunch-Protocol.txt */ if (cv_rendezvousserver.string[0] && c == 10 && holepunchpacket->magic == hole_punch_magic && @@ -631,6 +632,7 @@ static boolean hole_punch(ssize_t c) { return false; } +#endif } // Returns true if a packet was received from a new node, false in all other cases @@ -1366,6 +1368,7 @@ static SINT8 SOCK_NetMakeNodewPort(const char *address, const char *port) static void rendezvous(int size) { +#ifdef MASTERSERVER char *addrs = strdup(cv_rendezvousserver.string); char *host = strtok(addrs, ":"); @@ -1396,6 +1399,7 @@ static void rendezvous(int size) } free(addrs); +#endif } static void SOCK_RequestHolePunch(INT32 node) diff --git a/src/m_menu.c b/src/m_menu.c index abda573bd..fbaf86b97 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1048,7 +1048,11 @@ static menuitem_t MP_MainMenu[] = {IT_HEADER, NULL, "Join a game", NULL, 132-24}, #ifndef NONET +#ifndef MASTERSERVER + {IT_GRAYEDOUT, NULL, "Internet server browser...",NULL, 142-24}, +#else {IT_STRING|IT_CALL, NULL, "Internet server browser...",M_PreConnectMenu, 142-24}, +#endif {IT_STRING|IT_CALL, NULL, "Join last server", M_ConnectLastServer, 150-24}, {IT_STRING|IT_KEYHANDLER, NULL, "Specify IPv4 address:", M_HandleConnectIP, 158-24}, #else @@ -1065,7 +1069,11 @@ static menuitem_t MP_MainMenu[] = static menuitem_t MP_ServerMenu[] = { {IT_STRING|IT_CVAR, NULL, "Max. Player Count", &cv_maxplayers, 10}, +#ifndef MASTERSERVER + {IT_GRAYEDOUT, NULL, "Advertise", NULL, 20}, +#else {IT_STRING|IT_CVAR, NULL, "Advertise", &cv_advertise, 20}, +#endif {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Server Name", &cv_servername, 30}, {IT_STRING|IT_CVAR, NULL, "Game Type", &cv_newgametype, 68}, @@ -1777,9 +1785,15 @@ static const char* OP_ServerOptionsTooltips[] = #ifndef NONET static menuitem_t OP_AdvServerOptionsMenu[] = { - {IT_STRING | IT_CVAR | IT_CV_STRING, - NULL, "Server Browser Address", &cv_masterserver, 10}, +#ifndef MASTERSERVER + {IT_GRAYEDOUT, + NULL, "Server Browser Address", NULL, 10}, +#else + {IT_STRING | IT_CVAR | IT_CV_STRING, + + NULL, "Server Browser Address", &cv_masterserver, 10}, +#endif {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 40}, {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 50}, {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 60}, @@ -9892,6 +9906,7 @@ static void M_DrawConnectMenu(void) highlightflags, va("%u of %d", serverlistpage+1, numPages)); // Did you change the Server Browser address? Have a little reminder. + #ifdef MASTERSERVER if (CV_IsSetToDefault(&cv_masterserver)) mservflags = mservflags|highlightflags|V_30TRANS; else @@ -9900,6 +9915,7 @@ static void M_DrawConnectMenu(void) mservflags, va("MS: %s", cv_masterserver.string)); M_DrawServerCountAndHorizontalBar(); + #endif // When switching pages, slide the old page and the // new page across the screen @@ -10011,6 +10027,7 @@ void M_SortServerList(void) #ifdef UPDATE_ALERT static void M_CheckMODVersion(int id) { +#ifdef MASTERSERVER char updatestring[500]; const char *updatecheck = GetMODVersion(id); if(updatecheck) @@ -10024,6 +10041,7 @@ static void M_CheckMODVersion(int id) I_unlock_mutex(m_menu_mutex); #endif } +#endif MASTERSERVER } #endif/*UPDATE_ALERT*/ @@ -10031,6 +10049,7 @@ static void M_CheckMODVersion(int id) static void Check_new_version_thread (int *id) { +#ifdef MASTERSERVER M_SetWaitingMode(M_WAITING_VERSION); M_CheckMODVersion(*id); @@ -10043,6 +10062,7 @@ Check_new_version_thread (int *id) { free(id); } +#endif MASTERSERVER } #endif/*defined (UPDATE_ALERT) && defined (HAVE_THREADS)*/ @@ -10108,6 +10128,7 @@ boolean firstDismissedNagThisBoot = true; static void M_HandleMasterServerResetChoice(event_t *ev) { +#ifdef MASTERSERVER INT32 choice = -1; choice = ev->data1; @@ -10132,31 +10153,34 @@ static void M_HandleMasterServerResetChoice(event_t *ev) } } } +#endif } static void M_PreStartServerMenu(INT32 choice) { - (void)choice; + (void)choice; +#ifdef 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; } - +#endif M_StartServerMenu(-1); + } static void M_PreConnectMenu(INT32 choice) { (void)choice; - +#ifdef 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; } - +#endif M_ConnectMenuModChecks(-1); } @@ -10399,7 +10423,9 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) static void M_DrawServerMenu(void) { + M_DrawLevelSelectOnly(false, false); + #ifdef MASTERSERVER if (currentMenu == &MP_ServerDef && cv_advertise.value) // Remind players where they're hosting. { int mservflags = V_ALLOWLOWERCASE; @@ -10409,7 +10435,9 @@ static void M_DrawServerMenu(void) mservflags = mservflags|warningflags; V_DrawCenteredThinString(BASEVIDWIDTH/2, BASEVIDHEIGHT-12, mservflags, va("Master Server: %s", cv_masterserver.string)); } + #endif M_DrawGenericMenu(); + } static void M_MapChange(INT32 choice) diff --git a/src/mserv.c b/src/mserv.c index 5c33cfe88..e39201eba 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -57,8 +57,12 @@ static void Command_Listserv_f(void); #endif/*MASTERSERVER*/ + + static void Update_parameters (void); +#ifdef MASTERSERVER + static void MasterServer_OnChange(void); static void Advertise_OnChange(void); @@ -69,16 +73,22 @@ static CV_PossibleValue_t masterserver_update_rate_cons_t[] = { {0, NULL} }; +#endif + +#ifdef MASTERSERVER consvar_t cv_masterserver = {"masterserver", "https://ms.kartkrew.org/ms/api", CV_SAVE|CV_CALL, NULL, MasterServer_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_rendezvousserver = {"holepunchserver", "relay.kartkrew.org", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +#endif consvar_t cv_servername = {"servername", "SRB2Kart server", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Update_parameters, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_server_contact = {"server_contact", "", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Update_parameters, 0, NULL, NULL, 0, 0, NULL}; - +#ifdef MASTERSERVER consvar_t cv_masterserver_update_rate = {"masterserver_update_rate", "15", CV_SAVE|CV_CALL|CV_NOINIT, masterserver_update_rate_cons_t, MasterClient_Ticker, 0, NULL, NULL, 0, 0, NULL}; 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}; +#endif + #if defined (MASTERSERVER) && defined (HAVE_THREADS) int ms_QueryId; @@ -98,6 +108,7 @@ UINT16 current_port = 0; void AddMServCommands(void) { #ifndef NONET +#ifdef MASTERSERVER CV_RegisterVar(&cv_masterserver); CV_RegisterVar(&cv_masterserver_update_rate); CV_RegisterVar(&cv_masterserver_timeout); @@ -106,6 +117,7 @@ void AddMServCommands(void) CV_RegisterVar(&cv_masterserver_nagattempts); CV_RegisterVar(&cv_advertise); CV_RegisterVar(&cv_rendezvousserver); +#endif CV_RegisterVar(&cv_servername); CV_RegisterVar(&cv_server_contact); #ifdef MASTERSERVER @@ -564,6 +576,7 @@ static void MasterServer_OnChange(void) static void Advertise_OnChange(void) { +#ifdef MASTERSERVER int different; if (cv_advertise.value) @@ -595,4 +608,5 @@ Advertise_OnChange(void) { M_PopupMasterServerRules(); } +#endif } diff --git a/src/mserv.h b/src/mserv.h index c4c2d078f..10199d3b0 100644 --- a/src/mserv.h +++ b/src/mserv.h @@ -51,9 +51,12 @@ typedef struct #endif // ================================ GLOBALS =============================== - -extern consvar_t cv_masterserver, cv_servername; +#ifdef MASTERSERVER +extern consvar_t cv_masterserver; +#endif +extern consvar_t cv_servername; extern consvar_t cv_server_contact; +#ifdef MASTERSERVER extern consvar_t cv_masterserver_update_rate; extern consvar_t cv_masterserver_timeout; extern consvar_t cv_masterserver_debug; @@ -63,7 +66,7 @@ extern consvar_t cv_rendezvousserver; extern consvar_t cv_advertise; extern consvar_t cv_masterserver_nagattempts; - +#endif #ifdef HAVE_THREADS extern int ms_QueryId; extern I_mutex ms_QueryId_mutex; @@ -71,7 +74,7 @@ extern I_mutex ms_QueryId_mutex; extern msg_server_t *ms_ServerList; extern I_mutex ms_ServerList_mutex; #endif - +#ifdef MASTERSERVER void RegisterServer(void); void UnregisterServer(void); @@ -97,3 +100,5 @@ int HMS_compare_mod_version (char *buffer, size_t size_of_buffer); const char * HMS_fetch_rules (char *buffer, size_t size_of_buffer); #endif + +#endif \ No newline at end of file