* Remove FS_SetRestrictions

* Add FS_CheckPak0 for better error messages where dumb users are involved
This commit is contained in:
Tim Angus 2006-01-05 02:06:25 +00:00
parent 58e7fc0a1a
commit 1171a63aea

View file

@ -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. // 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 // 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 // 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 // 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 lastValidBase[MAX_OSPATH];
char lastValidGame[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 #ifdef FS_MISSING
FILE* missingFiles = NULL; FILE* missingFiles = NULL;
#endif #endif
@ -2856,66 +2852,48 @@ static void FS_Startup( const char *gameName ) {
Com_Printf( "%d files in pk3 files\n", fs_packFiles ); Com_Printf( "%d files in pk3 files\n", fs_packFiles );
} }
/* /*
=================== ===================
FS_SetRestrictions FS_CheckPak0
Looks for product keys and restricts media add on ability Checks that pak0.pk3 is present and its checksum is correct
if the full version is not found 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; 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( path->pack->checksum == DEMO_PAK0_CHECKSUM ) {
Com_Printf( "\n\n"
// if fs_restrict is set, don't even look for the id file, "**************************************************\n"
// which allows the demo release to be tested even if "WARNING: It looks like you're using pak0.pk3\n"
// the full game is present "from the demo. This may work fine, but it is not\n"
if ( !fs_restrict->integer ) { "guaranteed or supported.\n"
// look for the full game id "**************************************************\n\n\n" );
FS_ReadFile( "productid.txt", (void **)&productId ); } else if( path->pack->checksum != PAK0_CHECKSUM ) {
if ( productId ) { Com_Printf( "\n\n"
// check against the hardcoded string "**************************************************\n"
int seed, i; "WARNING: pak0.pk3 is present but its checksum (%u)\n"
"is not correct. Please re-copy pak0.pk3 from your\n"
seed = 5000; "legitimate Q3 CDROM.\n"
for ( i = 0 ; i < sizeof( fs_scrambledProductId ) ; i++ ) { "**************************************************\n\n\n",
if ( ( fs_scrambledProductId[i] ^ (seed&255) ) != productId[i] ) { path->pack->checksum );
break;
}
seed = (69069 * seed + 1);
} }
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" ); if( !foundPak0 ) {
Com_Error( ERR_FATAL, "Couldn't find pak0.pk3. Check that your Q3\n"
// restart the filesystem with just the demo directory "executable is in the correct place and that every file\n"
FS_Shutdown(qfalse); "in the baseq3 directory is present and readable." );
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 );
}
}
} }
} }
@ -3286,8 +3264,7 @@ void FS_InitFilesystem( void ) {
// try to start up normally // try to start up normally
FS_Startup( BASEGAME ); FS_Startup( BASEGAME );
// see if we are going to allow add-ons FS_CheckPak0( );
FS_SetRestrictions();
// if we can't find default.cfg, assume that the paths are // if we can't find default.cfg, assume that the paths are
// busted and error out now, rather than getting an unreadable // busted and error out now, rather than getting an unreadable
@ -3323,8 +3300,7 @@ void FS_Restart( int checksumFeed ) {
// try to start up normally // try to start up normally
FS_Startup( BASEGAME ); FS_Startup( BASEGAME );
// see if we are going to allow add-ons FS_CheckPak0( );
FS_SetRestrictions();
// if we can't find default.cfg, assume that the paths are // if we can't find default.cfg, assume that the paths are
// busted and error out now, rather than getting an unreadable // busted and error out now, rather than getting an unreadable