mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
*** Merged Code from Multiplayer Branch Revision 2993 ***
- Updated VFS - Fixed Map Editor not properly initialized with VFS - New Map Editor Release (Build: 2993( git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2994 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+157
-15
@@ -41,6 +41,9 @@
|
||||
#include "Campaign Types.h"
|
||||
#endif
|
||||
|
||||
#include "VFS/vfs.h"
|
||||
#include "VFS/vfs_file_raii.h"
|
||||
|
||||
extern BOOLEAN gfOverheadMapDirty;
|
||||
|
||||
#define MAP_SIZE 208
|
||||
@@ -1883,14 +1886,16 @@ 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 );
|
||||
|
||||
@@ -1902,12 +1907,20 @@ void CreateGlobalSummary()
|
||||
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";
|
||||
vfs::UInt32 io;
|
||||
wfile.file().Write(str.c_str(), str.length(), io);
|
||||
#endif
|
||||
|
||||
// Snap: Restore the data directory once we are finished.
|
||||
//SetFileManCurrentDirectory( DataDir );
|
||||
@@ -2225,10 +2238,12 @@ 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;
|
||||
@@ -2236,28 +2251,35 @@ void LoadGlobalSummary()
|
||||
CHAR8 szSector[6];
|
||||
|
||||
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
|
||||
@@ -2272,10 +2294,15 @@ 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 = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
|
||||
#endif
|
||||
if( hfile )
|
||||
{
|
||||
gbSectorLevels[x][y] |= GROUND_LEVEL_MASK;
|
||||
@@ -2285,14 +2312,23 @@ 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 = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
|
||||
#endif
|
||||
if( hfile )
|
||||
{
|
||||
gbSectorLevels[x][y] |= BASEMENT1_LEVEL_MASK;
|
||||
@@ -2302,14 +2338,23 @@ 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 = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
|
||||
#endif
|
||||
if( hfile )
|
||||
{
|
||||
gbSectorLevels[x][y] |= BASEMENT2_LEVEL_MASK;
|
||||
@@ -2319,14 +2364,23 @@ 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 = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
|
||||
#endif
|
||||
if( hfile )
|
||||
{
|
||||
gbSectorLevels[x][y] |= BASEMENT3_LEVEL_MASK;
|
||||
@@ -2336,14 +2390,23 @@ 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 = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
|
||||
#endif
|
||||
if( hfile )
|
||||
{
|
||||
gbSectorLevels[x][y] |= ALTERNATE_GROUND_MASK;
|
||||
@@ -2353,14 +2416,23 @@ 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 = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
|
||||
#endif
|
||||
if( hfile )
|
||||
{
|
||||
gbSectorLevels[x][y] |= ALTERNATE_B1_MASK;
|
||||
@@ -2370,14 +2442,23 @@ 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 = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
|
||||
#endif
|
||||
if( hfile )
|
||||
{
|
||||
gbSectorLevels[x][y] |= ALTERNATE_B2_MASK;
|
||||
@@ -2387,14 +2468,23 @@ 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 = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
|
||||
#endif
|
||||
if( hfile )
|
||||
{
|
||||
gbSectorLevels[x][y] |= ALTERNATE_B1_MASK;;
|
||||
@@ -2404,16 +2494,20 @@ 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 );
|
||||
|
||||
@@ -2430,6 +2524,7 @@ void LoadGlobalSummary()
|
||||
|
||||
void GenerateSummaryList()
|
||||
{
|
||||
#ifndef USE_VFS
|
||||
FILE *fp;
|
||||
STRING512 DataDir;
|
||||
STRING512 ExecDir;
|
||||
@@ -2455,24 +2550,39 @@ void GenerateSummaryList()
|
||||
"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);
|
||||
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";
|
||||
vfs::UInt32 io;
|
||||
wfile.file().Write(str.c_str(), str.length(),io);
|
||||
}
|
||||
catch(CBasicException &ex)
|
||||
{
|
||||
RETHROWEXCEPTION(L"Could not create readme.txt",&ex);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void WriteSectorSummaryUpdate( STR8 puiFilename, UINT8 ubLevel, SUMMARYFILE *pSummaryFileInfo )
|
||||
{
|
||||
#ifndef USE_VFS
|
||||
FILE *fp;
|
||||
STRING512 DataDir;
|
||||
STRING512 ExecDir;
|
||||
STRING512 Dir;
|
||||
CHAR8 *ptr;
|
||||
#endif
|
||||
INT8 x, y;
|
||||
|
||||
#ifndef USE_VFS
|
||||
// Snap: save current directory
|
||||
GetFileManCurrentDirectory( DataDir );
|
||||
|
||||
@@ -2498,6 +2608,14 @@ void WriteSectorSummaryUpdate( STR8 puiFilename, UINT8 ubLevel, SUMMARYFILE *pSu
|
||||
Assert( fp );
|
||||
fwrite( pSummaryFileInfo, 1, sizeof( SUMMARYFILE ), fp );
|
||||
fclose( fp );
|
||||
#else
|
||||
vfs::Path fname(puiFilename);
|
||||
THROWIFFALSE(MatchPattern(L"*.dat", fname()), L"Illegal sector summary filename");
|
||||
vfs::COpenWriteFile wfile(vfs::Path(L"DevInfo")+vfs::Path(puiFilename),true,true);
|
||||
vfs::UInt32 io;
|
||||
wfile.file().Write((vfs::Byte*)pSummaryFileInfo,sizeof(SUMMARYFILE), io);
|
||||
wfile.file().Close();
|
||||
#endif
|
||||
|
||||
//CHRISL:
|
||||
if(gusNumEntriesWithOutdatedOrNoSummaryInfo > 0)
|
||||
@@ -2520,12 +2638,13 @@ void WriteSectorSummaryUpdate( STR8 puiFilename, UINT8 ubLevel, SUMMARYFILE *pSu
|
||||
gpSectorSummary[x][y][ubLevel] = NULL;
|
||||
}
|
||||
gpSectorSummary[x][y][ubLevel] = pSummaryFileInfo;
|
||||
|
||||
#ifndef USE_VFS
|
||||
// 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 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void SummaryNewGroundLevelCallback( GUI_BUTTON *btn, INT32 reason )
|
||||
@@ -2566,8 +2685,12 @@ void LoadSummary( STR8 pSector, UINT8 ubLevel, FLOAT dMajorMapVersion )
|
||||
CHAR8 filename[40];
|
||||
SUMMARYFILE temp;
|
||||
INT32 x, y;
|
||||
#ifndef USE_VFS
|
||||
FILE *fp;
|
||||
sprintf( filename, pSector );
|
||||
#else
|
||||
sprintf( filename, "DevInfo\\%s", pSector );
|
||||
#endif
|
||||
if( ubLevel % 4 )
|
||||
{
|
||||
CHAR8 str[4];
|
||||
@@ -2579,7 +2702,7 @@ void LoadSummary( STR8 pSector, UINT8 ubLevel, FLOAT dMajorMapVersion )
|
||||
strcat( filename, "_a" );
|
||||
}
|
||||
strcat( filename, ".sum" );
|
||||
|
||||
#ifndef USE_VFS
|
||||
fp = fopen( filename, "rb" );
|
||||
if( !fp )
|
||||
{
|
||||
@@ -2598,6 +2721,15 @@ void LoadSummary( STR8 pSector, UINT8 ubLevel, FLOAT dMajorMapVersion )
|
||||
return;
|
||||
}
|
||||
fread( &temp, 1, sizeof( SUMMARYFILE ), fp );
|
||||
#else
|
||||
if(!GetVFS()->FileExists(filename))
|
||||
{
|
||||
return;
|
||||
}
|
||||
vfs::COpenReadFile rfile(filename);
|
||||
vfs::UInt32 io;
|
||||
rfile.file().Read((vfs::Byte*)&temp,sizeof(SUMMARYFILE),io);
|
||||
#endif
|
||||
//CHRISL: Again, this basically forces the maps to be updated whether we actually access the map or not. Why don't we just
|
||||
// update the map when the map actually needs to be loaded?
|
||||
/* if( temp.ubSummaryVersion < MINIMUMVERSION || dMajorMapVersion < gdMajorMapVersion )
|
||||
@@ -2624,8 +2756,9 @@ void LoadSummary( STR8 pSector, UINT8 ubLevel, FLOAT dMajorMapVersion )
|
||||
memcpy( gpSectorSummary[x][y][ubLevel], &temp, sizeof( SUMMARYFILE ) );
|
||||
if( gpSectorSummary[x][y][ubLevel]->ubSummaryVersion < GLOBAL_SUMMARY_VERSION )
|
||||
gusNumEntriesWithOutdatedOrNoSummaryInfo++;
|
||||
|
||||
#ifndef USE_VFS
|
||||
fclose( fp );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -2800,7 +2933,9 @@ void ExtractTempFilename()
|
||||
|
||||
BOOLEAN ReEvaluateWorld( const STR8 puiFilename )
|
||||
{
|
||||
#ifndef USE_VFS
|
||||
STRING512 DataDir;
|
||||
#endif
|
||||
STRING512 MapsDir;
|
||||
FLOAT dMajorVersion;
|
||||
UINT8 dMinorVersion;
|
||||
@@ -2808,9 +2943,10 @@ BOOLEAN ReEvaluateWorld( const STR8 puiFilename )
|
||||
CHAR8 name[50];
|
||||
HWFILE hfile;
|
||||
UINT32 uiNumBytesRead;
|
||||
|
||||
#ifndef USE_VFS
|
||||
GetFileManCurrentDirectory( DataDir );
|
||||
sprintf( MapsDir, "%s\\Maps", DataDir );
|
||||
#endif
|
||||
|
||||
if( gbSectorLevels[gsSelSectorX-1][gsSelSectorY-1] & GROUND_LEVEL_MASK )
|
||||
ubLevel = 0;
|
||||
@@ -2828,16 +2964,22 @@ BOOLEAN ReEvaluateWorld( const STR8 puiFilename )
|
||||
ubLevel = 6;
|
||||
else if( gbSectorLevels[gsSelSectorX-1][gsSelSectorY-1] & ALTERNATE_B3_MASK )
|
||||
ubLevel = 7;
|
||||
|
||||
#ifndef USE_VFS
|
||||
SetFileManCurrentDirectory( MapsDir );
|
||||
hfile = FileOpen( puiFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
|
||||
#else
|
||||
sprintf( MapsDir, "Maps\\%s", puiFilename );
|
||||
hfile = FileOpen( MapsDir, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
|
||||
#endif
|
||||
if( hfile )
|
||||
{
|
||||
FileRead( hfile, &dMajorVersion, sizeof( FLOAT ), &uiNumBytesRead );
|
||||
FileRead( hfile, &dMinorVersion, sizeof( UINT8 ), &uiNumBytesRead );
|
||||
FileClose( hfile );
|
||||
}
|
||||
#ifndef USE_VFS
|
||||
SetFileManCurrentDirectory( DataDir );
|
||||
#endif
|
||||
|
||||
if(dMajorVersion < gdMajorMapVersion || dMinorVersion < gubMinorMapVersion)
|
||||
gfMajorUpdate = TRUE;
|
||||
|
||||
+4
-4
@@ -13,12 +13,12 @@
|
||||
#ifdef JA2EDITOR
|
||||
|
||||
//MAP EDITOR BUILD VERSION
|
||||
CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.2975" };
|
||||
CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.2993" };
|
||||
|
||||
#elif defined JA2BETAVERSION
|
||||
|
||||
//BETA/TEST BUILD VERSION
|
||||
CHAR16 zVersionLabel[256] = { L"Debug v1.13.2975" };
|
||||
CHAR16 zVersionLabel[256] = { L"Debug v1.13.2993" };
|
||||
|
||||
#elif defined CRIPPLED_VERSION
|
||||
|
||||
@@ -28,11 +28,11 @@ CHAR16 zVersionLabel[256] = { L"Beta v. 0.98" };
|
||||
#else
|
||||
|
||||
//RELEASE BUILD VERSION
|
||||
CHAR16 zVersionLabel[256] = { L"Release v1.13.2975" };
|
||||
CHAR16 zVersionLabel[256] = { L"Release v1.13.2963" };
|
||||
|
||||
#endif
|
||||
|
||||
CHAR8 czVersionNumber[16] = { "Build 09.06.06" }; //YY.MM.DD
|
||||
CHAR8 czVersionNumber[16] = { "Build 09.06.09" }; //YY.MM.DD
|
||||
CHAR16 zTrackingNumber[16] = { L"Z" };
|
||||
|
||||
|
||||
|
||||
+134
-147
@@ -32,6 +32,8 @@
|
||||
#include "LaptopSave.h"
|
||||
#endif
|
||||
|
||||
#include "VFS/Tools/ParserTools.h"
|
||||
|
||||
#define FULL_NAME_CURSOR_Y LAPTOP_SCREEN_WEB_UL_Y + 138
|
||||
#define NICK_NAME_CURSOR_Y LAPTOP_SCREEN_WEB_UL_Y + 195
|
||||
#define MALE_BOX_X 2 + 192 + LAPTOP_SCREEN_UL_X
|
||||
@@ -455,39 +457,38 @@ void GetPlayerKeyBoardInputForIMPBeginScreen( void )
|
||||
// handle input events
|
||||
while( DequeueEvent(&InputEvent) )
|
||||
{
|
||||
/*
|
||||
/*
|
||||
// HOOK INTO MOUSE HOOKS
|
||||
switch(InputEvent.usEvent)
|
||||
switch(InputEvent.usEvent)
|
||||
{
|
||||
|
||||
case LEFT_BUTTON_DOWN:
|
||||
MouseSystemHook(LEFT_BUTTON_DOWN, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
|
||||
break;
|
||||
break;
|
||||
case LEFT_BUTTON_UP:
|
||||
MouseSystemHook(LEFT_BUTTON_UP, (INT16)MousePos.x, (INT16)MousePos.y ,_LeftButtonDown, _RightButtonDown);
|
||||
break;
|
||||
break;
|
||||
case RIGHT_BUTTON_DOWN:
|
||||
MouseSystemHook(RIGHT_BUTTON_DOWN, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
|
||||
break;
|
||||
break;
|
||||
case RIGHT_BUTTON_UP:
|
||||
MouseSystemHook(RIGHT_BUTTON_UP, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
*/
|
||||
if( !HandleTextInput( &InputEvent ) && (InputEvent.usEvent == KEY_DOWN || InputEvent.usEvent == KEY_REPEAT) )
|
||||
*/
|
||||
if( !HandleTextInput( &InputEvent ) && (InputEvent.usEvent == KEY_DOWN || InputEvent.usEvent == KEY_REPEAT) )
|
||||
{
|
||||
switch( InputEvent.usParam )
|
||||
switch( InputEvent.usParam )
|
||||
{
|
||||
case (( ENTER )):
|
||||
// check to see if gender was highlighted..if so, select it
|
||||
if( FEMALE_GENDER_SELECT == ubTextEnterMode )
|
||||
{
|
||||
// check to see if gender was highlighted..if so, select it
|
||||
if( FEMALE_GENDER_SELECT == ubTextEnterMode )
|
||||
{
|
||||
bGenderFlag = IMP_FEMALE;
|
||||
}
|
||||
}
|
||||
else if( MALE_GENDER_SELECT == ubTextEnterMode )
|
||||
{
|
||||
{
|
||||
bGenderFlag = IMP_MALE;
|
||||
}
|
||||
}
|
||||
|
||||
// increment to next selection box
|
||||
IncrementTextEnterMode( );
|
||||
@@ -497,12 +498,12 @@ void GetPlayerKeyBoardInputForIMPBeginScreen( void )
|
||||
// handle space bar
|
||||
if( FEMALE_GENDER_SELECT == ubTextEnterMode )
|
||||
{
|
||||
bGenderFlag = IMP_FEMALE;
|
||||
bGenderFlag = IMP_FEMALE;
|
||||
DecrementTextEnterMode( );
|
||||
}
|
||||
else if( MALE_GENDER_SELECT == ubTextEnterMode )
|
||||
else if( MALE_GENDER_SELECT == ubTextEnterMode )
|
||||
{
|
||||
bGenderFlag = IMP_MALE;
|
||||
bGenderFlag = IMP_MALE;
|
||||
IncrementTextEnterMode( );
|
||||
}
|
||||
else
|
||||
@@ -511,22 +512,22 @@ void GetPlayerKeyBoardInputForIMPBeginScreen( void )
|
||||
}
|
||||
fNewCharInString = TRUE;
|
||||
break;
|
||||
case (( ESC )):
|
||||
HandleLapTopESCKey(); // WANNE: Fix for proper closing of the IMP laptop page
|
||||
LeaveLapTopScreen( );
|
||||
case (( ESC )):
|
||||
HandleLapTopESCKey(); // WANNE: Fix for proper closing of the IMP laptop page
|
||||
LeaveLapTopScreen( );
|
||||
break;
|
||||
case (( TAB )):
|
||||
// tab hit, increment to next selection box
|
||||
IncrementTextEnterMode( );
|
||||
fNewCharInString = TRUE;
|
||||
case (( TAB )):
|
||||
// tab hit, increment to next selection box
|
||||
IncrementTextEnterMode( );
|
||||
fNewCharInString = TRUE;
|
||||
break;
|
||||
case ( 265 ):
|
||||
case ( 265 ):
|
||||
// tab and shift
|
||||
DecrementTextEnterMode( );
|
||||
fNewCharInString = TRUE;
|
||||
DecrementTextEnterMode( );
|
||||
fNewCharInString = TRUE;
|
||||
break;
|
||||
default:
|
||||
HandleBeginScreenTextEvent( InputEvent.usParam );
|
||||
default:
|
||||
HandleBeginScreenTextEvent( InputEvent.usParam );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -544,59 +545,48 @@ void HandleBeginScreenTextEvent( UINT32 uiKey )
|
||||
{
|
||||
case ( BACKSPACE ):
|
||||
|
||||
switch( ubTextEnterMode )
|
||||
switch( ubTextEnterMode )
|
||||
{
|
||||
case( FULL_NAME_MODE ):
|
||||
if( uiFullNameCharacterPosition >= 0 )
|
||||
{
|
||||
case( FULL_NAME_MODE ):
|
||||
if( uiFullNameCharacterPosition >= 0 )
|
||||
{
|
||||
|
||||
|
||||
// decrement StringPosition
|
||||
if( uiFullNameCharacterPosition > 0)
|
||||
{
|
||||
uiFullNameCharacterPosition-=1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// null out char
|
||||
pFullNameString[uiFullNameCharacterPosition] = 0;
|
||||
// decrement StringPosition
|
||||
if( uiFullNameCharacterPosition > 0)
|
||||
{
|
||||
uiFullNameCharacterPosition-=1;
|
||||
}
|
||||
// null out char
|
||||
pFullNameString[uiFullNameCharacterPosition] = 0;
|
||||
|
||||
// move cursor back by sizeof char
|
||||
uiFullNameCursorPosition = 196 + LAPTOP_SCREEN_UL_X + StringPixLength( pFullNameString, FONT14ARIAL );
|
||||
uiFullNameCursorPosition = 196 + LAPTOP_SCREEN_UL_X + StringPixLength( pFullNameString, FONT14ARIAL );
|
||||
|
||||
// string has been altered, redisplay
|
||||
fNewCharInString = TRUE;
|
||||
}
|
||||
break;
|
||||
case ( NICK_NAME_MODE ):
|
||||
if( uiNickNameCharacterPosition >= 0 )
|
||||
{
|
||||
|
||||
|
||||
// decrement StringPosition
|
||||
if( uiNickNameCharacterPosition > 0 )
|
||||
// string has been altered, redisplay
|
||||
fNewCharInString = TRUE;
|
||||
}
|
||||
break;
|
||||
case ( NICK_NAME_MODE ):
|
||||
if( uiNickNameCharacterPosition >= 0 )
|
||||
{
|
||||
// decrement StringPosition
|
||||
if( uiNickNameCharacterPosition > 0 )
|
||||
uiNickNameCharacterPosition-=1;
|
||||
|
||||
// null out char
|
||||
pNickNameString[uiNickNameCharacterPosition] = 0;
|
||||
// null out char
|
||||
pNickNameString[uiNickNameCharacterPosition] = 0;
|
||||
|
||||
// move cursor back by sizeof char
|
||||
uiNickNameCursorPosition = 196 + LAPTOP_SCREEN_UL_X + StringPixLength( pNickNameString, FONT14ARIAL );
|
||||
uiNickNameCursorPosition = 196 + LAPTOP_SCREEN_UL_X + StringPixLength( pNickNameString, FONT14ARIAL );
|
||||
|
||||
// string has been altered, redisplay
|
||||
fNewCharInString = TRUE;
|
||||
}
|
||||
|
||||
break;
|
||||
// string has been altered, redisplay
|
||||
fNewCharInString = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
//Heinz (18.01.2009): Russian layout
|
||||
//
|
||||
//Heinz (18.01.2009): Russian layout
|
||||
//
|
||||
#if defined(RUSSIAN)
|
||||
if( ( (DWORD)GetKeyboardLayout(0) & 0xFFFF ) == 0x419)
|
||||
{
|
||||
@@ -609,91 +599,88 @@ void HandleBeginScreenTextEvent( UINT32 uiKey )
|
||||
uiKey == '_' || uiKey == '.' || uiKey == ' ') ) uiKey = '#';
|
||||
if(uiKey != '#')
|
||||
#else
|
||||
#ifndef USE_CODE_PAGE
|
||||
if( uiKey >= 'A' && uiKey <= 'Z' ||
|
||||
uiKey >= 'a' && uiKey <= 'z' ||
|
||||
uiKey >= '0' && uiKey <= '9' ||
|
||||
uiKey == '_' || uiKey == '.' ||
|
||||
uiKey == ' ' )
|
||||
#else
|
||||
if( charSet::IsFromSet( uiKey, charSet::CS_SPACE|charSet::CS_ALPHA_NUM|charSet::CS_SPECIAL_ALPHA ) )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
{
|
||||
// if the current string position is at max or great, do nothing
|
||||
{
|
||||
// if the current string position is at max or great, do nothing
|
||||
switch( ubTextEnterMode )
|
||||
{
|
||||
case( FULL_NAME_MODE ):
|
||||
if( uiFullNameCharacterPosition >= MAX_FULL_NAME )
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(uiFullNameCharacterPosition < 1 )
|
||||
{
|
||||
uiFullNameCharacterPosition = 0;
|
||||
}
|
||||
// make sure we haven't moved too far
|
||||
if( ( uiFullNameCursorPosition + StringPixLength( ( CHAR16 *)&(uiKey ), FONT14ARIAL ) ) > (UINT32)FULL_NAME_REGION_WIDTH + 196 + LAPTOP_SCREEN_UL_X)
|
||||
{
|
||||
// do nothing for now, when pop up is in place, display
|
||||
break;
|
||||
}
|
||||
// valid char, capture and convert to CHAR16
|
||||
pFullNameString[uiFullNameCharacterPosition] = ( CHAR16 )uiKey;
|
||||
|
||||
|
||||
// null out next char position
|
||||
pFullNameString[uiFullNameCharacterPosition + 1] = 0;
|
||||
|
||||
// move cursor position ahead
|
||||
uiFullNameCursorPosition = 196 + LAPTOP_SCREEN_UL_X + StringPixLength( pFullNameString, FONT14ARIAL );
|
||||
|
||||
// increment string position
|
||||
uiFullNameCharacterPosition +=1;
|
||||
|
||||
// string has been altered, redisplay
|
||||
fNewCharInString = TRUE;
|
||||
}
|
||||
{
|
||||
case( FULL_NAME_MODE ):
|
||||
if( uiFullNameCharacterPosition >= MAX_FULL_NAME )
|
||||
{
|
||||
break;
|
||||
case ( NICK_NAME_MODE ):
|
||||
if( uiNickNameCharacterPosition >= MAX_NICK_NAME )
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(uiNickNameCharacterPosition == -1)
|
||||
{
|
||||
uiNickNameCharacterPosition = 0;
|
||||
}
|
||||
|
||||
// make sure we haven't moved too far
|
||||
if( ( uiNickNameCursorPosition + StringPixLength( (CHAR16 *)&(uiKey ), FONT14ARIAL ) ) > (UINT32)NICK_NAME_REGION_WIDTH + 196 + LAPTOP_SCREEN_UL_X )
|
||||
{
|
||||
// do nothing for now, when pop up is in place, display
|
||||
break;
|
||||
}
|
||||
|
||||
// valid char, capture and convert to CHAR16
|
||||
pNickNameString[uiNickNameCharacterPosition] = ( CHAR16 )uiKey;
|
||||
|
||||
// null out next char position
|
||||
pNickNameString[uiNickNameCharacterPosition + 1] = 0;
|
||||
|
||||
// move cursor position ahead
|
||||
uiNickNameCursorPosition = 196 + LAPTOP_SCREEN_UL_X + StringPixLength( pNickNameString, FONT14ARIAL );
|
||||
|
||||
// increment string position
|
||||
uiNickNameCharacterPosition +=1;
|
||||
|
||||
// string has been altered, redisplay
|
||||
fNewCharInString = TRUE;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(uiFullNameCharacterPosition < 1 )
|
||||
{
|
||||
uiFullNameCharacterPosition = 0;
|
||||
}
|
||||
// make sure we haven't moved too far
|
||||
if( ( uiFullNameCursorPosition + StringPixLength( ( CHAR16 *)&(uiKey ), FONT14ARIAL ) ) > (UINT32)FULL_NAME_REGION_WIDTH + 196 + LAPTOP_SCREEN_UL_X)
|
||||
{
|
||||
// do nothing for now, when pop up is in place, display
|
||||
break;
|
||||
}
|
||||
// valid char, capture and convert to CHAR16
|
||||
pFullNameString[uiFullNameCharacterPosition] = ( CHAR16 )uiKey;
|
||||
|
||||
// null out next char position
|
||||
pFullNameString[uiFullNameCharacterPosition + 1] = 0;
|
||||
|
||||
// move cursor position ahead
|
||||
uiFullNameCursorPosition = 196 + LAPTOP_SCREEN_UL_X + StringPixLength( pFullNameString, FONT14ARIAL );
|
||||
|
||||
// increment string position
|
||||
uiFullNameCharacterPosition +=1;
|
||||
|
||||
// string has been altered, redisplay
|
||||
fNewCharInString = TRUE;
|
||||
}
|
||||
break;
|
||||
case ( NICK_NAME_MODE ):
|
||||
if( uiNickNameCharacterPosition >= MAX_NICK_NAME )
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(uiNickNameCharacterPosition == -1)
|
||||
{
|
||||
uiNickNameCharacterPosition = 0;
|
||||
}
|
||||
// make sure we haven't moved too far
|
||||
if( ( uiNickNameCursorPosition + StringPixLength( (CHAR16 *)&(uiKey ), FONT14ARIAL ) ) > (UINT32)NICK_NAME_REGION_WIDTH + 196 + LAPTOP_SCREEN_UL_X )
|
||||
{
|
||||
// do nothing for now, when pop up is in place, display
|
||||
break;
|
||||
}
|
||||
// valid char, capture and convert to CHAR16
|
||||
pNickNameString[uiNickNameCharacterPosition] = ( CHAR16 )uiKey;
|
||||
|
||||
// null out next char position
|
||||
pNickNameString[uiNickNameCharacterPosition + 1] = 0;
|
||||
|
||||
// move cursor position ahead
|
||||
uiNickNameCursorPosition = 196 + LAPTOP_SCREEN_UL_X + StringPixLength( pNickNameString, FONT14ARIAL );
|
||||
|
||||
// increment string position
|
||||
uiNickNameCharacterPosition +=1;
|
||||
|
||||
// string has been altered, redisplay
|
||||
fNewCharInString = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return;
|
||||
|
||||
+2
-2
@@ -660,7 +660,7 @@ UINT32 MPHostScreenInit( void )
|
||||
GetPrivateProfileStringW( L"Ja2_mp Settings",L"DAMAGE_MULTIPLIER", L"0.7", gzDmgMultiplierField, 5 , L"..\\Ja2_mp.ini" );
|
||||
GetPrivateProfileStringW( L"Ja2_mp Settings",L"TIMED_TURN_SECS_PER_TICK", L"25", gzTimerField, 5 , L"..\\Ja2_mp.ini" );
|
||||
GetPrivateProfileStringW( L"Ja2_mp Settings",L"FILE_TRANSFER_DIRECTORY", L"MULTIPLAYER/Servers/My Server", gzFileTransferDirectory, 100, L"..\\Ja2_mp.ini" );
|
||||
GetStringProperty( L"Ja2_mp Settings", L"KIT_BAG", L"[201,214,243]", kbag, 100, L"..\\Ja2_mp.ini" );
|
||||
GetPrivateProfileStringW( L"Ja2_mp Settings",L"KIT_BAG", L"[201,214,243]", gzKitBag, 100, L"..\\Ja2_mp.ini" );
|
||||
GetPrivateProfileStringW( L"Ja2_mp Settings",L"TIME", L"13.50", &szTime[0], 5 , L"..\\Ja2_mp.ini" );
|
||||
|
||||
giMPHOverrideMaxAI = GetPrivateProfileIntW( L"Ja2_mp Settings",L"OVERRIDE_MAX_AI", 0, L"..\\Ja2_mp.ini" );
|
||||
@@ -673,7 +673,7 @@ UINT32 MPHostScreenInit( void )
|
||||
giMPHUseNIV = GetPrivateProfileIntW( L"Ja2_mp Settings",L"ALLOW_CUSTOM_NIV", 0, L"..\\Ja2_mp.ini" );
|
||||
giMPHSendFiles = GetPrivateProfileIntW( L"Ja2_mp Settings",L"SYNC_CLIENTS_MP_DIR", 1, L"..\\Ja2_mp.ini" );
|
||||
guiMPHGameType = GetPrivateProfileIntW( L"Ja2_mp Settings",L"GAME_MODE", MP_TYPE_DEATHMATCH, L"..\\Ja2_mp.ini" );
|
||||
giMPHDifficultLevel = GetPrivateProfileIntW( L"Ja2_mp Settings",L"DIFFICULT_LEVEL", 2, L"..\\Ja2_mp.ini" );
|
||||
guiMPHDifficultLevel = GetPrivateProfileIntW( L"Ja2_mp Settings",L"DIFFICULT_LEVEL", 2, L"..\\Ja2_mp.ini" );
|
||||
#else
|
||||
// read settings from JA2_mp.ini
|
||||
CPropertyContainer props;
|
||||
|
||||
@@ -108,6 +108,7 @@
|
||||
#include "VFS/vfs_file_raii.h"
|
||||
#include "VFS/iteratedir.h"
|
||||
#include "VFS/File/vfs_file.h"
|
||||
#include "VFS/Tools/ParserTools.h"
|
||||
|
||||
#include "keys.h"
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "IniReader.h"
|
||||
#include "VFS/vfs.h"
|
||||
#include "VFS/Tools/ParserTools.h"
|
||||
#include "MPJoinScreen.h"
|
||||
|
||||
#include "game init.h"
|
||||
|
||||
@@ -1822,8 +1822,11 @@ BOOLEAN GetFileFirst( CHAR8 * pSpec, GETFILESTRUCT *pGFStruct )
|
||||
size = std::min<unsigned int>(size,260-1);
|
||||
sprintf( pGFStruct->zFileName, s.c_str());
|
||||
pGFStruct->zFileName[size] = 0;
|
||||
|
||||
pGFStruct->iFindHandle = 0;
|
||||
pGFStruct->uiFileSize = file_iter.value()->GetFileSize();
|
||||
pGFStruct->uiFileAttribs = ( file_iter.value()->IsWriteable() ? FILE_IS_NORMAL : FILE_IS_READONLY );
|
||||
|
||||
// don't care for the rest of variables in pGFStruct
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@@ -1878,7 +1881,10 @@ BOOLEAN GetFileNext( GETFILESTRUCT *pGFStruct )
|
||||
sprintf( pGFStruct->zFileName, s.c_str());
|
||||
pGFStruct->zFileName[size] = 0;
|
||||
|
||||
// don't care for the rest of variables in pGFStruct
|
||||
pGFStruct->iFindHandle = 0;
|
||||
pGFStruct->uiFileSize = file_iter.value()->GetFileSize();
|
||||
pGFStruct->uiFileAttribs = ( file_iter.value()->IsWriteable() ? FILE_IS_NORMAL : FILE_IS_READONLY );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
@@ -610,7 +610,7 @@ INT16 SubstringPixLength(STR16 string, UINT32 iStart, UINT32 iEnd, INT32 UseFont
|
||||
{
|
||||
Assert (string != NULL);
|
||||
Assert(iStart >= 0 && iStart <= iEnd);
|
||||
Assert(iEnd < wcslen(string));
|
||||
Assert(iEnd <= wcslen(string));
|
||||
|
||||
INT16 cnt = 0;
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
#include "vfs.h"
|
||||
#include "PropertyContainer.h"
|
||||
#include "VFS/vfs.h"
|
||||
#include "VFS/Tools/Log.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
//#define DEBUG_MEM_LEAKS // turns on tracking of every MemAlloc and MemFree!
|
||||
|
||||
+980
-873
File diff suppressed because it is too large
Load Diff
+231
-182
@@ -34,16 +34,18 @@
|
||||
#include "utilities.h"
|
||||
#endif
|
||||
|
||||
#include "input.h"
|
||||
#include "zmouse.h"
|
||||
#include "input.h"
|
||||
#include "zmouse.h"
|
||||
|
||||
#include "VFS/vfs.h"
|
||||
#include "VFS/vfs_init.h"
|
||||
#include "VFS/File/vfs_file.h"
|
||||
#include "VFS/Location/vfs_slf_library.h"
|
||||
#include "VFS/Tools/Log.h"
|
||||
#include "VFS/Tools/ParserTools.h"
|
||||
#include "Text.h"
|
||||
|
||||
#define USE_CONSOLE 1
|
||||
#define USE_CONSOLE 0
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -69,9 +71,11 @@
|
||||
static void MAGIC(std::string const& aarrrrgggh = "")
|
||||
{}
|
||||
|
||||
static bool s_VfsIsInitialized = false;
|
||||
static bool s_VfsIsInitialized = false;
|
||||
static std::list<vfs::Path> vfs_config_ini;
|
||||
|
||||
static bool s_DebugKeyboardInput = false;
|
||||
static vfs::Path s_CodePage;
|
||||
|
||||
void SHOWEXCEPTION(CBasicException& ex)
|
||||
{
|
||||
@@ -81,25 +85,25 @@ void SHOWEXCEPTION(CBasicException& ex)
|
||||
catch(CBasicException &ex2) {
|
||||
LogException(ex2);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern UINT32 MemDebugCounter;
|
||||
extern UINT32 MemDebugCounter;
|
||||
#ifdef JA2
|
||||
extern BOOLEAN gfPauseDueToPlayerGamePause;
|
||||
extern int iScreenMode;
|
||||
extern BOOL bScreenModeCmdLine;
|
||||
extern BOOLEAN gfPauseDueToPlayerGamePause;
|
||||
extern int iScreenMode;
|
||||
extern BOOL bScreenModeCmdLine;
|
||||
#endif
|
||||
|
||||
extern BOOLEAN CheckIfGameCdromIsInCDromDrive();
|
||||
extern void QueueEvent(UINT16 ubInputEvent, UINT32 usParam, UINT32 uiParam);
|
||||
extern BOOLEAN CheckIfGameCdromIsInCDromDrive();
|
||||
extern void QueueEvent(UINT16 ubInputEvent, UINT32 usParam, UINT32 uiParam);
|
||||
|
||||
// Prototype Declarations
|
||||
|
||||
INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LPARAM lParam);
|
||||
BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow);
|
||||
void ShutdownStandardGamingPlatform(void);
|
||||
void GetRuntimeSettings( );
|
||||
INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LPARAM lParam);
|
||||
BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow);
|
||||
void ShutdownStandardGamingPlatform(void);
|
||||
void GetRuntimeSettings( );
|
||||
|
||||
int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCommandLine, int sCommandShow);
|
||||
|
||||
@@ -108,18 +112,18 @@ Console g_Console("", "", "Lua Console", "no");
|
||||
#endif
|
||||
|
||||
#if !defined(JA2) && !defined(UTILS)
|
||||
void ProcessCommandLine(CHAR8 *pCommandLine);
|
||||
BOOLEAN RunSetup(void);
|
||||
void ProcessCommandLine(CHAR8 *pCommandLine);
|
||||
BOOLEAN RunSetup(void);
|
||||
|
||||
// Should the game immediately load the quick save at startup?
|
||||
BOOLEAN gfLoadAtStartup=FALSE;
|
||||
BOOLEAN gfUsingBoundsChecker=FALSE;
|
||||
CHAR8 *gzStringDataOverride=NULL;
|
||||
BOOLEAN gfCapturingVideo = FALSE;
|
||||
BOOLEAN gfLoadAtStartup=FALSE;
|
||||
BOOLEAN gfUsingBoundsChecker=FALSE;
|
||||
CHAR8 *gzStringDataOverride=NULL;
|
||||
BOOLEAN gfCapturingVideo = FALSE;
|
||||
|
||||
#endif
|
||||
|
||||
HINSTANCE ghInstance;
|
||||
HINSTANCE ghInstance;
|
||||
|
||||
|
||||
#ifdef JA2
|
||||
@@ -131,27 +135,27 @@ RECT rcWindow;
|
||||
POINT ptWindowSize;
|
||||
|
||||
// moved from header file: 24mar98:HJH
|
||||
UINT32 giStartMem;
|
||||
//UINT8 gbPixelDepth; // redefintion... look down a few lines (jonathanl)
|
||||
UINT32 giStartMem;
|
||||
//UINT8 gbPixelDepth; // redefintion... look down a few lines (jonathanl)
|
||||
// GLOBAL RUN-TIME SETTINGS
|
||||
|
||||
UINT32 guiMouseWheelMsg; // For mouse wheel messages
|
||||
UINT32 guiMouseWheelMsg; // For mouse wheel messages
|
||||
|
||||
BOOLEAN gfApplicationActive;
|
||||
BOOLEAN gfProgramIsRunning;
|
||||
BOOLEAN gfGameInitialized = FALSE;
|
||||
//UINT32 giStartMem; // redefintion... look up a few lines (jonathanl)
|
||||
BOOLEAN gfDontUseDDBlits = FALSE;
|
||||
BOOLEAN gfApplicationActive;
|
||||
BOOLEAN gfProgramIsRunning;
|
||||
BOOLEAN gfGameInitialized = FALSE;
|
||||
//UINT32 giStartMem; // redefintion... look up a few lines (jonathanl)
|
||||
BOOLEAN gfDontUseDDBlits = FALSE;
|
||||
|
||||
// There were TWO of them??!?! -- DB
|
||||
//CHAR8 gzCommandLine[ 100 ];
|
||||
CHAR8 gzCommandLine[100]; // Command line given
|
||||
//CHAR8 gzCommandLine[ 100 ];
|
||||
CHAR8 gzCommandLine[100]; // Command line given
|
||||
|
||||
CHAR8 gzErrorMsg[2048]="";
|
||||
BOOLEAN gfIgnoreMessages=FALSE;
|
||||
CHAR8 gzErrorMsg[2048]="";
|
||||
BOOLEAN gfIgnoreMessages=FALSE;
|
||||
|
||||
// GLOBAL VARIBLE, SET TO DEFAULT BUT CAN BE CHANGED BY THE GAME IF INIT FILE READ
|
||||
UINT8 gbPixelDepth = PIXEL_DEPTH;
|
||||
UINT8 gbPixelDepth = PIXEL_DEPTH;
|
||||
|
||||
INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
@@ -171,7 +175,7 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
|
||||
if ( Message == guiMouseWheelMsg )
|
||||
{
|
||||
QueueEvent(MOUSE_WHEEL, wParam, lParam);
|
||||
return( 0L );
|
||||
return( 0L );
|
||||
}
|
||||
|
||||
switch(Message)
|
||||
@@ -188,8 +192,8 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
|
||||
*/
|
||||
#ifdef JA2
|
||||
case WM_MOVE:
|
||||
// if( 1==iScreenMode )
|
||||
{
|
||||
// if( 1==iScreenMode )
|
||||
{
|
||||
GetClientRect(hWindow, &rcWindow);
|
||||
// Go ahead and clamp the client width and height
|
||||
rcWindow.right = SCREEN_WIDTH;
|
||||
@@ -214,7 +218,7 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
|
||||
SetWindowPos( hWindow, NULL, xPos, yPos, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_GETMINMAXINFO:
|
||||
{
|
||||
@@ -226,21 +230,21 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
|
||||
break;
|
||||
}
|
||||
#else
|
||||
case WM_MOUSEMOVE:
|
||||
break;
|
||||
case WM_MOUSEMOVE:
|
||||
break;
|
||||
|
||||
case WM_SIZING:
|
||||
case WM_SIZING:
|
||||
{
|
||||
LPRECT lpWindow;
|
||||
LPRECT lpWindow;
|
||||
INT32 iWidth, iHeight, iX, iY;
|
||||
BOOLEAN fWidthByHeight=FALSE, fHoldRight=FALSE;
|
||||
BOOLEAN fWidthByHeight=FALSE, fHoldRight=FALSE;
|
||||
|
||||
lpWindow = (LPRECT) lParam;
|
||||
lpWindow = (LPRECT) lParam;
|
||||
|
||||
iWidth=lpWindow->right-lpWindow->left;
|
||||
iHeight=lpWindow->bottom-lpWindow->top;
|
||||
iX = (lpWindow->left + lpWindow->right)/2;
|
||||
iY = (lpWindow->top + lpWindow->bottom)/2;
|
||||
iWidth = lpWindow->right-lpWindow->left;
|
||||
iHeight = lpWindow->bottom-lpWindow->top;
|
||||
iX = (lpWindow->left + lpWindow->right)/2;
|
||||
iY = (lpWindow->top + lpWindow->bottom)/2;
|
||||
|
||||
switch(wParam)
|
||||
{
|
||||
@@ -303,7 +307,6 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
|
||||
lpWindow->bottom = lpWindow->top + iHeight;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
switch(wParam)
|
||||
{
|
||||
@@ -311,7 +314,9 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
|
||||
case WMSZ_BOTTOMLEFT:
|
||||
case WMSZ_BOTTOMRIGHT:
|
||||
if(iHeight < SCREEN_HEIGHT)
|
||||
{
|
||||
lpWindow->bottom=lpWindow->top+SCREEN_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
switch(wParam)
|
||||
@@ -320,7 +325,9 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
|
||||
case WMSZ_TOPLEFT:
|
||||
case WMSZ_TOPRIGHT:
|
||||
if(iHeight < SCREEN_HEIGHT)
|
||||
{
|
||||
lpWindow->top=lpWindow->bottom-SCREEN_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
switch(wParam)
|
||||
@@ -329,7 +336,9 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
|
||||
case WMSZ_LEFT:
|
||||
case WMSZ_TOPLEFT:
|
||||
if(iWidth < SCREEN_WIDTH)
|
||||
{
|
||||
lpWindow->left=lpWindow->right-SCREEN_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
switch(wParam)
|
||||
@@ -338,7 +347,9 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
|
||||
case WMSZ_RIGHT:
|
||||
case WMSZ_TOPRIGHT:
|
||||
if(iWidth < SCREEN_WIDTH)
|
||||
{
|
||||
lpWindow->right=lpWindow->left+SCREEN_WIDTH;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -367,8 +378,8 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
|
||||
|
||||
case WM_MOVE:
|
||||
{
|
||||
INT32 xPos = (INT32)LOWORD(lParam); // horizontal position
|
||||
INT32 yPos = (INT32)HIWORD(lParam); // vertical position
|
||||
INT32 xPos = (INT32)LOWORD(lParam); // horizontal position
|
||||
INT32 yPos = (INT32)HIWORD(lParam); // vertical position
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
@@ -380,12 +391,11 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
|
||||
#ifdef LUACONSOLE
|
||||
PollConsole( );
|
||||
#endif
|
||||
|
||||
if (gfApplicationActive)
|
||||
{
|
||||
GameLoop();
|
||||
GameLoop();
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case WM_ACTIVATEAPP:
|
||||
switch(wParam)
|
||||
@@ -394,122 +404,132 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
|
||||
if (fRestore == TRUE)
|
||||
{
|
||||
#ifdef JA2
|
||||
RestoreVideoManager();
|
||||
RestoreVideoSurfaces(); // Restore any video surfaces
|
||||
|
||||
// unpause the JA2 Global clock
|
||||
if ( !gfPauseDueToPlayerGamePause )
|
||||
{
|
||||
PauseTime( FALSE );
|
||||
}
|
||||
#else
|
||||
if(!VideoInspectorIsEnabled())
|
||||
{
|
||||
RestoreVideoManager();
|
||||
RestoreVideoManager();
|
||||
RestoreVideoSurfaces(); // Restore any video surfaces
|
||||
}
|
||||
|
||||
MoveTimer(TIMER_RESUME);
|
||||
// unpause the JA2 Global clock
|
||||
if ( !gfPauseDueToPlayerGamePause )
|
||||
{
|
||||
PauseTime( FALSE );
|
||||
}
|
||||
#else
|
||||
if(!VideoInspectorIsEnabled())
|
||||
{
|
||||
RestoreVideoManager();
|
||||
RestoreVideoSurfaces(); // Restore any video surfaces
|
||||
}
|
||||
|
||||
MoveTimer(TIMER_RESUME);
|
||||
#endif
|
||||
gfApplicationActive = TRUE;
|
||||
gfApplicationActive = TRUE;
|
||||
}
|
||||
break;
|
||||
case FALSE: // We are suspending direct draw
|
||||
|
||||
if (iScreenMode == 0)
|
||||
{
|
||||
#ifdef JA2
|
||||
// pause the JA2 Global clock
|
||||
//PauseTime( TRUE );
|
||||
SuspendVideoManager();
|
||||
// pause the JA2 Global clock
|
||||
//PauseTime( TRUE );
|
||||
SuspendVideoManager();
|
||||
#else
|
||||
#ifndef UTIL
|
||||
if(!VideoInspectorIsEnabled())
|
||||
SuspendVideoManager();
|
||||
if(!VideoInspectorIsEnabled())
|
||||
{
|
||||
SuspendVideoManager();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
// suspend movement timer, to prevent timer crash if delay becomes long
|
||||
// * it doesn't matter whether the 3-D engine is actually running or not, or if it's even been initialized
|
||||
// * restore is automatic, no need to do anything on reactivation
|
||||
// suspend movement timer, to prevent timer crash if delay becomes long
|
||||
// * it doesn't matter whether the 3-D engine is actually running or not, or if it's even been initialized
|
||||
// * restore is automatic, no need to do anything on reactivation
|
||||
#if !defined( JA2 ) && !defined( UTIL )
|
||||
MoveTimer(TIMER_SUSPEND);
|
||||
MoveTimer(TIMER_SUSPEND);
|
||||
#endif
|
||||
|
||||
// gfApplicationActive = FALSE;
|
||||
fRestore = TRUE;
|
||||
// gfApplicationActive = FALSE;
|
||||
fRestore = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_CREATE:
|
||||
case WM_CREATE:
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
ShutdownStandardGamingPlatform();
|
||||
ShutdownStandardGamingPlatform();
|
||||
// ShowCursor(TRUE);
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
case WM_SETFOCUS:
|
||||
//if (iScreenMode == 0)
|
||||
{
|
||||
case WM_SETFOCUS:
|
||||
//if (iScreenMode == 0)
|
||||
{
|
||||
#if !defined( JA2 ) && !defined( UTIL )
|
||||
if(!VideoInspectorIsEnabled())
|
||||
{
|
||||
RestoreVideoManager();
|
||||
}
|
||||
gfApplicationActive=TRUE;
|
||||
// RestrictMouseToXYXY(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
#else
|
||||
RestoreCursorClipRect( );
|
||||
RestoreCursorClipRect( );
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_KILLFOCUS:
|
||||
if (iScreenMode == 0)
|
||||
{
|
||||
case WM_KILLFOCUS:
|
||||
if (iScreenMode == 0)
|
||||
{
|
||||
#if !defined( JA2 ) && !defined( UTIL )
|
||||
if(!VideoInspectorIsEnabled())
|
||||
{
|
||||
SuspendVideoManager();
|
||||
|
||||
}
|
||||
gfApplicationActive=FALSE;
|
||||
FreeMouseCursor();
|
||||
#endif
|
||||
// Set a flag to restore surfaces once a WM_ACTIVEATEAPP is received
|
||||
fRestore = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
#if defined( JA2 )
|
||||
case WM_DEVICECHANGE:
|
||||
{
|
||||
//DEV_BROADCAST_HDR *pHeader = (DEV_BROADCAST_HDR *)lParam;
|
||||
case WM_DEVICECHANGE:
|
||||
{
|
||||
//DEV_BROADCAST_HDR *pHeader = (DEV_BROADCAST_HDR *)lParam;
|
||||
|
||||
////if a device has been removed
|
||||
//if( wParam == DBT_DEVICEREMOVECOMPLETE )
|
||||
//{
|
||||
// //if its a disk
|
||||
// if( pHeader->dbch_devicetype == DBT_DEVTYP_VOLUME )
|
||||
// {
|
||||
// //check to see if the play cd is still in the cdrom
|
||||
// if( !CheckIfGameCdromIsInCDromDrive() )
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
break;
|
||||
////if a device has been removed
|
||||
//if( wParam == DBT_DEVICEREMOVECOMPLETE )
|
||||
//{
|
||||
// //if its a disk
|
||||
// if( pHeader->dbch_devicetype == DBT_DEVTYP_VOLUME )
|
||||
// {
|
||||
// //check to see if the play cd is still in the cdrom
|
||||
// if( !CheckIfGameCdromIsInCDromDrive() )
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case WM_SYSKEYUP:
|
||||
case WM_KEYUP:
|
||||
KeyUp(wParam, lParam);
|
||||
break;
|
||||
case WM_SYSKEYUP:
|
||||
case WM_KEYUP:
|
||||
KeyUp(wParam, lParam);
|
||||
break;
|
||||
|
||||
case WM_SYSKEYDOWN:
|
||||
case WM_KEYDOWN:
|
||||
KeyDown(wParam, lParam);
|
||||
case WM_SYSKEYDOWN:
|
||||
case WM_KEYDOWN:
|
||||
#ifdef USE_CODE_PAGE
|
||||
if(s_DebugKeyboardInput)
|
||||
{
|
||||
static CLog& debugKeys = *CLog::Create(L"DebugKeys.txt");
|
||||
static int input_counter = 1;
|
||||
debugKeys << (input_counter++) << " : " << (int)wParam << CLog::endl;
|
||||
}
|
||||
#endif // USE_CODE_PAGE
|
||||
KeyDown(wParam, lParam);
|
||||
gfSGPInputReceived = TRUE;
|
||||
break;
|
||||
|
||||
@@ -528,7 +548,6 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the pressed keys
|
||||
gfKeyState[ ALT ] = FALSE;
|
||||
gfKeyState[ CTRL ] = FALSE;
|
||||
@@ -551,8 +570,8 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
|
||||
cout << "> ";
|
||||
}
|
||||
break;
|
||||
default
|
||||
: return DefWindowProc(hWindow, Message, wParam, lParam);
|
||||
default :
|
||||
return DefWindowProc(hWindow, Message, wParam, lParam);
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
@@ -609,7 +628,8 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
FastDebugMsg("Initializing Memory Manager");
|
||||
// Initialize the Memory Manager
|
||||
if (InitializeMemoryManager() == FALSE)
|
||||
{ // We were unable to initialize the memory manager
|
||||
{
|
||||
// We were unable to initialize the memory manager
|
||||
FastDebugMsg("FAILED : Initializing Memory Manager");
|
||||
return FALSE;
|
||||
}
|
||||
@@ -618,7 +638,8 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
FastDebugMsg("Initializing Mutex Manager");
|
||||
// Initialize the Dirty Rectangle Manager
|
||||
if (InitializeMutexManager() == FALSE)
|
||||
{ // We were unable to initialize the game
|
||||
{
|
||||
// We were unable to initialize the game
|
||||
FastDebugMsg("FAILED : Initializing Mutex Manager");
|
||||
return FALSE;
|
||||
}
|
||||
@@ -627,7 +648,8 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
FastDebugMsg("Initializing File Manager");
|
||||
// Initialize the File Manager
|
||||
if (InitializeFileManager(NULL) == FALSE)
|
||||
{ // We were unable to initialize the file manager
|
||||
{
|
||||
// We were unable to initialize the file manager
|
||||
FastDebugMsg("FAILED : Initializing File Manager");
|
||||
return FALSE;
|
||||
}
|
||||
@@ -638,7 +660,8 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
FastDebugMsg("Initializing Input Manager");
|
||||
// Initialize the Input Manager
|
||||
if (InitializeInputManager() == FALSE)
|
||||
{ // We were unable to initialize the input manager
|
||||
{
|
||||
// We were unable to initialize the input manager
|
||||
FastDebugMsg("FAILED : Initializing Input Manager");
|
||||
return FALSE;
|
||||
}
|
||||
@@ -646,7 +669,8 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
FastDebugMsg("Initializing Video Manager");
|
||||
// Initialize DirectDraw (DirectX 2)
|
||||
if (InitializeVideoManager(hInstance, (UINT16) sCommandShow, (void *) WindowProcedure) == FALSE)
|
||||
{ // We were unable to initialize the video manager
|
||||
{
|
||||
// We were unable to initialize the video manager
|
||||
FastDebugMsg("FAILED : Initializing Video Manager");
|
||||
return FALSE;
|
||||
}
|
||||
@@ -654,7 +678,7 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
// Initialize Video Object Manager
|
||||
FastDebugMsg("Initializing Video Object Manager");
|
||||
if ( !InitializeVideoObjectManager( ) )
|
||||
{
|
||||
{
|
||||
FastDebugMsg("FAILED : Initializing Video Object Manager");
|
||||
return FALSE;
|
||||
}
|
||||
@@ -674,17 +698,9 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
STRING512 sExecutableDir;
|
||||
GetExecutableDirectory( sExecutableDir );
|
||||
|
||||
//vfs::Path fullpath = vfs::Path(sExecutableDir) + vfs::Path("vfs_config.ini");
|
||||
|
||||
// set current directory to exe's directory
|
||||
SetCurrentDirectory(sExecutableDir);
|
||||
|
||||
//if(!InitVirtualFileSystem( fullpath ))
|
||||
//{
|
||||
// FastDebugMsg("FAILED : Initializing Virtual File System");
|
||||
// return FALSE;
|
||||
//}
|
||||
//THROWIFFALSE( InitVirtualFileSystem( fullpath ), L"Initializing Virtual File System failed");
|
||||
THROWIFFALSE( InitVirtualFileSystem( vfs_config_ini ), L"Initializing Virtual File System failed");
|
||||
|
||||
s_VfsIsInitialized = true;
|
||||
@@ -693,6 +709,25 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
GetVFS()->GetVirtualLocation(vfs::Path("ShadeTables"),true)->SetIsExclusive(true);
|
||||
GetVFS()->GetVirtualLocation(vfs::Path(pMessageStrings[MSG_SAVEDIRECTORY]+3),true)->SetIsExclusive(true);
|
||||
GetVFS()->GetVirtualLocation(vfs::Path(pMessageStrings[MSG_MPSAVEDIRECTORY]+3),true)->SetIsExclusive(true);
|
||||
|
||||
#ifdef USE_CODE_PAGE
|
||||
charSet::InitializeCharSets();
|
||||
|
||||
if(!s_CodePage.empty())
|
||||
{
|
||||
try
|
||||
{
|
||||
CodePageReader cpr;
|
||||
cpr.ReadCodePage(s_CodePage);
|
||||
}
|
||||
catch(CBasicException& ex)
|
||||
{
|
||||
std::wstringstream wss;
|
||||
wss << L"Could not process codepage file \"" << s_CodePage() << L"\"";
|
||||
RETHROWEXCEPTION(wss.str().c_str(), &ex);
|
||||
}
|
||||
}
|
||||
#endif // USE_CODE_PAGE
|
||||
#else
|
||||
// Snap: moved the following from InitJA2SplashScreen for clarity
|
||||
STRING512 CurrentDir;
|
||||
@@ -719,13 +754,14 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
// Snap: Get the custom Data directory location from ja2.ini (if any)
|
||||
// and initialize the custom catalogue
|
||||
char customDataPath[MAX_PATH];
|
||||
if ( GetPrivateProfileString( "Ja2 Settings","CUSTOM_DATA_LOCATION", "", customDataPath, MAX_PATH, "..\\Ja2.ini" ) ) {
|
||||
if ( GetPrivateProfileString( "Ja2 Settings","CUSTOM_DATA_LOCATION", "", customDataPath, MAX_PATH, "..\\Ja2.ini" ) )
|
||||
{
|
||||
gCustomDataCat.NewCat(std::string(CurrentDir) + '\\' + customDataPath);
|
||||
}
|
||||
#endif
|
||||
//#ifdef JA2
|
||||
InitJA2SplashScreen();
|
||||
//#endif
|
||||
//#ifdef JA2
|
||||
InitJA2SplashScreen();
|
||||
//#endif
|
||||
|
||||
// Make sure we start up our local clock (in milliseconds)
|
||||
// We don't need to check for a return value here since so far its always TRUE
|
||||
@@ -742,7 +778,7 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
FastDebugMsg("Initializing the Font Manager");
|
||||
// Init the manager and copy the TransTable stuff into it.
|
||||
if ( !InitializeFontManager( 8, pFontTable ) )
|
||||
{
|
||||
{
|
||||
FastDebugMsg("FAILED : Initializing Font Manager");
|
||||
return FALSE;
|
||||
}
|
||||
@@ -753,10 +789,11 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
// Initialize the Sound Manager (DirectSound)
|
||||
#ifndef UTIL
|
||||
if (InitializeSoundManager() == FALSE)
|
||||
{ // We were unable to initialize the sound manager
|
||||
{
|
||||
// We were unable to initialize the sound manager
|
||||
FastDebugMsg("FAILED : Initializing Sound Manager");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
FastDebugMsg("Initializing Random");
|
||||
@@ -766,7 +803,8 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
FastDebugMsg("Initializing Game Manager");
|
||||
// Initialize the Game
|
||||
if (InitializeGame() == FALSE)
|
||||
{ // We were unable to initialize the game
|
||||
{
|
||||
// We were unable to initialize the game
|
||||
FastDebugMsg("FAILED : Initializing Game Manager");
|
||||
return FALSE;
|
||||
}
|
||||
@@ -779,7 +817,7 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
if(!exlist.empty())
|
||||
{
|
||||
RETHROWEXCEPTION(L"Error during reading runtime settings", &exlist.front());
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -812,7 +850,7 @@ void ShutdownStandardGamingPlatform(void)
|
||||
|
||||
if (gfGameInitialized)
|
||||
{
|
||||
ShutdownGame();
|
||||
ShutdownGame();
|
||||
}
|
||||
|
||||
|
||||
@@ -925,19 +963,19 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
|
||||
//_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF);
|
||||
|
||||
/****************************************************************************************************/
|
||||
/* */
|
||||
/* DEBUG MEMORY ALLOCATION ON THE HEAP : uncomment when required */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* */
|
||||
/* _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_EVERY_1024_DF); */
|
||||
/* */
|
||||
/****************************************************************************************************/
|
||||
/* */
|
||||
/* DEBUG MEMORY ALLOCATION ON THE HEAP : uncomment when required */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* */
|
||||
/*.._CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_EVERY_1024_DF); */
|
||||
/* */
|
||||
/****************************************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
ghInstance = hInstance;
|
||||
|
||||
// Copy commandline!
|
||||
// Copy commandline!
|
||||
#ifdef JA2
|
||||
strncpy( gzCommandLine, pCommandLine, 100);
|
||||
gzCommandLine[99]='\0';
|
||||
@@ -961,8 +999,9 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
|
||||
#else
|
||||
|
||||
if(!RunSetup())
|
||||
{
|
||||
return(0);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
// ShowCursor(FALSE);
|
||||
@@ -1002,7 +1041,7 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
|
||||
FastDebugMsg("Initializing the Font Manager");
|
||||
// Init the manager and copy the TransTable stuff into it.
|
||||
if ( !InitializeFontManager( 8, pFontTable ) )
|
||||
{
|
||||
{
|
||||
FastDebugMsg("FAILED : Initializing Font Manager");
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1044,7 +1083,7 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
|
||||
#ifdef LUACONSOLE
|
||||
if (1==iScreenMode)
|
||||
{
|
||||
CreateConsole();
|
||||
CreateConsole();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1107,21 +1146,24 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
|
||||
|
||||
#if 0
|
||||
else
|
||||
{ // Windows hasn't processed any messages, therefore we handle the rest
|
||||
{
|
||||
// Windows hasn't processed any messages, therefore we handle the rest
|
||||
#ifdef LUACONSOLE
|
||||
PollConsole( );
|
||||
#endif
|
||||
|
||||
if (gfApplicationActive == FALSE)
|
||||
{ // Well we got nothing to do but to wait for a message to activate
|
||||
WaitMessage();
|
||||
}
|
||||
{
|
||||
// Well we got nothing to do but to wait for a message to activate
|
||||
WaitMessage();
|
||||
}
|
||||
else
|
||||
{ // Well, the game is active, so we handle the game stuff
|
||||
GameLoop();
|
||||
{
|
||||
// Well, the game is active, so we handle the game stuff
|
||||
GameLoop();
|
||||
|
||||
// After this frame, reset input given flag
|
||||
gfSGPInputReceived = FALSE;
|
||||
// After this frame, reset input given flag
|
||||
gfSGPInputReceived = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1158,7 +1200,7 @@ void SGPExit(void)
|
||||
#if !defined( JA2 ) && !defined( UTIL )
|
||||
if (gfGameInitialized)
|
||||
{
|
||||
// ARM: if in DEBUG mode & we've ShutdownWithErrorBox, don't unload screens and release data structs to permit easier debugging
|
||||
// ARM: if in DEBUG mode & we've ShutdownWithErrorBox, don't unload screens and release data structs to permit easier debugging
|
||||
#ifdef _DEBUG
|
||||
if (gfIgnoreMessages)
|
||||
{
|
||||
@@ -1289,6 +1331,11 @@ void GetRuntimeSettings( )
|
||||
|
||||
// WANNE: Should we play the intro?
|
||||
iPlayIntro = oProps.GetIntProperty("Ja2 Settings","PLAY_INTRO", iPlayIntro);
|
||||
|
||||
#ifdef USE_CODE_PAGE
|
||||
s_DebugKeyboardInput = oProps.GetBoolProperty(L"Ja2 Settings", L"DEBUG_KEYS", false);
|
||||
s_CodePage = oProps.GetStringProperty(L"Ja2 Settings", L"CODE_PAGE");
|
||||
#endif // USE_CODE_PAGE
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1305,19 +1352,20 @@ void ShutdownWithErrorBox(CHAR8 *pcMessage)
|
||||
|
||||
void ProcessCommandLine(CHAR8 *pCommandLine)
|
||||
{
|
||||
CHAR8 cSeparators[]="\t =";
|
||||
CHAR8 *pCopy=NULL, *pToken;
|
||||
CHAR8 cSeparators[] = "\t =";
|
||||
CHAR8 *pCopy=NULL, *pToken;
|
||||
|
||||
pCopy=(CHAR8 *)MemAlloc(strlen(pCommandLine) + 1);
|
||||
pCopy = (CHAR8 *)MemAlloc(strlen(pCommandLine) + 1);
|
||||
|
||||
Assert(pCopy);
|
||||
if(!pCopy)
|
||||
{
|
||||
return;
|
||||
|
||||
}
|
||||
memcpy(pCopy, pCommandLine, strlen(pCommandLine)+1);
|
||||
|
||||
pToken=strtok(pCopy, cSeparators);
|
||||
while(pToken)
|
||||
while(pToken)
|
||||
{
|
||||
if(!_strnicmp(pToken, "/NOSOUND", 8))
|
||||
{
|
||||
@@ -1368,8 +1416,9 @@ CHAR8 *pCopy=NULL, *pToken;
|
||||
BOOLEAN RunSetup(void)
|
||||
{
|
||||
if(!FileExists(VideoGetConfigFile()))
|
||||
{
|
||||
_spawnl(_P_WAIT, "3DSetup.EXE", "3DSetup.EXE", VideoGetConfigFile(), NULL);
|
||||
|
||||
}
|
||||
return(FileExists(VideoGetConfigFile()));
|
||||
}
|
||||
|
||||
@@ -1391,7 +1440,7 @@ void ProcessJa2CommandLineBeforeInitialization(CHAR8 *pCommandLine)
|
||||
memcpy(pCopy, pCommandLine, strlen(pCommandLine)+1);
|
||||
|
||||
pToken=strtok(pCopy, cSeparators);
|
||||
while(pToken)
|
||||
while(pToken)
|
||||
{
|
||||
//if its the NO SOUND option
|
||||
if(!_strnicmp(pToken, "/NOSOUND", 8))
|
||||
@@ -1403,20 +1452,20 @@ void ProcessJa2CommandLineBeforeInitialization(CHAR8 *pCommandLine)
|
||||
{
|
||||
//overwrite Graphic setting from JA2_settings.ini
|
||||
iScreenMode=0; /* 1 for Windowed, 0 for Fullscreen */
|
||||
bScreenModeCmdLine = TRUE; /* if set TRUE, INI is no longer evaluated */
|
||||
/* no resolution read from Args. Still from INI, but could be added here, too...*/
|
||||
bScreenModeCmdLine = TRUE; /* if set TRUE, INI is no longer evaluated */
|
||||
/* no resolution read from Args. Still from INI, but could be added here, too...*/
|
||||
}
|
||||
else if(!_strnicmp(pToken, "/WINDOW", 7))
|
||||
{
|
||||
//overwrite Graphic setting from JA2_settings.ini
|
||||
iScreenMode=1; /* 1 for Windowed, 0 for Fullscreen */
|
||||
bScreenModeCmdLine = TRUE; /* if set TRUE, INI is no longer evaluated */
|
||||
/* no resolution read from Args. Still from INI, but could be added here, too...*/
|
||||
bScreenModeCmdLine = TRUE; /* if set TRUE, INI is no longer evaluated */
|
||||
/* no resolution read from Args. Still from INI, but could be added here, too...*/
|
||||
}
|
||||
|
||||
//get the next token
|
||||
//get the next token
|
||||
pToken=strtok(NULL, cSeparators);
|
||||
}
|
||||
|
||||
MemFree(pCopy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1801,8 +1801,8 @@ UINT32 uiCount;
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
#include "vfs.h"
|
||||
#include "PropertyContainer.h"
|
||||
#include "VFS/vfs.h"
|
||||
#include "VFS/Tools/Log.h"
|
||||
|
||||
// Lesh modifications
|
||||
// Sound debug
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#endif
|
||||
|
||||
#include "resource.h"
|
||||
#include "VFS/vfs.h"
|
||||
#include "VFS/vfs_file_raii.h"
|
||||
|
||||
#ifndef _MT
|
||||
#define _MT
|
||||
@@ -1907,7 +1909,9 @@ void RefreshScreen(void *DummyVariable)
|
||||
LPDIRECTDRAWSURFACE _pTmpBuffer;
|
||||
LPDIRECTDRAWSURFACE2 pTmpBuffer;
|
||||
DDSURFACEDESC SurfaceDescription;
|
||||
#ifndef USE_VFS
|
||||
FILE *OutputFile;
|
||||
#endif
|
||||
CHAR8 FileName[64];
|
||||
INT32 iIndex;
|
||||
STRING512 DataDir;
|
||||
@@ -1915,10 +1919,11 @@ void RefreshScreen(void *DummyVariable)
|
||||
UINT16 *p16BPPData;
|
||||
|
||||
// Snap: save current directory
|
||||
#ifndef USE_VFS
|
||||
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
|
||||
@@ -1968,12 +1973,24 @@ 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};
|
||||
vfs::UInt32 io;
|
||||
wfile.file().Write(head,18,io);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Lock temp surface
|
||||
@@ -2010,11 +2027,19 @@ void RefreshScreen(void *DummyVariable)
|
||||
ConvertRGBDistribution565To555( p16BPPData, SCREEN_WIDTH );
|
||||
|
||||
// Write
|
||||
#ifndef USE_VFS
|
||||
fwrite( p16BPPData, SCREEN_WIDTH * 2, 1, OutputFile);
|
||||
#else
|
||||
wfile.file().Write((vfs::Byte*)p16BPPData, SCREEN_WIDTH * 2, io);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef USE_VFS
|
||||
fwrite((void *)(((UINT8 *)SurfaceDescription.lpSurface) + (iIndex * SCREEN_WIDTH * 2)), SCREEN_WIDTH * 2, 1, OutputFile);
|
||||
#else
|
||||
wfile.file().Write((vfs::Byte*)(((UINT8 *)SurfaceDescription.lpSurface) + (iIndex * SCREEN_WIDTH * 2)), SCREEN_WIDTH * 2, io);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2023,9 +2048,9 @@ void RefreshScreen(void *DummyVariable)
|
||||
{
|
||||
MemFree( p16BPPData );
|
||||
}
|
||||
|
||||
#ifndef USE_VFS
|
||||
fclose(OutputFile);
|
||||
|
||||
#endif
|
||||
//
|
||||
// Unlock temp surface
|
||||
//
|
||||
@@ -2038,6 +2063,10 @@ void RefreshScreen(void *DummyVariable)
|
||||
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
|
||||
}
|
||||
}
|
||||
catch(CBasicException& ex)
|
||||
{
|
||||
RETHROWEXCEPTION(L"",&ex);
|
||||
}
|
||||
|
||||
//
|
||||
// Release temp surface
|
||||
@@ -2045,11 +2074,12 @@ 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
|
||||
}
|
||||
|
||||
//
|
||||
@@ -3306,58 +3336,81 @@ 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
|
||||
vfs::UInt32 io;
|
||||
wfile.file().Write((vfs::Byte*)&Header, sizeof(TARGA_HEADER), io);
|
||||
#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
|
||||
wfile.file().Write( (vfs::Byte*)( pDest + ( iCountY * SCREEN_WIDTH ) + iCountX ), sizeof(UINT16), io);
|
||||
#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(CBasicException& ex)
|
||||
{
|
||||
LogException(ex);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -4562,8 +4562,8 @@ void HourlyCheckStrategicAI()
|
||||
|
||||
|
||||
#ifdef JA2BETAVERSION
|
||||
#include "vfs.h"
|
||||
#include "PropertyContainer.h"
|
||||
#include "VFS/vfs.h"
|
||||
#include "VFS/Tools/Log.h"
|
||||
|
||||
static CLog& s_stratD = *CLog::Create(L"Strategic Decisions.txt", true);
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include "stdio.h"
|
||||
#endif
|
||||
|
||||
#include "vfs.h"
|
||||
#include "PropertyContainer.h"
|
||||
#include "VFS/vfs.h"
|
||||
#include "VFS/Tools/Log.h"
|
||||
|
||||
#ifdef _ANIMSUBSYSTEM_DEBUG
|
||||
|
||||
|
||||
@@ -406,7 +406,7 @@ BOOLEAN GetMLGFilename( SGPFILENAME filename, UINT16 usMLGGraphicID )
|
||||
break;
|
||||
case MLG_MP_GOLDPIECEBUTTONS:
|
||||
sprintf( filename, "%s\\MPGOLDPIECEBUTTONS_%s.sti", zLanguage, zLanguage );
|
||||
break;
|
||||
break
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+24
-2
@@ -21,6 +21,8 @@
|
||||
#include "Sound Control.h"
|
||||
#endif
|
||||
|
||||
#include "VFS/Tools/ParserTools.h"
|
||||
|
||||
STR16 szClipboard;
|
||||
BOOLEAN gfNoScroll = FALSE;
|
||||
|
||||
@@ -943,7 +945,11 @@ BOOLEAN HandleTextInput( InputAtom *Event )
|
||||
UINT32 key = Event->usParam;
|
||||
UINT16 type = gpActive->usInputType;
|
||||
//Handle space key
|
||||
#ifndef USE_CODE_PAGE
|
||||
if( key == SPACE && type & INPUTTYPE_SPACES )
|
||||
#else
|
||||
if( charSet::IsFromSet(key, charSet::CS_SPACE) && type & INPUTTYPE_SPACES )
|
||||
#endif
|
||||
{
|
||||
AddChar( key );
|
||||
return TRUE;
|
||||
@@ -955,7 +961,11 @@ BOOLEAN HandleTextInput( InputAtom *Event )
|
||||
return TRUE;
|
||||
}
|
||||
//Handle numerics
|
||||
#ifndef USE_CODE_PAGE
|
||||
if( key >= '0' && key <= '9' && type & INPUTTYPE_NUMERICSTRICT )
|
||||
#else
|
||||
if( charSet::IsFromSet(key, charSet::CS_NUMERIC) && type & INPUTTYPE_NUMERICSTRICT )
|
||||
#endif
|
||||
{
|
||||
AddChar( key );
|
||||
return TRUE;
|
||||
@@ -963,17 +973,25 @@ BOOLEAN HandleTextInput( InputAtom *Event )
|
||||
//Handle alphas
|
||||
if( type & INPUTTYPE_ALPHA )
|
||||
{
|
||||
#ifndef USE_CODE_PAGE
|
||||
if( key >= 'A' && key <= 'Z' )
|
||||
#else
|
||||
if( charSet::IsFromSet(key, charSet::CS_ALPHA_UC) )
|
||||
#endif
|
||||
{
|
||||
if( type & INPUTTYPE_LOWERCASE )
|
||||
key -= 32;
|
||||
key -= 32; // won't work for non-ascii alpha characters
|
||||
AddChar( key );
|
||||
return TRUE;
|
||||
}
|
||||
#ifndef USE_CODE_PAGE
|
||||
if( key >= 'a' && key <= 'z' )
|
||||
#else
|
||||
if( charSet::IsFromSet(key, charSet::CS_ALPHA_LC) )
|
||||
#endif
|
||||
{
|
||||
if( type & INPUTTYPE_UPPERCASE )
|
||||
key += 32;
|
||||
key += 32; // won't work for non-ascii alpha characters
|
||||
AddChar( key );
|
||||
return TRUE;
|
||||
}
|
||||
@@ -982,10 +1000,14 @@ BOOLEAN HandleTextInput( InputAtom *Event )
|
||||
if( type & INPUTTYPE_SPECIAL )
|
||||
{
|
||||
//More can be added, but not all of the fonts support these
|
||||
#ifndef USE_CODE_PAGE
|
||||
if( key >= 0x21 && key <= 0x2f || // ! " # $ % & ' ( ) * + , - . /
|
||||
key >= 0x3a && key <= 0x40 || // : ; < = > ? @
|
||||
key >= 0x5b && key <= 0x5f || // [ \ ] ^ _
|
||||
key >= 0x7b && key <= 0x7d ) // { | }
|
||||
#else
|
||||
if( charSet::IsFromSet(key, charSet::CS_SPECIAL_ALPHA|charSet::CS_SPECIAL_NON_CHAR) )
|
||||
#endif
|
||||
{
|
||||
AddChar( key );
|
||||
return TRUE;
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@
|
||||
#endif
|
||||
|
||||
#include "VFS/vfs.h"
|
||||
#include "PropertyContainer.h"
|
||||
#include "VFS/Tools/Log.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
+3
-533
@@ -6,211 +6,12 @@
|
||||
#include "vfs_file_raii.h"
|
||||
#include "iteratedir.h"
|
||||
|
||||
#include "Tools/Tools.h"
|
||||
#include "Tools/ParserTools.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
static const vfs::UInt32 BUFFER_SIZE = 1024;
|
||||
|
||||
class CReadLine
|
||||
{
|
||||
public:
|
||||
CReadLine(vfs::tReadableFile& rFile) : _file(rFile), _buffer_pos(0), _eof(false)
|
||||
{
|
||||
memset(_buffer,0,sizeof(_buffer));
|
||||
FillBuffer();
|
||||
vfs::UByte utf8bom[3] = {0xef,0xbb,0xbf};
|
||||
if(memcmp(utf8bom, &_buffer[0],3) == 0)
|
||||
{
|
||||
_buffer_pos += 3;
|
||||
}
|
||||
};
|
||||
bool FillBuffer()
|
||||
{
|
||||
if(!_eof)
|
||||
{
|
||||
// reading can be done byte-wise or line-wise.
|
||||
// we have no control over this here, so we have to account for both cases.
|
||||
|
||||
vfs::UInt32 read = 0;
|
||||
// fill the buffer from the start, BUFFER_SIZE charactes at max (_buffer has BUFFER_SIZE+1 elements)
|
||||
_eof = !_file.Read(&_buffer[0],BUFFER_SIZE,read);
|
||||
// if read() fails, it means that we are at the end of the file,
|
||||
// but we probably have read a couple of valid bytes, so we need to do one last 'correct' run
|
||||
|
||||
// bite-wise read files usually terminate a line with \n (or \r\n on WIN32)
|
||||
// line-wise read files just returns 0-terminated string
|
||||
|
||||
// always terminate the string with 0
|
||||
_buffer[read] = 0;
|
||||
|
||||
_buffer_pos = 0;
|
||||
_buffer_last = read;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool FromBuffer(std::string& line)
|
||||
{
|
||||
bool done = false;
|
||||
while(!done)
|
||||
{
|
||||
if(_buffer_pos < _buffer_last)
|
||||
{
|
||||
// start where we left last time
|
||||
vfs::Byte *temp = &_buffer[_buffer_pos];
|
||||
vfs::UInt32 start_pos = _buffer_pos;
|
||||
// go until we hit 0. since our buffer is always 0 terminated, the second test should be redundant.
|
||||
while(*temp && (_buffer_pos < _buffer_last))
|
||||
{
|
||||
// stop when we find a line terminator
|
||||
if(*temp == '\n' || *temp == '\r' /* || *temp == '\0' */)
|
||||
{
|
||||
break;
|
||||
}
|
||||
temp++;
|
||||
_buffer_pos++;
|
||||
}
|
||||
// need to append substring, as we might have refilles the buffer (because there was no \n or \r\n terminator)
|
||||
line.append( (char*)&_buffer[start_pos], _buffer_pos - start_pos );
|
||||
|
||||
// if we reach the (real) end of the buffer (that always terminate with 0), this means
|
||||
// that there was no line terminator and that we have to refill the buffer.
|
||||
if( _buffer_pos < BUFFER_SIZE && (*temp == '\n' || *temp == '\r' || *temp == 0) )
|
||||
{
|
||||
// found the line terminator
|
||||
if(*temp == '\r')
|
||||
{
|
||||
// the \r is most probably followed by \n. 'swallow' both characters
|
||||
*temp++;
|
||||
_buffer_pos++;
|
||||
if( (_buffer_pos < BUFFER_SIZE) && (*temp == '\n' || *temp == 0) )
|
||||
{
|
||||
// increase buffer position, so that we can start with a valid character in the next run
|
||||
_buffer_pos++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
done = !FillBuffer();
|
||||
}
|
||||
}
|
||||
else if(*temp == '\n' || *temp == 0)
|
||||
{
|
||||
// increase buffer position, so that we can start with a valid character in the next run
|
||||
_buffer_pos++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
done = !FillBuffer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
done = !FillBuffer();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool GetLine(std::string& line)
|
||||
{
|
||||
line.clear();
|
||||
return FromBuffer(line);
|
||||
}
|
||||
private:
|
||||
vfs::Byte _buffer[BUFFER_SIZE+1];
|
||||
vfs::tReadableFile& _file;
|
||||
vfs::UInt32 _buffer_pos;
|
||||
vfs::UInt32 _buffer_last;
|
||||
bool _eof;
|
||||
};
|
||||
|
||||
template<typename T_>
|
||||
bool ConvertTo(utf8string const& sStr, T_ &rVal)
|
||||
{
|
||||
std::wstringstream ss;
|
||||
ss.str(sStr.c_wcs());
|
||||
if(!(ss >> rVal))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T_>
|
||||
utf8string ToStringList(std::list<T_> const& rValList)
|
||||
{
|
||||
std::wstringstream ss;
|
||||
typename std::list<T_>::const_iterator cit = rValList.begin();
|
||||
if(cit != rValList.end())
|
||||
{
|
||||
ss << *cit;
|
||||
cit++;
|
||||
for(;cit != rValList.end(); ++cit)
|
||||
{
|
||||
ss << L" , " << *cit;
|
||||
}
|
||||
}
|
||||
if(!ss)
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
template<>
|
||||
utf8string ToStringList<utf8string>(std::list<utf8string> const& rValList)
|
||||
{
|
||||
std::wstringstream ss;
|
||||
std::list<utf8string>::const_iterator cit = rValList.begin();
|
||||
if(cit != rValList.end())
|
||||
{
|
||||
ss << (*cit);
|
||||
cit++;
|
||||
for(;cit != rValList.end(); ++cit)
|
||||
{
|
||||
ss << L" , " << (*cit);
|
||||
}
|
||||
}
|
||||
if(!ss)
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
class CSplitStringList
|
||||
{
|
||||
public:
|
||||
CSplitStringList(utf8string const& sList)
|
||||
: m_sList(sList), iCurrent(0),iNext(0)
|
||||
{};
|
||||
~CSplitStringList() {};
|
||||
|
||||
bool NextListEntry(utf8string &sEntry)
|
||||
{
|
||||
if(iNext >= 0)
|
||||
{
|
||||
iNext = m_sList.c_wcs().find_first_of(L",",iCurrent+1);
|
||||
if(iNext > iCurrent)
|
||||
{
|
||||
sEntry.r_wcs().assign(vfs::TrimString(m_sList,iCurrent,iNext-1).c_wcs());
|
||||
iCurrent = iNext+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// last or only entry
|
||||
sEntry.r_wcs().assign(vfs::TrimString(m_sList,iCurrent,m_sList.length()).c_wcs());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
const utf8string m_sList;
|
||||
int iCurrent,iNext;
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************************/
|
||||
/*************************************************************************************/
|
||||
@@ -962,334 +763,3 @@ void CPropertyContainer::SetBoolListProperty(utf8string const& sSection, utf8str
|
||||
/**************************************************************************************************/
|
||||
/**************************************************************************************************/
|
||||
|
||||
bool CTransferRules::InitFromTxtFile(vfs::Path const& sPath)
|
||||
{
|
||||
// try to open via VirtualFileSystem
|
||||
if(GetVFS()->FileExists(sPath))
|
||||
{
|
||||
return InitFromTxtFile(GetVFS()->GetRFile(sPath));
|
||||
}
|
||||
else
|
||||
{
|
||||
// file doesn't exist or VFS not initialized yet
|
||||
vfs::IBaseFile* pFile = new vfs::CTextFile(sPath);
|
||||
if(pFile)
|
||||
{
|
||||
bool success = InitFromTxtFile(vfs::tReadableFile::Cast(pFile));
|
||||
delete pFile;
|
||||
return success;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CTransferRules::InitFromTxtFile(vfs::tReadableFile* pFile)
|
||||
{
|
||||
if(pFile && pFile->OpenRead())
|
||||
{
|
||||
vfs::COpenReadFile rfile(pFile);
|
||||
std::string sBuffer;
|
||||
vfs::UInt32 line_counter = 0;
|
||||
CReadLine rl(*pFile);
|
||||
while(rl.GetLine(sBuffer))
|
||||
{
|
||||
line_counter++;
|
||||
// very simple parsing : key = value
|
||||
if(!sBuffer.empty())
|
||||
{
|
||||
// remove leading white spaces
|
||||
int iStart = sBuffer.find_first_not_of(" \t",0);
|
||||
char first = sBuffer.at(iStart);
|
||||
switch(first)
|
||||
{
|
||||
case '!':
|
||||
case ';':
|
||||
case '#':
|
||||
// comment -> do nothing
|
||||
break;
|
||||
default:
|
||||
int iEnd = sBuffer.find_first_of(" \t", iStart);
|
||||
if(iEnd != std::string::npos)
|
||||
{
|
||||
SRule rule;
|
||||
std::string action = sBuffer.substr(iStart, iEnd - iStart);
|
||||
if( StrCmp::Equal(action, "deny") )
|
||||
{
|
||||
rule.action = CTransferRules::DENY;
|
||||
}
|
||||
else if( StrCmp::Equal(action, "accept") )
|
||||
{
|
||||
rule.action = CTransferRules::ACCEPT;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring trybuffer = L"Invalid UTF-8 character in string";
|
||||
IGNOREEXCEPTION( trybuffer = utf8string(sBuffer).c_wcs() ); /* just make sure we don't break off when string conversion fails */
|
||||
std::wstringstream wss;
|
||||
wss << L"Unknown action in file \"" << pFile->GetFullPath()().c_wcs()
|
||||
<< L", line " << line_counter << " : " << utf8string(sBuffer).c_wcs();
|
||||
THROWEXCEPTION(wss.str().c_str());
|
||||
}
|
||||
try
|
||||
{
|
||||
rule.pattern = vfs::Path(vfs::TrimString(sBuffer, iEnd, sBuffer.length()));
|
||||
}
|
||||
catch(CBasicException& ex)
|
||||
{
|
||||
std::wstringstream wss;
|
||||
wss << L"Could not convert string, invalid utf8 encoding in file \"" << pFile->GetFullPath()().c_wcs()
|
||||
<< L"\", line " << line_counter;
|
||||
RETHROWEXCEPTION(wss.str().c_str(),&ex);
|
||||
}
|
||||
m_listRules.push_back(rule);
|
||||
}
|
||||
break;
|
||||
}; // end switch
|
||||
} // end if (empty)
|
||||
} // end while(!eof)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CTransferRules::SetDefaultAction(CTransferRules::EAction act)
|
||||
{
|
||||
m_eDefaultAction = act;
|
||||
}
|
||||
|
||||
CTransferRules::EAction CTransferRules::GetDefaultAction()
|
||||
{
|
||||
return m_eDefaultAction;
|
||||
}
|
||||
|
||||
CTransferRules::EAction CTransferRules::ApplyRule(utf8string const& sStr)
|
||||
{
|
||||
tPatternList::iterator sit = m_listRules.begin();
|
||||
for(; sit != m_listRules.end(); ++sit)
|
||||
{
|
||||
if(MatchPattern(sit->pattern(), sStr))
|
||||
{
|
||||
return sit->action;
|
||||
}
|
||||
}
|
||||
return m_eDefaultAction;
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
/********************************************************************/
|
||||
#ifdef WIN32
|
||||
const char CLog::endl[] = "\r\n";
|
||||
#else
|
||||
const char CLog::endl[] = "\n";
|
||||
#endif
|
||||
|
||||
std::list<CLog*>& CLog::_logs()
|
||||
{
|
||||
static std::list<CLog*> logs;
|
||||
return logs;
|
||||
}
|
||||
|
||||
CLog* CLog::Create(vfs::Path fileName, bool append, EFlushMode flushMode)
|
||||
{
|
||||
_logs().push_back(new CLog(fileName, append, flushMode));
|
||||
return _logs().back();
|
||||
}
|
||||
void CLog::FlushFinally()
|
||||
{
|
||||
std::list<CLog*>::iterator it = _logs().begin();
|
||||
for(; it != _logs().end(); ++it)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
_logs().clear();
|
||||
}
|
||||
|
||||
void CLog::FlushAll()
|
||||
{
|
||||
std::list<CLog*>::iterator it = _logs().begin();
|
||||
for(; it != _logs().end(); ++it)
|
||||
{
|
||||
(*it)->Flush();
|
||||
(*it)->_file = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CLog::CLog(vfs::Path fileName, bool append, EFlushMode flushMode)
|
||||
: _filename(fileName), _file(NULL), _own_file(false),
|
||||
_first_write(true), _flush_mode(flushMode), _append(append),
|
||||
_buffer_size(0), _buffer_test_size(512)
|
||||
{};
|
||||
|
||||
CLog::~CLog()
|
||||
{
|
||||
_test_flush(true);
|
||||
if(_file && _own_file)
|
||||
{
|
||||
delete _file;
|
||||
}
|
||||
}
|
||||
|
||||
CLog& CLog::operator<<(unsigned int const& t)
|
||||
{
|
||||
return PushNumber(t);
|
||||
}
|
||||
CLog& CLog::operator<<(unsigned short const& t)
|
||||
{
|
||||
return PushNumber(t);
|
||||
}
|
||||
CLog& CLog::operator<<(unsigned char const& t)
|
||||
{
|
||||
return PushNumber(t);
|
||||
}
|
||||
CLog& CLog::operator<<(int const& t)
|
||||
{
|
||||
return PushNumber(t);
|
||||
}
|
||||
CLog& CLog::operator<<(short const& t)
|
||||
{
|
||||
return PushNumber(t);
|
||||
}
|
||||
CLog& CLog::operator<<(char const& t)
|
||||
{
|
||||
return PushNumber(t);
|
||||
}
|
||||
CLog& CLog::operator<<(float const& t)
|
||||
{
|
||||
return PushNumber(t);
|
||||
}
|
||||
CLog& CLog::operator<<(double const& t)
|
||||
{
|
||||
return PushNumber(t);
|
||||
}
|
||||
|
||||
CLog& CLog::operator<<(const char* t)
|
||||
{
|
||||
_buffer << t;
|
||||
_buffer_size += strlen(t);
|
||||
_test_flush();
|
||||
return *this;
|
||||
}
|
||||
CLog& CLog::operator<<(const wchar_t* t)
|
||||
{
|
||||
std::string s = utf8string::as_utf8(t);
|
||||
_buffer << s;
|
||||
_buffer_size += s.length();
|
||||
_test_flush();
|
||||
return *this;
|
||||
}
|
||||
CLog& CLog::operator<<(std::string const& t)
|
||||
{
|
||||
_buffer << t;
|
||||
_buffer_size += t.length();
|
||||
_test_flush();
|
||||
return *this;
|
||||
}
|
||||
CLog& CLog::operator<<(std::wstring const& t)
|
||||
{
|
||||
std::string s = utf8string::as_utf8(t);
|
||||
_buffer << s;
|
||||
_buffer_size += s.length();
|
||||
_test_flush();
|
||||
return *this;
|
||||
}
|
||||
CLog& CLog::operator<<(utf8string const& t)
|
||||
{
|
||||
std::string s = t.utf8();
|
||||
_buffer << s;
|
||||
_buffer_size += s.length();
|
||||
_test_flush();
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLog& CLog::Endl()
|
||||
{
|
||||
_buffer << CLog::endl;
|
||||
_buffer_size += sizeof(CLog::endl)-1;
|
||||
_test_flush();
|
||||
return *this;
|
||||
}
|
||||
|
||||
void CLog::SetAppend(bool append)
|
||||
{
|
||||
_append = append;
|
||||
}
|
||||
|
||||
void CLog::SetBufferSize(vfs::UInt32 bufferSize)
|
||||
{
|
||||
_buffer_test_size = bufferSize;
|
||||
}
|
||||
|
||||
void CLog::_test_flush(bool force)
|
||||
{
|
||||
if( (_flush_mode == FLUSH_IMMEDIATELY) ||
|
||||
(_flush_mode == FLUSH_BUFFER && _buffer_size > _buffer_test_size) ||
|
||||
(/*_flush_mode == FLUSH_ON_DELETE &&*/ force == true) )
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
}
|
||||
|
||||
#include <ctime>
|
||||
void CLog::Flush()
|
||||
{
|
||||
vfs::UInt32 buflen = _buffer.str().length();
|
||||
if(buflen == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!_file)
|
||||
{
|
||||
try
|
||||
{
|
||||
vfs::COpenWriteFile file_raii(_filename,true,!_append);
|
||||
_file = &file_raii.file();
|
||||
file_raii.release();
|
||||
}
|
||||
catch(CBasicException& ex)
|
||||
{
|
||||
LogException(ex);
|
||||
// write file anyway
|
||||
_file = vfs::tWriteableFile::Cast(new vfs::CFile(_filename));
|
||||
_file->OpenWrite(true,!_append);
|
||||
_own_file = true;
|
||||
}
|
||||
}
|
||||
|
||||
vfs::COpenWriteFile wfile(_file);
|
||||
if(_append)
|
||||
{
|
||||
wfile.file().SetWriteLocation(0,vfs::IBaseFile::SD_END);
|
||||
}
|
||||
|
||||
vfs::UInt32 io;
|
||||
if(_first_write)
|
||||
{
|
||||
time_t rawtime;
|
||||
time ( &rawtime );
|
||||
std::string datetime(ctime(&rawtime));
|
||||
std::string s_out;
|
||||
|
||||
vfs::UInt32 wloc = wfile.file().GetWriteLocation();
|
||||
if(wloc > 0)
|
||||
{
|
||||
s_out = CLog::endl;
|
||||
}
|
||||
s_out += " *** ";
|
||||
s_out += datetime.substr(0,datetime.length()-1);
|
||||
s_out += " *** ";
|
||||
s_out += CLog::endl;
|
||||
s_out += CLog::endl;
|
||||
wfile.file().Write(s_out.c_str(), s_out.length(), io);
|
||||
_first_write = false;
|
||||
}
|
||||
|
||||
wfile.file().Write(_buffer.str().c_str(), buflen, io);
|
||||
_buffer.str("");
|
||||
_buffer.clear();
|
||||
_buffer_size = 0;
|
||||
|
||||
_append = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -104,115 +104,4 @@ private:
|
||||
tSections m_mapProps;
|
||||
};
|
||||
|
||||
/*************************************************************/
|
||||
/*************************************************************/
|
||||
|
||||
class CTransferRules
|
||||
{
|
||||
public:
|
||||
enum EAction
|
||||
{
|
||||
DENY,
|
||||
ACCEPT,
|
||||
};
|
||||
public:
|
||||
CTransferRules() : m_eDefaultAction(ACCEPT) {};
|
||||
|
||||
bool InitFromTxtFile(vfs::Path const& sPath);
|
||||
bool InitFromTxtFile(vfs::tReadableFile* pFile);
|
||||
|
||||
void SetDefaultAction(EAction act);
|
||||
EAction GetDefaultAction();
|
||||
|
||||
EAction ApplyRule(utf8string const& sStr);
|
||||
private:
|
||||
struct SRule
|
||||
{
|
||||
EAction action;
|
||||
vfs::Path pattern;
|
||||
};
|
||||
typedef std::list<SRule> tPatternList;
|
||||
tPatternList m_listRules;
|
||||
EAction m_eDefaultAction;
|
||||
};
|
||||
|
||||
/*************************************************************/
|
||||
/*************************************************************/
|
||||
|
||||
template<typename CharType, typename ValueType>
|
||||
std::basic_string<CharType> ToString(ValueType const& rVal)
|
||||
{
|
||||
std::basic_stringstream<CharType> tss;
|
||||
if( !(tss << rVal))
|
||||
{
|
||||
return std::basic_string<CharType>();
|
||||
}
|
||||
return tss.str();
|
||||
}
|
||||
|
||||
class CMemoryFile;
|
||||
class CLog
|
||||
{
|
||||
public:
|
||||
enum EFlushMode
|
||||
{
|
||||
FLUSH_ON_DELETE,
|
||||
FLUSH_BUFFER,
|
||||
FLUSH_IMMEDIATELY,
|
||||
};
|
||||
public:
|
||||
|
||||
CLog(vfs::Path fileName, bool append = false, EFlushMode flushMode = FLUSH_ON_DELETE);
|
||||
~CLog();
|
||||
|
||||
static CLog* Create(vfs::Path fileName, bool append = false, EFlushMode flushMode = FLUSH_ON_DELETE);
|
||||
static void FlushAll();
|
||||
static void FlushFinally();
|
||||
|
||||
CLog& operator<<(unsigned int const& t);
|
||||
CLog& operator<<(unsigned short const& t);
|
||||
CLog& operator<<(unsigned char const& t);
|
||||
CLog& operator<<(int const& t);
|
||||
CLog& operator<<(short const& t);
|
||||
CLog& operator<<(char const& t);
|
||||
CLog& operator<<(float const& t);
|
||||
CLog& operator<<(double const& t);
|
||||
|
||||
CLog& operator<<(const char* t);
|
||||
CLog& operator<<(const wchar_t* t);
|
||||
CLog& operator<<(std::string const& t);
|
||||
CLog& operator<<(std::wstring const& t);
|
||||
CLog& operator<<(utf8string const& t);
|
||||
|
||||
CLog& Endl();
|
||||
static const char endl[];
|
||||
|
||||
void SetAppend(bool append = true);
|
||||
void SetBufferSize(vfs::UInt32 bufferSize);
|
||||
|
||||
void Flush();
|
||||
private:
|
||||
void _test_flush(bool force=false);
|
||||
|
||||
template<typename T_>
|
||||
CLog& PushNumber(T_ const& t)
|
||||
{
|
||||
_buffer << ToString<char>(t);
|
||||
_buffer_size += sizeof(T_);
|
||||
_test_flush();
|
||||
return *this;
|
||||
}
|
||||
private:
|
||||
vfs::Path _filename;
|
||||
vfs::tWriteableFile* _file;
|
||||
bool _own_file;
|
||||
bool _first_write;
|
||||
EFlushMode _flush_mode;
|
||||
bool _append;
|
||||
vfs::UInt32 _buffer_size, _buffer_test_size;
|
||||
std::stringstream _buffer;
|
||||
private:
|
||||
static std::list<CLog*>& _logs();
|
||||
};
|
||||
|
||||
#endif // _PROPERTY_CONTAINER_H_
|
||||
|
||||
@@ -405,6 +405,34 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Tools"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Tools\Log.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Tools\Log.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Tools\ParserTools.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Tools\ParserTools.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Tools\Tools.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Tools\Tools.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\iteratedir.cpp"
|
||||
>
|
||||
|
||||
@@ -406,6 +406,34 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Tools"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Tools\Log.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Tools\Log.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Tools\ParserTools.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Tools\ParserTools.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Tools\Tools.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Tools\Tools.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\iteratedir.cpp"
|
||||
>
|
||||
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
#include "vfs_debug.h"
|
||||
|
||||
#include "utf8string.h"
|
||||
#include "PropertyContainer.h"
|
||||
#include "vfs_file_raii.h"
|
||||
#include "FILE/vfs_file.h"
|
||||
|
||||
#include "Tools/Log.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <ctime>
|
||||
|
||||
|
||||
+3
-1
@@ -1,6 +1,5 @@
|
||||
#include "vfs_init.h"
|
||||
#include "vfs.h"
|
||||
#include "PropertyContainer.h"
|
||||
#include "File/vfs_file.h"
|
||||
#include "File/vfs_memory_file.h"
|
||||
#include "Location/vfs_directory_tree.h"
|
||||
@@ -8,6 +7,9 @@
|
||||
#include "Location/vfs_7z_library.h"
|
||||
#include "Location/vfs_create_7z_library.h"
|
||||
|
||||
#include "PropertyContainer.h"
|
||||
#include "Tools/Log.h"
|
||||
|
||||
/********************************************************************/
|
||||
/********************************************************************/
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
#include "Location/vfs_lib_dir.h"
|
||||
#include "Location/vfs_directory_tree.h"
|
||||
|
||||
#include "PropertyContainer.h"
|
||||
#include "Tools/Log.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="MapEditor|Win32"
|
||||
OutputDirectory="\Games\Jagged Alliance 2"
|
||||
OutputDirectory="\games\jagged alliance 2"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets=".\ja2_2005Express.vsprops;.\ja2_2005ExpressEditor.vsprops"
|
||||
@@ -229,7 +229,7 @@
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Winmm.lib .\Multiplayer\raknet\RakNetLibStatic.lib ws2_32.lib"
|
||||
OutputFile="$(OutDir)\MapEditor_2634_EN_Release.exe"
|
||||
OutputFile="$(OutDir)\MapEditor_EN_Release_2993.exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
GenerateMapFile="true"
|
||||
@@ -267,7 +267,7 @@
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="MapEditorD|Win32"
|
||||
OutputDirectory="\Games\Jagged Alliance 2"
|
||||
OutputDirectory="\games\jagged alliance 2"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets=".\ja2_2005Express.vsprops;.\ja2_2005ExpressEditor.vsprops"
|
||||
@@ -316,7 +316,7 @@
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Winmm.lib .\Multiplayer\raknet\RakNetLibStaticDebug.lib ws2_32.lib"
|
||||
OutputFile="$(OutDir)\MapEditor_2634_EN_Debug.exe"
|
||||
OutputFile="$(OutDir)\MapEditor_EN_Debug_2993.exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="\games\jagged alliance 2"
|
||||
OutputDirectory="C:\games\jagged alliance 2 EN"
|
||||
IntermediateDirectory="build\VS2008\$(ProjectName)_$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets=".\ja2_VS2008.vsprops;.\ja2_VS2008Debug.vsprops;.\ja2_VS2008Linker.vsprops;.\ja2_VS2008Libs.vsprops"
|
||||
@@ -62,7 +62,7 @@
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Winmm.lib RakNetLibStatic.lib ws2_32.lib"
|
||||
OutputFile="$(OutDir)\JA2_EN_Debug_2963.exe"
|
||||
OutputFile="$(OutDir)\JA2_MP_EN_Debug_VS2008.exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="Multiplayer\raknet"
|
||||
IgnoreDefaultLibraryNames="libc"
|
||||
@@ -141,7 +141,7 @@
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Winmm.lib RakNetLibStatic.lib ws2_32.lib"
|
||||
OutputFile="$(OutDir)\JA2_EN_2963.exe"
|
||||
OutputFile="$(OutDir)\JA2_MP_EN_v1.1.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="Multiplayer\raknet"
|
||||
GenerateDebugInformation="false"
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
#endif
|
||||
|
||||
#include "VFS/vfs.h"
|
||||
#include "VFS/Tools/Log.h"
|
||||
|
||||
#define _UNICODE
|
||||
// Networking Stuff
|
||||
|
||||
Reference in New Issue
Block a user