*** Merged Code from Multiplayer Branch Revision 2960 ***

- Virtual File System (VFS) by birdflu. This is needed for Multiplayer and is also used for Single Player. Very neat system :-)
- Multiplayer Version 1.1 + some additional features and bugfixes
* INFO: If you compile a new EXE and want to test, be sure to also use the latest SVN GameDir files in your JA2 install directory *




git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2961 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2009-06-04 21:01:45 +00:00
parent 17f44f63e8
commit 47db604b50
301 changed files with 76701 additions and 1843 deletions
+43 -15
View File
@@ -12,7 +12,7 @@
#include "Fileman.h"
#endif
#include "VFS/vfs.h"
#define SHADE_TABLE_DIR "ShadeTables"
@@ -28,8 +28,10 @@ BOOLEAN gfForceBuildShadeTables = FALSE;
void DetermineRGBDistributionSettings()
{
#ifndef USE_VFS
STRING512 DataDir;
STRING512 ExecDir;
#endif
STRING512 ShadeTableDir;
UINT32 uiRBitMask, uiGBitMask, uiBBitMask;
UINT32 uiPrevRBitMask, uiPrevGBitMask, uiPrevBBitMask;
@@ -39,6 +41,7 @@ void DetermineRGBDistributionSettings()
BOOLEAN fCleanShadeTable = FALSE;
BOOLEAN fLoadedPrevRGBDist = FALSE;
#ifndef USE_VFS
// Snap: save current directory
GetFileManCurrentDirectory( DataDir );
@@ -48,7 +51,6 @@ void DetermineRGBDistributionSettings()
GetExecutableDirectory( ExecDir );
sprintf( ShadeTableDir, "%s\\%s", DataDir, SHADE_TABLE_DIR );
//Check to make sure we have a ShadeTable directory. If we don't create one!
if( !SetFileManCurrentDirectory( ShadeTableDir ) )
{
@@ -62,10 +64,22 @@ void DetermineRGBDistributionSettings()
}
fSaveRGBDist = TRUE;
}
// directory existed or was created.
SetFileManCurrentDirectory( DataDir );
#else
// changing the current directory can screw up the VFS; don't do it
// the creation of the SHADE_TABLE_DIR directory is done by the VFS
sprintf( ShadeTableDir, "%s", SHADE_TABLE_DIR );
#endif
CHAR8 sRGBDist[50];
sprintf( sRGBDist, "%s\\%s", SHADE_TABLE_DIR, "RGBDist.dat");
CHAR8 sResetShadeTables[50];
sprintf( sResetShadeTables, "%s\\%s", SHADE_TABLE_DIR, "ResetShadeTables.txt");
if( !fSaveRGBDist )
{ //Load the previous RGBDist and determine if it is the same one
if( !FileExists( "RGBDist.dat" ) || FileExists( "ResetShadeTables.txt" ) )
if( !FileExists( sRGBDist ) || FileExists( sResetShadeTables ) )
{ //Can't find the RGBDist.dat file. The directory exists, but the file doesn't, which
//means the user deleted the file manually. Now, set it up to create a new one.
fSaveRGBDist = TRUE;
@@ -73,7 +87,7 @@ void DetermineRGBDistributionSettings()
}
else
{
hfile = FileOpen( "RGBDist.dat", FILE_ACCESS_READ, FALSE );
hfile = FileOpen( sRGBDist, FILE_ACCESS_READ, FALSE );
if( !hfile )
{
AssertMsg( 0, "Couldn't open RGBDist.dat, even though it exists!" );
@@ -111,7 +125,7 @@ void DetermineRGBDistributionSettings()
{ //The RGB distribution is going to be saved in a tiny file for future reference. As long as the
//RGB distribution never changes, the shade table will grow until eventually, all tilesets are loaded,
//shadetables generated and saved in this directory.
hfile = FileOpen( "RGBDist.dat", FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE );
hfile = FileOpen( sRGBDist, FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE );
if( !hfile )
{
AssertMsg( 0, "Couldn't create RGBDist.dat for writing!" );
@@ -123,7 +137,10 @@ void DetermineRGBDistributionSettings()
}
// Snap: Restore the data directory once we are finished.
SetFileManCurrentDirectory( DataDir );
// BF : current directory was reset above
//SetFileManCurrentDirectory( DataDir );
//We're done, so restore the executable directory to JA2\Data.
//sprintf( DataDir, "%s\\Data", ExecDir );
//SetFileManCurrentDirectory( DataDir );
@@ -140,7 +157,11 @@ BOOLEAN LoadShadeTable( HVOBJECT pObj, UINT32 uiTileTypeIndex )
//We are assuming that the uiTileTypeIndex is referring to the correct file
//stored in the TileSurfaceFilenames[]. If it isn't, then that is a huge problem
//and should be fixed. Also assumes that the directory is set to Data\ShadeTables.
strcpy( ShadeFileName, TileSurfaceFilenames[ uiTileTypeIndex ] );
//BF
//strcpy( ShadeFileName, TileSurfaceFilenames[ uiTileTypeIndex ] );
sprintf( ShadeFileName, "%s\\%s", SHADE_TABLE_DIR, TileSurfaceFilenames[ uiTileTypeIndex ] );
ptr = strstr( ShadeFileName, "." );
if( !ptr )
{
@@ -149,12 +170,15 @@ BOOLEAN LoadShadeTable( HVOBJECT pObj, UINT32 uiTileTypeIndex )
ptr++;
sprintf( ptr, "sha" );
hfile = FileOpen( ShadeFileName, FILE_ACCESS_READ, FALSE );
if( !hfile )
{ //File doesn't exist, so generate it
FileClose( hfile );
//hfile = FileOpen( ShadeFileName, FILE_ACCESS_READ, FALSE );
//if( !hfile )
//{ //File doesn't exist, so generate it
// FileClose( hfile );
if(!FileExists(ShadeFileName))
{
return FALSE;
}
hfile = FileOpen( ShadeFileName, FILE_ACCESS_READ, FALSE );
//MISSING: Compare time stamps.
@@ -180,14 +204,18 @@ BOOLEAN SaveShadeTable( HVOBJECT pObj, UINT32 uiTileTypeIndex )
UINT32 uiNumBytesWritten;
CHAR8 ShadeFileName[ 100 ];
CHAR8 *ptr;
#ifdef JA2TESTVERSION
uiNumTablesSaved++;
#endif
#ifdef JA2TESTVERSION
uiNumTablesSaved++;
#endif
//ASSUMPTIONS:
//We are assuming that the uiTileTypeIndex is referring to the correct file
//stored in the TileSurfaceFilenames[]. If it isn't, then that is a huge problem
//and should be fixed. Also assumes that the directory is set to Data\ShadeTables.
strcpy( ShadeFileName, TileSurfaceFilenames[ uiTileTypeIndex ] );
// BF
//strcpy( ShadeFileName, TileSurfaceFilenames[ uiTileTypeIndex ] );
sprintf_s( ShadeFileName, "%s\\%s", SHADE_TABLE_DIR, TileSurfaceFilenames[ uiTileTypeIndex ] );
ptr = strstr( ShadeFileName, "." );
if( !ptr )
{