mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user