initial
This commit is contained in:
44
public/scenefilecache/ISceneFileCache.h
Normal file
44
public/scenefilecache/ISceneFileCache.h
Normal file
@@ -0,0 +1,44 @@
|
||||
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef ISCENEFILECACHE_H
|
||||
#define ISCENEFILECACHE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "interface.h"
|
||||
#include "appframework/iappsystem.h"
|
||||
|
||||
// the file cache can support persisting some calcs
|
||||
struct SceneCachedData_t
|
||||
{
|
||||
unsigned int msecs;
|
||||
float m_fLastSpeakSecs;
|
||||
int numSounds;
|
||||
int sceneId;
|
||||
};
|
||||
|
||||
class ISceneFileCache : public IAppSystem
|
||||
{
|
||||
public:
|
||||
|
||||
// async implemenation
|
||||
virtual size_t GetSceneBufferSize( char const *filename ) = 0;
|
||||
virtual bool GetSceneData( char const *filename, byte *buf, size_t bufsize ) = 0;
|
||||
|
||||
// persisted scene data, returns true if valid, false otherwise
|
||||
virtual bool GetSceneCachedData( char const *pFilename, SceneCachedData_t *pData ) = 0;
|
||||
virtual short GetSceneCachedSound( int iScene, int iSound ) = 0;
|
||||
virtual const char *GetSceneString( short stringId ) = 0;
|
||||
|
||||
// Physically reloads image from disk
|
||||
virtual void Reload() = 0;
|
||||
};
|
||||
|
||||
#define SCENE_FILE_CACHE_INTERFACE_VERSION "SceneFileCache002"
|
||||
|
||||
#endif // ISCENEFILECACHE_H
|
||||
69
public/scenefilecache/SceneImageFile.h
Normal file
69
public/scenefilecache/SceneImageFile.h
Normal file
@@ -0,0 +1,69 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: A Scene Image file aggregates all the compiled binary VCD files into
|
||||
// a single file.
|
||||
//
|
||||
//=====================================================================================//
|
||||
#ifndef SCENE_IMAGE_FILE_H
|
||||
#define SCENE_IMAGE_FILE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "commonmacros.h"
|
||||
#include "tier1/checksum_crc.h"
|
||||
|
||||
#define SCENE_IMAGE_ID MAKEID( 'V','S','I','F' )
|
||||
#define SCENE_IMAGE_VERSION 3
|
||||
|
||||
// scene summary: cached calcs for commmon startup queries, variable sized
|
||||
// note: if you want to add a member to this struct, one way to do it and
|
||||
// save memory is to make lastspeech_msecs be a uint16 rather than a uint32
|
||||
// and store it as a fixed point seconds (say, 8.8) rather than straight
|
||||
// msecs; that gives you an additional 16 bits to squeeze into this struct
|
||||
// without actually increasing memory usage. Override the inline float
|
||||
// GetDurToSpeechEnd() function if you do this; all game code uses that rather
|
||||
// than reading the lastspeech_msecs member directly.
|
||||
struct SceneImageSummary_t
|
||||
{
|
||||
unsigned int msecs;
|
||||
unsigned int lastspeech_msecs; ///< milliseconds from beginning of vcd to end of last speak event.
|
||||
int numSounds;
|
||||
int soundStrings[1]; // has numSounds
|
||||
|
||||
// return time in seconds from beginning of scene to end of last Speak event
|
||||
inline float GetDurToSpeechEnd( void ) const { return lastspeech_msecs * 0.001f; }
|
||||
};
|
||||
|
||||
// stored sorted by crc filename for binary search
|
||||
struct SceneImageEntry_t
|
||||
{
|
||||
CRC32_t crcFilename; // expected to be normalized as scenes\???.vcd
|
||||
int nDataOffset; // offset to dword aligned data from start
|
||||
int nDataLength;
|
||||
int nSceneSummaryOffset; // offset to summary
|
||||
};
|
||||
|
||||
struct SceneImageHeader_t
|
||||
{
|
||||
int nId;
|
||||
int nVersion;
|
||||
int nNumScenes; // number of scene files
|
||||
int nNumStrings; // number of unique strings in table
|
||||
int nSceneEntryOffset;
|
||||
|
||||
inline const char *String( short iString )
|
||||
{
|
||||
if ( iString < 0 || iString >= nNumStrings )
|
||||
{
|
||||
Assert( 0 );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// access string table (after header) to access pool
|
||||
unsigned int *pTable = (unsigned int *)((byte *)this + sizeof( SceneImageHeader_t ));
|
||||
return (char *)this + pTable[iString];
|
||||
}
|
||||
};
|
||||
|
||||
#endif // SCENE_IMAGE_FILE_H
|
||||
Reference in New Issue
Block a user