cleanup: remove low hanging LibraryDatabase.* nonsense

This commit is contained in:
Marco Antonio J. Costa
2026-07-24 04:54:29 -03:00
committed by majcosta
parent bbfd88c414
commit 916893ff66
5 changed files with 0 additions and 327 deletions
-287
View File
@@ -8,7 +8,6 @@
#include "Options Screen.h"
#include "Overhead.h"
#include "GameVersion.h"
#include "LibraryDataBase.h"
#include "DEBUG.H"
#include "HelpScreen.h"
#include "INIReader.h"
@@ -101,12 +100,6 @@ void InitGameSettings();
BOOLEAN GetCdromLocationFromIniFile( STR pRootOfCdromDrive );
extern BOOLEAN DoJA2FilesExistsOnDrive( CHAR8 *zCdLocation );
BOOLEAN GetCDromDriveLetter( STR8 pString );
BOOLEAN IsDriveLetterACDromDrive( STR pDriveLetter );
void CDromEjectionErrorMessageBoxCallBack( UINT8 bExitValue );
// these wrappers have the benefit that changing the location of the variable (gameinitoptionscreen/ini/ingame options) doesn't require huge changes throughout the code
// additionally, turning off a feature (for UB, for MP...) can be done here without additional checks in the code
bool UsingNewInventorySystem()
@@ -4306,260 +4299,6 @@ void FreeGameExternalOptions()
{
}
BOOLEAN GetCDLocation( )
{
UINT32 uiStrngLength = 0;
CHAR8 zCdLocation[ SGPFILENAME_LEN ];
UINT32 uiRetVal=0;
//Do a crude check to make sure the GAME_INI_FILE file is the right on
STRING512 ja2INIfile;
strcat(ja2INIfile, "..\\");
strcat(ja2INIfile, GAME_INI_FILE);
uiRetVal = GetPrivateProfileString( "Ja2 Settings","CD", "", zCdLocation, SGPFILENAME_LEN, ja2INIfile );
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
// Snap: don't clobber the INI 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, ja2INIfile );
GetPrivateProfileString( "Ja2 Settings","CD", "", zCdLocation, SGPFILENAME_LEN, ja2INIfile );
}
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 );
}
BOOLEAN GetCDromDriveLetter( STR8 pString )
{
UINT32 uiSize=0;
UINT8 ubCnt=0;
CHAR8 zDriveLetters[512];
CHAR8 zDriveLetter[16];
UINT32 uiDriveType;
uiSize = GetLogicalDriveStrings( 512, zDriveLetters );
for( ubCnt=0;ubCnt<uiSize;ubCnt++ )
{
//if the current char is not null
if( zDriveLetters[ ubCnt ] != '\0' )
{
//get the string
zDriveLetter[ 0 ] = zDriveLetters[ ubCnt ];
ubCnt++;
zDriveLetter[ 1 ] = zDriveLetters[ ubCnt ];
ubCnt++;
zDriveLetter[ 2 ] = zDriveLetters[ ubCnt ];
zDriveLetter[ 3 ] = '\0';
//Get the drive type
uiDriveType = GetDriveType( zDriveLetter );
switch( uiDriveType )
{
// The drive is a CD-ROM drive.
case DRIVE_CDROM:
strcpy( pString, zDriveLetter );
if ( DoJA2FilesExistsOnDrive( pString ) )
{
return( TRUE );
}
break;
default:
break;
}
}
}
return( FALSE );
}
/*
//Determine the type of drive the CDrom is on
uiDriveType = GetDriveType( zCdLocation );
switch( uiDriveType )
{
// The root directory does not exist.
case DRIVE_NO_ROOT_DIR:
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("CDrom Info '%s': %s", zCdLocation, "The root directory does not exist." ) );
break;
// The disk can be removed from the drive.
case DRIVE_REMOVABLE:
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("CDrom Info '%s': %s", zCdLocation, "The disk can be removed from the drive." ) );
break;
// The disk cannot be removed from the drive.
case DRIVE_FIXED:
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("CDrom Info '%s': %s", zCdLocation, "The disk cannot be removed from the drive." ) );
break;
// The drive is a remote (network) drive.
case DRIVE_REMOTE:
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("CDrom Info '%s': %s", zCdLocation, "The drive is a remote (network) drive." ) );
break;
// The drive is a CD-ROM drive.
case DRIVE_CDROM:
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("CDrom Info '%s': %s", zCdLocation, "The drive is a CD-ROM drive." ) );
break;
// The drive is a RAM disk.
case DRIVE_RAMDISK:
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("CDrom Info '%s': %s", zCdLocation, "The drive is a RAM disk." ) );
break;
// The drive type cannot be determined.
case DRIVE_UNKNOWN:
default:
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("CDrom Info '%s': %s", zCdLocation, "The drive type cannot be determined." ) );
break;
}
*/
BOOLEAN CheckIfGameCdromIsInCDromDrive()
{
CHAR8 zVolumeNameBuffer[512];
UINT32 uiVolumeSerialNumber=0;
UINT32 uiMaxComponentLength=0;
UINT32 uiFileSystemFlags=0;
CHAR8 zFileSystemNameBuffer[512];
CHAR8 zCdLocation[ SGPFILENAME_LEN ];
CHAR8 zCdFile[ SGPFILENAME_LEN ];
CHAR8 zCdromRootDrive[512];
UINT32 uiVolumeReturnValue;
UINT32 uiLastError = ERROR_SUCCESS;
if( !GetCdromLocationFromIniFile( zCdromRootDrive ) )
return( FALSE );
uiVolumeReturnValue = GetVolumeInformation( zCdromRootDrive, zVolumeNameBuffer, 512, (LPDWORD) &uiVolumeSerialNumber, (LPDWORD) &uiMaxComponentLength, (LPDWORD) &uiFileSystemFlags, zFileSystemNameBuffer, 512 );
if( !uiVolumeReturnValue )
{
uiLastError = GetLastError();
}
// OK, build filename
sprintf( zCdFile, "%s%s", zCdLocation, gCheckFilenames[ Random( 2 ) ] );
//If the cdrom drive is no longer in the drive
if( uiLastError == ERROR_NOT_READY || ( !FileExists( zCdFile ) ) )
{
CHAR8 sString[512];
//if a game has been started, add the msg about saving the game to a different entry
if( gTacticalStatus.fHasAGameBeenStarted )
{
sprintf( sString, "%S %S", pMessageStrings[ MSG_INTEGRITY_WARNING ], pMessageStrings[ MSG_CDROM_SAVE_GAME ] );
SaveGame( SAVE__ERROR_NUM, pMessageStrings[ MSG_CDROM_SAVE ] );
}
else
{
sprintf( sString, "%S", pMessageStrings[ MSG_INTEGRITY_WARNING ] );
}
// ATE: These are ness. due to reference counting
// in showcursor(). I'm not about to go digging in low level stuff at this
// point in the game development, so keep these here, as this works...
// ShowCursor(TRUE);
// ShowCursor(TRUE);
ShutdownWithErrorBox( sString );
//DoTester( );
//MessageBox(NULL, sString, "Error", MB_OK | MB_ICONERROR );
return( FALSE );
}
return( TRUE );
}
BOOLEAN GetCdromLocationFromIniFile( STR pRootOfCdromDrive )
{
UINT32 uiRetVal=0;
//Do a crude check to make sure the GAME_INI_FILE file is the right on
STRING512 ja2INIfile;
strcat(ja2INIfile, "..\\");
strcat(ja2INIfile, GAME_INI_FILE);
uiRetVal = GetPrivateProfileString( "Ja2 Settings","CD", "", pRootOfCdromDrive, SGPFILENAME_LEN, ja2INIfile );
if( uiRetVal == 0 )
{
pRootOfCdromDrive[0] = '\0';
return( FALSE);
}
else
{
//add the :\ to the dir
strcat( pRootOfCdromDrive, ":\\" );
return( TRUE );
}
}
void CDromEjectionErrorMessageBoxCallBack( UINT8 bExitValue )
{
if( bExitValue == MSG_BOX_RETURN_OK )
@@ -4576,32 +4315,6 @@ void CDromEjectionErrorMessageBoxCallBack( UINT8 bExitValue )
gfProgramIsRunning = FALSE;
}
}
BOOLEAN IsDriveLetterACDromDrive( STR pDriveLetter )
{
UINT32 uiDriveType;
CHAR8 zRootName[512];
sprintf( zRootName, "%s:\\", pDriveLetter );
//Get the drive type
uiDriveType = GetDriveType( zRootName );
switch( uiDriveType )
{
// The drive is a CD-ROM drive.
#ifdef JA2BETAVERSION
case DRIVE_NO_ROOT_DIR:
case DRIVE_REMOTE:
#endif
case DRIVE_CDROM:
return( TRUE );
break;
}
return( FALSE );
}
void DisplayGameSettings( )
{
//Display the version number
-4
View File
@@ -11,7 +11,6 @@
#include "Game Clock.h"
#include "Timer Control.h"
#include "Overhead.h"
#include "LibraryDataBase.h"
#include "Map Screen Interface.h"
#include "Tactical Save.h"
#include "Interface.h"
@@ -206,9 +205,6 @@ void ShutdownGame(void)
SaveGameSettings();
SaveFeatureFlags();
//shutdown the file database manager
ShutDownFileDatabase( );
if(gGameExternalOptions.fEnableInventoryPoolQ)//dnl ch51 081009
MemFreeInventoryPoolQ();
-1
View File
@@ -51,7 +51,6 @@
#include "Soldier Profile.h"
#include "Overhead.h"
#include "environment.h"
#include "LibraryDataBase.h"
#include "Music Control.h"
#include "SaveLoadGame.h"
#include "LaptopSave.h"
-27
View File
@@ -409,30 +409,3 @@ BOOLEAN PerformTimeLimitedCheck()
return( TRUE );
#endif
}
BOOLEAN DoJA2FilesExistsOnDrive( CHAR8 *zCdLocation )
{
BOOLEAN fFailed = FALSE;
CHAR8 zCdFile[ SGPFILENAME_LEN ];
INT32 cnt;
HWFILE hFile;
for ( cnt = 0; cnt < 4; 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;
}
FileClose( hFile );
}
return( !fFailed );
}
-8
View File
@@ -35,7 +35,6 @@
#include "FileMan.h"
#include "MemMan.h"
#include "DEBUG.H"
#include "LibraryDataBase.h"
#include "io.h"
#include "sgp_logger.h"
@@ -108,13 +107,6 @@ typedef struct FileSystemTag
//
//**************************************************************************
//The FileDatabaseHeader
DatabaseManagerHeaderStruct gFileDataBase;
//FileSystem gfs;
WIN32_FIND_DATA Win32FindInfo[20];
BOOLEAN fFindInfoInUse[20] = {FALSE,FALSE,FALSE,FALSE,FALSE,
FALSE,FALSE,FALSE,FALSE,FALSE,