From e490db9426580e027535fddd8107292b97189556 Mon Sep 17 00:00:00 2001 From: taysta Date: Sat, 4 May 2024 15:00:21 +0800 Subject: [PATCH 1/4] Enable the download prompt if the server has HTTP downloads enabled while UDP downloads are disabled. --- codemp/client/cl_main.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/codemp/client/cl_main.cpp b/codemp/client/cl_main.cpp index 4a982ddddd..33967a601a 100644 --- a/codemp/client/cl_main.cpp +++ b/codemp/client/cl_main.cpp @@ -1690,7 +1690,7 @@ void CL_InitDownloads(void) { { // autodownload is disabled on the client // but it's possible that some referenced files on the server are missing - if (FS_ComparePaks( missingfiles, sizeof( missingfiles ), qfalse ) ) + if ( FS_ComparePaks( missingfiles, sizeof( missingfiles ), qfalse ) ) { // NOTE TTimo I would rather have that printed as a modal message box // but at this point while joining the game we don't know wether we will successfully join or not @@ -1702,11 +1702,14 @@ void CL_InitDownloads(void) { else if ( FS_ComparePaks( clc.downloadList, sizeof( clc.downloadList ) , qtrue ) ) { const char *serverInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SERVERINFO ]; const char *serverAllowDownloads = Info_ValueForKey( serverInfo, "sv_allowDownload" ); + const char *serverHTTPDownloads = Info_ValueForKey( serverInfo, "sv_httpdownloads" ); Com_Printf("Need paks: %s\n", clc.downloadList ); - if ( serverAllowDownloads[0] && !atoi(serverAllowDownloads) ) { - // The server has an "sv_allowDownload" value set, but it's 0 + if ( (serverAllowDownloads[0] && !atoi(serverAllowDownloads)) && !atoi(serverHTTPDownloads) ) { + // Yes, the check is intentionally simpler for http, because: + // - if a server has neither of the cvars in the serverinfo, we want to display the prompt and try to download + // - if a server has only sv_allowDownload set and no sv_httpdownloads we want to base our decision on the sv_allowDownload cvar and not be thrown off by sv_httpdownloads not existing Com_Printf("Skipping downloads, because the server does not allow downloads\n"); } else if ( *clc.downloadList && clc.httpdl[0]) { // if autodownloading is not enabled on the server From a2448616b40f9b71124e9dd02eb70f3891c3d3c3 Mon Sep 17 00:00:00 2001 From: taysta Date: Sat, 4 May 2024 15:28:51 +0800 Subject: [PATCH 2/4] Remove unnecessary MBII game check, fs_filterGames handles this already right below the check. --- codemp/client/cl_main.cpp | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/codemp/client/cl_main.cpp b/codemp/client/cl_main.cpp index 33967a601a..eda119198e 100644 --- a/codemp/client/cl_main.cpp +++ b/codemp/client/cl_main.cpp @@ -3743,28 +3743,6 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { } } - // if this is an MB2 server, ignore it - if (!Q_stricmp(Info_ValueForKey(infoString, "game"), "mbii") && Q_stricmp(Cvar_VariableString("fs_game"), "mbii")) { - return; - } - - if ( cl_filterGames && cl_filterGames->string && cl_filterGames->string[0] ) { - const char *gameFolder = Info_ValueForKey( infoString, "game" ); - - // If no game folder was specified the server is using base. Use the BASEGAME string so we can filter for it. - if ( !gameFolder[0] ) gameFolder = BASEGAME; - - // NOTE: As the command tokenization doesn't support nested quotes we can't filter fs_game with spaces using - // this approach, but fs_game with spaces cause other issues as well, like downloads not working and at - // the time of writing this no public servers actually use an fs_game with spaces... - Cmd_TokenizeString( cl_filterGames->string ); - for ( i = 0; i < Cmd_Argc(); i++ ) { - if ( !Q_stricmp(Cmd_Argv(i), gameFolder) && Q_stricmp(Cmd_Argv(i), FS_GetCurrentGameDir(false)) ) { - return; - } - } - } - if ( cl_filterGames && cl_filterGames->string && cl_filterGames->string[0] ) { const char *gameFolder = Info_ValueForKey( infoString, "game" ); From 0325a0eb327a6805aeda3ec11788e0b35c49af37 Mon Sep 17 00:00:00 2001 From: taysta Date: Sat, 4 May 2024 15:30:13 +0800 Subject: [PATCH 3/4] Camelcase new cvars `sv_httpDownloads` `sv_httpServerPort` --- codemp/client/cl_main.cpp | 2 +- codemp/server/server.h | 4 ++-- codemp/server/sv_init.cpp | 14 +++++++------- codemp/server/sv_main.cpp | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/codemp/client/cl_main.cpp b/codemp/client/cl_main.cpp index eda119198e..f2705535db 100644 --- a/codemp/client/cl_main.cpp +++ b/codemp/client/cl_main.cpp @@ -1702,7 +1702,7 @@ void CL_InitDownloads(void) { else if ( FS_ComparePaks( clc.downloadList, sizeof( clc.downloadList ) , qtrue ) ) { const char *serverInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SERVERINFO ]; const char *serverAllowDownloads = Info_ValueForKey( serverInfo, "sv_allowDownload" ); - const char *serverHTTPDownloads = Info_ValueForKey( serverInfo, "sv_httpdownloads" ); + const char *serverHTTPDownloads = Info_ValueForKey( serverInfo, "sv_httpDownloads" ); Com_Printf("Need paks: %s\n", clc.downloadList ); diff --git a/codemp/server/server.h b/codemp/server/server.h index 71a65253de..565a99d467 100644 --- a/codemp/server/server.h +++ b/codemp/server/server.h @@ -285,8 +285,8 @@ extern cvar_t *sv_zombietime; extern cvar_t *sv_rconPassword; extern cvar_t *sv_privatePassword; extern cvar_t *sv_allowDownload; -extern cvar_t *sv_httpdownloads; -extern cvar_t *sv_httpserverport; +extern cvar_t *sv_httpDownloads; +extern cvar_t *sv_httpServerPort; extern cvar_t *sv_maxclients; extern cvar_t *sv_privateClients; extern cvar_t *sv_hostname; diff --git a/codemp/server/sv_init.cpp b/codemp/server/sv_init.cpp index 5329bd013e..f9cf579d08 100644 --- a/codemp/server/sv_init.cpp +++ b/codemp/server/sv_init.cpp @@ -752,19 +752,19 @@ Ghoul2 Insert End } */ - if (!sv_httpdownloads || sv_httpdownloads->modified || sv_httpserverport->modified) { + if (!sv_httpDownloads || sv_httpDownloads->modified || sv_httpServerPort->modified) { NET_HTTP_StopServer(); } // here because latched - sv_httpdownloads = Cvar_Get("sv_httpdownloads", "0", CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_LATCH); - sv_httpserverport = Cvar_Get("sv_httpserverport", "0", CVAR_ARCHIVE | CVAR_LATCH); + sv_httpDownloads = Cvar_Get("sv_httpDownloads", "0", CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_LATCH); + sv_httpServerPort = Cvar_Get("sv_httpServerPort", "0", CVAR_ARCHIVE | CVAR_LATCH); - if (sv_httpdownloads->integer) { - if (!Q_stricmpn(sv_httpserverport->string, "http://", strlen("http://"))) { - Com_Printf("HTTP Downloads: redirecting to %s\n", sv_httpserverport->string); + if (sv_httpDownloads->integer) { + if (!Q_stricmpn(sv_httpServerPort->string, "http://", strlen("http://"))) { + Com_Printf("HTTP Downloads: redirecting to %s\n", sv_httpServerPort->string); } else { - sv.http_port = NET_HTTP_StartServer(sv_httpserverport->integer); + sv.http_port = NET_HTTP_StartServer(sv_httpServerPort->integer); // allow connected clients to use HTTP server for (i = 0; i < sv_maxclients->integer; i++) { if (svs.clients[i].state >= CS_CONNECTED) { diff --git a/codemp/server/sv_main.cpp b/codemp/server/sv_main.cpp index 73be8837cf..c1310532e2 100644 --- a/codemp/server/sv_main.cpp +++ b/codemp/server/sv_main.cpp @@ -39,8 +39,8 @@ cvar_t *sv_zombietime; // seconds to sink messages after disconnect cvar_t *sv_rconPassword; // password for remote server commands cvar_t *sv_privatePassword; // password for the privateClient slots cvar_t *sv_allowDownload; -cvar_t *sv_httpdownloads; -cvar_t *sv_httpserverport; +cvar_t *sv_httpDownloads; +cvar_t *sv_httpServerPort; cvar_t *sv_maxclients; cvar_t *sv_privateClients; // number of clients reserved for password cvar_t *sv_hostname; @@ -576,9 +576,9 @@ void SVC_Info( netadr_t from ) { } // webserver port - if (sv_httpdownloads->integer) { - if (Q_stristr(sv_httpserverport->string, "http://")) { - Info_SetValueForKey(infostring, "mvhttpurl", sv_httpserverport->string); + if (sv_httpDownloads->integer) { + if (Q_stristr(sv_httpServerPort->string, "http://")) { + Info_SetValueForKey(infostring, "mvhttpurl", sv_httpServerPort->string); } else { Info_SetValueForKey(infostring, "mvhttp", va("%i", sv.http_port)); } From f18b4f1b4e769eb9048cdf34d6cc03c9b5dc149b Mon Sep 17 00:00:00 2001 From: taysta Date: Sat, 11 May 2024 16:04:03 +0800 Subject: [PATCH 4/4] Fix check that was preventing UDP downloads from working --- codemp/client/cl_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/client/cl_main.cpp b/codemp/client/cl_main.cpp index f2705535db..2eb0da9e54 100644 --- a/codemp/client/cl_main.cpp +++ b/codemp/client/cl_main.cpp @@ -1711,7 +1711,7 @@ void CL_InitDownloads(void) { // - if a server has neither of the cvars in the serverinfo, we want to display the prompt and try to download // - if a server has only sv_allowDownload set and no sv_httpdownloads we want to base our decision on the sv_allowDownload cvar and not be thrown off by sv_httpdownloads not existing Com_Printf("Skipping downloads, because the server does not allow downloads\n"); - } else if ( *clc.downloadList && clc.httpdl[0]) { + } else if ( *clc.downloadList ) { // if autodownloading is not enabled on the server cls.state = CA_CONNECTED;