Пример #1
0
BOOLEAN GetCDLocation( )
{
	UINT32	uiStrngLength = 0;
	CHAR8		zCdLocation[ SGPFILENAME_LEN ];
	UINT32	uiDriveType=0;
	UINT32	uiRetVal=0;

	//Do a crude check to make sure the Ja2.ini file is the right on

	uiRetVal = GetPrivateProfileString( "Ja2 Settings","CD", "", zCdLocation, SGPFILENAME_LEN, GAME_INI_FILE );
	if( uiRetVal == 0 || !IsDriveLetterACDromDrive( zCdLocation ) )
	{
		// the user most likely doesnt have the file, or the user has messed with the file
		// build a new one
		
		//First delete the old file
		FileDelete( GAME_INI_FILE );

		//Get the location of the cdrom drive
		if( GetCDromDriveLetter( zCdLocation ) )
		{
			CHAR8		*pTemp;

			//if it succeeded
			pTemp = strrchr( zCdLocation, ':' );
			pTemp[0] = '\0';
		}
		else
		{
			//put in a default location
			sprintf( zCdLocation, "c" );
		}

		//Now create a new file
		 WritePrivateProfileString( "Ja2 Settings", "CD", zCdLocation, GAME_INI_FILE );

		 GetPrivateProfileString( "Ja2 Settings","CD", "", zCdLocation, SGPFILENAME_LEN, GAME_INI_FILE );
	}

	uiStrngLength = strlen( zCdLocation );

	//if the string length is less the 1 character, it is a drive letter
	if( uiStrngLength == 1 )
	{
		sprintf( gzCdDirectory, "%s:\\%s", zCdLocation, CD_ROOT_DIR );
	}

	//else it is most likely a network location
	else if( uiStrngLength > 1 )
	{
		sprintf( gzCdDirectory, "%s\\%s", zCdLocation, CD_ROOT_DIR );
	}
	else
	{
		//no path was entered
		gzCdDirectory[ 0 ] = '.';
	}

	return( TRUE );
}
Пример #2
0
BOOLEAN PrepareLaserLockSystem()
{
	INT32	iInitRetVal=0;
	INT32	iRunRetVal=0;
	INT32	iCheckRetVal=0;
	CHAR8 zDirectory[512];

	CHAR8		zCdLocation[ SGPFILENAME_LEN ];
	CHAR8		zCdFile[ SGPFILENAME_LEN ];

	//Get the "current" file directory
	GetFileManCurrentDirectory( zDirectory );

	if( GetCDromDriveLetter( zCdLocation ) )
	{
		// OK, build filename
		sprintf( zCdFile, "%s%s", zCdLocation, "Data" );
	}
	else
	{
		goto FAILED_LASERLOK;
	}

	//Go back to the root directory
	SetFileManCurrentDirectory( zCdFile );
	//Init the laser lock system
	iInitRetVal = LASERLOK_Init( ghInstance );
	if( iInitRetVal != 0 )
		goto FAILED_LASERLOK;

	//makes the verification of the laserlok system
	iRunRetVal = LASERLOK_Run();
	if( iRunRetVal != 0 )
		goto FAILED_LASERLOK;

	//checks the result of the laserlok run function
	iCheckRetVal = LASERLOK_Check();
	if( iCheckRetVal != 0 )
		goto FAILED_LASERLOK;
	
	//Restore back to the proper directory
	SetFileManCurrentDirectory( zDirectory );
	return( TRUE );

FAILED_LASERLOK:
	//Restore back to the proper directory
	SetFileManCurrentDirectory( zDirectory );
	return( FALSE );
}
Пример #3
0
BOOLEAN HandleJA2CDCheckTwo( )
{
#ifdef NOCDCHECK

	return( TRUE );

#else
	BOOLEAN fFailed = TRUE;
	CHAR8		zCdLocation[ SGPFILENAME_LEN ];
	CHAR8		zCdFile[ SGPFILENAME_LEN ];

	// Check for a file on CD....
	if( GetCDromDriveLetter( zCdLocation ) )
	{
		// OK, build filename
		sprintf( zCdFile, "%s%s", zCdLocation, gCheckFilenames[ Random( 2 ) ] );

		// Check if it exists...
		if ( FileExists( zCdFile ) )
		{
			fFailed = FALSE;
		}
	}
	
	if ( fFailed )
	{
		CHAR8	zErrorMessage[256];

		sprintf( zErrorMessage, "%S", gzLateLocalizedString[ 56 ] );
		// Pop up message boc and get answer....
		if ( MessageBox( NULL, zErrorMessage, "Jagged Alliance 2", MB_OK ) == IDOK )
		{
			return( FALSE );
		}
	}
	else
	{
		return( TRUE );
	}

#endif

	return( FALSE );
}
Пример #4
0
BOOLEAN HandleJA2CDCheck( )
{
#ifdef	TIME_LIMITED_VERSION
	if( !PerformTimeLimitedCheck() )
	{
		return( FALSE );
	}
#endif


#ifdef NOCDCHECK

	return( TRUE );

#else
	BOOLEAN fFailed = FALSE;
	CHAR8		zCdLocation[ SGPFILENAME_LEN ];
	CHAR8		zCdFile[ SGPFILENAME_LEN ];
  INT32   cnt;
	HWFILE	hFile;

	// Check for a file on CD....
	if( GetCDromDriveLetter( zCdLocation ) )
	{
    for ( cnt = 0; cnt < 5; cnt++ )
    {     
		  // OK, build filename
		  sprintf( zCdFile, "%s%s", zCdLocation, gCheckFilenames[ cnt ] );

			hFile = FileOpen( zCdFile, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );

		  // Check if it exists...
		  if ( !hFile )
		  {
			  fFailed = TRUE;
				FileClose( hFile );
        break;
		  }

      // Check min size
//#ifndef GERMAN
//      if ( FileGetSize( hFile ) < gCheckFileMinSizes[ cnt ] )
//      {
//			  fFailed = TRUE;
//				FileClose( hFile );
//        break;  
//      }
//#endif

			FileClose( hFile );

    }
	}
  else
  {
		fFailed = TRUE;    
  }
	
	if ( fFailed )
	{
		CHAR8	zErrorMessage[256];

		sprintf( zErrorMessage, "%S", gzLateLocalizedString[ 56 ] );
		// Pop up message boc and get answer....
		if ( MessageBox( NULL, zErrorMessage, "Jagged Alliance 2", MB_OK ) == IDOK )
		{
			return( FALSE );
		}
	}

  return( TRUE );
	
#endif

}