- 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:
Wanne
2009-06-06 16:13:00 +00:00
parent 8c07f244f3
commit 3850e27bc5
11 changed files with 115 additions and 29 deletions
+4 -1
View File
@@ -32,6 +32,8 @@
#include "MessageBoxScreen.h"
#endif
#include "VFS/vfs.h"
extern STR16 gzIntroScreen[];
extern HVSURFACE ghFrameBuffer;
@@ -198,13 +200,14 @@ BOOLEAN EnterIntroScreen()
// return( TRUE );
// }
//#endif
#ifndef USE_VFS
//if the library doesnt exist, exit
if( !IsLibraryOpened( LIBRARY_INTRO ) )
{
PrepareToExitIntroScreen();
return( TRUE );
}
#endif
//initialize smacker
SmkInitialize( ghWindow, SCREEN_WIDTH, SCREEN_HEIGHT);
+13 -10
View File
@@ -3023,30 +3023,33 @@ void send_changestate (EV_S_CHANGESTATE * SChangeState)
void recieveSTATE(RPCParameters *rpcParameters)
{
EV_S_CHANGESTATE* new_state = (EV_S_CHANGESTATE*)rpcParameters->input;
//ScreenMsg( FONT_YELLOW, MSG_MPSYSTEM, L"recieved state");
SOLDIERTYPE * pSoldier=MercPtrs[ new_state->usSoldierID ];
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->ChangeSoldierStance( ANIM_CROUCH );
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 );
}
//AddGameEvent( S_CHANGESTATE, 0, &SChangeState );
//someday ;)
}
}
void send_death( SOLDIERTYPE *pSoldier )
+9 -3
View File
@@ -2522,6 +2522,7 @@ BOOLEAN SOLDIERTYPE::ChangeSoldierState( UINT16 usNewState, UINT16 usStartingAni
SChangeState.sYPos = this->sY;
SChangeState.fForce = fForce;
SChangeState.usNewDirection = this->ubDirection;
SChangeState.usTargetGridNo = this->sTargetGridNo;
//AddGameEvent( S_CHANGESTATE, 0, &SChangeState );
@@ -10694,8 +10695,10 @@ void SOLDIERTYPE::EVENT_SoldierBeginFirstAid( INT16 sGridNo, UINT8 ubDirection )
//else
{
// CHANGE TO ANIMATION
if(!is_networked)this->EVENT_InitNewSoldierAnim( START_AID, 0 , FALSE );
else this->ChangeSoldierState( START_AID, 0, 0 );
if(!is_networked)
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;
// 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
View File
@@ -30,6 +30,8 @@
#include "DirectDraw Calls.h"
#include "Cinematics.h"
#include "soundman.h"
#include "VFS/vfs.h"
#include "VFS/vfs_file_raii.h"
#ifdef JA2
#include "video.h"
@@ -200,6 +202,7 @@ SMKFLIC *SmkOpenFlic(CHAR8 *cFilename)
return(NULL);
}
#ifndef USE_VFS
// Attempt opening the filename
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
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
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");
return(NULL);
}
#ifndef USE_VFS
if(!(pSmack->SmackHandle=SmackOpen((CHAR8 *)hFile, SMACKFILEHANDLE | SMACKTRACKS, SMACKAUTOEXTRA)))
#else
// if(!(pSmack->SmackHandle=SmackOpen(cFilename, SMACKTRACKS, SMACKAUTOEXTRA)))
vfs::Path tempfilename;
try
{
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");
return(NULL);
+1
View File
@@ -68,6 +68,7 @@ typedef struct
UINT16 usStartingAniCode;
BOOLEAN fForce;
UINT8 usNewDirection;//hayden
UINT16 usTargetGridNo; // WANNE - MP: Used for manipulating the target grid no
} EV_S_CHANGESTATE;
+11
View File
@@ -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()
{
Close();
+2
View File
@@ -24,6 +24,8 @@ namespace vfs
virtual bool OpenRead();
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>
+4
View File
@@ -48,6 +48,10 @@ namespace vfs
return 0;
};
virtual bool _getRealPath(vfs::Path& rPath)
{
return false;
}
protected:
vfs::Path m_sFileName;
};
+11 -8
View File
@@ -8,15 +8,15 @@ ObjBlockAllocator<vfs::CVirtualFile>* vfs::CVirtualFile::_vfile_pool = NULL;
vfs::CVirtualFile* vfs::CVirtualFile::Create(vfs::Path const& sFilePath, vfs::CProfileStack& rPStack)
{
unsigned int ID=0;
#if 0
CVirtualFile* file = new CVirtualFile();
#else
#ifdef VFILE_BLOCK_CREATE
if(!_vfile_pool)
{
_vfile_pool = new ObjBlockAllocator<vfs::CVirtualFile>();
CFileAllocator::RegisterAllocator(_vfile_pool);
}
CVirtualFile* file = _vfile_pool->New(&ID);
#else
CVirtualFile* file = new CVirtualFile();
#endif
file->_path = sFilePath;
file->_pstack = &rPStack;
@@ -24,10 +24,14 @@ vfs::CVirtualFile* vfs::CVirtualFile::Create(vfs::Path const& sFilePath, vfs::CP
return file;
}
//vfs::CVirtualFile::CVirtualFile(vfs::Path const& sFilePath, CProfileStack& rPStack)
//: _path(sFilePath), _top_pname("_INVALID_"), _top_file(NULL), _rstack(rPStack)
//{
//};
void vfs::CVirtualFile::Destroy()
{
#ifndef VFILE_BLOCK_CREATE
delete this;
#endif
}
vfs::CVirtualFile::CVirtualFile()
: _path(""), _top_pname("_INVALID_"), _top_file(NULL), _pstack(NULL)
, _myID(-1)
@@ -36,7 +40,6 @@ vfs::CVirtualFile::CVirtualFile()
vfs::CVirtualFile::~CVirtualFile()
{
int i = 0;
}
vfs::Path const& vfs::CVirtualFile::Path()
+6 -2
View File
@@ -4,6 +4,8 @@
#include "vfs_profile.h"
#include <vector>
#define VFILE_BLOCK_CREATE
namespace vfs
{
class CVirtualFile
@@ -17,9 +19,9 @@ namespace vfs
};
public:
~CVirtualFile();
//CVirtualFile(vfs::Path const& sFilePath, CProfileStack& rPStack);
void Destroy();
static CVirtualFile* Create(vfs::Path const& sFilePath, CProfileStack& rPStack);
vfs::Path const& Path();
void Add(vfs::IBaseFile *pFile, utf8string sProfileName, bool bReplace = false);
bool Remove(vfs::IBaseFile *pFile);
@@ -37,7 +39,9 @@ namespace vfs
CProfileStack* _pstack;
private:
unsigned int _myID;
#ifdef VFILE_BLOCK_CREATE
static ObjBlockAllocator<CVirtualFile>* _vfile_pool;
#endif
};
} // end namspace
+4 -4
View File
@@ -55,10 +55,10 @@ vfs::CVirtualLocation::CVirtualLocation(vfs::Path const& sPath)
vfs::CVirtualLocation::~CVirtualLocation()
{
tVFiles::iterator it = m_mapVFiles.begin();
//for(; it != m_mapVFiles.end(); ++it)
//{
// delete it->second;
//}
for(; it != m_mapVFiles.end(); ++it)
{
it->second->Destroy();
}
m_mapVFiles.clear();
}