From 814e1755f54800f7c610a3147474bb00c9484253 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sun, 21 Jan 2024 11:37:44 -0600 Subject: [PATCH] Add better directions/error for missing default pk3 files --- code/qcommon/files.c | 118 +++++++++++++++++++++++++++++++++---------- 1 file changed, 91 insertions(+), 27 deletions(-) diff --git a/code/qcommon/files.c b/code/qcommon/files.c index 11d46aed..f9f721de 100644 --- a/code/qcommon/files.c +++ b/code/qcommon/files.c @@ -3452,6 +3452,64 @@ static void FS_Startup( const char *gameName ) } #ifndef STANDALONE +/* +=================== +FS_AppendUserFriendlyPakList +=================== +*/ +static void FS_AppendUserFriendlyPakList( char *buf, size_t bufsize, int foundPakFiles, int numPakFiles ) +{ + int missingCount = 0; + int missingIndex = 0; + int missingMin = numPakFiles; + int missingMax = 0; + qboolean missingConsecutive = qtrue; + int i; + + for ( i = 0; i < numPakFiles; i++ ) { + if ( foundPakFiles & ( 1 << i ) ) { + continue; + } + + missingCount++; + + if ( missingMin > i ) { + missingMin = i; + } + if ( missingMax < i ) { + missingMax = i; + } + + if ( i > missingMin && ( foundPakFiles & ( 1<< ( i - 1 ) ) ) ) { + missingConsecutive = qfalse; + } + } + + if ( missingConsecutive && missingMax >= missingMin + 2 ) { + Q_strcat( buf, bufsize, + va( " \"pak%d.pk3\" through \"pak%d.pk3\"", + missingMin, missingMax ) ); + } else { + for ( i = 0; i < numPakFiles; i++ ) { + if ( foundPakFiles & (1< 0 && missingCount > 2 ) { + Q_strcat( buf, bufsize, "," ); + } + + if ( missingIndex == missingCount - 1 && missingCount > 1 ) { + Q_strcat( buf, bufsize, " and" ); + } + + Q_strcat( buf, bufsize, va( " \"pak%d.pk3\"", i ) ); + + missingIndex++; + } + } +} + /* =================== FS_CheckPak0 @@ -3600,24 +3658,24 @@ static void FS_CheckPak0( void ) } } - - if(!com_standalone->integer && (foundPak & 0x1ff) != 0x1ff) + if(!com_standalone->integer && (foundPak & ((1<string, PATH_SEP, BASEGAME, PATH_SEP)); + + Q_strcat(errorText, sizeof(errorText), + "Quake 3 must be purchased to legitimately obtain pak0. " + "Quake 3 1.32 point release files (pak1 through pak8) " + "are freely available at:\n\n" + "https://ioquake3.org/extras/patch-data/\n\n"); Q_strcat(errorText, sizeof(errorText), va("Also check that your ioq3 executable is in " @@ -3627,23 +3685,29 @@ static void FS_CheckPak0( void ) Com_Error(ERR_FATAL, "%s", errorText); } - if(!com_standalone->integer && foundTA && (foundTA & 0x0f) != 0x0f) + if(!com_standalone->integer && foundTA && (foundTA & ((1<string, PATH_SEP, BASETA, PATH_SEP)); + + Q_strcat(errorText, sizeof(errorText), + "Quake 3 Team Arena must be purchased to legitimately obtain pak0. " + "Quake 3 Team Arena point release files (pak1 through pak3) " + "are freely available at:\n\n" + "https://ioquake3.org/extras/patch-data/\n\n"); + + Q_strcat(errorText, sizeof(errorText), + va("Also check that your ioq3 executable is in " + "the correct place and that every file " + "in the \"%s\" directory is present and readable", BASETA)); Com_Error(ERR_FATAL, "%s", errorText); }