mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
- Merged Source Code from MP branch Revision 2972
enable intro videos in VFS mode workaround for original intro hack allow to get real path of a file (only CVFSFile) streamline Allocator usage in VFile small non-VFS mode fixes in MPHostScreen.cpp Synced "Cutting Fences" in a multiplayer game git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2973 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -32,6 +32,8 @@
|
|||||||
#include "MessageBoxScreen.h"
|
#include "MessageBoxScreen.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "VFS/vfs.h"
|
||||||
|
|
||||||
extern STR16 gzIntroScreen[];
|
extern STR16 gzIntroScreen[];
|
||||||
extern HVSURFACE ghFrameBuffer;
|
extern HVSURFACE ghFrameBuffer;
|
||||||
|
|
||||||
@@ -198,13 +200,14 @@ BOOLEAN EnterIntroScreen()
|
|||||||
// return( TRUE );
|
// return( TRUE );
|
||||||
// }
|
// }
|
||||||
//#endif
|
//#endif
|
||||||
|
#ifndef USE_VFS
|
||||||
//if the library doesnt exist, exit
|
//if the library doesnt exist, exit
|
||||||
if( !IsLibraryOpened( LIBRARY_INTRO ) )
|
if( !IsLibraryOpened( LIBRARY_INTRO ) )
|
||||||
{
|
{
|
||||||
PrepareToExitIntroScreen();
|
PrepareToExitIntroScreen();
|
||||||
return( TRUE );
|
return( TRUE );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//initialize smacker
|
//initialize smacker
|
||||||
SmkInitialize( ghWindow, SCREEN_WIDTH, SCREEN_HEIGHT);
|
SmkInitialize( ghWindow, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||||
|
|||||||
+13
-10
@@ -3023,30 +3023,33 @@ void send_changestate (EV_S_CHANGESTATE * SChangeState)
|
|||||||
|
|
||||||
void recieveSTATE(RPCParameters *rpcParameters)
|
void recieveSTATE(RPCParameters *rpcParameters)
|
||||||
{
|
{
|
||||||
|
|
||||||
EV_S_CHANGESTATE* new_state = (EV_S_CHANGESTATE*)rpcParameters->input;
|
EV_S_CHANGESTATE* new_state = (EV_S_CHANGESTATE*)rpcParameters->input;
|
||||||
|
|
||||||
|
|
||||||
//ScreenMsg( FONT_YELLOW, MSG_MPSYSTEM, L"recieved state");
|
|
||||||
|
|
||||||
|
|
||||||
SOLDIERTYPE * pSoldier=MercPtrs[ new_state->usSoldierID ];
|
SOLDIERTYPE * pSoldier=MercPtrs[ new_state->usSoldierID ];
|
||||||
|
|
||||||
if(pSoldier->bActive)
|
if(pSoldier->bActive)
|
||||||
{
|
{
|
||||||
if(new_state->usNewState==93)
|
// Start first AID
|
||||||
|
if(new_state->usNewState==START_AID)
|
||||||
{
|
{
|
||||||
pSoldier->EVENT_InternalSetSoldierPosition( new_state->sXPos, new_state->sYPos ,FALSE, FALSE, FALSE );
|
pSoldier->EVENT_InternalSetSoldierPosition( new_state->sXPos, new_state->sYPos ,FALSE, FALSE, FALSE );
|
||||||
pSoldier->ChangeSoldierStance( ANIM_CROUCH );
|
pSoldier->ChangeSoldierStance( ANIM_CROUCH );
|
||||||
pSoldier->EVENT_SetSoldierDirection( new_state->usNewDirection );
|
pSoldier->EVENT_SetSoldierDirection( new_state->usNewDirection );
|
||||||
|
|
||||||
}
|
}
|
||||||
//if(new_state->usNewState==95)ScreenMsg( FONT_YELLOW, MSG_MPSYSTEM, L"All Bandaged.");
|
// Start cutting fence
|
||||||
|
else if (new_state->usNewState==CUTTING_FENCE)
|
||||||
|
{
|
||||||
|
// The usTargetGridNo holds the GridNo of the fence tile
|
||||||
|
pSoldier->sTargetGridNo = new_state->usTargetGridNo;
|
||||||
|
|
||||||
|
pSoldier->EVENT_InternalSetSoldierPosition( new_state->sXPos, new_state->sYPos ,FALSE, FALSE, FALSE );
|
||||||
|
pSoldier->ChangeSoldierStance( ANIM_CROUCH );
|
||||||
|
pSoldier->EVENT_SetSoldierDirection( new_state->usNewDirection );
|
||||||
|
}
|
||||||
|
|
||||||
pSoldier->EVENT_InitNewSoldierAnim( new_state->usNewState, new_state->usStartingAniCode, new_state->fForce );
|
pSoldier->EVENT_InitNewSoldierAnim( new_state->usNewState, new_state->usStartingAniCode, new_state->fForce );
|
||||||
}
|
}
|
||||||
//AddGameEvent( S_CHANGESTATE, 0, &SChangeState );
|
|
||||||
//someday ;)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_death( SOLDIERTYPE *pSoldier )
|
void send_death( SOLDIERTYPE *pSoldier )
|
||||||
|
|||||||
@@ -2522,6 +2522,7 @@ BOOLEAN SOLDIERTYPE::ChangeSoldierState( UINT16 usNewState, UINT16 usStartingAni
|
|||||||
SChangeState.sYPos = this->sY;
|
SChangeState.sYPos = this->sY;
|
||||||
SChangeState.fForce = fForce;
|
SChangeState.fForce = fForce;
|
||||||
SChangeState.usNewDirection = this->ubDirection;
|
SChangeState.usNewDirection = this->ubDirection;
|
||||||
|
SChangeState.usTargetGridNo = this->sTargetGridNo;
|
||||||
|
|
||||||
|
|
||||||
//AddGameEvent( S_CHANGESTATE, 0, &SChangeState );
|
//AddGameEvent( S_CHANGESTATE, 0, &SChangeState );
|
||||||
@@ -10694,8 +10695,10 @@ void SOLDIERTYPE::EVENT_SoldierBeginFirstAid( INT16 sGridNo, UINT8 ubDirection )
|
|||||||
//else
|
//else
|
||||||
{
|
{
|
||||||
// CHANGE TO ANIMATION
|
// CHANGE TO ANIMATION
|
||||||
if(!is_networked)this->EVENT_InitNewSoldierAnim( START_AID, 0 , FALSE );
|
if(!is_networked)
|
||||||
else this->ChangeSoldierState( START_AID, 0, 0 );
|
this->EVENT_InitNewSoldierAnim( START_AID, 0 , FALSE );
|
||||||
|
else
|
||||||
|
this->ChangeSoldierState( START_AID, 0, 0 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12350,7 +12353,10 @@ void SOLDIERTYPE::EVENT_SoldierBeginCutFence( INT16 sGridNo, UINT8 ubDirection )
|
|||||||
this->sTargetGridNo = sGridNo;
|
this->sTargetGridNo = sGridNo;
|
||||||
|
|
||||||
// CHANGE TO ANIMATION
|
// CHANGE TO ANIMATION
|
||||||
this->EVENT_InitNewSoldierAnim( CUTTING_FENCE, 0 , FALSE );
|
if (!is_networked)
|
||||||
|
this->EVENT_InitNewSoldierAnim( CUTTING_FENCE, 0 , FALSE );
|
||||||
|
else
|
||||||
|
this->ChangeSoldierState( CUTTING_FENCE, 0, 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+50
-1
@@ -30,6 +30,8 @@
|
|||||||
#include "DirectDraw Calls.h"
|
#include "DirectDraw Calls.h"
|
||||||
#include "Cinematics.h"
|
#include "Cinematics.h"
|
||||||
#include "soundman.h"
|
#include "soundman.h"
|
||||||
|
#include "VFS/vfs.h"
|
||||||
|
#include "VFS/vfs_file_raii.h"
|
||||||
|
|
||||||
#ifdef JA2
|
#ifdef JA2
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
@@ -200,6 +202,7 @@ SMKFLIC *SmkOpenFlic(CHAR8 *cFilename)
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef USE_VFS
|
||||||
// Attempt opening the filename
|
// Attempt opening the filename
|
||||||
if(!(pSmack->hFileHandle=FileOpen(cFilename, FILE_OPEN_EXISTING | FILE_ACCESS_READ, FALSE)))
|
if(!(pSmack->hFileHandle=FileOpen(cFilename, FILE_OPEN_EXISTING | FILE_ACCESS_READ, FALSE)))
|
||||||
{
|
{
|
||||||
@@ -209,6 +212,36 @@ SMKFLIC *SmkOpenFlic(CHAR8 *cFilename)
|
|||||||
|
|
||||||
//Get the real file handle for the file man handle for the smacker file
|
//Get the real file handle for the file man handle for the smacker file
|
||||||
hFile = GetRealFileHandleFromFileManFileHandle( pSmack->hFileHandle );
|
hFile = GetRealFileHandleFromFileManFileHandle( pSmack->hFileHandle );
|
||||||
|
#else
|
||||||
|
vfs::Path introname(cFilename);
|
||||||
|
vfs::Path dir,filename;
|
||||||
|
introname.SplitLast(dir,filename);
|
||||||
|
vfs::Path tempfile = vfs::Path(L"Temp") + filename;
|
||||||
|
if(!GetVFS()->FileExists(tempfile))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(!GetVFS()->FileExists(introname))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
vfs::COpenReadFile rfile(introname);
|
||||||
|
vfs::UInt32 size = rfile.file().GetFileSize();
|
||||||
|
std::vector<vfs::Byte> data(size);
|
||||||
|
vfs::UInt32 io;
|
||||||
|
rfile.file().Read(&data[0],size,io);
|
||||||
|
|
||||||
|
vfs::COpenWriteFile wfile(tempfile,true);
|
||||||
|
wfile.file().Write(&data[0],size,io);
|
||||||
|
}
|
||||||
|
catch(CBasicException& ex)
|
||||||
|
{
|
||||||
|
std::wstringstream wss;
|
||||||
|
wss << L"Intro file \"" << filename() << L"\" could not be extracted";
|
||||||
|
RETHROWEXCEPTION(wss.str().c_str(),&ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Allocate a Smacker buffer for video decompression
|
// Allocate a Smacker buffer for video decompression
|
||||||
if(!(pSmack->SmackBuffer=SmackBufferOpen(hDisplayWindow,SMACKAUTOBLIT,SCREEN_WIDTH,SCREEN_HEIGHT,0,0)))
|
if(!(pSmack->SmackBuffer=SmackBufferOpen(hDisplayWindow,SMACKAUTOBLIT,SCREEN_WIDTH,SCREEN_HEIGHT,0,0)))
|
||||||
@@ -216,9 +249,25 @@ SMKFLIC *SmkOpenFlic(CHAR8 *cFilename)
|
|||||||
ErrorMsg("SMK ERROR: Can't allocate a Smacker decompression buffer");
|
ErrorMsg("SMK ERROR: Can't allocate a Smacker decompression buffer");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
#ifndef USE_VFS
|
||||||
if(!(pSmack->SmackHandle=SmackOpen((CHAR8 *)hFile, SMACKFILEHANDLE | SMACKTRACKS, SMACKAUTOEXTRA)))
|
if(!(pSmack->SmackHandle=SmackOpen((CHAR8 *)hFile, SMACKFILEHANDLE | SMACKTRACKS, SMACKAUTOEXTRA)))
|
||||||
|
#else
|
||||||
// if(!(pSmack->SmackHandle=SmackOpen(cFilename, SMACKTRACKS, SMACKAUTOEXTRA)))
|
// if(!(pSmack->SmackHandle=SmackOpen(cFilename, SMACKTRACKS, SMACKAUTOEXTRA)))
|
||||||
|
vfs::Path tempfilename;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
vfs::COpenWriteFile wfile(tempfile);
|
||||||
|
if(!wfile.file()._getRealPath(tempfilename))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(CBasicException& ex)
|
||||||
|
{
|
||||||
|
RETHROWEXCEPTION(L"Temporary intro file could not be read", &ex);
|
||||||
|
}
|
||||||
|
if(!(pSmack->SmackHandle=SmackOpen(tempfilename().utf8().c_str(), SMACKTRACKS, SMACKAUTOEXTRA)))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
ErrorMsg("SMK ERROR: Smacker won't open the SMK file");
|
ErrorMsg("SMK ERROR: Smacker won't open the SMK file");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ typedef struct
|
|||||||
UINT16 usStartingAniCode;
|
UINT16 usStartingAniCode;
|
||||||
BOOLEAN fForce;
|
BOOLEAN fForce;
|
||||||
UINT8 usNewDirection;//hayden
|
UINT8 usNewDirection;//hayden
|
||||||
|
UINT16 usTargetGridNo; // WANNE - MP: Used for manipulating the target grid no
|
||||||
|
|
||||||
} EV_S_CHANGESTATE;
|
} EV_S_CHANGESTATE;
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,17 @@ vfs::Path vfs::CVFSFile::GetFullPath()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool vfs::CVFSFile::_getRealPath(vfs::Path& rPath)
|
||||||
|
{
|
||||||
|
if(_pLoc_)
|
||||||
|
{
|
||||||
|
rPath = static_cast<IDirectory<CVFSFile::write_type>*>(_pLoc_)->GetRealPath() + m_sFileName;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool vfs::CVFSFile::Delete()
|
bool vfs::CVFSFile::Delete()
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ namespace vfs
|
|||||||
|
|
||||||
virtual bool OpenRead();
|
virtual bool OpenRead();
|
||||||
virtual bool OpenWrite(bool bCreateWhenNotExist = false, bool bTruncate = false);
|
virtual bool OpenWrite(bool bCreateWhenNotExist = false, bool bTruncate = false);
|
||||||
|
|
||||||
|
virtual bool _getRealPath(vfs::Path& rPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CVFSTextFile : public vfs::CTextFile, public vfs::ILocationAware<vfs::CFile::read_type, vfs::CFile::write_type>
|
class CVFSTextFile : public vfs::CTextFile, public vfs::ILocationAware<vfs::CFile::read_type, vfs::CFile::write_type>
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ namespace vfs
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
virtual bool _getRealPath(vfs::Path& rPath)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
vfs::Path m_sFileName;
|
vfs::Path m_sFileName;
|
||||||
};
|
};
|
||||||
|
|||||||
+11
-8
@@ -8,15 +8,15 @@ ObjBlockAllocator<vfs::CVirtualFile>* vfs::CVirtualFile::_vfile_pool = NULL;
|
|||||||
vfs::CVirtualFile* vfs::CVirtualFile::Create(vfs::Path const& sFilePath, vfs::CProfileStack& rPStack)
|
vfs::CVirtualFile* vfs::CVirtualFile::Create(vfs::Path const& sFilePath, vfs::CProfileStack& rPStack)
|
||||||
{
|
{
|
||||||
unsigned int ID=0;
|
unsigned int ID=0;
|
||||||
#if 0
|
#ifdef VFILE_BLOCK_CREATE
|
||||||
CVirtualFile* file = new CVirtualFile();
|
|
||||||
#else
|
|
||||||
if(!_vfile_pool)
|
if(!_vfile_pool)
|
||||||
{
|
{
|
||||||
_vfile_pool = new ObjBlockAllocator<vfs::CVirtualFile>();
|
_vfile_pool = new ObjBlockAllocator<vfs::CVirtualFile>();
|
||||||
CFileAllocator::RegisterAllocator(_vfile_pool);
|
CFileAllocator::RegisterAllocator(_vfile_pool);
|
||||||
}
|
}
|
||||||
CVirtualFile* file = _vfile_pool->New(&ID);
|
CVirtualFile* file = _vfile_pool->New(&ID);
|
||||||
|
#else
|
||||||
|
CVirtualFile* file = new CVirtualFile();
|
||||||
#endif
|
#endif
|
||||||
file->_path = sFilePath;
|
file->_path = sFilePath;
|
||||||
file->_pstack = &rPStack;
|
file->_pstack = &rPStack;
|
||||||
@@ -24,10 +24,14 @@ vfs::CVirtualFile* vfs::CVirtualFile::Create(vfs::Path const& sFilePath, vfs::CP
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
//vfs::CVirtualFile::CVirtualFile(vfs::Path const& sFilePath, CProfileStack& rPStack)
|
void vfs::CVirtualFile::Destroy()
|
||||||
//: _path(sFilePath), _top_pname("_INVALID_"), _top_file(NULL), _rstack(rPStack)
|
{
|
||||||
//{
|
#ifndef VFILE_BLOCK_CREATE
|
||||||
//};
|
delete this;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
vfs::CVirtualFile::CVirtualFile()
|
vfs::CVirtualFile::CVirtualFile()
|
||||||
: _path(""), _top_pname("_INVALID_"), _top_file(NULL), _pstack(NULL)
|
: _path(""), _top_pname("_INVALID_"), _top_file(NULL), _pstack(NULL)
|
||||||
, _myID(-1)
|
, _myID(-1)
|
||||||
@@ -36,7 +40,6 @@ vfs::CVirtualFile::CVirtualFile()
|
|||||||
|
|
||||||
vfs::CVirtualFile::~CVirtualFile()
|
vfs::CVirtualFile::~CVirtualFile()
|
||||||
{
|
{
|
||||||
int i = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vfs::Path const& vfs::CVirtualFile::Path()
|
vfs::Path const& vfs::CVirtualFile::Path()
|
||||||
|
|||||||
+6
-2
@@ -4,6 +4,8 @@
|
|||||||
#include "vfs_profile.h"
|
#include "vfs_profile.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#define VFILE_BLOCK_CREATE
|
||||||
|
|
||||||
namespace vfs
|
namespace vfs
|
||||||
{
|
{
|
||||||
class CVirtualFile
|
class CVirtualFile
|
||||||
@@ -17,9 +19,9 @@ namespace vfs
|
|||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
~CVirtualFile();
|
~CVirtualFile();
|
||||||
//CVirtualFile(vfs::Path const& sFilePath, CProfileStack& rPStack);
|
void Destroy();
|
||||||
static CVirtualFile* Create(vfs::Path const& sFilePath, CProfileStack& rPStack);
|
static CVirtualFile* Create(vfs::Path const& sFilePath, CProfileStack& rPStack);
|
||||||
|
|
||||||
vfs::Path const& Path();
|
vfs::Path const& Path();
|
||||||
void Add(vfs::IBaseFile *pFile, utf8string sProfileName, bool bReplace = false);
|
void Add(vfs::IBaseFile *pFile, utf8string sProfileName, bool bReplace = false);
|
||||||
bool Remove(vfs::IBaseFile *pFile);
|
bool Remove(vfs::IBaseFile *pFile);
|
||||||
@@ -37,7 +39,9 @@ namespace vfs
|
|||||||
CProfileStack* _pstack;
|
CProfileStack* _pstack;
|
||||||
private:
|
private:
|
||||||
unsigned int _myID;
|
unsigned int _myID;
|
||||||
|
#ifdef VFILE_BLOCK_CREATE
|
||||||
static ObjBlockAllocator<CVirtualFile>* _vfile_pool;
|
static ObjBlockAllocator<CVirtualFile>* _vfile_pool;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
} // end namspace
|
} // end namspace
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -55,10 +55,10 @@ vfs::CVirtualLocation::CVirtualLocation(vfs::Path const& sPath)
|
|||||||
vfs::CVirtualLocation::~CVirtualLocation()
|
vfs::CVirtualLocation::~CVirtualLocation()
|
||||||
{
|
{
|
||||||
tVFiles::iterator it = m_mapVFiles.begin();
|
tVFiles::iterator it = m_mapVFiles.begin();
|
||||||
//for(; it != m_mapVFiles.end(); ++it)
|
for(; it != m_mapVFiles.end(); ++it)
|
||||||
//{
|
{
|
||||||
// delete it->second;
|
it->second->Destroy();
|
||||||
//}
|
}
|
||||||
m_mapVFiles.clear();
|
m_mapVFiles.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user