Merge pull request #237 from 1dot13/remove-novfs-ifdefs

Remove ifdefs related to USE_VFS
This commit is contained in:
Asdow
2023-10-08 18:53:35 +03:00
committed by GitHub
39 changed files with 11 additions and 1976 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ set(usingMsBuild $<STREQUAL:${CMAKE_VS_PLATFORM_NAME},Win32>)
# TODO: build our own Lua 5.1.2 from source so we can use whichever
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>: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
+2 -41
View File
@@ -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
}
}
}
-2
View File
@@ -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
+2 -177
View File
@@ -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 );
@@ -2203,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 ) )
{
@@ -2281,12 +2256,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 +2264,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 +2288,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 +2303,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 +2322,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 +2341,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 +2360,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 +2379,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 +2398,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 +2417,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 +2436,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 +2458,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 +2469,6 @@ void GenerateSummaryList()
{
SGP_RETHROW(L"Could not create readme.txt", ex);
}
#endif
}
//dnl ch28 260909
-11
View File
@@ -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);
-1
View File
@@ -476,7 +476,6 @@ void GameInitFiles( )
{
if ( FileExists( FILES_DAT_FILE ) == TRUE )
{
FileClearAttributes( FILES_DAT_FILE );
FileDelete( FILES_DAT_FILE );
}
-1
View File
@@ -460,7 +460,6 @@ void GameInitFinances()
// unlink Finances data file
if( (FileExists( FINANCES_DATA_FILE ) ) )
{
FileClearAttributes( FINANCES_DATA_FILE );
FileDelete( FINANCES_DATA_FILE );
}
GetBalanceFromDisk( );
-1
View File
@@ -227,7 +227,6 @@ void GameInitHistory()
if( ( FileExists( HISTORY_DATA_FILE ) ) )
{
// unlink history file
FileClearAttributes( HISTORY_DATA_FILE );
FileDelete( HISTORY_DATA_FILE );
}
-4
View File
@@ -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" );
}
}
-2
View File
@@ -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() )
-28
View File
@@ -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;
}
-2
View File
@@ -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
-2
View File
@@ -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();
-2
View File
@@ -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)
{
File diff suppressed because it is too large Load Diff
-7
View File
@@ -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);
@@ -157,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 );
@@ -180,10 +177,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);
-18
View File
@@ -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
+1 -21
View File
@@ -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
#endif
-16
View File
@@ -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<WIN_LASTFONT; i++)
{
GetPrivateProfileString(FontInfo[i].FontName, "Name", FontInfo[i].LogFont.lfFaceName, FontInfo[i].LogFont.lfFaceName, LF_FACESIZE, INIFile);
FontInfo[i].LogFont.lfHeight = gWinFontAdjust + GetPrivateProfileInt(FontInfo[i].FontName, "Height", FontInfo[i].LogFont.lfHeight, INIFile);
FontInfo[i].LogFont.lfWeight = GetPrivateProfileInt(FontInfo[i].FontName, "Weight", FontInfo[i].LogFont.lfWeight, INIFile);
}
#else
vfs::PropertyContainer props;
props.initFromIniFile(GAME_INI_FILE);
@@ -216,7 +201,6 @@ Weight=400
FontInfo[i].LogFont.lfHeight = gWinFontAdjust + (LONG)props.getIntProperty(FontInfo[i].FontName, "Height", FontInfo[i].LogFont.lfHeight);
FontInfo[i].LogFont.lfWeight = (LONG)props.getIntProperty(FontInfo[i].FontName, "Weight", FontInfo[i].LogFont.lfWeight);
}
#endif
}
void InitWinFonts( )
-122
View File
@@ -144,9 +144,7 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
#ifdef USE_VFS
static void PopulateSectionFromCommandLine(vfs::PropertyContainer &oProps, vfs::String const& sSection);
#endif
HINSTANCE ghInstance;
@@ -194,9 +192,7 @@ extern bool g_bUseXML_Strings;// = false;
bool g_bUseXML_Structures = false;
//bool g_bUseXML_Tilesets = false;
#ifdef USE_VFS
static vfs::Path sp_force_load_jsd_xml_file;
#endif
INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LPARAM lParam)
{
@@ -497,7 +493,6 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
return FALSE;
}
#ifdef USE_VFS
//vfs::Path exe_dir, exe_file;
//os::getExecutablePath(exe_dir, exe_file);
@@ -545,41 +540,6 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
}
}
#endif // USE_CODE_PAGE
#else
// Snap: moved the following from InitJA2SplashScreen for clarity
STRING512 CurrentDir;
STRING512 DataDir;
// Get Executable Directory
GetExecutableDirectory( CurrentDir );
// Adjust Current Dir
sprintf( DataDir, "%s\\Data", CurrentDir );
if ( !SetFileManCurrentDirectory( DataDir ) )
{
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Could not find data directory, shutting down");
return FALSE;
}
//Initialize the file database
//InitializeFileDatabase( gGameLibaries, NUMBER_OF_LIBRARIES ); // ?!?! doesn't take parameters (jonathanl)
InitializeFileDatabase();
// Snap: Initialize the Data directory catalogue
gDefaultDataCat.NewCat(DataDir);
STRING512 ja2INIfile;
strcat(ja2INIfile, "..\\");
strcat(ja2INIfile, GAME_INI_FILE);
// Snap: Get the custom Data directory location from GAME_INI_FILE (if any)
// and initialize the custom catalogue
char customDataPath[MAX_PATH];
if ( GetPrivateProfileString( "Ja2 Settings","CUSTOM_DATA_LOCATION", "", customDataPath, MAX_PATH, ja2INIfile ) )
{
gCustomDataCat.NewCat(std::string(CurrentDir) + '\\' + customDataPath);
}
#endif
if(g_bUseXML_Strings)
{
@@ -721,7 +681,6 @@ void ShutdownStandardGamingPlatform(void)
vfs::ObjectAllocator::clear();
}
#ifdef USE_VFS
#include "MPJoinScreen.h"
vfs::String getGameID()
@@ -735,7 +694,6 @@ vfs::String getGameID()
}
return _id;
}
#endif
#include "debug_util.h"
#include <vfs/Aspects/vfs_logging.h>
@@ -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)
{
-34
View File
@@ -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::STimeLog> sgp::Logger::_logs;
std::vector<sgp::Logger::LogData> 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::_flush>(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::_endl>(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::_endl>(sgp:
template <>
sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< <sgp::_lock>(sgp::_lock const& l)
{
#if defined(USE_VFS)
_log.file->lock();
#endif
return *this;
}
+3 -31
View File
@@ -2,13 +2,9 @@
#define SGP_LOGGER_H
#include <vector>
#if defined(USE_VFS)
# include <vfs/Core/vfs_string.h>
# include <vfs/Tools/vfs_log.h>
# include <vfs/Tools/vfs_hp_timer.h>
#else
# include <iostream>
#endif
#include <vfs/Core/vfs_string.h>
#include <vfs/Tools/vfs_log.h>
#include <vfs/Tools/vfs_hp_timer.h>
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(){
-28
View File
@@ -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)
{
@@ -1869,31 +1867,5 @@ 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
}
//*****************************************************************************************
// InitLogging
// Creates empty log file
//
// Returns nothing
//
// Created: 10.12.2005 Lesh
//*****************************************************************************************
void InitLogging()
{
#ifndef USE_VFS
if ((SndDebug = fopen(SndDebugFileName, "wt")) != NULL)
{
fclose(SndDebug);
}
#endif
}
-79
View File
@@ -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
}
-21
View File
@@ -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, "<ALT_SECTORS_LIST>\n");
for(y = 1;y <= 16;y++)
{
fprintf (outfile, "\t<ROW y=\"%c\">",(y+0x40));
for(x = 1;x <= 16; x++)
{
fprintf (outfile, " %d",RandomSector[ ((y - 1) * 16) + (x - 1) ] );
}
fprintf (outfile, " </ROW>\n");
}
fprintf (outfile, "</ALT_SECTORS_LIST>\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);
}
-41
View File
@@ -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
-75
View File
@@ -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
}
-26
View File
@@ -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
-6
View File
@@ -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 );
-31
View File
@@ -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");
-2
View File
@@ -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( )
{
-8
View File
@@ -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)
{
-16
View File
@@ -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<CHAR8*>(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);
-18
View File
@@ -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);
-20
View File
@@ -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
}
+1 -110
View File
@@ -12,9 +12,7 @@
#include <vfs/Core/vfs.h>
#ifdef USE_VFS
std::set<vfs::Path,vfs::Path::Less> CIniReader::m_merge_files;
#endif
std::stack<std::string> iniErrorMessages;
template<typename ValueType>
@@ -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<int>(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<int>(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<unsigned int>(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<int>(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;
}
+1 -5
View File
@@ -56,18 +56,14 @@ public:
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<vfs::Path, vfs::Path::Less> m_merge_files;
#endif
};
#endif//INIREADER_H
#endif//INIREADER_H
-14
View File
@@ -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
}
-19
View File
@@ -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();