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

Add better directions/error for missing Quake 3 / Team Arena pk3 files #634

Merged
merged 3 commits into from
Aug 28, 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
119 changes: 92 additions & 27 deletions code/qcommon/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -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<<i) ) {
continue;
}

if ( missingIndex > 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
Expand Down Expand Up @@ -3600,24 +3658,24 @@ static void FS_CheckPak0( void )
}
}


if(!com_standalone->integer && (foundPak & 0x1ff) != 0x1ff)
if(!com_standalone->integer && (foundPak & ((1<<NUM_ID_PAKS)-1)) != ((1<<NUM_ID_PAKS)-1))
{
char errorText[MAX_STRING_CHARS] = "";

if((foundPak & 0x01) != 0x01)
{
Q_strcat(errorText, sizeof(errorText),
"\"pak0.pk3\" is missing. Please copy it "
"from your legitimate Q3 CDROM. ");
}
Q_strcat(errorText, sizeof(errorText),
"Quake 3 data files are missing. Please copy");

if((foundPak & 0x1fe) != 0x1fe)
{
Q_strcat(errorText, sizeof(errorText),
"Point Release files are missing. Please "
"re-install the 1.32 point release. ");
}
FS_AppendUserFriendlyPakList(errorText, sizeof(errorText), foundPak, NUM_ID_PAKS);

Q_strcat(errorText, sizeof(errorText),
va(" from the \"%s\" directory in your Quake 3 install or CD-ROM to:\n\n"
"%s%c%s%c\n\n", BASEGAME, fs_basepath->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 "
Expand All @@ -3627,23 +3685,30 @@ static void FS_CheckPak0( void )
Com_Error(ERR_FATAL, "%s", errorText);
}

if(!com_standalone->integer && foundTA && (foundTA & 0x0f) != 0x0f)
if(!com_standalone->integer && (foundTA & ((1<<NUM_TA_PAKS)-1)) != ((1<<NUM_TA_PAKS)-1)
&& (!Q_stricmp(fs_gamedirvar->string, BASETA) || !Q_stricmp(fs_basegame->string, BASETA)))
{
char errorText[MAX_STRING_CHARS] = "";

if((foundTA & 0x01) != 0x01)
{
Com_sprintf(errorText, sizeof(errorText),
"\"" BASETA "%cpak0.pk3\" is missing. Please copy it "
"from your legitimate Quake 3 Team Arena CDROM. ", PATH_SEP);
}
Q_strcat(errorText, sizeof(errorText),
"Quake 3 Team Arena data files are missing. Please copy");

if((foundTA & 0x0e) != 0x0e)
{
Q_strcat(errorText, sizeof(errorText),
"Team Arena Point Release files are missing. Please "
"re-install the latest Team Arena point release.");
}
FS_AppendUserFriendlyPakList(errorText, sizeof(errorText), foundTA, NUM_TA_PAKS);

Q_strcat(errorText, sizeof(errorText),
va(" from the \"%s\" directory in your Quake 3 Team Arena install or CD-ROM to:\n\n"
"%s%c%s%c\n\n", BASETA, fs_basepath->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);
}
Expand Down
2 changes: 2 additions & 0 deletions code/sys/sys_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,8 @@ Display an error message
*/
void Sys_ErrorDialog( const char *error )
{
Sys_Print( va( "%s\n", error ) );

if( Sys_Dialog( DT_YES_NO, va( "%s. Copy console log to clipboard?", error ),
"Error" ) == DR_YES )
{
Expand Down