From 4b1de56b016ce375675218ef0ee1fe719ee4e48f Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:45:06 +0300 Subject: [PATCH 1/6] Remove #ifdefs for USE_VFS --- CMakeLists.txt | 2 +- Editor/LoadScreen.cpp | 43 +- Editor/LoadScreen.h | 2 - Editor/Sector Summary.cpp | 176 ----- Laptop/IMP Confirm.cpp | 11 - MainMenuScreen.cpp | 2 - SaveLoadGame.cpp | 28 - SaveLoadScreen.cpp | 2 - Standard Gaming Platform/DEBUG.H | 2 - Standard Gaming Platform/DEBUG.cpp | 2 - Standard Gaming Platform/FileMan.cpp | 902 ------------------------ Standard Gaming Platform/MemMan.cpp | 18 - Standard Gaming Platform/Types.h | 22 +- Standard Gaming Platform/WinFont.cpp | 16 - Standard Gaming Platform/sgp.cpp | 122 ---- Standard Gaming Platform/sgp_logger.cpp | 34 - Standard Gaming Platform/sgp_logger.h | 34 +- Standard Gaming Platform/soundman.cpp | 14 - Standard Gaming Platform/video.cpp | 79 --- Strategic/Campaign Init.cpp | 21 - Strategic/Strategic AI.cpp | 41 -- Strategic/strategicmap.cpp | 75 -- Tactical/Tactical Save.cpp | 26 - TileEngine/SaveLoadMap.cpp | 6 - TileEngine/Shade Table Util.cpp | 31 - TileEngine/WorldDat.cpp | 2 - TileEngine/worlddef.cpp | 8 - Utils/Cinematics Bink.cpp | 16 - Utils/Cinematics.cpp | 18 - Utils/Debug Control.cpp | 20 - Utils/INIReader.cpp | 111 +-- Utils/INIReader.h | 6 +- Utils/message.cpp | 14 - jascreens.cpp | 19 - 34 files changed, 9 insertions(+), 1916 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b196f87e6..5a36e8481 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ set(usingMsBuild $) # TODO: build our own Lua 5.1.2 from source so we can use whichever set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") -add_compile_definitions(CINTERFACE XML_STATIC VFS_STATIC VFS_WITH_SLF VFS_WITH_7ZIP USE_VFS _CRT_SECURE_NO_DEPRECATE) +add_compile_definitions(CINTERFACE XML_STATIC VFS_STATIC VFS_WITH_SLF VFS_WITH_7ZIP _CRT_SECURE_NO_DEPRECATE) include_directories(${CMAKE_SOURCE_DIR} "ext/VFS/include" Utils TileEngine TacticalAI ModularizedTacticalAI Tactical Strategic "Standard Gaming Platform" Res Lua Laptop Multiplayer "Multiplayer/raknet" Editor Console) # external libraries diff --git a/Editor/LoadScreen.cpp b/Editor/LoadScreen.cpp index 81a9e0248..7c7d70b4e 100644 --- a/Editor/LoadScreen.cpp +++ b/Editor/LoadScreen.cpp @@ -83,9 +83,7 @@ INT32 iCurrFileShown; INT32 iLastFileClicked; INT32 iLastClickTime; -#ifdef USE_VFS CHAR8 gzProfileName[FILENAME_BUFLEN];//dnl ch81 021213 -#endif CHAR16 gzFilename[FILENAME_BUFLEN];//dnl ch39 190909 extern INT16 gsSelSectorX; extern INT16 gsSelSectorY; @@ -165,7 +163,6 @@ void LoadSaveScreenEntry() } iTopFileShown = iTotalFiles = 0; -#ifdef USE_VFS//dnl ch37 300909 gzProfileName[0] = 0;//dnl ch81 021213 FDLG_LIST* TempFileList = NULL; vfs::CProfileStack* st = getVFS()->getProfileStack(); @@ -220,25 +217,6 @@ void LoadSaveScreenEntry() } while(FileList->pPrev) FileList = FileList->pPrev; -#else - if(GetFileFirst("MAPS\\*.dat", &FileInfo)) - { - if(strlen(FileInfo.zFileName) < FILENAME_BUFLEN) - { - FileList = AddToFDlgList(FileList, &FileInfo); - iTotalFiles++; - } - while(GetFileNext(&FileInfo)) - { - if(strlen(FileInfo.zFileName) < FILENAME_BUFLEN) - { - FileList = AddToFDlgList(FileList, &FileInfo); - iTotalFiles++; - } - } - GetFileClose(&FileInfo); - } -#endif swprintf( zOrigName, L"%s Map (*.dat)", iCurrentAction == ACTION_SAVE_MAP ? L"Save" : L"Load" ); swprintf( gzFilename, L"%S", gubFilename ); @@ -283,7 +261,8 @@ UINT32 ProcessLoadSaveScreenMessageBoxResult() { if( gfReadOnly ) { - FileClearAttributes( gszCurrFilename ); + // Other call sites have replaced this with FileDelete(); for VFS, should we do the same here? + //FileClearAttributes( gszCurrFilename ); gfReadOnly = FALSE; } FileDelete( gszCurrFilename ); @@ -468,19 +447,6 @@ UINT32 LoadSaveScreenHandle(void) } sprintf(gszCurrFilename, "MAPS\\%S", gzFilename); gfFileExists = FALSE; -#ifndef USE_VFS - gfReadOnly = FALSE; - if(FileExists(gszCurrFilename)) - { - gfFileExists = TRUE; - if(GetFileFirst(gszCurrFilename, &FileInfo)) - { - if(FileInfo.uiFileAttribs & (FILE_IS_READONLY|FILE_IS_DIRECTORY|FILE_IS_HIDDEN|FILE_IS_SYSTEM|FILE_IS_OFFLINE|FILE_IS_TEMPORARY)) - gfReadOnly = TRUE; - GetFileClose(&FileInfo); - } - } -#else gfReadOnly = TRUE; vfs::CProfileStack* st = getVFS()->getProfileStack(); vfs::CProfileStack::Iterator it = st->begin(); @@ -502,7 +468,6 @@ UINT32 LoadSaveScreenHandle(void) } it.next(); } -#endif if(gfReadOnly) { CreateMessageBox(L" File is read only! Choose a different name? "); @@ -726,7 +691,6 @@ void SelectFileDialogYPos( UINT16 usRelativeYPos ) iLastClickTime = iCurrClickTime; iLastFileClicked = x; //dnl ch81 021213 -#ifdef USE_VFS gzProfileName[0] = 0; while(FListNode = FListNode->pPrev) { @@ -737,7 +701,6 @@ void SelectFileDialogYPos( UINT16 usRelativeYPos ) break; } } -#endif break; } FListNode = FListNode->pNext; @@ -950,7 +913,6 @@ void HandleMainKeyEvents( InputAtom *pEvent ) SetInputFieldStringWith16BitString(0, L""); wcscpy(gzFilename, L""); } -#ifdef USE_VFS gzProfileName[0] = 0; while(curr = curr->pPrev) { @@ -961,7 +923,6 @@ void HandleMainKeyEvents( InputAtom *pEvent ) break; } } -#endif } } } diff --git a/Editor/LoadScreen.h b/Editor/LoadScreen.h index 07b08c743..c8adac4cf 100644 --- a/Editor/LoadScreen.h +++ b/Editor/LoadScreen.h @@ -51,9 +51,7 @@ extern CHAR16 gzErrorCatchString[ 256 ]; //dnl ch81 031213 extern CHAR16 gzFilename[FILENAME_BUFLEN]; -#ifdef USE_VFS extern CHAR8 gzProfileName[FILENAME_BUFLEN]; -#endif #endif #endif diff --git a/Editor/Sector Summary.cpp b/Editor/Sector Summary.cpp index aa4865524..b71742472 100644 --- a/Editor/Sector Summary.cpp +++ b/Editor/Sector Summary.cpp @@ -1923,40 +1923,14 @@ BOOLEAN HandleSummaryInput( InputAtom *pEvent ) void CreateGlobalSummary() { -#ifndef USE_VFS - FILE *fp; - STRING512 Dir; - STRING512 ExecDir; -#endif OutputDebugString( "Generating GlobalSummary Information...\n" ); gfGlobalSummaryExists = FALSE; //Set current directory to JA2\DevInfo which contains all of the summary data -#ifndef USE_VFS - GetExecutableDirectory( ExecDir ); - sprintf( Dir, "%s\\DevInfo", ExecDir ); - - // Snap: save current directory - //GetFileManCurrentDirectory( DataDir ); - - //Directory doesn't exist, so create it, and continue. - if( !MakeFileManDirectory( Dir ) ) - AssertMsg( 0, "Can't create new directory, JA2\\DevInfo for summary information." ); - if( !SetFileManCurrentDirectory( Dir ) ) - AssertMsg( 0, "Can't set to new directory, JA2\\DevInfo for summary information." ); - - //Generate a simple readme file. - fp = fopen( "readme.txt", "w" ); - Assert( fp ); - fprintf( fp, "%s\n%s\n", "This information is used in conjunction with the editor.", - "This directory or it's contents shouldn't be included with final release." ); - fclose( fp ); -#else vfs::COpenWriteFile wfile(L"DevInfo\\readme.txt",true,true); std::string str = "This information is used in conjunction with the editor.\n"; str += "This directory or it's contents shouldn't be included with final release.\n"; SGP_TRYCATCH_RETHROW( wfile->write(str.c_str(), str.length()), L"" ); -#endif // Snap: Restore the data directory once we are finished. //SetFileManCurrentDirectory( DataDir ); @@ -2281,12 +2255,6 @@ void CalculateOverrideStatus() void LoadGlobalSummary() { HWFILE hfile; -#ifndef USE_VFS - STRING512 DataDir; - STRING512 ExecDir; - STRING512 DevInfoDir; - STRING512 MapsDir; -#endif UINT32 uiNumBytesRead; FLOAT dMajorVersion; INT32 x,y; @@ -2295,34 +2263,16 @@ void LoadGlobalSummary() OutputDebugString( "Executing LoadGlobalSummary()...\n" ); // Snap: save current directory -#ifndef USE_VFS - GetFileManCurrentDirectory( DataDir ); -#endif gfMustForceUpdateAllMaps = FALSE; gusNumberOfMapsToBeForceUpdated = 0; gfGlobalSummaryExists = FALSE; //Set current directory to JA2\DevInfo which contains all of the summary data -#ifndef USE_VFS - GetExecutableDirectory( ExecDir ); - sprintf( DevInfoDir, "%s\\DevInfo", ExecDir ); - sprintf( MapsDir, "%s\\Maps", DataDir ); - //Check to make sure we have a DevInfo directory. If we don't create one! - if( !SetFileManCurrentDirectory( DevInfoDir ) ) - { - OutputDebugString( "LoadGlobalSummary() aborted -- doesn't exist on this local computer.\n"); - return; - } -#endif //TEMP -#ifndef USE_VFS - FileDelete( "_global.sum" ); -#else if(FileExists("DevInfo\\_global.sum")) { FileDelete( "DevInfo\\_global.sum" ); } -#endif gfGlobalSummaryExists = TRUE; //Analyse all sectors to see if matching maps exist. For any maps found, the information @@ -2337,19 +2287,12 @@ void LoadGlobalSummary() sprintf( szSector, "%c%d", 'A' + y, x + 1 ); //main ground level -#ifndef USE_VFS - sprintf( szFilename, "%c%d.dat", 'A' + y, x + 1 ); - SetFileManCurrentDirectory( MapsDir ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - SetFileManCurrentDirectory( DevInfoDir ); -#else sprintf( szFilename, "Maps\\%c%d.dat", 'A' + y, x + 1 ); hfile = NULL; if(FileExists(szFilename)) { hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); } -#endif if( hfile ) { gbSectorLevels[x][y] |= GROUND_LEVEL_MASK; @@ -2359,27 +2302,16 @@ void LoadGlobalSummary() } else { -#ifndef USE_VFS - sprintf( szFilename, "%s.sum", szSector ); -#else sprintf( szFilename, "DevInfo\\%s.sum", szSector ); -#endif FileDelete( szFilename ); } //main B1 level -#ifndef USE_VFS - sprintf( szFilename, "%c%d_b1.dat", 'A' + y, x + 1 ); - SetFileManCurrentDirectory( MapsDir ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - SetFileManCurrentDirectory( DevInfoDir ); -#else sprintf( szFilename, "Maps\\%c%d_b1.dat", 'A' + y, x + 1 ); hfile = NULL; if(FileExists(szFilename)) { hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); } -#endif if( hfile ) { gbSectorLevels[x][y] |= BASEMENT1_LEVEL_MASK; @@ -2389,27 +2321,16 @@ void LoadGlobalSummary() } else { -#ifndef USE_VFS - sprintf( szFilename, "%s_b1.sum", szSector ); -#else sprintf( szFilename, "DevInfo\\%s_b1.sum", szSector ); -#endif FileDelete( szFilename ); } //main B2 level -#ifndef USE_VFS - sprintf( szFilename, "%c%d_b2.dat", 'A' + y, x + 1 ); - SetFileManCurrentDirectory( MapsDir ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - SetFileManCurrentDirectory( DevInfoDir ); -#else sprintf( szFilename, "Maps\\%c%d_b2.dat", 'A' + y, x + 1 ); hfile = NULL; if(FileExists(szFilename)) { hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); } -#endif if( hfile ) { gbSectorLevels[x][y] |= BASEMENT2_LEVEL_MASK; @@ -2419,27 +2340,16 @@ void LoadGlobalSummary() } else { -#ifndef USE_VFS - sprintf( szFilename, "%s_b2.sum", szSector ); -#else sprintf( szFilename, "DevInfo\\%s_b2.sum", szSector ); -#endif FileDelete( szFilename ); } //main B3 level -#ifndef USE_VFS - sprintf( szFilename, "%c%d_b3.dat", 'A' + y, x + 1 ); - SetFileManCurrentDirectory( MapsDir ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - SetFileManCurrentDirectory( DevInfoDir ); -#else sprintf( szFilename, "Maps\\%c%d_b3.dat", 'A' + y, x + 1 ); hfile = NULL; if(FileExists(szFilename)) { hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); } -#endif if( hfile ) { gbSectorLevels[x][y] |= BASEMENT3_LEVEL_MASK; @@ -2449,27 +2359,16 @@ void LoadGlobalSummary() } else { -#ifndef USE_VFS - sprintf( szFilename, "%s_b3.sum", szSector ); -#else sprintf( szFilename, "DevInfo\\%s_b3.sum", szSector ); -#endif FileDelete( szFilename ); } //alternate ground level -#ifndef USE_VFS - sprintf( szFilename, "%c%d_a.dat", 'A' + y, x + 1 ); - SetFileManCurrentDirectory( MapsDir ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - SetFileManCurrentDirectory( DevInfoDir ); -#else sprintf( szFilename, "Maps\\%c%d_a.dat", 'A' + y, x + 1 ); hfile = NULL; if(FileExists(szFilename)) { hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); } -#endif if( hfile ) { gbSectorLevels[x][y] |= ALTERNATE_GROUND_MASK; @@ -2479,27 +2378,16 @@ void LoadGlobalSummary() } else { -#ifndef USE_VFS - sprintf( szFilename, "%s_a.sum", szSector ); -#else sprintf( szFilename, "DevInfo\\%s_a.sum", szSector ); -#endif FileDelete( szFilename ); } //alternate B1 level -#ifndef USE_VFS - sprintf( szFilename, "%c%d_b1_a.dat", 'A' + y, x + 1 ); - SetFileManCurrentDirectory( MapsDir ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - SetFileManCurrentDirectory( DevInfoDir ); -#else sprintf( szFilename, "Maps\\%c%d_b1_a.dat", 'A' + y, x + 1 ); hfile = NULL; if(FileExists(szFilename)) { hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); } -#endif if( hfile ) { gbSectorLevels[x][y] |= ALTERNATE_B1_MASK; @@ -2509,27 +2397,16 @@ void LoadGlobalSummary() } else { -#ifndef USE_VFS - sprintf( szFilename, "%s_b1_a.sum", szSector ); -#else sprintf( szFilename, "DevInfo\\%s_b1_a.sum", szSector ); -#endif FileDelete( szFilename ); } //alternate B2 level -#ifndef USE_VFS - sprintf( szFilename, "%c%d_b2_a.dat", 'A' + y, x + 1 ); - SetFileManCurrentDirectory( MapsDir ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - SetFileManCurrentDirectory( DevInfoDir ); -#else sprintf( szFilename, "Maps\\%c%d_b2_a.dat", 'A' + y, x + 1 ); hfile = NULL; if(FileExists(szFilename)) { hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); } -#endif if( hfile ) { gbSectorLevels[x][y] |= ALTERNATE_B2_MASK; @@ -2539,27 +2416,16 @@ void LoadGlobalSummary() } else { -#ifndef USE_VFS - sprintf( szFilename, "%s_b2_a.sum", szSector ); -#else sprintf( szFilename, "DevInfo\\%s_b2_a.sum", szSector ); -#endif FileDelete( szFilename ); } //alternate B3 level -#ifndef USE_VFS - sprintf( szFilename, "%c%d_b3_a.dat", 'A' + y, x + 1 ); - SetFileManCurrentDirectory( MapsDir ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - SetFileManCurrentDirectory( DevInfoDir ); -#else sprintf( szFilename, "Maps\\%c%d_b3_a.dat", 'A' + y, x + 1 ); hfile = NULL; if(FileExists(szFilename)) { hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); } -#endif if( hfile ) { gbSectorLevels[x][y] |= ALTERNATE_B1_MASK;; @@ -2569,20 +2435,12 @@ void LoadGlobalSummary() } else { -#ifndef USE_VFS - sprintf( szFilename, "%s_b3_a.sum", szSector ); -#else sprintf( szFilename, "DevInfo\\%s_b3_a.sum", szSector ); -#endif FileDelete( szFilename ); } } OutputDebugString( (LPCSTR)String("Sector Row %c complete... \n", y + 'A') ); } -#ifndef USE_VFS - // Snap: Restore the data directory once we are finished. - SetFileManCurrentDirectory( DataDir ); -#endif //sprintf( MapsDir, "%s\\Data", ExecDir ); //SetFileManCurrentDirectory( MapsDir ); @@ -2599,39 +2457,6 @@ void LoadGlobalSummary() void GenerateSummaryList() { -#ifndef USE_VFS - FILE *fp; - STRING512 DataDir; - STRING512 ExecDir; - STRING512 Dir; - - // Snap: save current directory - GetFileManCurrentDirectory( DataDir ); - - //Set current directory to JA2\DevInfo which contains all of the summary data - GetExecutableDirectory( ExecDir ); - sprintf( Dir, "%s\\DevInfo", ExecDir ); - if( !SetFileManCurrentDirectory( Dir ) ) - { - //Directory doesn't exist, so create it, and continue. - if( !MakeFileManDirectory( Dir ) ) - AssertMsg( 0, "Can't create new directory, JA2\\DevInfo for summary information." ); - if( !SetFileManCurrentDirectory( Dir ) ) - AssertMsg( 0, "Can't set to new directory, JA2\\DevInfo for summary information." ); - //Generate a simple readme file. - fp = fopen( "readme.txt", "w" ); - Assert( fp ); - fprintf( fp, "%s\n%s\n", "This information is used in conjunction with the editor.", - "This directory or it's contents shouldn't be included with final release." ); - fclose( fp ); - } - - // Snap: Restore the data directory once we are finished. - SetFileManCurrentDirectory( DataDir ); - //Set current directory back to data directory! - //sprintf( Dir, "%s\\Data", ExecDir ); - //SetFileManCurrentDirectory( Dir ); -#else try { vfs::COpenWriteFile wfile(L"DevInfo/readme.txt",true,true); @@ -2643,7 +2468,6 @@ void GenerateSummaryList() { SGP_RETHROW(L"Could not create readme.txt", ex); } -#endif } //dnl ch28 260909 diff --git a/Laptop/IMP Confirm.cpp b/Laptop/IMP Confirm.cpp index 817804620..fd74d9f2d 100644 --- a/Laptop/IMP Confirm.cpp +++ b/Laptop/IMP Confirm.cpp @@ -1336,16 +1336,6 @@ void WriteOutCurrentImpCharacter( INT32 iProfileId ) DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("WriteOutCurrentImpCharacter: Nickname.dat")); -#ifndef USE_VFS - char zFileName[13]; - char temp; - - for(int i=0;i < 9;i++) // Madd: I couldn't get strcpy or anything to work here... weird... if s/o wants to fix it, go ahead - { - temp = (char) gMercProfiles[iProfileId].zNickname[i]; - zFileName[i] = temp; - } -#else char zFileName[32]; if(vfs::Settings::getUseUnicode()) { @@ -1355,7 +1345,6 @@ void WriteOutCurrentImpCharacter( INT32 iProfileId ) { vfs::String::narrow(gMercProfiles[iProfileId].zNickname, 10, zFileName, 32); } -#endif // Changed by ADB, rev 1513 //strcat(zFileName,IMP_FILENAME_SUFFIX); diff --git a/MainMenuScreen.cpp b/MainMenuScreen.cpp index bebe6193c..22d2a2663 100644 --- a/MainMenuScreen.cpp +++ b/MainMenuScreen.cpp @@ -248,7 +248,6 @@ BOOLEAN InitMainMenu( ) { is_networked = FALSE; -#ifdef USE_VFS // remove Multiplayer profile if it exists vfs::CProfileStack *PS = getVFS()->getProfileStack(); vfs::CVirtualProfile *pProf = PS->getProfile("_MULTIPLAYER"); @@ -256,7 +255,6 @@ BOOLEAN InitMainMenu( ) { SGP_THROW_IFFALSE(PS->popProfile(), "Leaving Multiplayer mode : Could not remove \"_MULTIPLAYER\" profile"); } -#endif // Snap: UN-Init MP save game directory if ( !InitSaveDir() ) diff --git a/SaveLoadGame.cpp b/SaveLoadGame.cpp index 3d90f27e3..a013b4558 100644 --- a/SaveLoadGame.cpp +++ b/SaveLoadGame.cpp @@ -3553,33 +3553,6 @@ BOOLEAN Inventory::Save( HWFILE hFile, bool fSavingMap ) // The save directory now resides in the data directory (default or custom) BOOLEAN InitSaveDir() { -#ifndef USE_VFS - // Look for a custom data dir first - std::string dataDir = gCustomDataCat.GetRootDir(); - if( dataDir.empty() || FileGetAttributes( (STR) dataDir.c_str() ) == 0xFFFFFFFF ) { - dataDir = gDefaultDataCat.GetRootDir(); - } - - // The locale-specific save dir location is of the form L"..\\SavedGames" - // This has not changed; instead, we strip the ".." at the beginning - if(is_networked) - { - sprintf( gSaveDir, "%s%S", dataDir.c_str(), pMessageStrings[ MSG_MPSAVEDIRECTORY ] + 2 ); - } - else - sprintf( gSaveDir, "%s%S", dataDir.c_str(), pMessageStrings[ MSG_SAVEDIRECTORY ] + 2 ); - - // This was moved here from SaveGame - //Check to see if the save directory exists - if( FileGetAttributes( (STR) gSaveDir ) == 0xFFFFFFFF ) - { - //ok the direcotry doesnt exist, create it - if( !MakeFileManDirectory( (CHAR8 *)gSaveDir ) ) - { - return FALSE; - } - } -#else if(is_networked) { sprintf( gSaveDir, "%s", vfs::String::as_utf8(pMessageStrings[ MSG_MPSAVEDIRECTORY ] + 3).c_str() ); @@ -3588,7 +3561,6 @@ BOOLEAN InitSaveDir() { sprintf( gSaveDir, "%s", vfs::String::as_utf8(pMessageStrings[ MSG_SAVEDIRECTORY ] + 3).c_str() ); } -#endif return TRUE; } diff --git a/SaveLoadScreen.cpp b/SaveLoadScreen.cpp index 5fe319ff9..e5442659f 100644 --- a/SaveLoadScreen.cpp +++ b/SaveLoadScreen.cpp @@ -1350,7 +1350,6 @@ BOOLEAN InitSaveGameArray() gbSaveGameArray[VAL_SLOT_START + cnt] = TRUE; // anv: read last modified date property of save file -#ifdef USE_VFS // get full path to save file vfs::Path vfsPath; vfs::COpenReadFile rfile(zSaveGameName); @@ -1369,7 +1368,6 @@ BOOLEAN InitSaveGameArray() // close CloseHandle( hFile ); rfile->close(); -#endif } } else diff --git a/Standard Gaming Platform/DEBUG.H b/Standard Gaming Platform/DEBUG.H index 2b2e3169f..1d0d0c3ed 100644 --- a/Standard Gaming Platform/DEBUG.H +++ b/Standard Gaming Platform/DEBUG.H @@ -252,10 +252,8 @@ namespace sgp // compatibility with std::exception Exception(WString const& msg, std::exception& ex SGP_CALLER_LOCATION); -#if defined(USE_VFS) // compatibility with vfs::Exception Exception(WString const& msg, vfs::Exception& ex SGP_CALLER_LOCATION); -#endif virtual const char* what() const throw(); diff --git a/Standard Gaming Platform/DEBUG.cpp b/Standard Gaming Platform/DEBUG.cpp index 8463e9fb4..2aad673b1 100644 --- a/Standard Gaming Platform/DEBUG.cpp +++ b/Standard Gaming Platform/DEBUG.cpp @@ -562,7 +562,6 @@ sgp::Exception::Exception(sgp::WString const& msg, Exception& ex SGP_CALLER_LOCA _msg.push_back(excp); } -#if defined(USE_VFS) sgp::Exception::Exception(sgp::WString const& msg, vfs::Exception& ex SGP_CALLER_LOCATION_IMPL) { vfs::Exception::CALLSTACK::iterator it = ex.m_CallStack.begin(); @@ -584,7 +583,6 @@ sgp::Exception::Exception(sgp::WString const& msg, vfs::Exception& ex SGP_CALLER _msg.push_back(excp); } -#endif sgp::Exception::Exception(WString const& msg, std::exception& ex SGP_CALLER_LOCATION_IMPL) { diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index 0de5e3d80..e7f2a1d0d 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -47,7 +47,6 @@ using namespace std; #include #include -#ifdef USE_VFS #include #include @@ -66,7 +65,6 @@ struct SOperation typedef std::map tFILEMAP; static tFILEMAP s_mapFiles; -#endif //************************************************************************** // // Defines @@ -250,26 +248,7 @@ void FileDebug( BOOLEAN f ) //************************************************************************** BOOLEAN FileExists( STR strFilename ) { -#ifdef USE_VFS return getVFS()->fileExists(vfs::Path(strFilename)); -#else - // First check to see if it's in a library (most files should be there) - if ( gFileDataBase.fInitialized && - CheckIfFileExistInLibrary( strFilename ) ) return TRUE; - - // ... then check if it's in the custom Data directory - if ( gCustomDataCat.FindFile(strFilename) ) return TRUE; - - // ... then check if it's in the default Data directory - if ( gDefaultDataCat.FindFile(strFilename) ) return TRUE; - - // ... lastly, try to locate it in the file system - DWORD attribs = GetFileAttributes(strFilename); - if ( attribs != INVALID_FILE_ATTRIBUTES && !(attribs & FILE_ATTRIBUTE_DIRECTORY) ) - return TRUE; - - return FALSE; -#endif } //************************************************************************** @@ -296,22 +275,7 @@ BOOLEAN FileExists( STR strFilename ) //************************************************************************** extern BOOLEAN FileExistsNoDB( STR strFilename ) { -#ifdef USE_VFS return getVFS()->fileExists(vfs::Path(strFilename)); -#else - // First check if it's in the custom Data directory - if ( gCustomDataCat.FindFile(strFilename) ) return TRUE; - - // ... then check if it's in the default Data directory - if ( gDefaultDataCat.FindFile(strFilename) ) return TRUE; - - // ... lastly, try to locate it in the file system - DWORD attribs = GetFileAttributes(strFilename); - if ( attribs != INVALID_FILE_ATTRIBUTES && !(attribs & FILE_ATTRIBUTE_DIRECTORY) ) - return TRUE; - - return FALSE; -#endif } //************************************************************************** @@ -336,16 +300,7 @@ extern BOOLEAN FileExistsNoDB( STR strFilename ) //************************************************************************** BOOLEAN FileDelete( STR strFilename ) { -#ifdef USE_VFS return getVFS()->removeFileFromFS(vfs::Path(strFilename)); -#else - // Snap: delete the file from the default Data catalogue (if it is there) - // Since the path can be either relative or absolute, try both methods - gDefaultDataCat.RemoveFile(strFilename, true); - gDefaultDataCat.RemoveFile(strFilename, false); - - return( DeleteFile( (LPCSTR) strFilename ) ); -#endif } //************************************************************************** @@ -375,7 +330,6 @@ BOOLEAN FileDelete( STR strFilename ) //************************************************************************** HWFILE FileOpen( STR strFilename, UINT32 uiOptions, BOOLEAN fDeleteOnClose, STR strProfilename )//dnl ch81 021213 { -#ifdef USE_VFS vfs::Path path(strFilename); vfs::IBaseFile *pFile = NULL; try @@ -418,148 +372,6 @@ HWFILE FileOpen( STR strFilename, UINT32 uiOptions, BOOLEAN fDeleteOnClose, STR SGP_ERROR( "Caught undefined exception" ); } return 0; -#else - HWFILE hFile; - HANDLE hRealFile; - DWORD dwAccess; - DWORD dwFlagsAndAttributes; - BOOLEAN fExists; - HDBFILE hDBFile; - DWORD dwCreationFlags; - HWFILE hLibFile; - - hFile = 0; - hDBFile = 0; - dwCreationFlags = 0; - - dwAccess = 0; - if ( uiOptions & FILE_ACCESS_READ ) - dwAccess |= GENERIC_READ; - if ( uiOptions & FILE_ACCESS_WRITE ) - dwAccess |= GENERIC_WRITE; - - dwFlagsAndAttributes = FILE_FLAG_RANDOM_ACCESS; - if ( fDeleteOnClose ) - dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE; - - // Snap: This seems like an unnecessary check, but I don't feel like - // rewriting the function to eliminate it... - - // check if the file exists - note that we use the function FileExistsNoDB - // because it doesn't check the databases, and we don't want to do that here - fExists = FileExistsNoDB( strFilename ); - - // Snap: First see if the file is in the custom Data catalogue: - std::string filePath; - if ( gCustomDataCat.FindFile(strFilename) ) { - filePath = gCustomDataCat.GetRootDir() + '\\'; - } - filePath += strFilename; - // Bad cast! strFilename should have been const. Oh well... - strFilename = const_cast( filePath.c_str() ); - // Now strFilename points either to the original file name, - // or to the full file path in the custom Data directory. - // Except for this substitution, the rest of the function is unchanged. - - //if the file is on the disk - if ( fExists ) - { - hRealFile = CreateFile( (LPCSTR) strFilename, dwAccess, 0, NULL, OPEN_ALWAYS, - dwFlagsAndAttributes, NULL ); - - if ( hRealFile == INVALID_HANDLE_VALUE ) - { - return(0); - } - - //create a file handle for the 'real file' - hFile = CreateRealFileHandle( hRealFile ); - } - - // if the file did not exist, try to open it from the database - else if ( gFileDataBase.fInitialized ) - { - //if the file is to be opened for writing, return an error cause you cant write a file that is in the database library - if( fDeleteOnClose ) - { - return( 0 ); - } - - //if the file doesnt exist on the harddrive, but it is to be created, dont try to load it from the file database - if( uiOptions & FILE_ACCESS_WRITE ) - { - //if the files is to be written to - if( ( uiOptions & FILE_CREATE_NEW ) || ( uiOptions & FILE_OPEN_ALWAYS ) || ( uiOptions & FILE_CREATE_ALWAYS ) || ( uiOptions & FILE_TRUNCATE_EXISTING ) ) - { - hFile = 0; - } - } - //else if the file is to be opened using FILE_OPEN_EXISTING, and the file doesnt exists, fail out of the function) -// else if( uiOptions & FILE_OPEN_EXISTING ) -// { - //fail out of the function -// return( 0 ); -// } - else - { - //If the file is in the library, get a handle to it. - hLibFile = OpenFileFromLibrary( strFilename ); - - //tried to open a file that wasnt in the database - if( !hLibFile ) - return( 0 ); - else - return( hLibFile ); //return the file handle - } - } - - if ( !hFile ) - { - if ( uiOptions & FILE_CREATE_NEW ) - { - dwCreationFlags = CREATE_NEW; - } - else if ( uiOptions & FILE_CREATE_ALWAYS ) - { - dwCreationFlags = CREATE_ALWAYS; - } - else if ( uiOptions & FILE_OPEN_EXISTING || uiOptions & FILE_ACCESS_READ ) - { - dwCreationFlags = OPEN_EXISTING; - } - else if ( uiOptions & FILE_OPEN_ALWAYS ) - { - dwCreationFlags = OPEN_ALWAYS; - } - else if ( uiOptions & FILE_TRUNCATE_EXISTING ) - { - dwCreationFlags = TRUNCATE_EXISTING; - } - else - { - dwCreationFlags = OPEN_ALWAYS; - } - - - hRealFile = CreateFile( (LPCSTR) strFilename, dwAccess, 0, NULL, dwCreationFlags, - dwFlagsAndAttributes, NULL ); - if ( hRealFile == INVALID_HANDLE_VALUE ) - { - UINT32 uiLastError = GetLastError(); - char zString[1024]; - FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, 0, uiLastError, 0, zString, 1024, NULL); - - return(0); - } - - hFile = CreateRealFileHandle( hRealFile ); - } - - if ( !hFile ) - return(0); - - return(hFile); -#endif } //************************************************************************** @@ -581,43 +393,12 @@ HWFILE FileOpen( STR strFilename, UINT32 uiOptions, BOOLEAN fDeleteOnClose, STR //************************************************************************** void FileClose( HWFILE hFile ) { -#ifdef USE_VFS vfs::IBaseFile *pFile = (vfs::IBaseFile*)hFile; if(pFile) { pFile->close(); s_mapFiles.erase(pFile); } -#else - INT16 sLibraryID; - UINT32 uiFileNum; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its the 'real file' library - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //if its not already closed - if( gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].uiFileID != 0 ) - { - CloseHandle( gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle ); - gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].uiFileID = 0; - gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle= 0; - gFileDataBase.RealFiles.iNumFilesOpen--; - if( gFileDataBase.RealFiles.iNumFilesOpen < 0 ) - { - //if for some reason we are below 0, report an error ( should never be ) - Assert( 0 ); - } - } - } - else - { - //if the database is initialized - if( gFileDataBase.fInitialized ) - CloseLibraryFile( sLibraryID, uiFileNum ); - } -#endif } //************************************************************************** @@ -669,7 +450,6 @@ class TimeCounter BOOLEAN FileRead( HWFILE hFile, PTR pDest, UINT32 uiBytesToRead, UINT32 *puiBytesRead ) { -#ifdef USE_VFS #ifdef JA2TESTVERSION TimeCounter timer; #endif @@ -702,80 +482,10 @@ BOOLEAN FileRead( HWFILE hFile, PTR pDest, UINT32 uiBytesToRead, UINT32 *puiByte } } return FALSE; -#else - HANDLE hRealFile; - DWORD dwNumBytesToRead, dwNumBytesRead; - BOOLEAN fRet = FALSE; - INT16 sLibraryID; - UINT32 uiFileNum; - -#ifdef JA2TESTVERSION - UINT32 uiStartTime = GetJA2Clock(); -#endif - - //init the variables - dwNumBytesToRead = dwNumBytesRead = 0; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - dwNumBytesToRead = (DWORD)uiBytesToRead; - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //if the file is opened - if( uiFileNum != 0 ) - { - hRealFile = gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle; - - fRet = ReadFile( hRealFile, pDest, dwNumBytesToRead, &dwNumBytesRead, NULL ); - if ( dwNumBytesToRead != dwNumBytesRead ) - { - UINT32 uiLastError = GetLastError(); - char zString[1024]; - FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, 0, uiLastError, 0, zString, 1024, NULL); - - fRet = FALSE; - } - - if ( puiBytesRead ) - *puiBytesRead = (UINT32)dwNumBytesRead; - } - } - else - { - //if the database is initialized - if( gFileDataBase.fInitialized ) - { - //if the library is open - if( IsLibraryOpened( sLibraryID ) ) - { - //if the file is opened - if( gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].uiFileID != 0 ) - { - //read the data from the library - fRet = LoadDataFromLibrary( sLibraryID, uiFileNum, pDest, dwNumBytesToRead, (UINT32 *) &dwNumBytesRead ); - if ( puiBytesRead ) - { - *puiBytesRead = (UINT32)dwNumBytesRead; - } - } - } - } - } - #ifdef JA2TESTVERSION - //Add the time that we spent in this function to the total. - uiTotalFileReadTime += GetJA2Clock() - uiStartTime; - uiTotalFileReadCalls++; - #endif - - return(fRet); -#endif } BOOLEAN FileReadLine( HWFILE hFile, std::string* pDest ) { -#ifdef USE_VFS vfs::IBaseFile *pFile = (vfs::IBaseFile*)hFile; if ( pFile && FileCheckEndOfFile( hFile ) == FALSE && (s_mapFiles[pFile].op == SOperation::READ) ) { @@ -787,7 +497,6 @@ BOOLEAN FileReadLine( HWFILE hFile, std::string* pDest ) return TRUE; } } -#endif // ifdef USE_VFS return FALSE; } @@ -836,7 +545,6 @@ BOOLEAN FileReadLine( HWFILE hFile, STR8 pDest, UINT32 uiDestSize, UINT32 *puiBy BOOLEAN FileWrite( HWFILE hFile, PTR pDest, UINT32 uiBytesToWrite, UINT32 *puiBytesWritten ) { -#ifdef USE_VFS if(uiBytesToWrite == 0)//dnl ch38 110909 { *puiBytesWritten = 0; @@ -871,42 +579,6 @@ BOOLEAN FileWrite( HWFILE hFile, PTR pDest, UINT32 uiBytesToWrite, UINT32 *puiBy } } return FALSE; -#else - HANDLE hRealFile; - DWORD dwNumBytesToWrite, dwNumBytesWritten; - BOOLEAN fRet; - INT16 sLibraryID; - UINT32 uiFileNum; - - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - dwNumBytesToWrite = (DWORD)uiBytesToWrite; - - //get the real file handle to the file - hRealFile = gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle; - - fRet = WriteFile( hRealFile, pDest, dwNumBytesToWrite, &dwNumBytesWritten, NULL ); - - if (dwNumBytesToWrite != dwNumBytesWritten) - fRet = FALSE; - - if ( puiBytesWritten ) - *puiBytesWritten = (UINT32)dwNumBytesWritten; - } - else - { - //we cannot write to a library file - if ( puiBytesWritten ) - *puiBytesWritten = 0; - return(FALSE); - } - - return(fRet); -#endif } //************************************************************************** @@ -932,7 +604,6 @@ BOOLEAN FileWrite( HWFILE hFile, PTR pDest, UINT32 uiBytesToWrite, UINT32 *puiBy BOOLEAN FileLoad( STR strFilename, PTR pDest, UINT32 uiBytesToRead, UINT32 *puiBytesRead ) { -#ifdef USE_VFS vfs::tReadableFile *pFile = getVFS()->getReadFile(vfs::Path(strFilename)); vfs::COpenReadFile rfile(pFile); if(pFile) @@ -952,30 +623,6 @@ BOOLEAN FileLoad( STR strFilename, PTR pDest, UINT32 uiBytesToRead, UINT32 *puiB return TRUE; } return FALSE; -#else - HWFILE hFile; - UINT32 uiNumBytesRead; - BOOLEAN fRet; - - hFile = FileOpen( strFilename, FILE_ACCESS_READ, FALSE ); - if ( hFile ) - { - fRet = FileRead( hFile, pDest, uiBytesToRead, &uiNumBytesRead ); - FileClose( hFile ); - - if (uiBytesToRead != uiNumBytesRead) - fRet = FALSE; - - if ( puiBytesRead ) - *puiBytesRead = uiNumBytesRead; - - CHECKF( uiNumBytesRead == uiBytesToRead ); - } - else - fRet = FALSE; - - return(fRet); -#endif } //************************************************************************** @@ -1008,7 +655,6 @@ BOOLEAN FileLoad( STR strFilename, PTR pDest, UINT32 uiBytesToRead, UINT32 *puiB BOOLEAN _cdecl FilePrintf( HWFILE hFile, STR8 strFormatted, ... ) { -#ifdef USE_VFS CHAR8 strToSend[160]; /* itemdescription of item 0 will NOT fit if only 80 Chars per Line!, Sergeant_Kolja, 2007-06-10 */ va_list argptr; BOOLEAN fRetVal = FALSE; @@ -1020,34 +666,6 @@ BOOLEAN _cdecl FilePrintf( HWFILE hFile, STR8 strFormatted, ... ) fRetVal = FileWrite( hFile, strToSend, strlen(strToSend), NULL ); return( fRetVal ); -#else - CHAR8 strToSend[160]; /* itemdescription of item 0 will NOT fit if only 80 Chars per Line!, Sergeant_Kolja, 2007-06-10 */ - va_list argptr; - BOOLEAN fRetVal = FALSE; - - INT16 sLibraryID; - UINT32 uiFileNum; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - va_start(argptr, strFormatted); - _vsnprintf( strToSend, DIM(strToSend), strFormatted, argptr ); /* made StringLen Save, Sergeant_Kolja, 2007-06-10 */ - strToSend[ DIM(strToSend)-1 ] = 0; - va_end(argptr); - - fRetVal = FileWrite( hFile, strToSend, strlen(strToSend), NULL ); - } - else - { - //its a library file, cant write to it so return an error - fRetVal = FALSE; - } - - return( fRetVal ); -#endif } //************************************************************************** @@ -1077,7 +695,6 @@ BOOLEAN _cdecl FilePrintf( HWFILE hFile, STR8 strFormatted, ... ) BOOLEAN FileSeek( HWFILE hFile, UINT32 uiDistance, UINT8 uiHow ) { -#ifdef USE_VFS INT32 iDistance = (INT32)uiDistance; vfs::IBaseFile *pFile = (vfs::IBaseFile*)hFile; @@ -1125,50 +742,6 @@ BOOLEAN FileSeek( HWFILE hFile, UINT32 uiDistance, UINT8 uiHow ) } } return FALSE; -#else - HANDLE hRealFile; - LONG lDistanceToMove; - DWORD dwMoveMethod; - INT32 iDistance=0; - - INT16 sLibraryID; - UINT32 uiFileNum; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //Get the handle to the real file - hRealFile = gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle; - - iDistance = (INT32) uiDistance; - - if ( uiHow == FILE_SEEK_FROM_START ) - dwMoveMethod = FILE_BEGIN; - else if ( uiHow == FILE_SEEK_FROM_END ) - { - dwMoveMethod = FILE_END; - if( iDistance > 0 ) - iDistance = -(iDistance); - } - else - dwMoveMethod = FILE_CURRENT; - - lDistanceToMove = (LONG)uiDistance; - - if ( SetFilePointer( hRealFile, iDistance, NULL, dwMoveMethod ) == 0xFFFFFFFF ) - return(FALSE); - } - else - { - //if the database is initialized - if( gFileDataBase.fInitialized ) - LibraryFileSeek( sLibraryID, uiFileNum, uiDistance, uiHow ); - } - - return(TRUE); -#endif } //************************************************************************** @@ -1196,7 +769,6 @@ BOOLEAN FileSeek( HWFILE hFile, UINT32 uiDistance, UINT8 uiHow ) INT32 FileGetPos( HWFILE hFile ) { -#ifdef USE_VFS vfs::IBaseFile *pFile = (vfs::IBaseFile*)hFile; if(pFile && (s_mapFiles[pFile].op == SOperation::WRITE)) { @@ -1216,44 +788,6 @@ INT32 FileGetPos( HWFILE hFile ) } return BAD_INDEX; -#else - HANDLE hRealFile; - UINT32 uiPositionInFile=0; - - INT16 sLibraryID; - UINT32 uiFileNum; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //Get the handle to the real file - hRealFile = gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle; - - uiPositionInFile = SetFilePointer( hRealFile, 0, NULL, FILE_CURRENT); - if( uiPositionInFile == 0xFFFFFFFF ) - { - uiPositionInFile = 0; - } - return( uiPositionInFile ); - } - else - { - //if the library is open - if( IsLibraryOpened( sLibraryID ) ) - { - //check if the file is open - if( gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].uiFileID != 0 ) - { - uiPositionInFile = gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].uiFilePosInFile; - return( uiPositionInFile ); - } - } - } - - return(BAD_INDEX); -#endif } //************************************************************************** @@ -1281,43 +815,12 @@ INT32 FileGetPos( HWFILE hFile ) UINT32 FileGetSize( HWFILE hFile ) { -#ifdef USE_VFS vfs::IBaseFile *pFile = (vfs::IBaseFile*)hFile; if(pFile) { return pFile->getSize(); } return 0; -#else - HANDLE hRealHandle; - UINT32 uiFileSize = 0xFFFFFFFF; - - INT16 sLibraryID; - UINT32 uiFileNum; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //Get the handle to a real file - hRealHandle = gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle; - - uiFileSize = GetFileSize( hRealHandle, NULL ); - } - else - { - //if the library is open - if( IsLibraryOpened( sLibraryID ) ) - uiFileSize = gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].pFileHeader->uiFileLength; - } - - - if ( uiFileSize == 0xFFFFFFFF ) - return(0); - else - return( uiFileSize ); -#endif } //************************************************************************** @@ -1632,9 +1135,6 @@ INT32 GetFilesInDirectory( HCONTAINER hStack, CHAR *pcDir, HANDLE hFile, WIN32_F BOOLEAN SetFileManCurrentDirectory( STR pcDirectory ) { -#ifndef USE_VFS - return( SetCurrentDirectory( pcDirectory ) ); -#else try { vfs::OS::setCurrectDirectory(pcDirectory); @@ -1645,19 +1145,11 @@ BOOLEAN SetFileManCurrentDirectory( STR pcDirectory ) return FALSE; } return TRUE; -#endif } BOOLEAN GetFileManCurrentDirectory( STRING512 pcDirectory ) { -#ifndef USE_VFS - if (GetCurrentDirectory( 512, pcDirectory ) == 0) - { - return( FALSE ); - } - return( TRUE ); -#else try { vfs::Path sDir; @@ -1670,7 +1162,6 @@ BOOLEAN GetFileManCurrentDirectory( STRING512 pcDirectory ) return FALSE; } return TRUE; -#endif } @@ -1707,11 +1198,7 @@ BOOLEAN DirectoryExists( STRING512 pcDirectory ) BOOLEAN MakeFileManDirectory( STRING512 pcDirectory ) { -#ifndef USE_VFS - return CreateDirectory( pcDirectory, NULL ); -#else return FALSE; -#endif } @@ -1721,87 +1208,8 @@ BOOLEAN MakeFileManDirectory( STRING512 pcDirectory ) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// BOOLEAN RemoveFileManDirectory( STRING512 pcDirectory, BOOLEAN fRecursive ) { -#ifdef USE_VFS // ignore 'recursive' flag, just delete every file in that subtree (but leave the directories) return getVFS()->removeDirectoryFromFS(pcDirectory); -#else - WIN32_FIND_DATA sFindData; - HANDLE SearchHandle; - const CHAR8 *pFileSpec = "*.*"; - BOOLEAN fDone = FALSE; - BOOLEAN fRetval=FALSE; - CHAR8 zOldDir[512]; - CHAR8 zSubdirectory[512]; - - GetFileManCurrentDirectory( zOldDir ); - - if( !SetFileManCurrentDirectory( pcDirectory ) ) - { - FastDebugMsg(String("RemoveFileManDirectory: ERROR - SetFileManCurrentDirectory on %s failed, error %d", pcDirectory, GetLastError())); - return( FALSE ); //Error going into directory - } - - //If there are files in the directory, DELETE THEM - SearchHandle = FindFirstFile( pFileSpec, &sFindData); - if( SearchHandle != INVALID_HANDLE_VALUE ) - { - - fDone = FALSE; - do - { - // if the object is a directory - if( GetFileAttributes( sFindData.cFileName ) == FILE_ATTRIBUTE_DIRECTORY ) - { - // only go in if the fRecursive flag is TRUE (like Deltree) - if (fRecursive) - { - sprintf(zSubdirectory, "%s\\%s", pcDirectory, sFindData.cFileName); - - if ((strcmp(sFindData.cFileName, ".") != 0) && (strcmp(sFindData.cFileName, "..") != 0)) - { - if (!RemoveFileManDirectory(zSubdirectory, TRUE)) - { - FastDebugMsg(String("RemoveFileManDirectory: ERROR - Recursive call on %s failed", zSubdirectory)); - break; - } - } - } - // otherwise, all the individual files will be deleted, but the subdirectories remain, causing - // RemoveDirectory() at the end to fail, thus this function will return FALSE in that event (failure) - } - else - { - FileDelete( sFindData.cFileName ); - } - - //find the next file in the directory - fRetval = FindNextFile( SearchHandle, &sFindData ); - if( fRetval == 0 ) - { - fDone = TRUE; - } - } while(!fDone); - - // very important: close the find handle, or subsequent RemoveDirectory() calls will fail - FindClose( SearchHandle ); - } - - if( !SetFileManCurrentDirectory( zOldDir ) ) - { - FastDebugMsg(String("RemoveFileManDirectory: ERROR - SetFileManCurrentDirectory on %s failed, error %d", zOldDir, GetLastError())); - return( FALSE ); //Error returning from subdirectory - } - - - // The directory MUST be empty - fRetval = RemoveDirectory( pcDirectory ); - if (!fRetval) - { - FastDebugMsg(String("RemoveFileManDirectory: ERROR - RemoveDirectory on %s failed, error %d", pcDirectory, GetLastError())); - } - - return fRetval; -#endif } @@ -1811,102 +1219,22 @@ BOOLEAN RemoveFileManDirectory( STRING512 pcDirectory, BOOLEAN fRecursive ) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// BOOLEAN EraseDirectory( STRING512 pcDirectory) { -#ifdef USE_VFS // ignore 'recursive' flag, just delete every file in that subtree (but leave the directories) return getVFS()->removeDirectoryFromFS(pcDirectory); -#else - WIN32_FIND_DATA sFindData; - HANDLE SearchHandle; - const CHAR8 *pFileSpec = "*.*"; - BOOLEAN fDone = FALSE; - CHAR8 zOldDir[512]; - - GetFileManCurrentDirectory( zOldDir ); - - if( !SetFileManCurrentDirectory( pcDirectory ) ) - { - FastDebugMsg(String("EraseDirectory: ERROR - SetFileManCurrentDirectory on %s failed, error %d", pcDirectory, GetLastError())); - return( FALSE ); //Error going into directory - } - - //If there are files in the directory, DELETE THEM - SearchHandle = FindFirstFile( pFileSpec, &sFindData); - if( SearchHandle != INVALID_HANDLE_VALUE ) - { - - fDone = FALSE; - do - { - // if it's a file, not a directory - if( GetFileAttributes( sFindData.cFileName ) != FILE_ATTRIBUTES_DIRECTORY ) - { - FileDelete( sFindData.cFileName ); - } - - //find the next file in the directory - if ( !FindNextFile( SearchHandle, &sFindData )) - { - fDone = TRUE; - } - } while(!fDone); - - // very important: close the find handle, or subsequent RemoveDirectory() calls will fail - FindClose( SearchHandle ); - } - - // Snap: Delete the directory from the default Data catalogue (if it is there) - // Since the path can be either relative or absolute, try both methods - gDefaultDataCat.RemoveDir(pcDirectory, true); - gDefaultDataCat.RemoveDir(pcDirectory, false); - - if( !SetFileManCurrentDirectory( zOldDir ) ) - { - FastDebugMsg(String("EraseDirectory: ERROR - SetFileManCurrentDirectory on %s failed, error %d", zOldDir, GetLastError())); - return( FALSE ); //Error returning from directory - } - - return( TRUE ); -#endif } BOOLEAN GetExecutableDirectory( STRING512 pcDirectory ) { -#ifdef USE_VFS vfs::Path exe_dir, exe_file; vfs::OS::getExecutablePath(exe_dir, exe_file); strncpy(pcDirectory, exe_dir.to_string().c_str(), 512); return true; -#else - SGPFILENAME ModuleFilename; - UINT32 cnt; - - if ( GetModuleFileName( NULL, ModuleFilename, sizeof( ModuleFilename ) ) == 0 ) - { - return( FALSE ); - } - - // Now get directory - strcpy( pcDirectory, ModuleFilename ); - - for ( cnt = strlen( pcDirectory ) - 1; cnt >= 0; cnt -- ) - { - if ( pcDirectory[ cnt ] == '\\' ) - { - pcDirectory[ cnt ] = '\0'; - break; - } - } -#endif - return( TRUE ); } -#ifdef USE_VFS static vfs::CVirtualFileSystem::Iterator file_iter; -#endif BOOLEAN GetFileFirst( CHAR8 * pSpec, GETFILESTRUCT *pGFStruct ) { -#ifdef USE_VFS CHECKF( pSpec != NULL ); CHECKF( pGFStruct != NULL ); @@ -1927,43 +1255,10 @@ BOOLEAN GetFileFirst( CHAR8 * pSpec, GETFILESTRUCT *pGFStruct ) return TRUE; } return FALSE; -#else - INT32 x,iWhich=0; - BOOLEAN fFound; - - CHECKF( pSpec != NULL ); - CHECKF( pGFStruct != NULL ); - - fFound = FALSE; - for( x = 0; x < 20 && !fFound; x++) - { - if( !fFindInfoInUse[x] ) - { - iWhich = x; - fFound = TRUE; - } - } - - if ( !fFound ) - return(FALSE); - - pGFStruct->iFindHandle = iWhich; - - hFindInfoHandle[iWhich] = FindFirstFile( pSpec, &Win32FindInfo[iWhich] ); - - if ( hFindInfoHandle[iWhich] == INVALID_HANDLE_VALUE ) - return(FALSE); - fFindInfoInUse[iWhich] = TRUE; - - W32toSGPFileFind( pGFStruct, &Win32FindInfo[iWhich] ); - - return(TRUE); -#endif } BOOLEAN GetFileNext( GETFILESTRUCT *pGFStruct ) { -#ifdef USE_VFS if(!file_iter.end()) { file_iter.next(); @@ -1984,32 +1279,11 @@ BOOLEAN GetFileNext( GETFILESTRUCT *pGFStruct ) return TRUE; } return FALSE; -#else - CHECKF( pGFStruct != NULL ); - - if ( FindNextFile(hFindInfoHandle[pGFStruct->iFindHandle], &Win32FindInfo[pGFStruct->iFindHandle]) ) - { - W32toSGPFileFind( pGFStruct, &Win32FindInfo[pGFStruct->iFindHandle] ); - return(TRUE); - } - return(FALSE); -#endif } void GetFileClose( GETFILESTRUCT *pGFStruct ) { -#ifdef USE_VFS file_iter = vfs::CVirtualFileSystem::Iterator(); -#else - if ( pGFStruct == NULL ) - return; - - FindClose( hFindInfoHandle[pGFStruct->iFindHandle] ); - hFindInfoHandle[pGFStruct->iFindHandle] = INVALID_HANDLE_VALUE; - fFindInfoInUse[pGFStruct->iFindHandle] = FALSE; - - return; -#endif } void W32toSGPFileFind( GETFILESTRUCT *pGFStruct, WIN32_FIND_DATA *pW32Struct ) @@ -2226,18 +1500,13 @@ UINT32 FileGetAttributes( STR strFilename ) BOOLEAN FileClearAttributes( STR strFilename ) { -#ifndef USE_VFS - return SetFileAttributes( (LPCSTR) strFilename, FILE_ATTRIBUTE_NORMAL ); -#else return TRUE; -#endif } //returns true if at end of file, else false BOOLEAN FileCheckEndOfFile( HWFILE hFile ) { -#ifdef USE_VFS vfs::size_t current_position, max_position; vfs::IBaseFile *pFile = (vfs::IBaseFile*)hFile; @@ -2262,139 +1531,13 @@ BOOLEAN FileCheckEndOfFile( HWFILE hFile ) } } return FALSE; -#else - INT16 sLibraryID; - UINT32 uiFileNum; - HANDLE hRealFile; -// UINT8 Data; - UINT32 uiOldFilePtrLoc=0; - UINT32 uiEndOfFilePtrLoc=0; - UINT32 temp=0; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //Get the handle to the real file - hRealFile = gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle; - - //Get the current position of the file pointer - uiOldFilePtrLoc = SetFilePointer( hRealFile, 0, NULL, FILE_CURRENT ); - - //Get the end of file ptr location - uiEndOfFilePtrLoc = SetFilePointer( hRealFile, 0, NULL, FILE_END ); - - //reset back to the original location - temp = SetFilePointer( hRealFile, -( (INT32)( uiEndOfFilePtrLoc - uiOldFilePtrLoc ) ), NULL, FILE_END ); - - //if the 2 pointers are the same, we are at the end of a file - if( uiEndOfFilePtrLoc <= uiOldFilePtrLoc ) - { - return( 1 ); - } - } - - //else it is a library file - else - { - //if the database is initialized - if( gFileDataBase.fInitialized ) - { - //if the library is open - if( IsLibraryOpened( sLibraryID ) ) - { - //if the file is opened - if( gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].uiFileID != 0 ) - { - UINT32 uiLength; //uiOffsetInLibrary -// HANDLE hLibraryFile; -// UINT32 uiNumBytesRead; - UINT32 uiCurPos; - - uiLength = gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].pFileHeader->uiFileLength; - uiCurPos = gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].uiFilePosInFile; - - //if we are trying to read more data then the size of the file, return an error - if( uiCurPos >= uiLength ) - { - return( TRUE ); - } - } - } - } - } - - //we are not and the end of a file - return( 0 ); -#endif } BOOLEAN GetFileManFileTime( HWFILE hFile, SGP_FILETIME *pCreationTime, SGP_FILETIME *pLastAccessedTime, SGP_FILETIME *pLastWriteTime ) { -#ifndef USE_VFS - HANDLE hRealFile; - INT16 sLibraryID; - UINT32 uiFileNum; - - FILETIME sCreationUtcFileTime; - FILETIME sLastAccessedUtcFileTime; - FILETIME sLastWriteUtcFileTime; - - //Initialize the passed in variables - if (pCreationTime) memset( pCreationTime, 0, sizeof( SGP_FILETIME ) ); - if (pLastAccessedTime) memset( pLastAccessedTime, 0, sizeof( SGP_FILETIME ) ); - if (pLastWriteTime) memset( pLastWriteTime, 0, sizeof( SGP_FILETIME ) ); - - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //get the real file handle to the file - hRealFile = gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle; - - //Gets the UTC file time for the 'real' file - GetFileTime( hRealFile, &sCreationUtcFileTime, &sLastAccessedUtcFileTime, &sLastWriteUtcFileTime ); - - //converts the creation UTC file time to the current time used for the file - if(pCreationTime) - FileTimeToLocalFileTime( &sCreationUtcFileTime, pCreationTime ); - - //converts the accessed UTC file time to the current time used for the file - if (pLastAccessedTime) - FileTimeToLocalFileTime( &sLastAccessedUtcFileTime, pLastAccessedTime ); - - //converts the write UTC file time to the current time used for the file - if (pLastWriteTime) - FileTimeToLocalFileTime( &sLastWriteUtcFileTime, pLastWriteTime ); - } - else - { - //if the database is initialized - if( gFileDataBase.fInitialized ) - { - //if the library is open - if( IsLibraryOpened( sLibraryID ) ) - { - //if the file is opened - if( gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].uiFileID != 0 ) - { - if( !GetLibraryFileTime( sLibraryID, uiFileNum, pLastWriteTime ) ) - { - return( FALSE ); - } - } - } - } - } - return( TRUE ); -#else return( FALSE ); -#endif } @@ -2405,60 +1548,15 @@ INT32 CompareSGPFileTimes( SGP_FILETIME *pFirstFileTime, SGP_FILETIME *pSecondFi UINT32 FileSize(STR strFilename) { -#ifdef USE_VFS vfs::IBaseFile *pFile = getVFS()->getFile(vfs::Path(strFilename)); if(pFile) { return pFile->getSize(); } return 0; -#else -HWFILE hFile; -UINT32 uiSize; - - if((hFile=FileOpen(strFilename, FILE_OPEN_EXISTING | FILE_ACCESS_READ, FALSE))==0) - return(0); - - uiSize=FileGetSize(hFile); - FileClose(hFile); - - return(uiSize); -#endif -} - - - -HANDLE GetRealFileHandleFromFileManFileHandle( HWFILE hFile ) -{ -#ifndef USE_VFS - INT16 sLibraryID; - UINT32 uiFileNum; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its the 'real file' library - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //if its not already closed - if( gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].uiFileID != 0 ) - { - return( gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle ); - } - } - else - { - //if the file is not opened, dont close it - if( gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].uiFileID != 0 ) - { - return( gFileDataBase.pLibraries[ sLibraryID ].hLibraryHandle ); - } - } -#endif - return( 0 ); } - //************************************************************************** // // AddSubdirectoryToPath diff --git a/Standard Gaming Platform/MemMan.cpp b/Standard Gaming Platform/MemMan.cpp index 8db377900..caa545e8c 100644 --- a/Standard Gaming Platform/MemMan.cpp +++ b/Standard Gaming Platform/MemMan.cpp @@ -204,23 +204,6 @@ void ShutdownMemoryManager( void ) #ifndef EXTREME_MEMORY_DEBUGGING #ifdef JA2BETAVERSION { -#ifndef USE_VFS - FILE *fp; - fp = fopen( "MemLeakInfo.txt", "a" ); - if( fp ) - { - fprintf( fp, "\n\n" ); - fprintf( fp, ">>>>> MEMORY LEAK DETECTED!!! <<<<<\n" ); - fprintf( fp, " %d bytes memory total was allocated\n", guiMemAlloced ); - fprintf( fp, "- %d bytes memory total was freed\n", guiMemFreed ); - fprintf( fp, "_______________________________________________\n" ); - fprintf( fp, "%d bytes memory total STILL allocated\n", guiMemTotal ); - fprintf( fp, "%d memory blocks still allocated\n", MemDebugCounter ); - fprintf( fp, "guiScreenExitedFrom = %S\n", gzJA2ScreenNames[ gMsgBox.uiExitScreen ] ); - fprintf( fp, "\n\n" ); - } - fclose( fp ); -#else sgp::Logger_ID log_id = sgp::Logger::instance().createLogger(); sgp::Logger::LogInstance memLeak = SGP_LOG(log_id); memLeak << sgp::endl << sgp::endl; @@ -232,7 +215,6 @@ void ShutdownMemoryManager( void ) memLeak << MemDebugCounter << " memory blocks still allocated" << sgp::endl; memLeak << "guiScreenExitedFrom = " << gzJA2ScreenNames[ gMsgBox.uiExitScreen ] << sgp::endl; memLeak << sgp::endl << sgp::endl; -#endif } #endif #endif diff --git a/Standard Gaming Platform/Types.h b/Standard Gaming Platform/Types.h index 0fc57bef2..6c304ad39 100644 --- a/Standard Gaming Platform/Types.h +++ b/Standard Gaming Platform/Types.h @@ -141,15 +141,6 @@ typedef VECTOR4 COLOR; // rgba color array inline void convert_string(std::wstring const& str_in, std::string &str_out) { -#if !defined(USE_VFS) - const wchar_t* src = str_in.c_str(); - size_t len = wcstombs(NULL, src, str_in.length()); - if(len > 0) - { - str_out.resize(len); - wcstombs(&str_out[0], src, len); - } -#else if(vfs::Settings::getUseUnicode()) { str_out = vfs::String::as_utf8(str_in); @@ -158,20 +149,10 @@ inline void convert_string(std::wstring const& str_in, std::string &str_out) { vfs::String::narrow(str_in, str_out); } -#endif } inline void convert_string(std::string const& str_in, std::wstring &str_out) { -#if !defined(USE_VFS) - const char* src = str_in.c_str(); - size_t len = mbstowcs(NULL, src, str_in.length()); - if(len > 0) - { - str_out.resize(len); - mbstowcs(&str_out[0], src, len); - } -#else if(vfs::Settings::getUseUnicode()) { vfs::String::as_utf16(str_in, str_out); @@ -180,8 +161,7 @@ inline void convert_string(std::string const& str_in, std::wstring &str_out) { vfs::String::widen(str_in, str_out); } -#endif } -#endif \ No newline at end of file +#endif diff --git a/Standard Gaming Platform/WinFont.cpp b/Standard Gaming Platform/WinFont.cpp index bfed0c1be..223e634fb 100644 --- a/Standard Gaming Platform/WinFont.cpp +++ b/Standard Gaming Platform/WinFont.cpp @@ -189,21 +189,6 @@ Name=Tahoma Height=-20 Weight=400 */ -#ifndef USE_VFS - char INIFile[MAX_PATH]; - GetExecutableDirectory( INIFile ); - strcat(INIFile, "\\"); - strcat(INIFile, GAME_INI_FILE); - - - gWinFontAdjust = GetPrivateProfileInt("Ja2 Settings", "WIN_FONT_ADJUST", 0, INIFile); - for (UINT16 i=0; i @@ -841,9 +799,7 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC -#ifdef USE_VFS vfs::Log::setSharedString( getGameID() ); -#endif //if(!vfs::Aspects::getMutexFactory()) //{ // vfs::Aspects::setMutexFactory( new VfsMutexFactory() ); @@ -914,15 +870,6 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC // ShowCursor(FALSE); -#ifdef USE_VFS - //vfs::Path exe_dir, exe_file; - //os::getExecutablePath(exe_dir, exe_file); - //os::setCurrectDirectory(exe_dir); -#else - STRING512 sExecutableDir; - GetExecutableDirectory( sExecutableDir ); - SetCurrentDirectory(sExecutableDir); -#endif try { // Inititialize the SGP @@ -934,9 +881,7 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC } HANDLE_FATAL_ERROR; -#ifdef USE_VFS vfs::Log::flushReleaseAll(); -#endif #ifdef LUACONSOLE if (1==iScreenMode) @@ -1051,39 +996,10 @@ void GetRuntimeSettings( ) /* Detect cnc-ddraw and disable windowed mode */ BOOL bCncDdraw = GetProcAddress(GetModuleHandleW(L"ddraw.dll"), "GameHandlesClose") != NULL; -#ifndef USE_VFS - CHAR8 zMaximize[ 50 ]; - CHAR8 zWindowedMode[ 50 ]; - - // Runtime settings - for now use INI file - later use registry - STRING512 INIFile; // Path to the ini file - CHAR8 zScreenResolution[ 50 ]; - - // Get Executable Directory - GetExecutableDirectory( INIFile ); - - strcat(INIFile, "\\"); - strcat(INIFile, GAME_INI_FILE); -#else vfs::PropertyContainer oProps; oProps.initFromIniFile(GAME_INI_FILE); PopulateSectionFromCommandLine(oProps, "Ja2 Settings"); -#endif -#ifndef USE_VFS - if (GetPrivateProfileString( "Ja2 Settings","SCREEN_RESOLUTION", "", zScreenResolution, 50, INIFile )) - { - iResolution = atoi(zScreenResolution); - } - if (GetPrivateProfileString( "Ja2 Settings","SCREEN_MODE_WINDOWED_MAXIMIZE", "", zMaximize, 50, INIFile )) - { - iMaximize = atoi(zMaximize); - } - if (GetPrivateProfileString( "Ja2 Settings","SCREEN_MODE_WINDOWED", "", zWindowedMode, 50, INIFile )) - { - iWindowedMode = bCncDdraw ? 0 : atoi(zWindowedMode); - } -#else vfs::String loc = oProps.getStringProperty("Ja2 Settings", L"LOCALE"); if(!loc.empty()) { @@ -1142,9 +1058,7 @@ void GetRuntimeSettings( ) CIniReader::RegisterFileForMerging(*it); } } -#endif -#ifdef USE_VFS extern bool g_bUsePngItemImages; g_bUsePngItemImages = oProps.getBoolProperty(L"Ja2 Settings", L"USE_PNG_ITEM_IMAGES", false); g_bUseXML_Structures = oProps.getBoolProperty(L"Ja2 Settings", L"USE_XML_STRUCTURES", false); @@ -1164,17 +1078,9 @@ void GetRuntimeSettings( ) s_bExportStrings = oProps.getBoolProperty(L"Ja2 Settings", L"EXPORT_STRINGS", false); sp_force_load_jsd_xml_file = oProps.getStringProperty(L"Ja2 Settings", L"FORCE_LOAD_JSD_XML_FILE", L""); -#endif #ifdef JA2EDITOR -#ifndef USE_VFS - if (GetPrivateProfileString( "Ja2 Settings","EDITOR_SCREEN_RESOLUTION", "", zScreenResolution, 50, INIFile )) - { - iResolution = atoi(zScreenResolution); - } -#else iResolution = (int)oProps.getIntProperty("Ja2 Settings","EDITOR_SCREEN_RESOLUTION", -1); -#endif #endif int iResX; @@ -1311,30 +1217,6 @@ void GetRuntimeSettings( ) } // Adjust again - -#ifndef USE_VFS - gbPixelDepth = GetPrivateProfileInt( "SGP", "PIXEL_DEPTH", PIXEL_DEPTH, INIFile ); - - SCREEN_WIDTH = GetPrivateProfileInt( "SGP", "WIDTH", iResX, INIFile ); - SCREEN_HEIGHT = GetPrivateProfileInt( "SGP", "HEIGHT", iResY, INIFile ); - - iScreenWidthOffset = (SCREEN_WIDTH - 640) / 2; - iScreenHeightOffset = (SCREEN_HEIGHT - 480) / 2; - - /* Sergeant_Kolja. 2007-02-20: runtime Windowed mode instead of compile-time */ - /* 1 for Windowed, 0 for Fullscreen */ - if( !bScreenModeCmdLine ) - iScreenMode = bCncDdraw ? 0 : (int) GetPrivateProfileInt( "Ja2 Settings","SCREEN_MODE_WINDOWED", iScreenMode, INIFile ); - - // WANNE: Should we play the intro? - iPlayIntro = (int) GetPrivateProfileInt( "Ja2 Settings","PLAY_INTRO", iPlayIntro, INIFile ); - iUseWinFonts = (int) GetPrivateProfileInt( "Ja2 Settings","USE_WINFONTS", iUseWinFonts, INIFile,); - fTooltipScaleFactor = ((int)GetPrivateProfileInt("Ja2 Settings", "TOOLTIP_SCALE_FACTOR", 100, INIFile, )) / 100; - if (fTooltipScaleFactor < 1) fTooltipScaleFactor = 1; - - // haydent: mouse scrolling - iDisableMouseScrolling = (int) GetPrivateProfileInt( "Ja2 Settings","DISABLE_MOUSE_SCROLLING", iDisableMouseScrolling, INIFile ); -#else gbPixelDepth = PIXEL_DEPTH; SCREEN_WIDTH = iResX; @@ -1388,8 +1270,6 @@ void GetRuntimeSettings( ) // get timer/clock initialization state //SetHiSpeedClockMode( oProps.getBoolProperty("Ja2 Settings", "HIGHSPEED_TIMER", false) ? TRUE : FALSE ); SetHiSpeedClockMode( TRUE ); - -#endif } @@ -1464,7 +1344,6 @@ void ProcessJa2CommandLineBeforeInitialization(CHAR8 *pCommandLine) MemFree(pCopy); } -#ifdef USE_VFS static void PopulateSectionFromCommandLine(vfs::PropertyContainer &oProps, vfs::String const& sSection) { const wchar_t* lpCommandLine = GetCommandLineW(); @@ -1496,7 +1375,6 @@ static void PopulateSectionFromCommandLine(vfs::PropertyContainer &oProps, vfs:: } } } -#endif static LONG __stdcall SGPExceptionFilter(int exceptionCount, EXCEPTION_POINTERS* pExceptInfo) { diff --git a/Standard Gaming Platform/sgp_logger.cpp b/Standard Gaming Platform/sgp_logger.cpp index 54772ebaa..dc82bbdec 100644 --- a/Standard Gaming Platform/sgp_logger.cpp +++ b/Standard Gaming Platform/sgp_logger.cpp @@ -16,16 +16,12 @@ static inline void flush_screen(std::wstringstream& stream) int sgp::Logger::_next_log_id = -1; -#if defined(USE_VFS) //std::vector sgp::Logger::_logs; std::vector sgp::Logger::_logs; -#endif sgp::Logger::Logger() { -#if defined(USE_VFS) connectFile(this->createLogger(), L"game_log.log", false, sgp::Logger::FLUSH_ON_ENDL); -#endif } sgp::Logger::~Logger() @@ -47,9 +43,7 @@ bool sgp::Logger::shutdown() { for(::size_t i=0; i < _logs.size(); ++i) { -#if defined(USE_VFS) disconnectFile(i); -#endif disconnectStream(i); disconnectScreen(i); } @@ -102,7 +96,6 @@ void sgp::Logger::flushMode(sgp::Logger_ID id, sgp::Logger::FlushMode fmode) } -#if defined(USE_VFS) void sgp::Logger::connectFile(sgp::Logger_ID id, vfs::Path const& log_file, bool append, FlushMode fmode) { if(id >= 0 && id < _logs.size()) @@ -128,7 +121,6 @@ void sgp::Logger::disconnectFile(sgp::Logger_ID id) } } } -#endif void sgp::Logger::connectStream(sgp::Logger_ID id, std::ostream& stream) { @@ -170,29 +162,10 @@ void sgp::Logger::disconnectScreen(sgp::Logger_ID id) } -//#if defined(USE_VFS) -//int sgp::Logger::createLogger(vfs::Path const& log_file, bool append, FlushMode fp) -//{ -// vfs::Log::EFlushMode fm; -// if(fp == sgp::Logger::FLUSH_ON_DELETE) fm = vfs::Log::FLUSH_ON_DELETE; -// else if(fp == sgp::Logger::FLUSH_IMMIDIATELY) fm = vfs::Log::FLUSH_IMMEDIATELY; -// else if(fp == sgp::Logger::FLUSH_FULL_BUFFER) fm = vfs::Log::FLUSH_BUFFER; -// else if(fp == sgp::Logger::FLUSH_ON_ENDL) fm = vfs::Log::FLUSH_ON_ENDL; -// else fm = vfs::Log::FLUSH_IMMEDIATELY; -// -// _logs.push_back(STimeLog()); -// _next_log_id++; -// _logs[_next_log_id]._log = vfs::Log::create(log_file,append,fm); -// _logs[_next_log_id]._timer.startTimer(); -// return _next_log_id; -//} -//#endif - sgp::Logger::LogInstance sgp::Logger::logger(sgp::Logger_ID id) { if(id < _logs.size()) { -#if defined(USE_VFS) std::wstringstream tmp; tmp << L"[" << _logs[id].timer.running() << L"] : "; std::wstring str(tmp.str()); @@ -208,7 +181,6 @@ sgp::Logger::LogInstance sgp::Logger::logger(sgp::Logger_ID id) if(ld.screen) { (*ld.screen) << str; } -#endif return sgp::Logger::LogInstance(&ld); } SGP_THROW(L"Unknown log id"); @@ -219,10 +191,8 @@ sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< (sgp { if(_log.file) { -#if defined(USE_VFS) (*_log.file).flush(); (*_log.file).unlock(); -#endif } if(_log.stream) { @@ -240,14 +210,12 @@ sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< (sgp: { if(_log.file) { -#if defined(USE_VFS) (*_log.file) << vfs::Log::endl; if(_log.file->flushMode() == vfs::Log::FLUSH_ON_ENDL) { (*_log.file).flush(); } (*_log.file).unlock(); -#endif } if(_log.stream) { @@ -263,8 +231,6 @@ sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< (sgp: template <> sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< (sgp::_lock const& l) { -#if defined(USE_VFS) _log.file->lock(); -#endif return *this; } diff --git a/Standard Gaming Platform/sgp_logger.h b/Standard Gaming Platform/sgp_logger.h index d93c7cd69..db457eb50 100644 --- a/Standard Gaming Platform/sgp_logger.h +++ b/Standard Gaming Platform/sgp_logger.h @@ -2,13 +2,9 @@ #define SGP_LOGGER_H #include -#if defined(USE_VFS) -# include -# include -# include -#else -# include -#endif +#include +#include +#include namespace sgp { @@ -22,13 +18,9 @@ namespace sgp { struct LogData { -#if defined(USE_VFS) LogData() : file(NULL), stream(NULL), screen(NULL) {}; vfs::HPTimer timer; vfs::Log* file; -#else - LogData() : stream(NULL), screen(NULL) {}; -#endif std::wostream* stream; std::wstringstream* screen; }; @@ -53,9 +45,7 @@ namespace sgp LogInstance& operator<<(T const& t){ if(_log.stream) (*_log.stream) << t; if(_log.screen) (*_log.screen) << t; -#if defined(USE_VFS) if(_log.file ) (*_log.file) << t; -#endif return *this; } private: @@ -72,10 +62,8 @@ namespace sgp Logger_ID createLogger(); -#if defined(USE_VFS) void connectFile(Logger_ID id, vfs::Path const& log_file, bool append, FlushMode fp); void disconnectFile(Logger_ID id); -#endif void connectStream(Logger_ID id, std::ostream& stream); void disconnectStream(Logger_ID id); @@ -102,44 +90,28 @@ namespace sgp Logger::LogInstance& Logger::LogInstance::operator<< <_flush>(_flush const& f); } -#if defined(USE_VFS) inline sgp::Logger::LogInstance SGP_LOG(sgp::Logger_ID id, vfs::String const& str){ -#else -inline sgp::Logger::LogInstance SGP_LOG(int id, const char* str){ -#endif return sgp::Logger::instance().logger(id) << (str) << sgp::endl; } inline sgp::Logger::LogInstance SGP_LOG(sgp::Logger_ID id){ return sgp::Logger::instance().logger(id); } -#if defined(USE_VFS) inline sgp::Logger::LogInstance SGP_INFO(vfs::String const& str){ -#else -inline sgp::Logger::LogInstance SGP_INFO(const char* str){ -#endif return sgp::Logger::instance().logger(0) << str << sgp::endl; } inline sgp::Logger::LogInstance SGP_INFO(){ return sgp::Logger::instance().logger(0); } -#if defined(USE_VFS) inline sgp::Logger::LogInstance SGP_WARNING(vfs::String const& str){ -#else -inline sgp::Logger::LogInstance SGP_WARNING(const char* str){ -#endif return sgp::Logger::instance().logger(0) << "WARNING : " << str << sgp::endl; } inline sgp::Logger::LogInstance SGP_WARNING(){ return sgp::Logger::instance().logger(0) << "WARNING : "; } -#if defined(USE_VFS) inline sgp::Logger::LogInstance SGP_ERROR(vfs::String const& str){ -#else -inline sgp::Logger::LogInstance SGP_ERROR(const char* str){ -#endif return sgp::Logger::instance().logger(0) << "ERROR : " << str << sgp::endl; } inline sgp::Logger::LogInstance SGP_ERROR(){ diff --git a/Standard Gaming Platform/soundman.cpp b/Standard Gaming Platform/soundman.cpp index 22077f741..a2f5869eb 100644 --- a/Standard Gaming Platform/soundman.cpp +++ b/Standard Gaming Platform/soundman.cpp @@ -1869,15 +1869,7 @@ void SoundLog(CHAR8 *strMessage) sgp::Logger::instance().connectFile(id, SndDebugFileName, true, sgp::Logger::FLUSH_ON_DELETE); } } s_SoundLog; -#ifndef USE_VFS - if ((SndDebug = fopen(SndDebugFileName, "a+t")) != NULL) - { - fprintf(SndDebug, "%s\n", strMessage); - fclose(SndDebug); - } -#else SGP_LOG(s_SoundLog.id, vfs::String::widen(strMessage,strlen(strMessage))); -#endif } //***************************************************************************************** @@ -1890,10 +1882,4 @@ void SoundLog(CHAR8 *strMessage) //***************************************************************************************** void InitLogging() { -#ifndef USE_VFS - if ((SndDebug = fopen(SndDebugFileName, "wt")) != NULL) - { - fclose(SndDebug); - } -#endif } diff --git a/Standard Gaming Platform/video.cpp b/Standard Gaming Platform/video.cpp index 0432e5121..bd1bcca26 100644 --- a/Standard Gaming Platform/video.cpp +++ b/Standard Gaming Platform/video.cpp @@ -1888,22 +1888,10 @@ void RefreshScreen(void *DummyVariable) LPDIRECTDRAWSURFACE _pTmpBuffer; LPDIRECTDRAWSURFACE2 pTmpBuffer; DDSURFACEDESC SurfaceDescription; -#ifndef USE_VFS - FILE *OutputFile; -#endif CHAR8 FileName[64]; INT32 iIndex; UINT16 *p16BPPData; - // Snap: save current directory -#ifndef USE_VFS - STRING512 DataDir; - STRING512 ExecDir; - - GetFileManCurrentDirectory( DataDir ); - GetExecutableDirectory( ExecDir ); - SetFileManCurrentDirectory( ExecDir ); -#endif // // Create temporary system memory surface. This is used to correct problems with the backbuffer // surface which can be interlaced or have a funky pitch @@ -1953,23 +1941,13 @@ void RefreshScreen(void *DummyVariable) { sprintf( FileName, "SCREEN%03d.TGA", guiPrintFrameBufferIndex++); } -#ifndef USE_VFS - while( (_access( FileName, 0 )) != -1 ); -#else while(FileExists(FileName)); -#endif -#ifndef USE_VFS - if ((OutputFile = fopen( FileName, "wb")) != NULL) - { - fprintf(OutputFile, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, LOBYTE(SCREEN_WIDTH), HIBYTE(SCREEN_WIDTH), LOBYTE(SCREEN_HEIGHT), HIBYTE(SCREEN_HEIGHT), 0x10, 0); -#else try { vfs::COpenWriteFile wfile(FileName,true,true); char head[] = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, LOBYTE(SCREEN_WIDTH), HIBYTE(SCREEN_WIDTH), LOBYTE(SCREEN_HEIGHT), HIBYTE(SCREEN_HEIGHT), 0x10, 0}; SGP_TRYCATCH_RETHROW(wfile->write(head,18), L""); -#endif // // Lock temp surface @@ -2006,19 +1984,11 @@ void RefreshScreen(void *DummyVariable) ConvertRGBDistribution565To555( p16BPPData, SCREEN_WIDTH ); // Write -#ifndef USE_VFS - fwrite( p16BPPData, SCREEN_WIDTH * 2, 1, OutputFile); -#else SGP_TRYCATCH_RETHROW(wfile->write((vfs::Byte*)p16BPPData, SCREEN_WIDTH * 2), L""); -#endif } else { -#ifndef USE_VFS - fwrite((void *)(((UINT8 *)SurfaceDescription.lpSurface) + (iIndex * SCREEN_WIDTH * 2)), SCREEN_WIDTH * 2, 1, OutputFile); -#else SGP_TRYCATCH_RETHROW(wfile->write((vfs::Byte*)(((UINT8 *)SurfaceDescription.lpSurface) + (iIndex * SCREEN_WIDTH * 2)), SCREEN_WIDTH * 2), L""); -#endif } } @@ -2027,9 +1997,6 @@ void RefreshScreen(void *DummyVariable) { MemFree( p16BPPData ); } -#ifndef USE_VFS - fclose(OutputFile); -#endif // // Unlock temp surface // @@ -2043,12 +2010,10 @@ void RefreshScreen(void *DummyVariable) } } -#ifdef USE_VFS catch(std::exception& ex) { SGP_RETHROW(L"", ex); } -#endif // // Release temp surface @@ -2056,12 +2021,6 @@ void RefreshScreen(void *DummyVariable) gfPrintFrameBuffer = FALSE; IDirectDrawSurface2_Release(pTmpBuffer); -#ifndef USE_VFS - // Snap: Restore the data directory once we are finished. - SetFileManCurrentDirectory( DataDir ); - //strcat( ExecDir, "\\Data" ); - //SetFileManCurrentDirectory( ExecDir ); -#endif } // @@ -3322,80 +3281,42 @@ void RefreshMovieCache( ) { TARGA_HEADER Header; INT32 iCountX, iCountY; -#ifndef USE_VFS - FILE *disk; -#endif CHAR8 cFilename[_MAX_PATH]; static UINT32 uiPicNum=0; UINT16 *pDest; INT32 cnt; -#ifndef USE_VFS - STRING512 DataDir; - STRING512 ExecDir; -#endif PauseTime( TRUE ); -#ifndef USE_VFS - // Snap: save current directory - GetFileManCurrentDirectory( DataDir ); - - GetExecutableDirectory( ExecDir ); - SetFileManCurrentDirectory( ExecDir ); -#else try { -#endif for ( cnt = 0; cnt < giNumFrames; cnt++ ) { sprintf( cFilename, "JA%5.5d.TGA", uiPicNum++ ); -#ifndef USE_VFS - if( ( disk = fopen(cFilename, "wb"))==NULL ) - return; -#else vfs::COpenWriteFile wfile(cFilename, true, true); -#endif memset(&Header, 0, sizeof(TARGA_HEADER)); Header.ubTargaType=2; // Uncompressed 16/24/32 bit Header.usImageWidth=SCREEN_WIDTH; Header.usImageHeight=SCREEN_HEIGHT; Header.ubBitsPerPixel=16; -#ifndef USE_VFS - fwrite(&Header, sizeof(TARGA_HEADER), 1, disk); -#else SGP_TRYCATCH_RETHROW(wfile->write((vfs::Byte*)&Header, sizeof(TARGA_HEADER)), L""); -#endif pDest = gpFrameData[ cnt ]; for(iCountY=SCREEN_HEIGHT-1; iCountY >=0 ; iCountY-=1) { for(iCountX=0; iCountX < SCREEN_WIDTH; iCountX ++ ) { -#ifndef USE_VFS - fwrite( ( pDest + ( iCountY * SCREEN_WIDTH ) + iCountX ), sizeof(UINT16), 1, disk); -#else SGP_TRYCATCH_RETHROW(wfile->write( (vfs::Byte*)( pDest + ( iCountY * SCREEN_WIDTH ) + iCountX ), sizeof(UINT16)), L""); -#endif } } -#ifndef USE_VFS - fclose(disk); -#endif } PauseTime( FALSE ); giNumFrames = 0; -#ifndef USE_VFS - // Snap: Restore the data directory once we are finished. - SetFileManCurrentDirectory( DataDir ); - //strcat( ExecDir, "\\Data" ); - //SetFileManCurrentDirectory( ExecDir ); -#else } catch(std::exception& ex) { SGP_ERROR(ex.what()); } -#endif } diff --git a/Strategic/Campaign Init.cpp b/Strategic/Campaign Init.cpp index c3faaa385..0da5809b6 100644 --- a/Strategic/Campaign Init.cpp +++ b/Strategic/Campaign Init.cpp @@ -206,26 +206,6 @@ BOOLEAN ReadInAltSectors(STR fileName) BOOLEAN WriteInAltSectors(STR fileName) { -#ifndef USE_VFS - // Lets output the current Strategic map format using the XML structure I've devised. - FILE *outfile = fopen(fileName, "wt"); - - UINT32 x, y; - - fprintf (outfile, "\n"); - for(y = 1;y <= 16;y++) - { - fprintf (outfile, "\t",(y+0x40)); - for(x = 1;x <= 16; x++) - { - fprintf (outfile, " %d",RandomSector[ ((y - 1) * 16) + (x - 1) ] ); - } - fprintf (outfile, " \n"); - } - fprintf (outfile, "\n"); - - fclose(outfile); -#else XMLWriter xmlw; xmlw.openNode(L"ALT_SECTORS_LIST"); UINT32 x, y; @@ -241,7 +221,6 @@ BOOLEAN WriteInAltSectors(STR fileName) } xmlw.closeNode(); xmlw.writeToFile(fileName); -#endif return (TRUE); } diff --git a/Strategic/Strategic AI.cpp b/Strategic/Strategic AI.cpp index c64d85ed1..bf1d52b59 100644 --- a/Strategic/Strategic AI.cpp +++ b/Strategic/Strategic AI.cpp @@ -5430,22 +5430,11 @@ void LogStrategicMsg( STR8 str, ... ) { va_list argptr; CHAR8 string[512]; -#ifndef USE_VFS - FILE *fp; - - fp = fopen( "Strategic Decisions.txt", "a" ); - if( !fp ) - return; -#endif va_start(argptr, str ); vsprintf( string, str, argptr); va_end(argptr); -#ifndef USE_VFS - fprintf( fp, "%s\n", string ); -#else SGP_LOG(s_stratD.id, string); -#endif if( gfDisplayStrategicAILogs ) { @@ -5455,33 +5444,17 @@ void LogStrategicMsg( STR8 str, ... ) { OutputDebugString( (LPCSTR)String( "%s\n", string ) ); } - -#ifndef USE_VFS - fclose( fp ); -#endif } void LogStrategicEvent( STR8 str, ... ) { va_list argptr; CHAR8 string[512]; -#ifndef USE_VFS - FILE *fp; - - fp = fopen( "Strategic Decisions.txt", "a" ); - if( !fp ) - return; -#endif va_start(argptr, str ); vsprintf( string, str, argptr); va_end(argptr); -#ifndef USE_VFS - fprintf( fp, "\n%S:\n", WORLDTIMESTR ); - fprintf( fp, "%s\n", string ); -#else SGP_LOG(s_stratD.id) << sgp::endl << WORLDTIMESTR << ":" << sgp::endl << string << sgp::endl; -#endif if( gfDisplayStrategicAILogs ) { ScreenMsg( FONT_LTKHAKI, MSG_DIALOG, L"%S", string ); @@ -5490,25 +5463,11 @@ void LogStrategicEvent( STR8 str, ... ) { OutputDebugString( (LPCSTR)String( "%s\n", string ) ); } -#ifndef USE_VFS - fclose( fp ); -#endif } void ClearStrategicLog() { -#ifndef USE_VFS - FILE *fp; - fp = fopen( "Strategic Decisions.txt", "w" ); - if( !fp ) - return; - - fprintf( fp, "STRATEGIC LOG\n" ); - - fclose( fp ); -#else SGP_LOG(s_stratD.id) << sgp::flush; -#endif } #endif diff --git a/Strategic/strategicmap.cpp b/Strategic/strategicmap.cpp index 9fa2cff67..f194853a9 100644 --- a/Strategic/strategicmap.cpp +++ b/Strategic/strategicmap.cpp @@ -1659,80 +1659,6 @@ void EndLoadScreen( ) 'A' + gWorldSectorY - 1, gWorldSectorX, gbWorldSectorZ, uiSeconds, uiHundreths ); } ScreenMsg( FONT_YELLOW, MSG_TESTVERSION, str ); -#ifndef USE_VFS - FILE *fp; - - if ( fStartNewFile ) - { //start new file - fp = fopen( "TimeResults.txt", "w" ); - ScreenMsg( FONT_YELLOW, MSG_TESTVERSION, L"See JA2\\Data\\TimeResults.txt for more detailed timings." ); - fStartNewFile = FALSE; - } - else - { //append to end of file - fp = fopen( "TimeResults.txt", "a" ); - - if ( fp ) - { - fprintf( fp, "\n\n--------------------------------------------------------------------\n\n" ); - } - } - if ( fp ) - { - //Record all of the timings. - fprintf( fp, "%S\n", str ); - fprintf( fp, "EnterSector() supersets LoadWorld(). This includes other external sections.\n" ); - //FileRead() - fprintf( fp, "\n\nVARIOUS FUNCTION TIMINGS (exclusive of actual function timings in second heading)\n" ); - uiSeconds = uiTotalFileReadTime / 1000; - uiHundreths = (uiTotalFileReadTime / 10) % 100; - fprintf( fp, "FileRead: %d.%02d (called %d times)\n", uiSeconds, uiHundreths, uiTotalFileReadCalls ); - - fprintf( fp, "\n\nSECTIONS OF LOADWORLD (all parts should add up to 100%)\n" ); - //TrashWorld() - uiSeconds = uiTrashWorldTime / 1000; - uiHundreths = (uiTrashWorldTime / 10) % 100; - fprintf( fp, "TrashWorld: %d.%02d\n", uiSeconds, uiHundreths ); - //LoadMapTilesets() - uiSeconds = uiLoadMapTilesetTime / 1000; - uiHundreths = (uiLoadMapTilesetTime / 10) % 100; - fprintf( fp, "LoadMapTileset: %d.%02d\n", uiSeconds, uiHundreths ); - //LoadMapLights() - uiSeconds = uiLoadMapLightsTime / 1000; - uiHundreths = (uiLoadMapLightsTime / 10) % 100; - fprintf( fp, "LoadMapLights: %d.%02d\n", uiSeconds, uiHundreths ); - uiSeconds = uiBuildShadeTableTime / 1000; - uiHundreths = (uiBuildShadeTableTime / 10) % 100; - fprintf( fp, " 1) BuildShadeTables: %d.%02d\n", uiSeconds, uiHundreths ); - - uiPercentage = uiNumImagesReloaded * 100 / giNumberOfTileTypes; - fprintf( fp, " 2) %d%% of the tileset images were actually reloaded.\n", uiPercentage ); - if ( (uiNumTablesSaved + uiNumTablesLoaded) != 0 ) - { - uiPercentage = uiNumTablesSaved * 100 / (uiNumTablesSaved + uiNumTablesLoaded); - } - else - { - uiPercentage = 0; - } - fprintf( fp, " 3) Of that, %d%% of the shade tables were generated (not loaded).\n", uiPercentage ); - if ( gfForceBuildShadeTables ) - fprintf( fp, " NOTE: Force building of shadetables enabled on this local computer.\n" ); - - - //Unaccounted - uiUnaccounted = uiLoadWorldTime - uiTrashWorldTime - uiLoadMapTilesetTime - uiLoadMapLightsTime; - uiSeconds = uiUnaccounted / 1000; - uiHundreths = (uiUnaccounted / 10) % 100; - fprintf( fp, "Unaccounted: %d.%02d\n", uiSeconds, uiHundreths ); - //LoadWorld() - uiSeconds = uiLoadWorldTime / 1000; - uiHundreths = (uiLoadWorldTime / 10) % 100; - fprintf( fp, "\nTotal: %d.%02d\n", uiSeconds, uiHundreths ); - - fclose( fp ); - } -#else sgp::Logger_ID time_log_id = sgp::Logger::instance( ).createLogger( ); sgp::Logger::instance( ).connectFile( time_log_id, L"TimeResults.txt", true, sgp::Logger::FLUSH_ON_ENDL ); sgp::Logger::LogInstance timeResults = SGP_LOG( time_log_id ); @@ -1793,7 +1719,6 @@ void EndLoadScreen( ) uiSeconds = uiLoadWorldTime / 1000; uiHundreths = (uiLoadWorldTime / 10) % 100; timeResults << vfs::Log::endl << "Total: " << uiSeconds << "." << uiHundreths << sgp::endl; -#endif // USE_VFS #endif } diff --git a/Tactical/Tactical Save.cpp b/Tactical/Tactical Save.cpp index 7a5036705..6f84aa342 100644 --- a/Tactical/Tactical Save.cpp +++ b/Tactical/Tactical Save.cpp @@ -1678,33 +1678,7 @@ BOOLEAN RetrieveTempFileFromSavedGame( HWFILE hFile, UINT32 uiType, INT16 sMapX, //Deletes the Temp map Directory BOOLEAN InitTacticalSave( BOOLEAN fCreateTempDir ) { -#ifndef USE_VFS - UINT32 uiRetVal; - - //If the Map Temp directory exists, removes the temp files - uiRetVal = FileGetAttributes( MAPS_DIR ); - if( uiRetVal != 0xFFFFFFFF ) - { - if( uiRetVal & FILE_ATTRIBUTES_DIRECTORY ) - { - //Erase the directory - if( !EraseDirectory( MAPS_DIR ) ) - { - //error erasing the temporary maps directory - } - } - } - else - { - if( !MakeFileManDirectory( MAPS_DIR ) ) - { - //Erro creating the temp map directory - AssertMsg( 0, "Error creating the Temp Directory."); - } - } -#else EraseDirectory( MAPS_DIR ); -#endif if( fCreateTempDir ) { //Create the initial temp file for the Npc Quote Info diff --git a/TileEngine/SaveLoadMap.cpp b/TileEngine/SaveLoadMap.cpp index 0931fe915..3ca80d74c 100644 --- a/TileEngine/SaveLoadMap.cpp +++ b/TileEngine/SaveLoadMap.cpp @@ -557,12 +557,6 @@ BOOLEAN LoadAllMapChangesFromMapTempFileAndApplyThem( ) { ReSetSectorFlag( gWorldSectorX, gWorldSectorY, gbWorldSectorZ, SF_MAP_MODIFICATIONS_TEMP_FILE_EXISTS ); } -#ifndef USE_VFS - FileClose( hFile ); -#else - // FileClose( hFile ); - // file already deleted. can't close it anymore (handle is invalid) -#endif //Free the memory used for the temp array MemFree( pTempArrayOfMaps ); diff --git a/TileEngine/Shade Table Util.cpp b/TileEngine/Shade Table Util.cpp index f802fa443..b2345f4f6 100644 --- a/TileEngine/Shade Table Util.cpp +++ b/TileEngine/Shade Table Util.cpp @@ -24,10 +24,6 @@ BOOLEAN gfForceBuildShadeTables = FALSE; void DetermineRGBDistributionSettings() { -#ifndef USE_VFS - STRING512 DataDir; - STRING512 ExecDir; -#endif STRING512 ShadeTableDir; UINT32 uiRBitMask, uiGBitMask, uiBBitMask; UINT32 uiPrevRBitMask, uiPrevGBitMask, uiPrevBBitMask; @@ -37,36 +33,9 @@ void DetermineRGBDistributionSettings() BOOLEAN fCleanShadeTable = FALSE; BOOLEAN fLoadedPrevRGBDist = FALSE; -#ifndef USE_VFS - // Snap: save current directory - GetFileManCurrentDirectory( DataDir ); - - //First, determine if we have a file saved. If not, then this is the first time, and - //all shade tables will have to be built and saved to disk. This can be time consuming, adding up to - //3-4 seconds to the time of a map load. - GetExecutableDirectory( ExecDir ); - sprintf( ShadeTableDir, "%s\\%s", DataDir, SHADE_TABLE_DIR ); - - //Check to make sure we have a ShadeTable directory. If we don't create one! - if( !SetFileManCurrentDirectory( ShadeTableDir ) ) - { - if( !MakeFileManDirectory( ShadeTableDir ) ) - { - AssertMsg( 0, "ShadeTable directory doesn't exist, and couldn't create one!" ); - } - if( !SetFileManCurrentDirectory( ShadeTableDir ) ) - { - AssertMsg( 0, "Couldn't access the newly created ShadeTable directory." ); - } - fSaveRGBDist = TRUE; - } - // directory existed or was created. - SetFileManCurrentDirectory( DataDir ); -#else // changing the current directory can screw up the VFS; don't do it // the creation of the SHADE_TABLE_DIR directory is done by the VFS sprintf( ShadeTableDir, "%s", SHADE_TABLE_DIR ); -#endif CHAR8 sRGBDist[50]; sprintf( sRGBDist, "%s\\%s", SHADE_TABLE_DIR, "RGBDist.dat"); diff --git a/TileEngine/WorldDat.cpp b/TileEngine/WorldDat.cpp index 5e9a15805..92b1b2041 100644 --- a/TileEngine/WorldDat.cpp +++ b/TileEngine/WorldDat.cpp @@ -138,7 +138,6 @@ void InitEngineTilesets( ) #endif } -#ifdef USE_VFS void ExportTilesets(vfs::Path const& filename) { UINT32 uiNumBytesRead = 0; @@ -217,7 +216,6 @@ void ExportTilesets(vfs::Path const& filename) xmlw.closeNode(); xmlw.writeToFile(filename); } -#endif void SetTilesetOneTerrainValues( ) { diff --git a/TileEngine/worlddef.cpp b/TileEngine/worlddef.cpp index bf616f584..628a35e3d 100644 --- a/TileEngine/worlddef.cpp +++ b/TileEngine/worlddef.cpp @@ -2437,14 +2437,10 @@ BOOLEAN EvaluateWorld(STR8 pSector, UINT8 ubLevel) if(ValidMapFileName(szFileName)) strcpy(szFilename, pSector); sprintf(szDirFilename, "MAPS\\%s", szFilename); -#ifdef USE_VFS//dnl ch81 021213 if(guiCurrentScreen == LOADSAVE_SCREEN) hfile = FileOpen(szDirFilename, FILE_ACCESS_READ, FALSE, gzProfileName); else hfile = FileOpen(szDirFilename, FILE_ACCESS_READ); -#else - hfile = FileOpen(szDirFilename, FILE_ACCESS_READ, FALSE); -#endif if(!hfile) return(FALSE); uiFileSize = FileGetSize(hfile); @@ -2851,7 +2847,6 @@ BOOLEAN LoadWorld(const STR8 puiFilename, FLOAT* pMajorMapVersion, UINT8* pMinor else sprintf(aFilename, "MAPS\\%s", puiFilename); // Open file -#ifdef USE_VFS//dnl ch81 021213 #ifdef JA2EDITOR if(guiCurrentScreen == LOADSAVE_SCREEN) hfile = FileOpen(aFilename, FILE_ACCESS_READ, FALSE, gzProfileName); @@ -2859,9 +2854,6 @@ BOOLEAN LoadWorld(const STR8 puiFilename, FLOAT* pMajorMapVersion, UINT8* pMinor hfile = FileOpen(aFilename, FILE_ACCESS_READ); #else hfile = FileOpen(aFilename, FILE_ACCESS_READ); -#endif -#else - hfile = FileOpen(aFilename, FILE_ACCESS_READ, FALSE); #endif if(!hfile) { diff --git a/Utils/Cinematics Bink.cpp b/Utils/Cinematics Bink.cpp index 2e17d1a2d..4393c13be 100644 --- a/Utils/Cinematics Bink.cpp +++ b/Utils/Cinematics Bink.cpp @@ -171,17 +171,6 @@ BINKFLIC *BinkOpenFlic( const CHAR8 *cFilename ) ErrorMsg("BINK ERROR: Out of flic slots, cannot open another"); return(NULL); } -#ifndef USE_VFS - // Attempt opening the filename - if(!(pBink->hFileHandle = FileOpen( const_cast(cFilename), FILE_OPEN_EXISTING | FILE_ACCESS_READ, FALSE ) ) ) - { - ErrorMsg("BINK ERROR: Can't open the BINK file"); - return(NULL); - } - - //Get the real file handle for the file man handle for the smacker file - HANDLE hFile = GetRealFileHandleFromFileManFileHandle( pBink->hFileHandle ); -#else vfs::Path introname(cFilename); vfs::Path dir,filename; introname.splitLast(dir,filename); @@ -207,11 +196,7 @@ BINKFLIC *BinkOpenFlic( const CHAR8 *cFilename ) SGP_RETHROW(_BS(L"Intro file \"") << filename << L"\" could not be extracted" << _BS::wget, ex); } } -#endif -#ifndef USE_VFS - if( !( pBink->BinkHandle = BinkOpen((CHAR8 *)hFile, BINKFILEHANDLE ) ) ) //| SMACKTRACKS -#else vfs::Path tempfilename; try { @@ -226,7 +211,6 @@ BINKFLIC *BinkOpenFlic( const CHAR8 *cFilename ) SGP_RETHROW(L"Temporary intro file could not be read", ex); } if( !( pBink->BinkHandle = BinkOpen(tempfilename.to_string().c_str(), BINKNOTHREADEDIO /*BINKFILEHANDLE*/ ) ) ) //| SMACKTRACKS -#endif { ErrorMsg("BINK ERROR: Bink won't open the BINK file"); return(NULL); diff --git a/Utils/Cinematics.cpp b/Utils/Cinematics.cpp index 8dc056048..5e810cbd2 100644 --- a/Utils/Cinematics.cpp +++ b/Utils/Cinematics.cpp @@ -194,19 +194,6 @@ SMKFLIC *SmkOpenFlic(const CHAR8 *cFilename) return(NULL); } -#ifndef USE_VFS - // Attempt opening the filename - if(!(pSmack->hFileHandle=FileOpen(cFilename, FILE_OPEN_EXISTING | FILE_ACCESS_READ, FALSE))) - { - ErrorMsg("SMK ERROR: Can't open the SMK file"); - return(NULL); - } - - HANDLE hFile; - - //Get the real file handle for the file man handle for the smacker file - hFile = GetRealFileHandleFromFileManFileHandle( pSmack->hFileHandle ); -#else vfs::Path introname(cFilename); vfs::Path dir,filename; introname.splitLast(dir,filename); @@ -232,7 +219,6 @@ SMKFLIC *SmkOpenFlic(const CHAR8 *cFilename) SGP_RETHROW(_BS(L"Intro file \"") << filename << L"\" could not be extracted" << _BS::wget, ex); } } -#endif // Allocate a Smacker buffer for video decompression if(!(pSmack->SmackBuffer=SmackBufferOpen(hDisplayWindow,SMACKAUTOBLIT,SCREEN_WIDTH,SCREEN_HEIGHT,0,0))) @@ -240,9 +226,6 @@ SMKFLIC *SmkOpenFlic(const CHAR8 *cFilename) ErrorMsg("SMK ERROR: Can't allocate a Smacker decompression buffer"); return(NULL); } -#ifndef USE_VFS - if(!(pSmack->SmackHandle=SmackOpen((CHAR8 *)hFile, SMACKFILEHANDLE | SMACKTRACKS, SMACKAUTOEXTRA))) -#else // if(!(pSmack->SmackHandle=SmackOpen(cFilename, SMACKTRACKS, SMACKAUTOEXTRA))) vfs::Path tempfilename; try @@ -258,7 +241,6 @@ SMKFLIC *SmkOpenFlic(const CHAR8 *cFilename) SGP_RETHROW(L"Temporary intro file could not be read", ex); } if(!(pSmack->SmackHandle=SmackOpen(tempfilename.to_string().c_str(), SMACKTRACKS, SMACKAUTOEXTRA))) -#endif { ErrorMsg("SMK ERROR: Smacker won't open the SMK file"); return(NULL); diff --git a/Utils/Debug Control.cpp b/Utils/Debug Control.cpp index b1fa6fa75..21ca49e0c 100644 --- a/Utils/Debug Control.cpp +++ b/Utils/Debug Control.cpp @@ -62,30 +62,10 @@ static struct LiveLog { void LiveMessage( CHAR8 *strMessage) { -#ifndef USE_VFS - FILE *OutFile; - - if ((OutFile = fopen("Log.txt", "a+t")) != NULL) - { - fprintf(OutFile, "%s\n", strMessage); - fclose(OutFile); - } -#else SGP_LOG(s_LiveLog.id, strMessage); -#endif } void MPDebugMsg( CHAR8 *strMessage) { -#ifndef USE_VFS - FILE *OutFile; - - if ((OutFile = fopen("MPDebug.txt", "a+t")) != NULL) - { - fprintf(OutFile, "%s\n", strMessage); - fclose(OutFile); - } -#else static vfs::Log& mpMsg = *vfs::Log::create(L"MPDebug.txt", true); mpMsg << strMessage << vfs::Log::endl; -#endif } diff --git a/Utils/INIReader.cpp b/Utils/INIReader.cpp index f9649c86d..d238ddb07 100644 --- a/Utils/INIReader.cpp +++ b/Utils/INIReader.cpp @@ -12,9 +12,7 @@ #include -#ifdef USE_VFS std::set CIniReader::m_merge_files; -#endif std::stack iniErrorMessages; template @@ -32,26 +30,14 @@ void PushErrorMessage(std::string const& filename, iniErrorMessages.push(errMessage.str()); } -#ifdef USE_VFS void CIniReader::RegisterFileForMerging(vfs::Path const& filename) { m_merge_files.insert(filename); } -#endif CIniReader::CIniReader(const STR8 szFileName) { memset(m_szFileName,0,sizeof(m_szFileName)); -#ifndef USE_VFS - // Snap: Look for the INI file in the custom Data directory. - // If not there, leave at default location. - if ( gCustomDataCat.FindFile(szFileName) ) { - sprintf(m_szFileName, "%s\\%s", gCustomDataCat.GetRootDir().c_str(), szFileName); - } - else { - sprintf(m_szFileName, "%s\\%s", gDefaultDataCat.GetRootDir().c_str(), szFileName); - } -#else strncpy(m_szFileName,szFileName, std::min(strlen(szFileName), sizeof(m_szFileName)-1)); if(m_merge_files.find(szFileName) == m_merge_files.end()) { @@ -81,7 +67,6 @@ CIniReader::CIniReader(const STR8 szFileName) if(getVFS()->fileExists(OvrFileName)) m_oProps.initFromIniFile(vfs::Path(OvrFileName)); } -#endif } CIniReader::CIniReader(const STR8 szFileName, BOOLEAN Force_Custom_Data_Path) @@ -89,32 +74,6 @@ CIniReader::CIniReader(const STR8 szFileName, BOOLEAN Force_Custom_Data_Path) memset(m_szFileName,0,sizeof(m_szFileName)); // ary-05/05/2009 : force custom data path for potential non existing file -or- force default data path // : Also, flag file detection to allow functions to determine course of action for case of file [not found/is found]. -#ifndef USE_VFS - if ( Force_Custom_Data_Path ) - { - if ( gCustomDataCat.FindFile(szFileName) ) - { - CIniReader_File_Found = TRUE; - } - else - { - CIniReader_File_Found = FALSE; - } - sprintf(m_szFileName, "%s\\%s", gCustomDataCat.GetRootDir().c_str(), szFileName); - } - else - { - if ( gDefaultDataCat.FindFile(szFileName) ) - { - CIniReader_File_Found = TRUE; - } - else - { - CIniReader_File_Found = FALSE; - } - sprintf(m_szFileName, "%s\\%s", gDefaultDataCat.GetRootDir().c_str(), szFileName); - } -#else strncpy(m_szFileName,szFileName, std::min(strlen(szFileName), sizeof(m_szFileName)-1)); if(m_merge_files.find(szFileName) == m_merge_files.end()) { @@ -137,38 +96,24 @@ CIniReader::CIniReader(const STR8 szFileName, BOOLEAN Force_Custom_Data_Path) rev_order.pop(); } } - -#endif } void CIniReader::Clear() { -#ifndef USE_VFS - memset(m_szFileName, 0, MAX_PATH); -#else memset(m_szFileName, 0, MAX_PATH); m_oProps.clearContainer(); -#endif } int CIniReader::ReadInteger(const STR8 szSection, const STR8 szKey, int iDefaultValue) { -#ifndef USE_VFS - return GetPrivateProfileInt(szSection, szKey, iDefaultValue, m_szFileName); -#else return (int)(m_oProps.getIntProperty(szSection, szKey, iDefaultValue)); -#endif } int CIniReader::ReadInteger(const STR8 szSection, const STR8 szKey, int defaultValue, int minValue, int maxValue) { -#ifndef USE_VFS - int iniValueReadFromFile = (int)(GetPrivateProfileInt(szSection, szKey, defaultValue, m_szFileName)); -#else int iniValueReadFromFile = (int)(m_oProps.getIntProperty(szSection, szKey, defaultValue)); -#endif //AssertGE(iniValueReadFromFile, minValue); //AssertLE(iniValueReadFromFile, maxValue); if (iniValueReadFromFile < minValue) @@ -200,15 +145,7 @@ int CIniReader::ReadInteger(const STR8 szSection, const STR8 szKey, int defaultV double CIniReader::ReadDouble(const STR8 szSection, const STR8 szKey, double defaultValue, double minValue, double maxValue) { double iniValueReadFromFile; -#ifndef USE_VFS - char szResult[255]; - char szDefault[255]; - sprintf(szDefault, "%f", defaultValue); - GetPrivateProfileString(szSection, szKey, szDefault, szResult, 255, m_szFileName); - iniValueReadFromFile = (float) atof(szResult); -#else iniValueReadFromFile = m_oProps.getFloatProperty(szSection, szKey, defaultValue); -#endif //AssertGE(iniValueReadFromFile, minValue); //AssertLE(iniValueReadFromFile, maxValue); if (iniValueReadFromFile < minValue) @@ -227,15 +164,7 @@ double CIniReader::ReadDouble(const STR8 szSection, const STR8 szKey, double def FLOAT CIniReader::ReadFloat(const STR8 szSection, const STR8 szKey, FLOAT defaultValue, FLOAT minValue, FLOAT maxValue) { FLOAT iniValueReadFromFile; -#ifndef USE_VFS - char szResult[255]; - char szDefault[255]; - sprintf(szDefault, "%f", defaultValue); - GetPrivateProfileString(szSection, szKey, szDefault, szResult, 255, m_szFileName); - iniValueReadFromFile = (FLOAT) atof(szResult); -#else iniValueReadFromFile = (FLOAT) m_oProps.getFloatProperty(szSection, szKey, (float)defaultValue); -#endif //AssertGE(iniValueReadFromFile, minValue); //AssertLE(iniValueReadFromFile, maxValue); @@ -329,18 +258,6 @@ void CIniReader::ReadINT32Array(const STR8 szSection, const STR8 szKey, std::vec BOOLEAN CIniReader::ReadBoolean(const STR8 szSection, const STR8 szKey, bool defaultValue, bool bolDisplayError) { -#ifndef USE_VFS - char szResult[255]; - char szDefault[255]; - sprintf(szDefault, "%s", defaultValue? "TRUE" : "FALSE"); - GetPrivateProfileString(szSection, szKey, szDefault, szResult, 255, m_szFileName); - for (int idx=0; (szResult[idx] != 0) && (idx < 255); ++idx) - szResult[idx] = toupper(szResult[idx]); - if (strcmp(szResult, "TRUE") == 0) - return TRUE; - else if (strcmp(szResult, "FALSE") == 0) - return FALSE; -#else vfs::String str = m_oProps.getStringProperty(szSection, szKey, L""); if( vfs::StrCmp::Equal(str, L"true") ) { @@ -353,7 +270,7 @@ BOOLEAN CIniReader::ReadBoolean(const STR8 szSection, const STR8 szKey, bool def std::string szResult = str.utf8(); char szDefault[255]; sprintf(szDefault, "%s", defaultValue? "TRUE" : "FALSE"); -#endif + if(bolDisplayError){ std::stringstream errMessage; errMessage << "The value [" << szSection << "][" << szKey << "] = \"" << szResult << "\" " @@ -370,14 +287,10 @@ BOOLEAN CIniReader::ReadBoolean(const STR8 szSection, const STR8 szKey, bool def void CIniReader::ReadString(const STR8 szSection, const STR8 szKey, const STR8 szDefaultValue, STR8 input_buffer, size_t buffer_size) { -#ifndef USE_VFS - GetPrivateProfileString(szSection, szKey, szDefaultValue, input_buffer, buffer_size, m_szFileName); -#else std::string s = m_oProps.getStringProperty(szSection, szKey, szDefaultValue).utf8(); int len = std::min(s.length(),buffer_size-1); strncpy(input_buffer, s.c_str(), len); input_buffer[len] = 0; -#endif } // WANNE - MP: Old version, currently used by Multiplayer @@ -386,12 +299,8 @@ STR8 CIniReader::ReadString(const STR8 szSection, const STR8 szKey, const STR8 s // >>>>> Memory Leak <<<<< STR8 szResult = new char[255]; memset(szResult, 0x00, 255); -#ifndef USE_VFS - GetPrivateProfileString(szSection, szKey, szDefaultValue, szResult, 255, m_szFileName); -#else std::string s = m_oProps.getStringProperty(szSection, szKey, szDefaultValue).utf8(); strncpy(szResult, s.c_str(), std::min(s.length(),254)); -#endif return szResult; } @@ -429,20 +338,7 @@ UINT32 CIniReader::ReadUINT32(const STR8 szSection, const STR8 szKey, UINT32 def UINT32 CIniReader::ReadUINT(const STR8 szSection, const STR8 szKey, UINT32 defaultValue, UINT32 minValue, UINT32 maxValue ) { UINT32 iniValueReadFromFile; -#ifndef USE_VFS - STR8 szResult = new char[255]; - STR8 szDefault = new char[255]; - - memset(szResult, 0x00, 255); - memset(szDefault, 0x00, 255); - - sprintf(szDefault, "%u", defaultValue); - - this->ReadString (szSection , szKey , szDefault, szResult, (size_t) 255 ); - iniValueReadFromFile = (UINT32) strtoul(szResult,NULL,0); -#else iniValueReadFromFile = (UINT32) m_oProps.getUIntProperty(szSection, szKey, defaultValue); -#endif //AssertGE(iniValueReadFromFile, minValue); //AssertLE(iniValueReadFromFile, maxValue); @@ -457,10 +353,5 @@ UINT32 CIniReader::ReadUINT(const STR8 szSection, const STR8 szKey, UINT32 defau iniValueReadFromFile = maxValue; } -#ifndef USE_VFS - delete [] szResult ; - delete [] szDefault ; -#endif return iniValueReadFromFile; - } diff --git a/Utils/INIReader.h b/Utils/INIReader.h index 947cdeff5..11595a1e9 100644 --- a/Utils/INIReader.h +++ b/Utils/INIReader.h @@ -56,18 +56,14 @@ class CIniReader BOOLEAN Is_CIniReader_File_Found(void) {return (CIniReader_File_Found);} void Clear(); -#ifdef USE_VFS static void RegisterFileForMerging(vfs::Path const& filename); -#endif private: vfs::PropertyContainer m_oProps; char m_szFileName[MAX_PATH]; BOOLEAN CIniReader_File_Found; UINT32 ReadUINT(const STR8 szSection, const STR8 szKey, UINT32 defaultValue, UINT32 minValue, UINT32 maxValue); -#ifdef USE_VFS static std::set m_merge_files; -#endif }; -#endif//INIREADER_H \ No newline at end of file +#endif//INIREADER_H diff --git a/Utils/message.cpp b/Utils/message.cpp index 4c6163c48..2befaa263 100644 --- a/Utils/message.cpp +++ b/Utils/message.cpp @@ -1522,22 +1522,8 @@ static struct DebugMessageLog { void WriteMessageToFile( const STR16 pString ) { #ifdef JA2BETAVERSION -#ifndef USE_VFS - FILE *fp; - - fp = fopen( "DebugMessage.txt", "a" ); - - if( fp == NULL ) - { - return; - } - - fprintf( fp, "%S\n", pString ); - fclose( fp ); -#else SGP_LOG(s_DebugMessageLog.id, pString); #endif -#endif } diff --git a/jascreens.cpp b/jascreens.cpp index 4409a0b45..b431dd2e8 100644 --- a/jascreens.cpp +++ b/jascreens.cpp @@ -396,44 +396,25 @@ UINT32 InitScreenHandle(void) // Handle queued .ini file error messages int y = 40; -#ifdef USE_VFS sgp::Logger_ID ini_id = sgp::Logger::instance().createLogger(); sgp::Logger::instance().connectFile(ini_id, L"iniErrorReport.txt", false, sgp::Logger::FLUSH_ON_DELETE); sgp::Logger::LogInstance logger = sgp::Logger::instance().logger(ini_id); -#endif while (! iniErrorMessages.empty()) { -#ifndef USE_VFS - FILE *file_pointer; -#endif static BOOL iniErrorMessage_create_out_file = TRUE; std::string iniErrorMessage = iniErrorMessages.top(); CHAR16 str[256]; if (iniErrorMessage_create_out_file) { -#ifndef USE_VFS - fopen_s( &file_pointer, "..\\iniErrorReport.txt", "w" ); -#endif y += 25; swprintf( str, L"%S", "Warning: found the following ini errors. iniErrorReport.txt has been created." ); DisplayWrappedString( 10, y, 560, 2, FONT12ARIAL, FONT_ORANGE, str, FONT_BLACK, TRUE, LEFT_JUSTIFIED ); iniErrorMessage_create_out_file = FALSE; } - else - { -#ifndef USE_VFS - fopen_s( &file_pointer, "..\\iniErrorReport.txt", "a+" ); -#endif - } y += 25; swprintf( str, L"%S", iniErrorMessage.c_str() ); -#ifndef USE_VFS - fprintf_s (file_pointer , "%S\n" , str ); - fclose( file_pointer ); -#else logger << iniErrorMessage << sgp::endl; -#endif DisplayWrappedString( 10, y, 560, 2, FONT12ARIAL, FONT_ORANGE, str, FONT_BLACK, TRUE, LEFT_JUSTIFIED ); iniErrorMessages.pop(); From 0b5f14a3ad3dd4a220706206d77e338c4f7b651c Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:45:40 +0300 Subject: [PATCH 2/6] Remove empty function --- Standard Gaming Platform/FileMan.cpp | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index e7f2a1d0d..c11c12823 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -78,8 +78,6 @@ static tFILEMAP s_mapFiles; #define CHECKN(exp) if (!(exp)) { return(NULL); } #define CHECKBI(exp) if (!(exp)) { return(-1); } -#define PRINT_DEBUG_INFO FileDebugPrint(); - //************************************************************************** // // Typedefs @@ -148,7 +146,6 @@ TFileCat gCustomDataCat; // Init in InitializeStandardGamingPlatform (sgp.cpp) void W32toSGPFileFind( GETFILESTRUCT *pGFStruct, WIN32_FIND_DATA *pW32Struct ); -void FileDebugPrint( void ); HANDLE GetHandleToRealFile( HWFILE hFile, BOOLEAN *pfDatabaseFile ); HWFILE CreateFileHandle( HANDLE hRealFile, BOOLEAN fDatabaseFile ); void DestroyFileHandle( HWFILE hFile ); @@ -823,23 +820,6 @@ UINT32 FileGetSize( HWFILE hFile ) return 0; } -//************************************************************************** -// -// FileDebugPrint -// -// To print the state of memory to output. -// -// Parameter List : -// Return Value : -// Modification history : -// -// 24sep96:HJH ->creation -// -//************************************************************************** - -void FileDebugPrint( void ) -{ -} //************************************************************************** // From 74a25a20698f4c8cb64c6a361b8970251da9d348 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:46:36 +0300 Subject: [PATCH 3/6] Remove empty function --- Standard Gaming Platform/soundman.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/Standard Gaming Platform/soundman.cpp b/Standard Gaming Platform/soundman.cpp index a2f5869eb..743dd0877 100644 --- a/Standard Gaming Platform/soundman.cpp +++ b/Standard Gaming Platform/soundman.cpp @@ -61,7 +61,6 @@ FILE *SndDebug; // Debug logging void SoundLog(CHAR8 *strMessage); -void InitLogging(); // Cache system BOOLEAN SoundInitCache(void); @@ -213,7 +212,6 @@ BOOLEAN InitializeSoundManager(void) { UINT32 uiCount; - InitLogging(); if(fSoundSystemInit) { @@ -1871,15 +1869,3 @@ void SoundLog(CHAR8 *strMessage) } s_SoundLog; SGP_LOG(s_SoundLog.id, vfs::String::widen(strMessage,strlen(strMessage))); } - -//***************************************************************************************** -// InitLogging -// Creates empty log file -// -// Returns nothing -// -// Created: 10.12.2005 Lesh -//***************************************************************************************** -void InitLogging() -{ -} From f5e0d0bbd8611f08e54300ab170e401121f7a35c Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:47:13 +0300 Subject: [PATCH 4/6] Remove useless function --- Standard Gaming Platform/FileMan.cpp | 6 ------ Standard Gaming Platform/FileMan.h | 1 - 2 files changed, 7 deletions(-) diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index c11c12823..3b57cd692 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -1176,12 +1176,6 @@ BOOLEAN DirectoryExists( STRING512 pcDirectory ) } -BOOLEAN MakeFileManDirectory( STRING512 pcDirectory ) -{ - return FALSE; -} - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Removes ALL FILES in the specified directory (and all subdirectories with their files if fRecursive is TRUE) // Use EraseDirectory() to simply delete directory contents without deleting the directory itself diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index b35f06fef..0ef827c10 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -132,7 +132,6 @@ BOOLEAN GetFileManCurrentDirectory( STRING512 pcDirectory ); BOOLEAN GetExecutableDirectory( STRING512 pcDirectory ); BOOLEAN DirectoryExists( STRING512 pcDirectory ); -BOOLEAN MakeFileManDirectory( STRING512 pcDirectory ); // WARNING: THESE DELETE ALL FILES IN THE DIRECTORY ( and all subdirectories if fRecursive is TRUE!! ) BOOLEAN RemoveFileManDirectory( STRING512 pcDirectory, BOOLEAN fRecursive); From f11534e792e64e6aa4957c3e495abadf38574a6a Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:47:38 +0300 Subject: [PATCH 5/6] Remove orphan function declaration --- Standard Gaming Platform/FileMan.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index 0ef827c10..a1350eaa4 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -179,10 +179,6 @@ INT32 CompareSGPFileTimes( SGP_FILETIME *pFirstFileTime, SGP_FILETIME *pSecondFi // files times may be slightly different due to SourceSafe of copying BOOLEAN FileIsOlderThanFile(CHAR8 *pcFileName1, CHAR8 *pcFileName2, UINT32 ulNumSeconds); -// Pass in the Fileman file handle of an OPEN file and it will return.. -// if its a Real File, the return will be the handle of the REAL file -// if its a LIBRARY file, the return will be the handle of the LIBRARY -HANDLE GetRealFileHandleFromFileManFileHandle( HWFILE hFile ); BOOLEAN AddSubdirectoryToPath(CHAR8 *pDirectory); From 5a922e3a42c1400e118538ec8e990c59fed7b1d3 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:48:18 +0300 Subject: [PATCH 6/6] Remove useless function --- Editor/Sector Summary.cpp | 3 ++- Laptop/files.cpp | 1 - Laptop/finances.cpp | 1 - Laptop/history.cpp | 1 - Laptop/laptop.cpp | 4 ---- Standard Gaming Platform/FileMan.cpp | 5 ----- Standard Gaming Platform/FileMan.h | 2 -- 7 files changed, 2 insertions(+), 15 deletions(-) diff --git a/Editor/Sector Summary.cpp b/Editor/Sector Summary.cpp index b71742472..9c328cfaa 100644 --- a/Editor/Sector Summary.cpp +++ b/Editor/Sector Summary.cpp @@ -2177,7 +2177,8 @@ void SummarySaveMapCallback( GUI_BUTTON *btn, INT32 reason ) { CHAR8 filename[40]; sprintf( filename, "MAPS\\%S", gszDisplayName ); - FileClearAttributes( filename ); + // Other call sites have replaced this with FileDelete(); for VFS, should we do the same here? + //FileClearAttributes( filename ); } if( ExternalSaveMap( gszDisplayName ) ) { diff --git a/Laptop/files.cpp b/Laptop/files.cpp index feb802715..3de647b97 100644 --- a/Laptop/files.cpp +++ b/Laptop/files.cpp @@ -476,7 +476,6 @@ void GameInitFiles( ) { if ( FileExists( FILES_DAT_FILE ) == TRUE ) { - FileClearAttributes( FILES_DAT_FILE ); FileDelete( FILES_DAT_FILE ); } diff --git a/Laptop/finances.cpp b/Laptop/finances.cpp index 57c8acbaa..ac542863f 100644 --- a/Laptop/finances.cpp +++ b/Laptop/finances.cpp @@ -460,7 +460,6 @@ void GameInitFinances() // unlink Finances data file if( (FileExists( FINANCES_DATA_FILE ) ) ) { - FileClearAttributes( FINANCES_DATA_FILE ); FileDelete( FINANCES_DATA_FILE ); } GetBalanceFromDisk( ); diff --git a/Laptop/history.cpp b/Laptop/history.cpp index 6067098da..3ca4a8c47 100644 --- a/Laptop/history.cpp +++ b/Laptop/history.cpp @@ -227,7 +227,6 @@ void GameInitHistory() if( ( FileExists( HISTORY_DATA_FILE ) ) ) { // unlink history file - FileClearAttributes( HISTORY_DATA_FILE ); FileDelete( HISTORY_DATA_FILE ); } diff --git a/Laptop/laptop.cpp b/Laptop/laptop.cpp index 33e95d76d..00c2f1615 100644 --- a/Laptop/laptop.cpp +++ b/Laptop/laptop.cpp @@ -7136,28 +7136,24 @@ void ClearOutTempLaptopFiles( void ) // file file if ( (FileExists( "files.dat" ) == TRUE ) ) { - FileClearAttributes( "files.dat" ); FileDelete( "files.dat" ); } // finances if ( (FileExists( "finances.dat" ) == TRUE ) ) { - FileClearAttributes( "finances.dat" ); FileDelete( "finances.dat" ); } // email if ( (FileExists( "email.dat" ) == TRUE ) ) { - FileClearAttributes( "email.dat" ); FileDelete( "email.dat" ); } // history if ( (FileExists( "history.dat" ) == TRUE ) ) { - FileClearAttributes( "history.dat" ); FileDelete( "history.dat" ); } } diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index 3b57cd692..9e4c3804a 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -1472,11 +1472,6 @@ UINT32 FileGetAttributes( STR strFilename ) return( uiFileAttrib ); } -BOOLEAN FileClearAttributes( STR strFilename ) -{ - return TRUE; -} - //returns true if at end of file, else false BOOLEAN FileCheckEndOfFile( HWFILE hFile ) diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index a1350eaa4..e5ba08544 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -156,8 +156,6 @@ BOOLEAN FileMove(STR strOldName, STR strNewName); BOOLEAN FileSetAttributes( STR filename, UINT32 uiNewAttribs ); UINT32 FileGetAttributes( STR filename ); -BOOLEAN FileClearAttributes( STR strFilename ); - //returns true if at end of file, else false BOOLEAN FileCheckEndOfFile( HWFILE hFile );