Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autodl fixup #197

Merged
merged 4 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 7 additions & 26 deletions codemp/client/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1702,13 +1702,16 @@ 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]) {
} else if ( *clc.downloadList ) {
// if autodownloading is not enabled on the server
cls.state = CA_CONNECTED;

Expand Down Expand Up @@ -3740,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" );

Expand Down
4 changes: 2 additions & 2 deletions codemp/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions codemp/server/sv_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions codemp/server/sv_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down