diff --git a/code/qcommon/files.c b/code/qcommon/files.c index 8f4779d2..3602f810 100644 --- a/code/qcommon/files.c +++ b/code/qcommon/files.c @@ -200,7 +200,8 @@ or configs will never get loaded from disk! // every time a new demo pk3 file is built, this checksum must be updated. // the easiest way to get it is to just run the game and see what it spits out -#define DEMO_PAK_CHECKSUM 437558517u +#define DEMO_PAK0_CHECKSUM 2985612116u +#define PAK0_CHECKSUM 1566731103u // if this is defined, the executable positively won't work with any paks other // than the demo pak, even if productid is present. This is only used for our @@ -306,11 +307,6 @@ static char *fs_serverReferencedPakNames[MAX_SEARCH_PATHS]; // pk3 names char lastValidBase[MAX_OSPATH]; char lastValidGame[MAX_OSPATH]; -// productId: This file is copyright 1999 Id Software, and may not be duplicated except during a licensed installation of the full commercial version of Quake 3:Arena -static byte fs_scrambledProductId[152] = { -220, 129, 255, 108, 244, 163, 171, 55, 133, 65, 199, 36, 140, 222, 53, 99, 65, 171, 175, 232, 236, 193, 210, 250, 169, 104, 231, 231, 21, 201, 170, 208, 135, 175, 130, 136, 85, 215, 71, 23, 96, 32, 96, 83, 44, 240, 219, 138, 184, 215, 73, 27, 196, 247, 55, 139, 148, 68, 78, 203, 213, 238, 139, 23, 45, 205, 118, 186, 236, 230, 231, 107, 212, 1, 10, 98, 30, 20, 116, 180, 216, 248, 166, 35, 45, 22, 215, 229, 35, 116, 250, 167, 117, 3, 57, 55, 201, 229, 218, 222, 128, 12, 141, 149, 32, 110, 168, 215, 184, 53, 31, 147, 62, 12, 138, 67, 132, 54, 125, 6, 221, 148, 140, 4, 21, 44, 198, 3, 126, 12, 100, 236, 61, 42, 44, 251, 15, 135, 14, 134, 89, 92, 177, 246, 152, 106, 124, 78, 118, 80, 28, 42 -}; - #ifdef FS_MISSING FILE* missingFiles = NULL; #endif @@ -2856,66 +2852,48 @@ static void FS_Startup( const char *gameName ) { Com_Printf( "%d files in pk3 files\n", fs_packFiles ); } - /* =================== -FS_SetRestrictions +FS_CheckPak0 -Looks for product keys and restricts media add on ability -if the full version is not found +Checks that pak0.pk3 is present and its checksum is correct +Note: If you're building a game that doesn't depend on the +Q3 media pak0.pk3, you'll want to remove this function =================== */ -static void FS_SetRestrictions( void ) { +static void FS_CheckPak0( void ) +{ searchpath_t *path; - char *productId; + qboolean foundPak0 = qfalse; - return; + for( path = fs_searchpaths; path; path = path->next ) { + if( path->pack && + !Q_stricmpn( path->pack->pakBasename, "pak0", MAX_OSPATH ) ) { + foundPak0 = qtrue; -#ifndef PRE_RELEASE_DEMO - - // if fs_restrict is set, don't even look for the id file, - // which allows the demo release to be tested even if - // the full game is present - if ( !fs_restrict->integer ) { - // look for the full game id - FS_ReadFile( "productid.txt", (void **)&productId ); - if ( productId ) { - // check against the hardcoded string - int seed, i; - - seed = 5000; - for ( i = 0 ; i < sizeof( fs_scrambledProductId ) ; i++ ) { - if ( ( fs_scrambledProductId[i] ^ (seed&255) ) != productId[i] ) { - break; - } - seed = (69069 * seed + 1); + if( path->pack->checksum == DEMO_PAK0_CHECKSUM ) { + Com_Printf( "\n\n" + "**************************************************\n" + "WARNING: It looks like you're using pak0.pk3\n" + "from the demo. This may work fine, but it is not\n" + "guaranteed or supported.\n" + "**************************************************\n\n\n" ); + } else if( path->pack->checksum != PAK0_CHECKSUM ) { + Com_Printf( "\n\n" + "**************************************************\n" + "WARNING: pak0.pk3 is present but its checksum (%u)\n" + "is not correct. Please re-copy pak0.pk3 from your\n" + "legitimate Q3 CDROM.\n" + "**************************************************\n\n\n", + path->pack->checksum ); } - - FS_FreeFile( productId ); - - if ( i == sizeof( fs_scrambledProductId ) ) { - return; // no restrictions - } - Com_Error( ERR_FATAL, "Invalid product identification" ); } } -#endif - Cvar_Set( "fs_restrict", "1" ); - Com_Printf( "\nRunning in restricted demo mode.\n\n" ); - - // restart the filesystem with just the demo directory - FS_Shutdown(qfalse); - FS_Startup( DEMOGAME ); - - // make sure that the pak file has the header checksum we expect - for ( path = fs_searchpaths ; path ; path = path->next ) { - if ( path->pack ) { - // a tiny attempt to keep the checksum from being scannable from the exe - if ( (path->pack->checksum ^ 0x02261994u) != (DEMO_PAK_CHECKSUM ^ 0x02261994u) ) { - Com_Error( ERR_FATAL, "Corrupted pak0.pk3: %u", path->pack->checksum ); - } - } + if( !foundPak0 ) { + Com_Error( ERR_FATAL, "Couldn't find pak0.pk3. Check that your Q3\n" + "executable is in the correct place and that every file\n" + "in the baseq3 directory is present and readable." ); } } @@ -3286,8 +3264,7 @@ void FS_InitFilesystem( void ) { // try to start up normally FS_Startup( BASEGAME ); - // see if we are going to allow add-ons - FS_SetRestrictions(); + FS_CheckPak0( ); // if we can't find default.cfg, assume that the paths are // busted and error out now, rather than getting an unreadable @@ -3323,8 +3300,7 @@ void FS_Restart( int checksumFeed ) { // try to start up normally FS_Startup( BASEGAME ); - // see if we are going to allow add-ons - FS_SetRestrictions(); + FS_CheckPak0( ); // if we can't find default.cfg, assume that the paths are // busted and error out now, rather than getting an unreadable