mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2026-10-10 03:43:06 +08:00
Update headers and sources with content from PVKII
This commit is contained in:
committed by
Nicholas Hastings
parent
4c847fbe2f
commit
b47bd8801f
@@ -35,7 +35,10 @@ enum
|
||||
WL_NotInWater=0,
|
||||
WL_Feet,
|
||||
WL_Waist,
|
||||
WL_Eyes
|
||||
WL_Eyes,
|
||||
#ifdef PVK2_DLL
|
||||
WL_Max
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -46,7 +49,7 @@ enum
|
||||
typedef CBaseHandle EntityHandle_t;
|
||||
|
||||
|
||||
#define INVALID_ENTITY_HANDLE INVALID_EHANDLE
|
||||
#define INVALID_ENTITY_HANDLE INVALID_EHANDLE_INDEX
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Functions the engine provides to IGameMovement to assist in its movement.
|
||||
@@ -84,9 +87,6 @@ public:
|
||||
|
||||
virtual bool IsWorldEntity( const CBaseHandle &handle ) = 0;
|
||||
|
||||
// sets the entity being moved
|
||||
virtual void SetHost( CBasePlayer *host ) = 0;
|
||||
|
||||
protected:
|
||||
// Inherited classes can call this to set the singleton
|
||||
static void SetSingleton( IMoveHelper* pMoveHelper ) { sm_pSingleton = pMoveHelper; }
|
||||
|
||||
+13
-34
@@ -84,14 +84,6 @@ struct bbox_t
|
||||
Vector maxs;
|
||||
};
|
||||
|
||||
struct WorkshopMapDesc_t
|
||||
{
|
||||
char szMapName[MAX_PATH];
|
||||
char szOriginalMapName[MAX_PATH];
|
||||
uint32 uTimestamp;
|
||||
bool bDownloaded;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Interface the engine exposes to the game DLL
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -237,7 +229,7 @@ public:
|
||||
// Be sure to reset the lock after executing your code!!!
|
||||
virtual bool LockNetworkStringTables( bool lock ) = 0;
|
||||
|
||||
// Create a bot with the given name. Returns NULL if fake client can't be created
|
||||
// Create a bot with the given name. Returns nullptr if fake client can't be created
|
||||
virtual edict_t *CreateFakeClient( const char *netname ) = 0;
|
||||
|
||||
// Get a convar keyvalue for s specified client
|
||||
@@ -308,7 +300,7 @@ public:
|
||||
//
|
||||
// USE WITH CARE. Whatever tick the client is really currently on is subject to timing and
|
||||
// ordering differences, so you should account for about a quarter-second discrepancy in here.
|
||||
// Also, this will return NULL if the client doesn't exist or if this client hasn't acked any frames yet.
|
||||
// Also, this will return nullptr if the client doesn't exist or if this client hasn't acked any frames yet.
|
||||
//
|
||||
// iClientIndex is the CLIENT index, so if you use pPlayer->entindex(), subtract 1.
|
||||
virtual const CBitVec<MAX_EDICTS>* GetEntityTransmitBitsForClient( int iClientIndex ) = 0;
|
||||
@@ -348,7 +340,7 @@ public:
|
||||
|
||||
// Tells the engine we can immdiately re-use all edict indices
|
||||
// even though we may not have waited enough time
|
||||
virtual void AllowImmediateEdictReuse( ) = 0;
|
||||
virtual void AllowImmediateEdictReuse( ) = 0;
|
||||
|
||||
// Returns true if the engine is an internal build. i.e. is using the internal bugreporter.
|
||||
virtual bool IsInternalBuild( void ) = 0;
|
||||
@@ -398,7 +390,7 @@ public:
|
||||
virtual void SetGamestatsData( CGamestatsData *pGamestatsData ) = 0;
|
||||
virtual CGamestatsData *GetGamestatsData() = 0;
|
||||
|
||||
// Returns the SteamID of the specified player. It'll be NULL if the player hasn't authenticated yet.
|
||||
// Returns the SteamID of the specified player. It'll be nullptr if the player hasn't authenticated yet.
|
||||
virtual const CSteamID *GetClientSteamID( edict_t *pPlayerEdict ) = 0;
|
||||
|
||||
// Returns the SteamID of the game server
|
||||
@@ -408,13 +400,13 @@ public:
|
||||
// keyvalues are deleted inside the function
|
||||
virtual void ClientCommandKeyValues( edict_t *pEdict, KeyValues *pCommand ) = 0;
|
||||
|
||||
// Returns the SteamID of the specified player. It'll be NULL if the player hasn't authenticated yet.
|
||||
// Returns the SteamID of the specified player. It'll be nullptr if the player hasn't authenticated yet.
|
||||
virtual const CSteamID *GetClientSteamIDByPlayerIndex( int entnum ) = 0;
|
||||
// Gets a list of all clusters' bounds. Returns total number of clusters.
|
||||
virtual int GetClusterCount() = 0;
|
||||
virtual int GetAllClusterBounds( bbox_t *pBBoxList, int maxBBox ) = 0;
|
||||
|
||||
// Create a bot with the given name. Returns NULL if fake client can't be created
|
||||
// Create a bot with the given name. Returns nullptr if fake client can't be created
|
||||
virtual edict_t *CreateFakeClientEx( const char *netname, bool bReportFakeClient = true ) = 0;
|
||||
|
||||
// Server version from the steam.inf, this will be compared to the GC version
|
||||
@@ -453,6 +445,7 @@ public:
|
||||
virtual eFindMapResult FindMap( /* in/out */ char *pMapName, int nMapNameMax ) = 0;
|
||||
|
||||
virtual void SetPausedForced( bool bPaused, float flDuration = -1.f ) = 0;
|
||||
virtual void GetPublicIP( CUtlString &str ) const = 0;
|
||||
};
|
||||
|
||||
// These only differ in new items added to the end
|
||||
@@ -462,10 +455,8 @@ typedef IVEngineServer IVEngineServer022;
|
||||
|
||||
#define INTERFACEVERSION_SERVERGAMEDLL_VERSION_8 "ServerGameDLL008"
|
||||
#define INTERFACEVERSION_SERVERGAMEDLL_VERSION_9 "ServerGameDLL009"
|
||||
#define INTERFACEVERSION_SERVERGAMEDLL_VERSION_10 "ServerGameDLL010"
|
||||
#define INTERFACEVERSION_SERVERGAMEDLL_VERSION_11 "ServerGameDLL011"
|
||||
#define INTERFACEVERSION_SERVERGAMEDLL "ServerGameDLL012"
|
||||
#define INTERFACEVERSION_SERVERGAMEDLL_INT 12
|
||||
#define INTERFACEVERSION_SERVERGAMEDLL "ServerGameDLL010"
|
||||
#define INTERFACEVERSION_SERVERGAMEDLL_INT 10
|
||||
|
||||
class IServerGCLobby;
|
||||
|
||||
@@ -587,7 +578,7 @@ public:
|
||||
virtual IServerGCLobby *GetServerGCLobby() = 0;
|
||||
|
||||
// Return override string to show in the server browser
|
||||
// "map" column, or NULL to just use the default value
|
||||
// "map" column, or nullptr to just use the default value
|
||||
// (the map name)
|
||||
virtual const char *GetServerBrowserMapOverride() = 0;
|
||||
|
||||
@@ -621,7 +612,7 @@ public:
|
||||
};
|
||||
virtual ePrepareLevelResourcesResult AsyncPrepareLevelResources( /* in/out */ char *pszMapName, size_t nMapNameSize,
|
||||
/* in/out */ char *pszMapFile, size_t nMapFileSize,
|
||||
float *flProgress = NULL ) = 0;
|
||||
float *flProgress = nullptr ) = 0;
|
||||
|
||||
// Ask the game DLL to evaluate what it would do with this map name were it passed to PrepareLevelResources.
|
||||
// NOTE That this is this is syncronous and non-blocking, so it is possible that async PrepareLevelResources call
|
||||
@@ -641,11 +632,6 @@ public:
|
||||
|
||||
// Called to see if the game server is okay with a manual changelevel or map command
|
||||
virtual bool IsManualMapChangeOkay( const char **pszReason ) = 0;
|
||||
|
||||
// Josh: Allows the engine over all workshop maps and get some information about them.
|
||||
// Used primarily for listmaps code.
|
||||
// Returns true if uIndex was valid, false if invalid.
|
||||
virtual bool GetWorkshopMap( uint32 uIndex, WorkshopMapDesc_t *pDesc ) = 0;
|
||||
};
|
||||
|
||||
typedef IServerGameDLL IServerGameDLL008;
|
||||
@@ -688,8 +674,7 @@ public:
|
||||
};
|
||||
|
||||
#define INTERFACEVERSION_SERVERGAMECLIENTS_VERSION_3 "ServerGameClients003"
|
||||
#define INTERFACEVERSION_SERVERGAMECLIENTS_VERSION_4 "ServerGameClients004"
|
||||
#define INTERFACEVERSION_SERVERGAMECLIENTS "ServerGameClients005"
|
||||
#define INTERFACEVERSION_SERVERGAMECLIENTS "ServerGameClients004"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Player / Client related functions
|
||||
@@ -754,13 +739,10 @@ public:
|
||||
|
||||
// Hook for player spawning
|
||||
virtual void ClientSpawned( edict_t *pPlayer ) = 0;
|
||||
|
||||
// Hook for player voice
|
||||
virtual void ClientVoice( edict_t *pPlayer ) = 0;
|
||||
};
|
||||
|
||||
typedef IServerGameClients IServerGameClients003;
|
||||
typedef IServerGameClients IServerGameClients004;
|
||||
|
||||
|
||||
#define INTERFACEVERSION_UPLOADGAMESTATS "ServerUploadGameStats001"
|
||||
|
||||
@@ -841,9 +823,6 @@ public:
|
||||
virtual bool SteamIDAllowedToConnect( const CSteamID &steamId ) const = 0;
|
||||
virtual void UpdateServerDetails(void) = 0;
|
||||
virtual bool ShouldHibernate() = 0;
|
||||
|
||||
virtual bool MatchAllowsNameChanges() = 0;
|
||||
virtual bool GetPlayerGCMatchName( const CSteamID &steamId, char *pszOutGCMatchName, size_t nGCMatchNameLen ) = 0;
|
||||
};
|
||||
|
||||
#endif // EIFACE_H
|
||||
|
||||
+134
-134
@@ -39,23 +39,23 @@ public:
|
||||
{
|
||||
m_pBaseFileSystemPassThru = pBaseFileSystemPassThru;
|
||||
}
|
||||
virtual int Read( void* pOutput, int size, FileHandle_t file ) { return m_pBaseFileSystemPassThru->Read( pOutput, size, file ); }
|
||||
virtual int Write( void const* pInput, int size, FileHandle_t file ) { return m_pBaseFileSystemPassThru->Write( pInput, size, file ); }
|
||||
virtual FileHandle_t Open( const char *pFileName, const char *pOptions, const char *pathID ) { return m_pBaseFileSystemPassThru->Open( pFileName, pOptions, pathID ); }
|
||||
virtual void Close( FileHandle_t file ) { m_pBaseFileSystemPassThru->Close( file ); }
|
||||
virtual void Seek( FileHandle_t file, int pos, FileSystemSeek_t seekType ) { m_pBaseFileSystemPassThru->Seek( file, pos, seekType ); }
|
||||
virtual unsigned int Tell( FileHandle_t file ) { return m_pBaseFileSystemPassThru->Tell( file ); }
|
||||
virtual unsigned int Size( FileHandle_t file ) { return m_pBaseFileSystemPassThru->Size( file ); }
|
||||
virtual unsigned int Size( const char *pFileName, const char *pPathID ) { return m_pBaseFileSystemPassThru->Size( pFileName, pPathID ); }
|
||||
virtual void Flush( FileHandle_t file ) { m_pBaseFileSystemPassThru->Flush( file ); }
|
||||
virtual bool Precache( const char *pFileName, const char *pPathID ) { return m_pBaseFileSystemPassThru->Precache( pFileName, pPathID ); }
|
||||
virtual bool FileExists( const char *pFileName, const char *pPathID ) { return m_pBaseFileSystemPassThru->FileExists( pFileName, pPathID ); }
|
||||
virtual bool IsFileWritable( char const *pFileName, const char *pPathID ) { return m_pBaseFileSystemPassThru->IsFileWritable( pFileName, pPathID ); }
|
||||
virtual bool SetFileWritable( char const *pFileName, bool writable, const char *pPathID ) { return m_pBaseFileSystemPassThru->SetFileWritable( pFileName, writable, pPathID ); }
|
||||
virtual long GetFileTime( const char *pFileName, const char *pPathID ) { return m_pBaseFileSystemPassThru->GetFileTime( pFileName, pPathID ); }
|
||||
virtual bool ReadFile( const char *pFileName, const char *pPath, CUtlBuffer &buf, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL ) { return m_pBaseFileSystemPassThru->ReadFile( pFileName, pPath, buf, nMaxBytes, nStartingByte, pfnAlloc ); }
|
||||
virtual bool WriteFile( const char *pFileName, const char *pPath, CUtlBuffer &buf ) { return m_pBaseFileSystemPassThru->WriteFile( pFileName, pPath, buf ); }
|
||||
virtual bool UnzipFile( const char *pFileName, const char *pPath, const char *pDestination ) { return m_pBaseFileSystemPassThru->UnzipFile( pFileName, pPath, pDestination ); }
|
||||
int Read( void* pOutput, int size, FileHandle_t file ) override { return m_pBaseFileSystemPassThru->Read( pOutput, size, file ); }
|
||||
int Write( void const* pInput, int size, FileHandle_t file ) override { return m_pBaseFileSystemPassThru->Write( pInput, size, file ); }
|
||||
FileHandle_t Open( const char *pFileName, const char *pOptions, const char *pathID ) override { return m_pBaseFileSystemPassThru->Open( pFileName, pOptions, pathID ); }
|
||||
void Close( FileHandle_t file ) override { m_pBaseFileSystemPassThru->Close( file ); }
|
||||
void Seek( FileHandle_t file, int pos, FileSystemSeek_t seekType ) override { m_pBaseFileSystemPassThru->Seek( file, pos, seekType ); }
|
||||
unsigned int Tell( FileHandle_t file ) override { return m_pBaseFileSystemPassThru->Tell( file ); }
|
||||
unsigned int Size( FileHandle_t file ) override { return m_pBaseFileSystemPassThru->Size( file ); }
|
||||
unsigned int Size( const char *pFileName, const char *pPathID ) override { return m_pBaseFileSystemPassThru->Size( pFileName, pPathID ); }
|
||||
void Flush( FileHandle_t file ) override { m_pBaseFileSystemPassThru->Flush( file ); }
|
||||
bool Precache( const char *pFileName, const char *pPathID ) override { return m_pBaseFileSystemPassThru->Precache( pFileName, pPathID ); }
|
||||
bool FileExists( const char *pFileName, const char *pPathID ) override { return m_pBaseFileSystemPassThru->FileExists( pFileName, pPathID ); }
|
||||
bool IsFileWritable( char const *pFileName, const char *pPathID ) override { return m_pBaseFileSystemPassThru->IsFileWritable( pFileName, pPathID ); }
|
||||
bool SetFileWritable( char const *pFileName, bool writable, const char *pPathID ) override { return m_pBaseFileSystemPassThru->SetFileWritable( pFileName, writable, pPathID ); }
|
||||
long GetFileTime( const char *pFileName, const char *pPathID ) override { return m_pBaseFileSystemPassThru->GetFileTime( pFileName, pPathID ); }
|
||||
bool ReadFile( const char *pFileName, const char *pPath, CUtlBuffer &buf, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL ) override { return m_pBaseFileSystemPassThru->ReadFile( pFileName, pPath, buf, nMaxBytes, nStartingByte, pfnAlloc ); }
|
||||
bool WriteFile( const char *pFileName, const char *pPath, CUtlBuffer &buf ) override { return m_pBaseFileSystemPassThru->WriteFile( pFileName, pPath, buf ); }
|
||||
bool UnzipFile( const char *pFileName, const char *pPath, const char *pDestination ) override { return m_pBaseFileSystemPassThru->UnzipFile( pFileName, pPath, pDestination ); }
|
||||
|
||||
protected:
|
||||
IBaseFileSystem *m_pBaseFileSystemPassThru;
|
||||
@@ -87,25 +87,25 @@ public:
|
||||
|
||||
// IAppSystem stuff.
|
||||
// Here's where the app systems get to learn about each other
|
||||
virtual bool Connect( CreateInterfaceFn factory ) { return m_pFileSystemPassThru->Connect( factory ); }
|
||||
virtual void Disconnect() { m_pFileSystemPassThru->Disconnect(); }
|
||||
virtual void *QueryInterface( const char *pInterfaceName ) { return m_pFileSystemPassThru->QueryInterface( pInterfaceName ); }
|
||||
virtual InitReturnVal_t Init() { return m_pFileSystemPassThru->Init(); }
|
||||
virtual void Shutdown() { m_pFileSystemPassThru->Shutdown(); }
|
||||
bool Connect( CreateInterfaceFn factory ) override { return m_pFileSystemPassThru->Connect( factory ); }
|
||||
void Disconnect() override { m_pFileSystemPassThru->Disconnect(); }
|
||||
void *QueryInterface( const char *pInterfaceName ) override { return m_pFileSystemPassThru->QueryInterface( pInterfaceName ); }
|
||||
InitReturnVal_t Init() override { return m_pFileSystemPassThru->Init(); }
|
||||
void Shutdown() override { m_pFileSystemPassThru->Shutdown(); }
|
||||
|
||||
virtual void RemoveAllSearchPaths( void ) { m_pFileSystemPassThru->RemoveAllSearchPaths(); }
|
||||
virtual void AddSearchPath( const char *pPath, const char *pathID, SearchPathAdd_t addType ) { m_pFileSystemPassThru->AddSearchPath( pPath, pathID, addType ); }
|
||||
virtual bool RemoveSearchPath( const char *pPath, const char *pathID ) { return m_pFileSystemPassThru->RemoveSearchPath( pPath, pathID ); }
|
||||
virtual void RemoveFile( char const* pRelativePath, const char *pathID ) { m_pFileSystemPassThru->RemoveFile( pRelativePath, pathID ); }
|
||||
virtual bool RenameFile( char const *pOldPath, char const *pNewPath, const char *pathID ) { return m_pFileSystemPassThru->RenameFile( pOldPath, pNewPath, pathID ); }
|
||||
virtual void CreateDirHierarchy( const char *path, const char *pathID ) { m_pFileSystemPassThru->CreateDirHierarchy( path, pathID ); }
|
||||
virtual bool IsDirectory( const char *pFileName, const char *pathID ) { return m_pFileSystemPassThru->IsDirectory( pFileName, pathID ); }
|
||||
virtual void FileTimeToString( char* pStrip, int maxCharsIncludingTerminator, long fileTime ) { m_pFileSystemPassThru->FileTimeToString( pStrip, maxCharsIncludingTerminator, fileTime ); }
|
||||
virtual void SetBufferSize( FileHandle_t file, unsigned nBytes ) { m_pFileSystemPassThru->SetBufferSize( file, nBytes ); }
|
||||
virtual bool IsOk( FileHandle_t file ) { return m_pFileSystemPassThru->IsOk( file ); }
|
||||
virtual bool EndOfFile( FileHandle_t file ) { return m_pFileSystemPassThru->EndOfFile( file ); }
|
||||
virtual char *ReadLine( char *pOutput, int maxChars, FileHandle_t file ) { return m_pFileSystemPassThru->ReadLine( pOutput, maxChars, file ); }
|
||||
virtual int FPrintf( FileHandle_t file, PRINTF_FORMAT_STRING const char *pFormat, ... )
|
||||
void RemoveAllSearchPaths( void ) override { m_pFileSystemPassThru->RemoveAllSearchPaths(); }
|
||||
void AddSearchPath( const char *pPath, const char *pathID, SearchPathAdd_t addType ) override { m_pFileSystemPassThru->AddSearchPath( pPath, pathID, addType ); }
|
||||
bool RemoveSearchPath( const char *pPath, const char *pathID ) override { return m_pFileSystemPassThru->RemoveSearchPath( pPath, pathID ); }
|
||||
void RemoveFile( char const* pRelativePath, const char *pathID ) override { m_pFileSystemPassThru->RemoveFile( pRelativePath, pathID ); }
|
||||
bool RenameFile( char const *pOldPath, char const *pNewPath, const char *pathID ) override { return m_pFileSystemPassThru->RenameFile( pOldPath, pNewPath, pathID ); }
|
||||
void CreateDirHierarchy( const char *path, const char *pathID ) override { m_pFileSystemPassThru->CreateDirHierarchy( path, pathID ); }
|
||||
bool IsDirectory( const char *pFileName, const char *pathID ) override { return m_pFileSystemPassThru->IsDirectory( pFileName, pathID ); }
|
||||
void FileTimeToString( char* pStrip, int maxCharsIncludingTerminator, long fileTime ) override { m_pFileSystemPassThru->FileTimeToString( pStrip, maxCharsIncludingTerminator, fileTime ); }
|
||||
void SetBufferSize( FileHandle_t file, unsigned nBytes ) override { m_pFileSystemPassThru->SetBufferSize( file, nBytes ); }
|
||||
bool IsOk( FileHandle_t file ) override { return m_pFileSystemPassThru->IsOk( file ); }
|
||||
bool EndOfFile( FileHandle_t file ) override { return m_pFileSystemPassThru->EndOfFile( file ); }
|
||||
char *ReadLine( char *pOutput, int maxChars, FileHandle_t file ) override { return m_pFileSystemPassThru->ReadLine( pOutput, maxChars, file ); }
|
||||
int FPrintf( FileHandle_t file, PRINTF_FORMAT_STRING const char *pFormat, ... ) override
|
||||
{
|
||||
char str[8192];
|
||||
va_list marker;
|
||||
@@ -114,73 +114,73 @@ public:
|
||||
va_end( marker );
|
||||
return m_pFileSystemPassThru->FPrintf( file, "%s", str );
|
||||
}
|
||||
virtual CSysModule *LoadModule( const char *pFileName, const char *pPathID, bool bValidatedDllOnly ) { return m_pFileSystemPassThru->LoadModule( pFileName, pPathID, bValidatedDllOnly ); }
|
||||
virtual void UnloadModule( CSysModule *pModule ) { m_pFileSystemPassThru->UnloadModule( pModule ); }
|
||||
virtual const char *FindFirst( const char *pWildCard, FileFindHandle_t *pHandle ) { return m_pFileSystemPassThru->FindFirst( pWildCard, pHandle ); }
|
||||
virtual const char *FindNext( FileFindHandle_t handle ) { return m_pFileSystemPassThru->FindNext( handle ); }
|
||||
virtual bool FindIsDirectory( FileFindHandle_t handle ) { return m_pFileSystemPassThru->FindIsDirectory( handle ); }
|
||||
virtual void FindClose( FileFindHandle_t handle ) { m_pFileSystemPassThru->FindClose( handle ); }
|
||||
virtual const char *GetLocalPath( const char *pFileName, OUT_Z_CAP(maxLenInChars) char *pDest, int maxLenInChars ) { return m_pFileSystemPassThru->GetLocalPath( pFileName, pDest, maxLenInChars ); }
|
||||
virtual bool FullPathToRelativePath( const char *pFullpath, OUT_Z_CAP(maxLenInChars) char *pDest, int maxLenInChars ) { return m_pFileSystemPassThru->FullPathToRelativePath( pFullpath, pDest, maxLenInChars ); }
|
||||
virtual bool GetCaseCorrectFullPath_Ptr( const char *pFullPath, OUT_Z_CAP(maxLenInChars) char *pDest, int maxLenInChars ) { return m_pFileSystemPassThru->GetCaseCorrectFullPath_Ptr( pFullPath, pDest, maxLenInChars ); }
|
||||
virtual bool GetCurrentDirectory( char* pDirectory, int maxlen ) { return m_pFileSystemPassThru->GetCurrentDirectory( pDirectory, maxlen ); }
|
||||
virtual void PrintOpenedFiles( void ) { m_pFileSystemPassThru->PrintOpenedFiles(); }
|
||||
virtual void PrintSearchPaths( void ) { m_pFileSystemPassThru->PrintSearchPaths(); }
|
||||
virtual void SetWarningFunc( void (*pfnWarning)( PRINTF_FORMAT_STRING const char *fmt, ... ) ) { m_pFileSystemPassThru->SetWarningFunc( pfnWarning ); }
|
||||
virtual void SetWarningLevel( FileWarningLevel_t level ) { m_pFileSystemPassThru->SetWarningLevel( level ); }
|
||||
virtual void AddLoggingFunc( void (*pfnLogFunc)( const char *fileName, const char *accessType ) ){ m_pFileSystemPassThru->AddLoggingFunc( pfnLogFunc ); }
|
||||
virtual void RemoveLoggingFunc( FileSystemLoggingFunc_t logFunc ) { m_pFileSystemPassThru->RemoveLoggingFunc( logFunc ); }
|
||||
virtual FSAsyncStatus_t AsyncReadMultiple( const FileAsyncRequest_t *pRequests, int nRequests, FSAsyncControl_t *pControls ) { return m_pFileSystemPassThru->AsyncReadMultiple( pRequests, nRequests, pControls ); }
|
||||
virtual FSAsyncStatus_t AsyncReadMultipleCreditAlloc( const FileAsyncRequest_t *pRequests, int nRequests, const char *pszFile, int line, FSAsyncControl_t *pControls ) { return m_pFileSystemPassThru->AsyncReadMultipleCreditAlloc( pRequests, nRequests, pszFile, line, pControls ); }
|
||||
virtual FSAsyncStatus_t AsyncFinish(FSAsyncControl_t hControl, bool wait) { return m_pFileSystemPassThru->AsyncFinish( hControl, wait ); }
|
||||
virtual FSAsyncStatus_t AsyncGetResult( FSAsyncControl_t hControl, void **ppData, int *pSize ) { return m_pFileSystemPassThru->AsyncGetResult( hControl, ppData, pSize ); }
|
||||
virtual FSAsyncStatus_t AsyncAbort(FSAsyncControl_t hControl) { return m_pFileSystemPassThru->AsyncAbort( hControl ); }
|
||||
virtual FSAsyncStatus_t AsyncStatus(FSAsyncControl_t hControl) { return m_pFileSystemPassThru->AsyncStatus( hControl ); }
|
||||
virtual FSAsyncStatus_t AsyncFlush() { return m_pFileSystemPassThru->AsyncFlush(); }
|
||||
virtual void AsyncAddRef( FSAsyncControl_t hControl ) { m_pFileSystemPassThru->AsyncAddRef( hControl ); }
|
||||
virtual void AsyncRelease( FSAsyncControl_t hControl ) { m_pFileSystemPassThru->AsyncRelease( hControl ); }
|
||||
virtual FSAsyncStatus_t AsyncBeginRead( const char *pszFile, FSAsyncFile_t *phFile ) { return m_pFileSystemPassThru->AsyncBeginRead( pszFile, phFile ); }
|
||||
virtual FSAsyncStatus_t AsyncEndRead( FSAsyncFile_t hFile ) { return m_pFileSystemPassThru->AsyncEndRead( hFile ); }
|
||||
virtual void AsyncAddFetcher( IAsyncFileFetch *pFetcher ) { m_pFileSystemPassThru->AsyncAddFetcher( pFetcher ); }
|
||||
virtual void AsyncRemoveFetcher( IAsyncFileFetch *pFetcher ) { m_pFileSystemPassThru->AsyncRemoveFetcher( pFetcher ); }
|
||||
virtual const FileSystemStatistics *GetFilesystemStatistics() { return m_pFileSystemPassThru->GetFilesystemStatistics(); }
|
||||
virtual WaitForResourcesHandle_t WaitForResources( const char *resourcelist ) { return m_pFileSystemPassThru->WaitForResources( resourcelist ); }
|
||||
virtual bool GetWaitForResourcesProgress( WaitForResourcesHandle_t handle,
|
||||
float *progress, bool *complete ) { return m_pFileSystemPassThru->GetWaitForResourcesProgress( handle, progress, complete ); }
|
||||
virtual void CancelWaitForResources( WaitForResourcesHandle_t handle ) { m_pFileSystemPassThru->CancelWaitForResources( handle ); }
|
||||
virtual int HintResourceNeed( const char *hintlist, int forgetEverything ) { return m_pFileSystemPassThru->HintResourceNeed( hintlist, forgetEverything ); }
|
||||
virtual bool IsFileImmediatelyAvailable(const char *pFileName) { return m_pFileSystemPassThru->IsFileImmediatelyAvailable( pFileName ); }
|
||||
virtual void GetLocalCopy( const char *pFileName ) { m_pFileSystemPassThru->GetLocalCopy( pFileName ); }
|
||||
virtual FileNameHandle_t FindOrAddFileName( char const *pFileName ) { return m_pFileSystemPassThru->FindOrAddFileName( pFileName ); }
|
||||
virtual FileNameHandle_t FindFileName( char const *pFileName ) { return m_pFileSystemPassThru->FindFileName( pFileName ); }
|
||||
virtual bool String( const FileNameHandle_t& handle, char *buf, int buflen ) { return m_pFileSystemPassThru->String( handle, buf, buflen ); }
|
||||
CSysModule *LoadModule( const char *pFileName, const char *pPathID, bool bValidatedDllOnly ) override { return m_pFileSystemPassThru->LoadModule( pFileName, pPathID, bValidatedDllOnly ); }
|
||||
void UnloadModule( CSysModule *pModule ) override { m_pFileSystemPassThru->UnloadModule( pModule ); }
|
||||
const char *FindFirst( const char *pWildCard, FileFindHandle_t *pHandle ) override { return m_pFileSystemPassThru->FindFirst( pWildCard, pHandle ); }
|
||||
const char *FindNext( FileFindHandle_t handle ) override { return m_pFileSystemPassThru->FindNext( handle ); }
|
||||
bool FindIsDirectory( FileFindHandle_t handle ) override { return m_pFileSystemPassThru->FindIsDirectory( handle ); }
|
||||
void FindClose( FileFindHandle_t handle ) override { m_pFileSystemPassThru->FindClose( handle ); }
|
||||
const char *GetLocalPath( const char *pFileName, OUT_Z_CAP(maxLenInChars) char *pDest, int maxLenInChars ) override { return m_pFileSystemPassThru->GetLocalPath( pFileName, pDest, maxLenInChars ); }
|
||||
bool FullPathToRelativePath( const char *pFullpath, OUT_Z_CAP(maxLenInChars) char *pDest, int maxLenInChars ) override { return m_pFileSystemPassThru->FullPathToRelativePath( pFullpath, pDest, maxLenInChars ); }
|
||||
bool GetCaseCorrectFullPath_Ptr( const char *pFullPath, OUT_Z_CAP(maxLenInChars) char *pDest, int maxLenInChars ) override { return m_pFileSystemPassThru->GetCaseCorrectFullPath_Ptr( pFullPath, pDest, maxLenInChars ); }
|
||||
bool GetCurrentDirectory( char* pDirectory, int maxlen ) override { return m_pFileSystemPassThru->GetCurrentDirectory( pDirectory, maxlen ); }
|
||||
void PrintOpenedFiles( void ) override { m_pFileSystemPassThru->PrintOpenedFiles(); }
|
||||
void PrintSearchPaths( void ) override { m_pFileSystemPassThru->PrintSearchPaths(); }
|
||||
void SetWarningFunc( void (*pfnWarning)( PRINTF_FORMAT_STRING const char *fmt, ... ) ) override { m_pFileSystemPassThru->SetWarningFunc( pfnWarning ); }
|
||||
void SetWarningLevel( FileWarningLevel_t level ) override { m_pFileSystemPassThru->SetWarningLevel( level ); }
|
||||
void AddLoggingFunc( void (*pfnLogFunc)( const char *fileName, const char *accessType ) ) override{ m_pFileSystemPassThru->AddLoggingFunc( pfnLogFunc ); }
|
||||
void RemoveLoggingFunc( FileSystemLoggingFunc_t logFunc ) override { m_pFileSystemPassThru->RemoveLoggingFunc( logFunc ); }
|
||||
FSAsyncStatus_t AsyncReadMultiple( const FileAsyncRequest_t *pRequests, int nRequests, FSAsyncControl_t *pControls ) override { return m_pFileSystemPassThru->AsyncReadMultiple( pRequests, nRequests, pControls ); }
|
||||
FSAsyncStatus_t AsyncReadMultipleCreditAlloc( const FileAsyncRequest_t *pRequests, int nRequests, const char *pszFile, int line, FSAsyncControl_t *pControls ) override { return m_pFileSystemPassThru->AsyncReadMultipleCreditAlloc( pRequests, nRequests, pszFile, line, pControls ); }
|
||||
FSAsyncStatus_t AsyncFinish(FSAsyncControl_t hControl, bool wait) override { return m_pFileSystemPassThru->AsyncFinish( hControl, wait ); }
|
||||
FSAsyncStatus_t AsyncGetResult( FSAsyncControl_t hControl, void **ppData, int *pSize ) override { return m_pFileSystemPassThru->AsyncGetResult( hControl, ppData, pSize ); }
|
||||
FSAsyncStatus_t AsyncAbort(FSAsyncControl_t hControl) override { return m_pFileSystemPassThru->AsyncAbort( hControl ); }
|
||||
FSAsyncStatus_t AsyncStatus(FSAsyncControl_t hControl) override { return m_pFileSystemPassThru->AsyncStatus( hControl ); }
|
||||
FSAsyncStatus_t AsyncFlush() override { return m_pFileSystemPassThru->AsyncFlush(); }
|
||||
void AsyncAddRef( FSAsyncControl_t hControl ) override { m_pFileSystemPassThru->AsyncAddRef( hControl ); }
|
||||
void AsyncRelease( FSAsyncControl_t hControl ) override { m_pFileSystemPassThru->AsyncRelease( hControl ); }
|
||||
FSAsyncStatus_t AsyncBeginRead( const char *pszFile, FSAsyncFile_t *phFile ) override { return m_pFileSystemPassThru->AsyncBeginRead( pszFile, phFile ); }
|
||||
FSAsyncStatus_t AsyncEndRead( FSAsyncFile_t hFile ) override { return m_pFileSystemPassThru->AsyncEndRead( hFile ); }
|
||||
void AsyncAddFetcher( IAsyncFileFetch *pFetcher ) override { m_pFileSystemPassThru->AsyncAddFetcher( pFetcher ); }
|
||||
void AsyncRemoveFetcher( IAsyncFileFetch *pFetcher ) override { m_pFileSystemPassThru->AsyncRemoveFetcher( pFetcher ); }
|
||||
const FileSystemStatistics *GetFilesystemStatistics() override { return m_pFileSystemPassThru->GetFilesystemStatistics(); }
|
||||
WaitForResourcesHandle_t WaitForResources( const char *resourcelist ) override { return m_pFileSystemPassThru->WaitForResources( resourcelist ); }
|
||||
bool GetWaitForResourcesProgress( WaitForResourcesHandle_t handle,
|
||||
float *progress, bool *complete ) override { return m_pFileSystemPassThru->GetWaitForResourcesProgress( handle, progress, complete ); }
|
||||
void CancelWaitForResources( WaitForResourcesHandle_t handle ) override { m_pFileSystemPassThru->CancelWaitForResources( handle ); }
|
||||
int HintResourceNeed( const char *hintlist, int forgetEverything ) override { return m_pFileSystemPassThru->HintResourceNeed( hintlist, forgetEverything ); }
|
||||
bool IsFileImmediatelyAvailable(const char *pFileName) override { return m_pFileSystemPassThru->IsFileImmediatelyAvailable( pFileName ); }
|
||||
void GetLocalCopy( const char *pFileName ) override { m_pFileSystemPassThru->GetLocalCopy( pFileName ); }
|
||||
FileNameHandle_t FindOrAddFileName( char const *pFileName ) override { return m_pFileSystemPassThru->FindOrAddFileName( pFileName ); }
|
||||
FileNameHandle_t FindFileName( char const *pFileName ) override { return m_pFileSystemPassThru->FindFileName( pFileName ); }
|
||||
bool String( const FileNameHandle_t& handle, char *buf, int buflen ) override { return m_pFileSystemPassThru->String( handle, buf, buflen ); }
|
||||
virtual bool IsOk2( FileHandle_t file ) { return IsOk(file); }
|
||||
virtual void RemoveSearchPaths( const char *szPathID ) { m_pFileSystemPassThru->RemoveSearchPaths( szPathID ); }
|
||||
virtual bool IsSteam() const { return m_pFileSystemPassThru->IsSteam(); }
|
||||
virtual FilesystemMountRetval_t MountSteamContent( int nExtraAppId = -1 ) { return m_pFileSystemPassThru->MountSteamContent( nExtraAppId ); }
|
||||
void RemoveSearchPaths( const char *szPathID ) override { m_pFileSystemPassThru->RemoveSearchPaths( szPathID ); }
|
||||
bool IsSteam() const override { return m_pFileSystemPassThru->IsSteam(); }
|
||||
FilesystemMountRetval_t MountSteamContent( int nExtraAppId = -1 ) override { return m_pFileSystemPassThru->MountSteamContent( nExtraAppId ); }
|
||||
|
||||
virtual const char *FindFirstEx(
|
||||
const char *FindFirstEx(
|
||||
const char *pWildCard,
|
||||
const char *pPathID,
|
||||
FileFindHandle_t *pHandle
|
||||
) { return m_pFileSystemPassThru->FindFirstEx( pWildCard, pPathID, pHandle ); }
|
||||
virtual void MarkPathIDByRequestOnly( const char *pPathID, bool bRequestOnly ) { m_pFileSystemPassThru->MarkPathIDByRequestOnly( pPathID, bRequestOnly ); }
|
||||
virtual bool AddPackFile( const char *fullpath, const char *pathID ) { return m_pFileSystemPassThru->AddPackFile( fullpath, pathID ); }
|
||||
virtual FSAsyncStatus_t AsyncAppend(const char *pFileName, const void *pSrc, int nSrcBytes, bool bFreeMemory, FSAsyncControl_t *pControl ) { return m_pFileSystemPassThru->AsyncAppend( pFileName, pSrc, nSrcBytes, bFreeMemory, pControl); }
|
||||
virtual FSAsyncStatus_t AsyncWrite(const char *pFileName, const void *pSrc, int nSrcBytes, bool bFreeMemory, bool bAppend, FSAsyncControl_t *pControl ) { return m_pFileSystemPassThru->AsyncWrite( pFileName, pSrc, nSrcBytes, bFreeMemory, bAppend, pControl); }
|
||||
virtual FSAsyncStatus_t AsyncWriteFile(const char *pFileName, const CUtlBuffer *pSrc, int nSrcBytes, bool bFreeMemory, bool bAppend, FSAsyncControl_t *pControl ) { return m_pFileSystemPassThru->AsyncWriteFile( pFileName, pSrc, nSrcBytes, bFreeMemory, bAppend, pControl); }
|
||||
virtual FSAsyncStatus_t AsyncAppendFile(const char *pDestFileName, const char *pSrcFileName, FSAsyncControl_t *pControl ) { return m_pFileSystemPassThru->AsyncAppendFile(pDestFileName, pSrcFileName, pControl); }
|
||||
virtual void AsyncFinishAll( int iToPriority ) { m_pFileSystemPassThru->AsyncFinishAll(iToPriority); }
|
||||
virtual void AsyncFinishAllWrites() { m_pFileSystemPassThru->AsyncFinishAllWrites(); }
|
||||
virtual FSAsyncStatus_t AsyncSetPriority(FSAsyncControl_t hControl, int newPriority) { return m_pFileSystemPassThru->AsyncSetPriority(hControl, newPriority); }
|
||||
virtual bool AsyncSuspend() { return m_pFileSystemPassThru->AsyncSuspend(); }
|
||||
virtual bool AsyncResume() { return m_pFileSystemPassThru->AsyncResume(); }
|
||||
virtual const char *RelativePathToFullPath( const char *pFileName, const char *pPathID, OUT_Z_CAP(maxLenInChars) char *pDest, int maxLenInChars, PathTypeFilter_t pathFilter = FILTER_NONE, PathTypeQuery_t *pPathType = NULL ) { return m_pFileSystemPassThru->RelativePathToFullPath( pFileName, pPathID, pDest, maxLenInChars, pathFilter, pPathType ); }
|
||||
virtual int GetSearchPath( const char *pathID, bool bGetPackFiles, OUT_Z_CAP(maxLenInChars) char *pDest, int maxLenInChars ) { return m_pFileSystemPassThru->GetSearchPath( pathID, bGetPackFiles, pDest, maxLenInChars ); }
|
||||
) override { return m_pFileSystemPassThru->FindFirstEx( pWildCard, pPathID, pHandle ); }
|
||||
void MarkPathIDByRequestOnly( const char *pPathID, bool bRequestOnly ) override { m_pFileSystemPassThru->MarkPathIDByRequestOnly( pPathID, bRequestOnly ); }
|
||||
bool AddPackFile( const char *fullpath, const char *pathID ) override { return m_pFileSystemPassThru->AddPackFile( fullpath, pathID ); }
|
||||
FSAsyncStatus_t AsyncAppend(const char *pFileName, const void *pSrc, int nSrcBytes, bool bFreeMemory, FSAsyncControl_t *pControl ) override { return m_pFileSystemPassThru->AsyncAppend( pFileName, pSrc, nSrcBytes, bFreeMemory, pControl); }
|
||||
FSAsyncStatus_t AsyncWrite(const char *pFileName, const void *pSrc, int nSrcBytes, bool bFreeMemory, bool bAppend, FSAsyncControl_t *pControl ) override { return m_pFileSystemPassThru->AsyncWrite( pFileName, pSrc, nSrcBytes, bFreeMemory, bAppend, pControl); }
|
||||
FSAsyncStatus_t AsyncWriteFile(const char *pFileName, const CUtlBuffer *pSrc, int nSrcBytes, bool bFreeMemory, bool bAppend, FSAsyncControl_t *pControl ) override { return m_pFileSystemPassThru->AsyncWriteFile( pFileName, pSrc, nSrcBytes, bFreeMemory, bAppend, pControl); }
|
||||
FSAsyncStatus_t AsyncAppendFile(const char *pDestFileName, const char *pSrcFileName, FSAsyncControl_t *pControl ) override { return m_pFileSystemPassThru->AsyncAppendFile(pDestFileName, pSrcFileName, pControl); }
|
||||
void AsyncFinishAll( int iToPriority ) override { m_pFileSystemPassThru->AsyncFinishAll(iToPriority); }
|
||||
void AsyncFinishAllWrites() override { m_pFileSystemPassThru->AsyncFinishAllWrites(); }
|
||||
FSAsyncStatus_t AsyncSetPriority(FSAsyncControl_t hControl, int newPriority) override { return m_pFileSystemPassThru->AsyncSetPriority(hControl, newPriority); }
|
||||
bool AsyncSuspend() override { return m_pFileSystemPassThru->AsyncSuspend(); }
|
||||
bool AsyncResume() override { return m_pFileSystemPassThru->AsyncResume(); }
|
||||
const char *RelativePathToFullPath( const char *pFileName, const char *pPathID, OUT_Z_CAP(maxLenInChars) char *pDest, int maxLenInChars, PathTypeFilter_t pathFilter = FILTER_NONE, PathTypeQuery_t *pPathType = NULL ) override { return m_pFileSystemPassThru->RelativePathToFullPath( pFileName, pPathID, pDest, maxLenInChars, pathFilter, pPathType ); }
|
||||
int GetSearchPath( const char *pathID, bool bGetPackFiles, OUT_Z_CAP(maxLenInChars) char *pDest, int maxLenInChars ) override { return m_pFileSystemPassThru->GetSearchPath( pathID, bGetPackFiles, pDest, maxLenInChars ); }
|
||||
|
||||
virtual FileHandle_t OpenEx( const char *pFileName, const char *pOptions, unsigned flags = 0, const char *pathID = 0, char **ppszResolvedFilename = NULL ) { return m_pFileSystemPassThru->OpenEx( pFileName, pOptions, flags, pathID, ppszResolvedFilename );}
|
||||
virtual int ReadEx( void* pOutput, int destSize, int size, FileHandle_t file ) { return m_pFileSystemPassThru->ReadEx( pOutput, destSize, size, file ); }
|
||||
virtual int ReadFileEx( const char *pFileName, const char *pPath, void **ppBuf, bool bNullTerminate, bool bOptimalAlloc, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL ) { return m_pFileSystemPassThru->ReadFileEx( pFileName, pPath, ppBuf, bNullTerminate, bOptimalAlloc, nMaxBytes, nStartingByte, pfnAlloc ); }
|
||||
FileHandle_t OpenEx( const char *pFileName, const char *pOptions, unsigned flags = 0, const char *pathID = 0, char **ppszResolvedFilename = NULL ) override { return m_pFileSystemPassThru->OpenEx( pFileName, pOptions, flags, pathID, ppszResolvedFilename );}
|
||||
int ReadEx( void* pOutput, int destSize, int size, FileHandle_t file ) override { return m_pFileSystemPassThru->ReadEx( pOutput, destSize, size, file ); }
|
||||
int ReadFileEx( const char *pFileName, const char *pPath, void **ppBuf, bool bNullTerminate, bool bOptimalAlloc, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL ) override { return m_pFileSystemPassThru->ReadFileEx( pFileName, pPath, ppBuf, bNullTerminate, bOptimalAlloc, nMaxBytes, nStartingByte, pfnAlloc ); }
|
||||
|
||||
#if defined( TRACK_BLOCKING_IO )
|
||||
virtual void EnableBlockingFileAccessTracking( bool state ) { m_pFileSystemPassThru->EnableBlockingFileAccessTracking( state ); }
|
||||
@@ -188,68 +188,68 @@ public:
|
||||
|
||||
virtual IBlockingFileItemList *RetrieveBlockingFileAccessInfo() { return m_pFileSystemPassThru->RetrieveBlockingFileAccessInfo(); }
|
||||
#endif
|
||||
virtual void SetupPreloadData() {}
|
||||
virtual void DiscardPreloadData() {}
|
||||
void SetupPreloadData() override {}
|
||||
void DiscardPreloadData() override {}
|
||||
|
||||
virtual void LoadCompiledKeyValues( KeyValuesPreloadType_t type, char const *archiveFile ) { m_pFileSystemPassThru->LoadCompiledKeyValues( type, archiveFile ); }
|
||||
void LoadCompiledKeyValues( KeyValuesPreloadType_t type, char const *archiveFile ) override { m_pFileSystemPassThru->LoadCompiledKeyValues( type, archiveFile ); }
|
||||
|
||||
// If the "PreloadedData" hasn't been purged, then this'll try and instance the KeyValues using the fast path of compiled keyvalues loaded during startup.
|
||||
// Otherwise, it'll just fall through to the regular KeyValues loading routines
|
||||
virtual KeyValues *LoadKeyValues( KeyValuesPreloadType_t type, char const *filename, char const *pPathID = 0 ) { return m_pFileSystemPassThru->LoadKeyValues( type, filename, pPathID ); }
|
||||
virtual bool LoadKeyValues( KeyValues& head, KeyValuesPreloadType_t type, char const *filename, char const *pPathID = 0 ) { return m_pFileSystemPassThru->LoadKeyValues( head, type, filename, pPathID ); }
|
||||
virtual bool ExtractRootKeyName( KeyValuesPreloadType_t type, char *outbuf, size_t bufsize, char const *filename, char const *pPathID = 0 ) { return m_pFileSystemPassThru->ExtractRootKeyName( type, outbuf, bufsize, filename, pPathID ); }
|
||||
KeyValues *LoadKeyValues( KeyValuesPreloadType_t type, char const *filename, char const *pPathID = 0 ) override { return m_pFileSystemPassThru->LoadKeyValues( type, filename, pPathID ); }
|
||||
bool LoadKeyValues( KeyValues& head, KeyValuesPreloadType_t type, char const *filename, char const *pPathID = 0 ) override { return m_pFileSystemPassThru->LoadKeyValues( head, type, filename, pPathID ); }
|
||||
bool ExtractRootKeyName( KeyValuesPreloadType_t type, char *outbuf, size_t bufsize, char const *filename, char const *pPathID = 0 ) override { return m_pFileSystemPassThru->ExtractRootKeyName( type, outbuf, bufsize, filename, pPathID ); }
|
||||
|
||||
virtual bool GetFileTypeForFullPath( char const *pFullPath, wchar_t *buf, size_t bufSizeInBytes ) { return m_pFileSystemPassThru->GetFileTypeForFullPath( pFullPath, buf, bufSizeInBytes ); }
|
||||
bool GetFileTypeForFullPath( char const *pFullPath, wchar_t *buf, size_t bufSizeInBytes ) override { return m_pFileSystemPassThru->GetFileTypeForFullPath( pFullPath, buf, bufSizeInBytes ); }
|
||||
|
||||
virtual bool GetOptimalIOConstraints( FileHandle_t hFile, unsigned *pOffsetAlign, unsigned *pSizeAlign, unsigned *pBufferAlign ) { return m_pFileSystemPassThru->GetOptimalIOConstraints( hFile, pOffsetAlign, pSizeAlign, pBufferAlign ); }
|
||||
virtual void *AllocOptimalReadBuffer( FileHandle_t hFile, unsigned nSize, unsigned nOffset ) { return m_pFileSystemPassThru->AllocOptimalReadBuffer( hFile, nOffset, nSize ); }
|
||||
virtual void FreeOptimalReadBuffer( void *p ) { m_pFileSystemPassThru->FreeOptimalReadBuffer( p ); }
|
||||
bool GetOptimalIOConstraints( FileHandle_t hFile, unsigned *pOffsetAlign, unsigned *pSizeAlign, unsigned *pBufferAlign ) override { return m_pFileSystemPassThru->GetOptimalIOConstraints( hFile, pOffsetAlign, pSizeAlign, pBufferAlign ); }
|
||||
void *AllocOptimalReadBuffer( FileHandle_t hFile, unsigned nSize, unsigned nOffset ) override { return m_pFileSystemPassThru->AllocOptimalReadBuffer( hFile, nOffset, nSize ); }
|
||||
void FreeOptimalReadBuffer( void *p ) override { m_pFileSystemPassThru->FreeOptimalReadBuffer( p ); }
|
||||
|
||||
virtual void BeginMapAccess() { m_pFileSystemPassThru->BeginMapAccess(); }
|
||||
virtual void EndMapAccess() { m_pFileSystemPassThru->EndMapAccess(); }
|
||||
void BeginMapAccess() override { m_pFileSystemPassThru->BeginMapAccess(); }
|
||||
void EndMapAccess() override { m_pFileSystemPassThru->EndMapAccess(); }
|
||||
|
||||
virtual bool ReadToBuffer( FileHandle_t hFile, CUtlBuffer &buf, int nMaxBytes = 0, FSAllocFunc_t pfnAlloc = NULL ) { return m_pFileSystemPassThru->ReadToBuffer( hFile, buf, nMaxBytes, pfnAlloc ); }
|
||||
virtual bool FullPathToRelativePathEx( const char *pFullPath, const char *pPathId, OUT_Z_CAP(maxLenInChars) char *pDest, int maxLenInChars ) { return m_pFileSystemPassThru->FullPathToRelativePathEx( pFullPath, pPathId, pDest, maxLenInChars ); }
|
||||
virtual int GetPathIndex( const FileNameHandle_t &handle ) { return m_pFileSystemPassThru->GetPathIndex( handle ); }
|
||||
virtual long GetPathTime( const char *pPath, const char *pPathID ) { return m_pFileSystemPassThru->GetPathTime( pPath, pPathID ); }
|
||||
bool ReadToBuffer( FileHandle_t hFile, CUtlBuffer &buf, int nMaxBytes = 0, FSAllocFunc_t pfnAlloc = NULL ) override { return m_pFileSystemPassThru->ReadToBuffer( hFile, buf, nMaxBytes, pfnAlloc ); }
|
||||
bool FullPathToRelativePathEx( const char *pFullPath, const char *pPathId, OUT_Z_CAP(maxLenInChars) char *pDest, int maxLenInChars ) override { return m_pFileSystemPassThru->FullPathToRelativePathEx( pFullPath, pPathId, pDest, maxLenInChars ); }
|
||||
int GetPathIndex( const FileNameHandle_t &handle ) override { return m_pFileSystemPassThru->GetPathIndex( handle ); }
|
||||
long GetPathTime( const char *pPath, const char *pPathID ) override { return m_pFileSystemPassThru->GetPathTime( pPath, pPathID ); }
|
||||
|
||||
virtual DVDMode_t GetDVDMode() { return m_pFileSystemPassThru->GetDVDMode(); }
|
||||
DVDMode_t GetDVDMode() override { return m_pFileSystemPassThru->GetDVDMode(); }
|
||||
|
||||
virtual void EnableWhitelistFileTracking( bool bEnable, bool bCacheAllVPKHashes, bool bRecalculateAndCheckHashes )
|
||||
void EnableWhitelistFileTracking( bool bEnable, bool bCacheAllVPKHashes, bool bRecalculateAndCheckHashes ) override
|
||||
{ m_pFileSystemPassThru->EnableWhitelistFileTracking( bEnable, bCacheAllVPKHashes, bRecalculateAndCheckHashes ); }
|
||||
virtual void RegisterFileWhitelist( IPureServerWhitelist *pWhiteList, IFileList **ppFilesToReload ) OVERRIDE
|
||||
void RegisterFileWhitelist( IPureServerWhitelist *pWhiteList, IFileList **ppFilesToReload ) override
|
||||
{ m_pFileSystemPassThru->RegisterFileWhitelist( pWhiteList, ppFilesToReload ); }
|
||||
virtual void MarkAllCRCsUnverified()
|
||||
void MarkAllCRCsUnverified() override
|
||||
{ m_pFileSystemPassThru->MarkAllCRCsUnverified(); }
|
||||
virtual void CacheFileCRCs( const char *pPathname, ECacheCRCType eType, IFileList *pFilter )
|
||||
void CacheFileCRCs( const char *pPathname, ECacheCRCType eType, IFileList *pFilter ) override
|
||||
{ return m_pFileSystemPassThru->CacheFileCRCs( pPathname, eType, pFilter ); }
|
||||
virtual EFileCRCStatus CheckCachedFileHash( const char *pPathID, const char *pRelativeFilename, int nFileFraction, FileHash_t *pFileHash )
|
||||
EFileCRCStatus CheckCachedFileHash( const char *pPathID, const char *pRelativeFilename, int nFileFraction, FileHash_t *pFileHash ) override
|
||||
{ return m_pFileSystemPassThru->CheckCachedFileHash( pPathID, pRelativeFilename, nFileFraction, pFileHash ); }
|
||||
virtual int GetUnverifiedFileHashes( CUnverifiedFileHash *pFiles, int nMaxFiles )
|
||||
int GetUnverifiedFileHashes( CUnverifiedFileHash *pFiles, int nMaxFiles ) override
|
||||
{ return m_pFileSystemPassThru->GetUnverifiedFileHashes( pFiles, nMaxFiles ); }
|
||||
virtual int GetWhitelistSpewFlags()
|
||||
int GetWhitelistSpewFlags() override
|
||||
{ return m_pFileSystemPassThru->GetWhitelistSpewFlags(); }
|
||||
virtual void SetWhitelistSpewFlags( int spewFlags )
|
||||
void SetWhitelistSpewFlags( int spewFlags ) override
|
||||
{ m_pFileSystemPassThru->SetWhitelistSpewFlags( spewFlags ); }
|
||||
virtual void InstallDirtyDiskReportFunc( FSDirtyDiskReportFunc_t func ) { m_pFileSystemPassThru->InstallDirtyDiskReportFunc( func ); }
|
||||
void InstallDirtyDiskReportFunc( FSDirtyDiskReportFunc_t func ) override { m_pFileSystemPassThru->InstallDirtyDiskReportFunc( func ); }
|
||||
|
||||
virtual FileCacheHandle_t CreateFileCache() { return m_pFileSystemPassThru->CreateFileCache(); }
|
||||
virtual void AddFilesToFileCache( FileCacheHandle_t cacheId, const char **ppFileNames, int nFileNames, const char *pPathID ) { m_pFileSystemPassThru->AddFilesToFileCache( cacheId, ppFileNames, nFileNames, pPathID ); }
|
||||
virtual bool IsFileCacheFileLoaded( FileCacheHandle_t cacheId, const char *pFileName ) { return m_pFileSystemPassThru->IsFileCacheFileLoaded( cacheId, pFileName ); }
|
||||
virtual bool IsFileCacheLoaded( FileCacheHandle_t cacheId ) { return m_pFileSystemPassThru->IsFileCacheLoaded( cacheId ); }
|
||||
virtual void DestroyFileCache( FileCacheHandle_t cacheId ) { m_pFileSystemPassThru->DestroyFileCache( cacheId ); }
|
||||
FileCacheHandle_t CreateFileCache() override { return m_pFileSystemPassThru->CreateFileCache(); }
|
||||
void AddFilesToFileCache( FileCacheHandle_t cacheId, const char **ppFileNames, int nFileNames, const char *pPathID ) override { m_pFileSystemPassThru->AddFilesToFileCache( cacheId, ppFileNames, nFileNames, pPathID ); }
|
||||
bool IsFileCacheFileLoaded( FileCacheHandle_t cacheId, const char *pFileName ) override { return m_pFileSystemPassThru->IsFileCacheFileLoaded( cacheId, pFileName ); }
|
||||
bool IsFileCacheLoaded( FileCacheHandle_t cacheId ) override { return m_pFileSystemPassThru->IsFileCacheLoaded( cacheId ); }
|
||||
void DestroyFileCache( FileCacheHandle_t cacheId ) override { m_pFileSystemPassThru->DestroyFileCache( cacheId ); }
|
||||
|
||||
virtual bool RegisterMemoryFile( CMemoryFileBacking *pFile, CMemoryFileBacking **ppExistingFileWithRef ) { return m_pFileSystemPassThru->RegisterMemoryFile( pFile, ppExistingFileWithRef ); }
|
||||
virtual void UnregisterMemoryFile( CMemoryFileBacking *pFile ) { m_pFileSystemPassThru->UnregisterMemoryFile( pFile ); }
|
||||
virtual void CacheAllVPKFileHashes( bool bCacheAllVPKHashes, bool bRecalculateAndCheckHashes )
|
||||
bool RegisterMemoryFile( CMemoryFileBacking *pFile, CMemoryFileBacking **ppExistingFileWithRef ) override { return m_pFileSystemPassThru->RegisterMemoryFile( pFile, ppExistingFileWithRef ); }
|
||||
void UnregisterMemoryFile( CMemoryFileBacking *pFile ) override { m_pFileSystemPassThru->UnregisterMemoryFile( pFile ); }
|
||||
void CacheAllVPKFileHashes( bool bCacheAllVPKHashes, bool bRecalculateAndCheckHashes ) override
|
||||
{ return m_pFileSystemPassThru->CacheAllVPKFileHashes( bCacheAllVPKHashes, bRecalculateAndCheckHashes ); }
|
||||
virtual bool CheckVPKFileHash( int PackFileID, int nPackFileNumber, int nFileFraction, MD5Value_t &md5Value )
|
||||
bool CheckVPKFileHash( int PackFileID, int nPackFileNumber, int nFileFraction, MD5Value_t &md5Value ) override
|
||||
{ return m_pFileSystemPassThru->CheckVPKFileHash( PackFileID, nPackFileNumber, nFileFraction, md5Value ); }
|
||||
virtual void NotifyFileUnloaded( const char *pszFilename, const char *pPathId ) OVERRIDE
|
||||
void NotifyFileUnloaded( const char *pszFilename, const char *pPathId ) override
|
||||
{ m_pFileSystemPassThru->NotifyFileUnloaded( pszFilename, pPathId ); }
|
||||
|
||||
virtual void SetWriteProtectionEnable( bool bEnable ) { m_pFileSystemPassThru->SetWriteProtectionEnable( bEnable ); }
|
||||
virtual bool GetWriteProtectionEnable() const { return m_pFileSystemPassThru->GetWriteProtectionEnable(); }
|
||||
void SetWriteProtectionEnable( bool bEnable ) override { m_pFileSystemPassThru->SetWriteProtectionEnable( bEnable ); }
|
||||
bool GetWriteProtectionEnable() const override { return m_pFileSystemPassThru->GetWriteProtectionEnable(); }
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@@ -13,24 +13,36 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier0/platform.h"
|
||||
|
||||
#include "tier1/interface.h"
|
||||
#include "imaterialsystem.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// GL helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
FORCEINLINE bool IsEmulatingGL()
|
||||
{
|
||||
static bool bIsEmulatingGL = ( Plat_GetCommandLineA() ) ? ( strstr( Plat_GetCommandLineA(), "-r_emulate_gl" ) != NULL ) : false;
|
||||
static bool bIsEmulatingGL = ( Plat_GetCommandLineA() ) ? ( strstr( Plat_GetCommandLineA(), "-r_emulate_gl" ) != nullptr ) : false;
|
||||
return bIsEmulatingGL;
|
||||
}
|
||||
|
||||
FORCEINLINE bool IsOpenGL( void )
|
||||
{
|
||||
return IsPlatformOpenGL() || IsEmulatingGL();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Material system interface version
|
||||
//-----------------------------------------------------------------------------
|
||||
#define MATERIALSYSTEM_HARDWARECONFIG_INTERFACE_VERSION "MaterialSystemHardwareConfig012"
|
||||
|
||||
// HDRFIXME NOTE: must match common_ps_fxc.h
|
||||
enum HDRType_t
|
||||
{
|
||||
HDR_TYPE_NONE,
|
||||
HDR_TYPE_INTEGER,
|
||||
HDR_TYPE_FLOAT,
|
||||
};
|
||||
|
||||
// For now, vertex compression is simply "on or off" (for the sake of simplicity
|
||||
// and MeshBuilder perf.), but later we may support multiple flavours.
|
||||
enum VertexCompressionType_t
|
||||
|
||||
@@ -11,13 +11,6 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
// misyl: This is faster than doing fsincos these days.
|
||||
inline void SinCos( float radians, float *RESTRICT sine, float *RESTRICT cosine )
|
||||
{
|
||||
*sine = sinf( radians );
|
||||
*cosine = cosf( radians );
|
||||
}
|
||||
|
||||
#define FastRSqrt( x ) ( 1.0f / ::sqrtf( x ) )
|
||||
|
||||
#define FastCos ::cosf
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
|
||||
#include "mathlib/math_pfns.h"
|
||||
|
||||
#if defined(__i386__) || defined(_M_IX86)
|
||||
// For MMX intrinsics
|
||||
#include <xmmintrin.h>
|
||||
#endif
|
||||
|
||||
// XXX remove me
|
||||
#undef clamp
|
||||
@@ -108,7 +110,7 @@ FORCEINLINE float clamp( float val, float minVal, float maxVal )
|
||||
#else // DEBUG
|
||||
FORCEINLINE float clamp( float val, float minVal, float maxVal )
|
||||
{
|
||||
#if defined( PLATFORM_INTEL )
|
||||
#if defined(__i386__) || defined(_M_IX86)
|
||||
_mm_store_ss( &val,
|
||||
_mm_min_ss(
|
||||
_mm_max_ss(
|
||||
@@ -235,8 +237,7 @@ bool R_CullBoxSkipNear( const Vector& mins, const Vector& maxs, const Frustum_t
|
||||
|
||||
struct matrix3x4_t
|
||||
{
|
||||
matrix3x4_t() = default;
|
||||
|
||||
matrix3x4_t() {}
|
||||
matrix3x4_t(
|
||||
float m00, float m01, float m02, float m03,
|
||||
float m10, float m11, float m12, float m13,
|
||||
@@ -436,6 +437,42 @@ inline vec_t RoundInt (vec_t in)
|
||||
|
||||
int Q_log2(int val);
|
||||
|
||||
// Math routines done in optimized assembly math package routines
|
||||
void inline SinCos( float radians, float *sine, float *cosine )
|
||||
{
|
||||
#if defined( _X360 )
|
||||
XMScalarSinCos( sine, cosine, radians );
|
||||
#elif defined( PLATFORM_WINDOWS_PC32 )
|
||||
*sine = sin( radians );
|
||||
*cosine = cos( radians );
|
||||
|
||||
// The below implementation is actually slow
|
||||
/*_asm
|
||||
{
|
||||
fld DWORD PTR [radians]
|
||||
fsincos
|
||||
|
||||
mov edx, DWORD PTR [cosine]
|
||||
mov eax, DWORD PTR [sine]
|
||||
|
||||
fstp DWORD PTR [edx]
|
||||
fstp DWORD PTR [eax]
|
||||
}*/
|
||||
#elif defined( PLATFORM_WINDOWS_PC64 )
|
||||
*sine = sin( radians );
|
||||
*cosine = cos( radians );
|
||||
#elif defined( POSIX )
|
||||
sincosf(radians, sine, cosine);
|
||||
|
||||
// The below implementation is actually slow
|
||||
// double __cosr, __sinr;
|
||||
// __asm ("fsincos" : "=t" (__cosr), "=u" (__sinr) : "0" (radians));
|
||||
|
||||
// *sine = __sinr;
|
||||
// *cosine = __cosr;
|
||||
#endif
|
||||
}
|
||||
|
||||
#define SIN_TABLE_SIZE 256
|
||||
#define FTOIBIAS 12582912.f
|
||||
extern float SinCosTable[SIN_TABLE_SIZE];
|
||||
@@ -721,6 +758,12 @@ FORCEINLINE void V_swap( T& x, T& y )
|
||||
y = temp;
|
||||
}
|
||||
|
||||
// Do a swap with no temporary, this is necessary for bit-fields
|
||||
#define V_XOR_SWAP(x, y) \
|
||||
x ^= y; \
|
||||
y ^= x; \
|
||||
x ^= y
|
||||
|
||||
template <class T> FORCEINLINE T AVG(T a, T b)
|
||||
{
|
||||
return (a+b)/2;
|
||||
@@ -1174,7 +1217,7 @@ inline float SimpleSplineRemapValClamped( float val, float A, float B, float C,
|
||||
|
||||
FORCEINLINE int RoundFloatToInt(float f)
|
||||
{
|
||||
#if defined( PLATFORM_INTEL )
|
||||
#if defined(__i386__) || defined(_M_IX86) || defined( PLATFORM_WINDOWS_PC64 ) || defined(__x86_64__)
|
||||
return _mm_cvtss_si32(_mm_load_ss(&f));
|
||||
#elif defined( _X360 )
|
||||
#ifdef Assert
|
||||
@@ -1281,7 +1324,7 @@ FORCEINLINE int Float2Int( float a )
|
||||
inline int Floor2Int( float a )
|
||||
{
|
||||
int RetVal;
|
||||
#if defined( PLATFORM_INTEL )
|
||||
#if defined( __i386__ )
|
||||
// Convert to int and back, compare, subtract one if too big
|
||||
__m128 a128 = _mm_set_ss(a);
|
||||
RetVal = _mm_cvtss_si32(a128);
|
||||
@@ -1298,7 +1341,7 @@ inline int Floor2Int( float a )
|
||||
//-----------------------------------------------------------------------------
|
||||
FORCEINLINE unsigned int FastFToC( float c )
|
||||
{
|
||||
#if VALVE_LITTLE_ENDIAN
|
||||
#if defined( __i386__ )
|
||||
// IEEE float bit manipulation works for values between [0, 1<<23)
|
||||
union { float f; int i; } convert = { c*255.0f + (float)(1<<23) };
|
||||
return convert.i & 255;
|
||||
@@ -1313,7 +1356,7 @@ FORCEINLINE unsigned int FastFToC( float c )
|
||||
//-----------------------------------------------------------------------------
|
||||
FORCEINLINE int FastFloatToSmallInt( float c )
|
||||
{
|
||||
#if VALVE_LITTLE_ENDIAN
|
||||
#if defined( __i386__ )
|
||||
// IEEE float bit manipulation works for values between [-1<<22, 1<<22)
|
||||
union { float f; int i; } convert = { c + (float)(3<<22) };
|
||||
return (convert.i & ((1<<23)-1)) - (1<<22);
|
||||
@@ -1338,7 +1381,7 @@ inline float ClampToMsec( float in )
|
||||
inline int Ceil2Int( float a )
|
||||
{
|
||||
int RetVal;
|
||||
#if defined( PLATFORM_INTEL )
|
||||
#if defined( __i386__ )
|
||||
// Convert to int and back, compare, add one if too small
|
||||
__m128 a128 = _mm_load_ss(&a);
|
||||
RetVal = _mm_cvtss_si32(a128);
|
||||
@@ -2139,7 +2182,7 @@ inline bool CloseEnough( const Vector &a, const Vector &b, float epsilon = EQUAL
|
||||
// Fast compare
|
||||
// maxUlps is the maximum error in terms of Units in the Last Place. This
|
||||
// specifies how big an error we are willing to accept in terms of the value
|
||||
// of the least significant digit of the floating point number�s
|
||||
// of the least significant digit of the floating point number's
|
||||
// representation. maxUlps can also be interpreted in terms of how many
|
||||
// representable floats we are willing to accept between A and B.
|
||||
// This function will allow maxUlps-1 floats between A and B.
|
||||
|
||||
+51
-84
@@ -41,8 +41,6 @@ typedef union
|
||||
typedef fltx4 i32x4;
|
||||
typedef fltx4 u32x4;
|
||||
|
||||
typedef fltx4 bi32x4;
|
||||
|
||||
#elif ( defined( _X360 ) )
|
||||
|
||||
typedef union
|
||||
@@ -62,8 +60,6 @@ typedef __vector4 u32x4; // a VMX register; just a way of making it explicit tha
|
||||
typedef __m128 fltx4;
|
||||
typedef __m128 i32x4;
|
||||
typedef __m128 u32x4;
|
||||
typedef __m128 bi32x4;
|
||||
typedef __m128i shortx8;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -941,10 +937,10 @@ FORCEINLINE fltx4 UnsignedIntConvertToFltSIMD( const u32x4 &vSrcA )
|
||||
{
|
||||
Assert(0); /* pc has no such operation */
|
||||
fltx4 retval;
|
||||
SubFloat( retval, 0 ) = ( (float) SubInt( vSrcA, 0 ) );
|
||||
SubFloat( retval, 1 ) = ( (float) SubInt( vSrcA, 1 ) );
|
||||
SubFloat( retval, 2 ) = ( (float) SubInt( vSrcA, 2 ) );
|
||||
SubFloat( retval, 3 ) = ( (float) SubInt( vSrcA, 3 ) );
|
||||
SubFloat( retval, 0 ) = ( (float) SubInt( retval, 0 ) );
|
||||
SubFloat( retval, 1 ) = ( (float) SubInt( retval, 1 ) );
|
||||
SubFloat( retval, 2 ) = ( (float) SubInt( retval, 2 ) );
|
||||
SubFloat( retval, 3 ) = ( (float) SubInt( retval, 3 ) );
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -1735,26 +1731,16 @@ FORCEINLINE uint32 & SubInt( fltx4 & a, int idx )
|
||||
// Intel/SSE implementation
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
|
||||
FORCEINLINE void StoreAlignedSIMD( float * RESTRICT pSIMD, const fltx4 & a )
|
||||
{
|
||||
_mm_store_ps( pSIMD, a );
|
||||
}
|
||||
|
||||
FORCEINLINE void StoreAlignedSIMD( short * RESTRICT pSIMD, const shortx8 & a )
|
||||
{
|
||||
_mm_store_si128( (shortx8 *)pSIMD, a );
|
||||
}
|
||||
|
||||
FORCEINLINE void StoreUnalignedSIMD( float * RESTRICT pSIMD, const fltx4 & a )
|
||||
{
|
||||
_mm_storeu_ps( pSIMD, a );
|
||||
}
|
||||
|
||||
FORCEINLINE void StoreUnalignedSIMD( short* RESTRICT pSIMD, const shortx8& a )
|
||||
{
|
||||
_mm_storeu_si128((shortx8*)pSIMD, a);
|
||||
}
|
||||
|
||||
FORCEINLINE fltx4 RotateLeft( const fltx4 & a );
|
||||
FORCEINLINE fltx4 RotateLeft2( const fltx4 & a );
|
||||
@@ -1777,16 +1763,6 @@ FORCEINLINE fltx4 LoadAlignedSIMD( const void *pSIMD )
|
||||
return _mm_load_ps( reinterpret_cast< const float *> ( pSIMD ) );
|
||||
}
|
||||
|
||||
FORCEINLINE shortx8 LoadAlignedShortSIMD( const void *pSIMD )
|
||||
{
|
||||
return _mm_load_si128( reinterpret_cast< const shortx8 *> ( pSIMD ) );
|
||||
}
|
||||
|
||||
FORCEINLINE shortx8 LoadUnalignedShortSIMD( const void *pSIMD )
|
||||
{
|
||||
return _mm_loadu_si128( reinterpret_cast< const shortx8 *> ( pSIMD ) );
|
||||
}
|
||||
|
||||
FORCEINLINE fltx4 AndSIMD( const fltx4 & a, const fltx4 & b ) // a & b
|
||||
{
|
||||
return _mm_and_ps( a, b );
|
||||
@@ -1820,12 +1796,12 @@ FORCEINLINE fltx4 LoadAlignedSIMD( const VectorAligned & pSIMD )
|
||||
return SetWToZeroSIMD( LoadAlignedSIMD(pSIMD.Base()) );
|
||||
}
|
||||
|
||||
NO_ASAN_FORCEINLINE fltx4 LoadUnalignedSIMD( const void *pSIMD )
|
||||
FORCEINLINE fltx4 LoadUnalignedSIMD( const void *pSIMD )
|
||||
{
|
||||
return _mm_loadu_ps( reinterpret_cast<const float *>( pSIMD ) );
|
||||
}
|
||||
|
||||
NO_ASAN_FORCEINLINE fltx4 LoadUnaligned3SIMD( const void *pSIMD )
|
||||
FORCEINLINE fltx4 LoadUnaligned3SIMD( const void *pSIMD )
|
||||
{
|
||||
return _mm_loadu_ps( reinterpret_cast<const float *>( pSIMD ) );
|
||||
}
|
||||
@@ -2386,10 +2362,6 @@ FORCEINLINE void StoreUnalignedIntSIMD( int32 * RESTRICT pSIMD, const fltx4 & a
|
||||
_mm_storeu_ps( reinterpret_cast<float *>(pSIMD), a );
|
||||
}
|
||||
|
||||
FORCEINLINE fltx4 SignedIntConvertToFltSIMD( const shortx8 &vSrcA )
|
||||
{
|
||||
return _mm_cvtepi32_ps( vSrcA );
|
||||
}
|
||||
|
||||
// CHRISG: the conversion functions all seem to operate on m64's only...
|
||||
// how do we make them work here?
|
||||
@@ -2634,7 +2606,9 @@ public:
|
||||
return Vector( X(idx), Y(idx), Z(idx) );
|
||||
}
|
||||
|
||||
FourVectors() = default;
|
||||
FourVectors(void)
|
||||
{
|
||||
}
|
||||
|
||||
FourVectors( FourVectors const &src )
|
||||
{
|
||||
@@ -2650,37 +2624,40 @@ public:
|
||||
z=src.z;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// This garbage is still used by StudioRender, vrad, and etc, please get rid of it.
|
||||
/// LoadAndSwizzle - load 4 Vectors into a FourVectors, performing transpose op
|
||||
FORCEINLINE void LoadAndSwizzle(Vector const &a, Vector const &b, Vector const &c, Vector const &d)
|
||||
{
|
||||
// TransposeSIMD has large sub-expressions that the compiler can't eliminate on x360
|
||||
// use an unfolded implementation here
|
||||
#if _X360
|
||||
fltx4 tx = LoadUnalignedSIMD( &a.x );
|
||||
fltx4 ty = LoadUnalignedSIMD( &b.x );
|
||||
fltx4 tz = LoadUnalignedSIMD( &c.x );
|
||||
fltx4 tw = LoadUnalignedSIMD( &d.x );
|
||||
fltx4 r0 = __vmrghw(tx, tz);
|
||||
fltx4 r1 = __vmrghw(ty, tw);
|
||||
fltx4 r2 = __vmrglw(tx, tz);
|
||||
fltx4 r3 = __vmrglw(ty, tw);
|
||||
FORCEINLINE void LoadAndSwizzle(Vector const &a, Vector const &b, Vector const &c, Vector const &d)
|
||||
{
|
||||
// TransposeSIMD has large sub-expressions that the compiler can't eliminate on x360
|
||||
// use an unfolded implementation here
|
||||
#if _X360
|
||||
fltx4 tx = LoadUnalignedSIMD( &a.x );
|
||||
fltx4 ty = LoadUnalignedSIMD( &b.x );
|
||||
fltx4 tz = LoadUnalignedSIMD( &c.x );
|
||||
fltx4 tw = LoadUnalignedSIMD( &d.x );
|
||||
fltx4 r0 = __vmrghw(tx, tz);
|
||||
fltx4 r1 = __vmrghw(ty, tw);
|
||||
fltx4 r2 = __vmrglw(tx, tz);
|
||||
fltx4 r3 = __vmrglw(ty, tw);
|
||||
|
||||
x = __vmrghw(r0, r1);
|
||||
y = __vmrglw(r0, r1);
|
||||
z = __vmrghw(r2, r3);
|
||||
x = __vmrghw(r0, r1);
|
||||
y = __vmrglw(r0, r1);
|
||||
z = __vmrghw(r2, r3);
|
||||
#else
|
||||
x = LoadUnalignedSIMD( &( a.x ));
|
||||
y = LoadUnalignedSIMD( &( b.x ));
|
||||
z = LoadUnalignedSIMD( &( c.x ));
|
||||
fltx4 w = LoadUnalignedSIMD( &( d.x ));
|
||||
// now, matrix is:
|
||||
// x y z ?
|
||||
// x y z ?
|
||||
// x y z ?
|
||||
// x y z ?
|
||||
TransposeSIMD(x, y, z, w);
|
||||
x = LoadUnalignedSIMD( &( a.x ));
|
||||
y = LoadUnalignedSIMD( &( b.x ));
|
||||
z = LoadUnalignedSIMD( &( c.x ));
|
||||
fltx4 w = LoadUnalignedSIMD( &( d.x ));
|
||||
// now, matrix is:
|
||||
// x y z ?
|
||||
// x y z ?
|
||||
// x y z ?
|
||||
// x y z ?
|
||||
TransposeSIMD(x, y, z, w);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// LoadAndSwizzleAligned - load 4 Vectors into a FourVectors, performing transpose op.
|
||||
/// all 4 vectors must be 128 bit boundary
|
||||
@@ -2713,10 +2690,18 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
FORCEINLINE void LoadAndSwizzleAligned(VectorAligned const &a, VectorAligned const &b, VectorAligned const &c, VectorAligned const &d)
|
||||
{
|
||||
LoadAndSwizzleAligned( &a.x, &b.x, &c.x, &d.x );
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// This garbage is still used by StudioRender, vrad, and etc, please get rid of it.
|
||||
FORCEINLINE void LoadAndSwizzleAligned(Vector const &a, Vector const &b, Vector const &c, Vector const &d)
|
||||
{
|
||||
LoadAndSwizzleAligned( &a.x, &b.x, &c.x, &d.x );
|
||||
}
|
||||
#endif
|
||||
|
||||
/// return the squared length of all 4 vectors
|
||||
FORCEINLINE fltx4 length2(void) const
|
||||
@@ -2744,11 +2729,14 @@ public:
|
||||
(*this) *= ReciprocalSqrtSIMD(mag_sq); // *(1.0/sqrt(length^2))
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// This garbage is still used by StudioRender, vrad, and etc, please get rid of it.
|
||||
/// construct a FourVectors from 4 separate Vectors
|
||||
FORCEINLINE FourVectors(Vector const &a, Vector const &b, Vector const &c, Vector const &d)
|
||||
{
|
||||
LoadAndSwizzle(a,b,c,d);
|
||||
LoadAndSwizzle(a,b,c,d);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// construct a FourVectors from 4 separate Vectors
|
||||
FORCEINLINE FourVectors(VectorAligned const &a, VectorAligned const &b, VectorAligned const &c, VectorAligned const &d)
|
||||
@@ -3155,27 +3143,6 @@ FORCEINLINE fltx4 BiasSIMD( const fltx4 &val, const fltx4 &precalc_param )
|
||||
return DivSIMD( val, AddSIMD( MulSIMD( precalc_param, SubSIMD( Four_Ones, val ) ), Four_Ones ) );
|
||||
}
|
||||
|
||||
FORCEINLINE fltx4 LoadUnalignedFloatSIMD( const float *pFlt )
|
||||
{
|
||||
return _mm_load_ss(pFlt);
|
||||
}
|
||||
|
||||
inline const fltx4 Length3SIMD( const fltx4 vec )
|
||||
{
|
||||
fltx4 scLengthSqr = Dot3SIMD( vec, vec );
|
||||
bi32x4 isSignificant = CmpGtSIMD( scLengthSqr, Four_Epsilons );
|
||||
fltx4 scLengthInv = ReciprocalSqrtSIMD( scLengthSqr );
|
||||
return AndSIMD( isSignificant, MulSIMD( scLengthInv, scLengthSqr ) );
|
||||
}
|
||||
|
||||
inline const fltx4 Normalized3SIMD (const fltx4 vec)
|
||||
{
|
||||
fltx4 scLengthSqr = Dot3SIMD(vec,vec);
|
||||
bi32x4 isSignificant = CmpGtSIMD(scLengthSqr, Four_Epsilons);
|
||||
fltx4 scLengthInv = ReciprocalSqrtSIMD(scLengthSqr);
|
||||
return AndSIMD(isSignificant, MulSIMD(vec, scLengthInv));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Box/plane test
|
||||
// NOTE: The w component of emins + emaxs must be 1 for this to work
|
||||
|
||||
+9
-19
@@ -204,7 +204,6 @@ DBG_INTERFACE void _SpewInfo( SpewType_t type, const tchar* pFile, int line );
|
||||
DBG_INTERFACE SpewRetval_t _SpewMessage( PRINTF_FORMAT_STRING const tchar* pMsg, ... ) FMTFUNCTION( 1, 2 );
|
||||
DBG_INTERFACE SpewRetval_t _DSpewMessage( const tchar *pGroupName, int level, PRINTF_FORMAT_STRING const tchar* pMsg, ... ) FMTFUNCTION( 3, 4 );
|
||||
DBG_INTERFACE SpewRetval_t ColorSpewMessage( SpewType_t type, const Color *pColor, PRINTF_FORMAT_STRING const tchar* pMsg, ... ) FMTFUNCTION( 3, 4 );
|
||||
DBG_INTERFACE SpewRetval_t ColorSpewMessage2( SpewType_t type, const Color &color, PRINTF_FORMAT_STRING const tchar* pMsg, ... ) FMTFUNCTION( 3, 4 );
|
||||
DBG_INTERFACE void _ExitOnFatalAssert( const tchar* pFile, int line );
|
||||
DBG_INTERFACE bool ShouldUseNewAssertDialog();
|
||||
|
||||
@@ -566,11 +565,14 @@ public:
|
||||
#define SCOPE_MSG( msg )
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Utilities to suppress warnings or other annotations
|
||||
|
||||
// Note a variable is possibly unused to avoid analyzer warnings
|
||||
template< typename T > static FORCEINLINE void NoteUnused( const T& foo ) { return; }
|
||||
//-----------------------------------------------------------------------------
|
||||
// This macro predates universal static_assert support in our toolchains
|
||||
#define COMPILE_TIME_ASSERT( pred ) static_assert( pred, "Compile time assert constraint is not true: " #pred )
|
||||
|
||||
// ASSERT_INVARIANT used to be needed in order to allow COMPILE_TIME_ASSERTs at global
|
||||
// scope. However the new COMPILE_TIME_ASSERT macro supports that by default.
|
||||
#define ASSERT_INVARIANT( pred ) COMPILE_TIME_ASSERT( pred )
|
||||
|
||||
// NOTE: On GCC / Clang, assert_cast can sometimes fire even if the type is correct. We should just workaround these.
|
||||
// The situation where this would occur is
|
||||
@@ -607,7 +609,6 @@ FORCEINLINE void AssertValidReadWritePtr( const void* ptr, int count = 1 ) { _As
|
||||
#else
|
||||
|
||||
FORCEINLINE void AssertValidReadPtr( const void* ptr, int count = 1 ) { }
|
||||
FORCEINLINE void AssertValidReadPtr( const void* ptr, size_t count ) { }
|
||||
FORCEINLINE void AssertValidWritePtr( const void* ptr, int count = 1 ) { }
|
||||
FORCEINLINE void AssertValidReadWritePtr( const void* ptr, int count = 1 ) { }
|
||||
#define AssertValidStringPtr AssertValidReadPtr
|
||||
@@ -818,20 +819,9 @@ private:
|
||||
|
||||
|
||||
// This is horrible, but we don't want to integrate CS:GO new logging system atm.
|
||||
|
||||
#ifdef BUILDING_VPC
|
||||
#define Log_Warning( ignore, ... ) ::Warning( __VA_ARGS__ );
|
||||
#define Log_Msg( ignore, ... ) ::Msg( __VA_ARGS__ );
|
||||
#define Log_Warning( ignore, ... ) ::Msg( __VA_ARGS__ ); ::Log( __VA_ARGS__ );
|
||||
#define Log_Msg( ignore, ... ) ::Warning( __VA_ARGS__ ); ::Log( __VA_ARGS__ );
|
||||
#define Log_Error( ignore, ... ) ::Error( __VA_ARGS__ );
|
||||
#else
|
||||
#define Log_Warning( ignore, ... ) ::Warning( __VA_ARGS__ ); ::Log( __VA_ARGS__ );
|
||||
#define Log_Msg( ignore, ... ) ::Msg( __VA_ARGS__ ); ::Log( __VA_ARGS__ );
|
||||
#define Log_Error( ignore, ... ) ::Error( __VA_ARGS__ );
|
||||
#endif
|
||||
#define Log_Warning_Color( ignore, ... ) ::ColorSpewMessage2( SPEW_WARNING, __VA_ARGS__ );
|
||||
#define Log_Msg_Color( ignore, ... ) ::ColorSpewMessage2( SPEW_MESSAGE, __VA_ARGS__ );
|
||||
#define Log_Error_Color( ignore, ... ) ::ColorSpewMessage2( SPEW_ERROR, __VA_ARGS__ );
|
||||
#define DECLARE_LOGGING_CHANNEL( ... );
|
||||
#define DEFINE_LOGGING_CHANNEL_NO_TAGS( ... );
|
||||
#define Plat_FatalError( ... ) do { Log_Error( LOG_GENERAL, __VA_ARGS__ ); Plat_ExitProcess( EXIT_FAILURE ); } while( 0 )
|
||||
|
||||
|
||||
+181
-312
@@ -45,13 +45,15 @@
|
||||
#include "basetypes.h"
|
||||
#include "tier0/valve_off.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This macro predates universal static_assert support in our toolchains
|
||||
#define COMPILE_TIME_ASSERT( pred ) static_assert( pred, "Compile time assert constraint is not true: " #pred )
|
||||
|
||||
// ASSERT_INVARIANT used to be needed in order to allow COMPILE_TIME_ASSERTs at global
|
||||
// scope. However the new COMPILE_TIME_ASSERT macro supports that by default.
|
||||
#define ASSERT_INVARIANT( pred ) COMPILE_TIME_ASSERT( pred )
|
||||
#ifdef _DEBUG
|
||||
#if !defined( PLAT_COMPILE_TIME_ASSERT )
|
||||
#define PLAT_COMPILE_TIME_ASSERT( pred ) switch(0){case 0:case pred:;}
|
||||
#endif
|
||||
#else
|
||||
#if !defined( PLAT_COMPILE_TIME_ASSERT )
|
||||
#define PLAT_COMPILE_TIME_ASSERT( pred )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
@@ -69,37 +71,25 @@
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#ifdef _OSX
|
||||
#include <malloc/malloc.h>
|
||||
#else
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <new>
|
||||
#include <utility>
|
||||
|
||||
// need this for memset
|
||||
#include <string.h>
|
||||
|
||||
#include "tier0/valve_minmax_on.h" // GCC 4.2.2 headers screw up our min/max defs.
|
||||
|
||||
// Detect the architecture we are running on
|
||||
#if defined(__arm__) || defined( __aarch64__ ) || defined(_M_ARM) || defined(_M_ARM64)
|
||||
#define PLATFORM_ARM 1
|
||||
#elif defined(_M_X64) || defined(__x86_64__)
|
||||
#define PLATFORM_INTEL
|
||||
#define PLATFORM_X86 64
|
||||
#elif defined(_M_IX86) || defined(__i386__)
|
||||
#define PLATFORM_INTEL
|
||||
#define PLATFORM_X86 32
|
||||
#else
|
||||
#error Unknown processor architecture.
|
||||
#endif
|
||||
|
||||
#ifdef _RETAIL
|
||||
#define IsRetail() true
|
||||
#else
|
||||
#define IsRetail() false
|
||||
#endif
|
||||
|
||||
#if defined( DX_TO_GL_ABSTRACTION ) && defined( USE_DXVK )
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define IsRelease() false
|
||||
#define IsDebug() true
|
||||
@@ -123,7 +113,7 @@
|
||||
#define IsConsole() false
|
||||
#define IsX360() false
|
||||
#define IsPS3() false
|
||||
#define IS_WINDOWS_PC 1
|
||||
#define IS_WINDOWS_PC
|
||||
#define PLATFORM_WINDOWS_PC 1 // Windows PC
|
||||
#ifdef _WIN64
|
||||
#define IsPlatformWindowsPC64() true
|
||||
@@ -145,6 +135,12 @@
|
||||
#define IsX360() true
|
||||
#define IsPS3() false
|
||||
#endif
|
||||
// Adding IsPlatformOpenGL() to help fix a bunch of code that was using IsPosix() to infer if the DX->GL translation layer was being used.
|
||||
#if defined( DX_TO_GL_ABSTRACTION )
|
||||
#define IsPlatformOpenGL() true
|
||||
#else
|
||||
#define IsPlatformOpenGL() false
|
||||
#endif
|
||||
#elif defined(POSIX)
|
||||
#define IsPC() true
|
||||
#define IsWindows() false
|
||||
@@ -164,46 +160,11 @@
|
||||
#endif
|
||||
|
||||
#define IsPosix() true
|
||||
#define IsPlatformOpenGL() true
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
|
||||
#if PLATFORM_WINDOWS_PC
|
||||
|
||||
# if PLATFORM_64BITS
|
||||
# define PLATFORM_DIR "\\x64"
|
||||
# else
|
||||
# define PLATFORM_DIR ""
|
||||
# endif
|
||||
|
||||
//#elif PLATFORM_LINUX
|
||||
#elif LINUX
|
||||
|
||||
# if PLATFORM_64BITS
|
||||
# define PLATFORM_DIR "/linux64"
|
||||
# else
|
||||
# define PLATFORM_DIR ""
|
||||
# endif
|
||||
|
||||
//#elif PLATFORM_OSX
|
||||
#elif OSX
|
||||
|
||||
#if PLATFORM_ARM
|
||||
# define PLATFORM_DIR "/osxarm64"
|
||||
#else
|
||||
# if PLATFORM_64BITS
|
||||
# define PLATFORM_DIR "/osx64"
|
||||
# else
|
||||
# define PLATFORM_DIR ""
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
# error "Define a platform dir for me!"
|
||||
#endif
|
||||
|
||||
#define PLATFORM_BIN_DIR "bin" PLATFORM_DIR
|
||||
|
||||
typedef unsigned char uint8;
|
||||
typedef signed char int8;
|
||||
|
||||
@@ -231,13 +192,6 @@ typedef signed char int8;
|
||||
#define __m128 __vector4
|
||||
#endif
|
||||
|
||||
// Use this to specify that a function is an override of a virtual function.
|
||||
// This lets the compiler catch cases where you meant to override a virtual
|
||||
// function but you accidentally changed the function signature and created
|
||||
// an overloaded function. Usage in function declarations is like this:
|
||||
// int GetData() const OVERRIDE;
|
||||
#define OVERRIDE override
|
||||
|
||||
#else // _WIN32
|
||||
|
||||
typedef short int16;
|
||||
@@ -246,6 +200,17 @@ typedef signed char int8;
|
||||
typedef unsigned int uint32;
|
||||
typedef long long int64;
|
||||
typedef unsigned long long uint64;
|
||||
|
||||
// NOTE: Ripped from steamtypes.h
|
||||
// [u]int64 are actually defined as 'long long' and gcc 64-bit
|
||||
// doesn't automatically consider them the same as 'long int'.
|
||||
// Changing the types for [u]int64 is complicated by
|
||||
// there being many definitions, so we just
|
||||
// define a 'long int' here and use it in places that would
|
||||
// otherwise confuse the compiler.
|
||||
typedef long int lint64;
|
||||
typedef unsigned long int ulint64;
|
||||
|
||||
#ifdef PLATFORM_64BITS
|
||||
typedef long long intp;
|
||||
typedef unsigned long long uintp;
|
||||
@@ -253,37 +218,20 @@ typedef signed char int8;
|
||||
typedef int intp;
|
||||
typedef unsigned int uintp;
|
||||
#endif
|
||||
#ifndef USE_DXVK
|
||||
typedef void *HWND;
|
||||
#endif
|
||||
|
||||
// Avoid redefinition warnings if a previous header defines this.
|
||||
#undef OVERRIDE
|
||||
#if __cplusplus >= 201103L
|
||||
#define OVERRIDE override
|
||||
#if defined(__clang__)
|
||||
// warning: 'override' keyword is a C++11 extension [-Wc++11-extensions]
|
||||
// Disabling this warning is less intrusive than enabling C++11 extensions
|
||||
#pragma GCC diagnostic ignored "-Wc++11-extensions"
|
||||
#endif
|
||||
#else
|
||||
#define OVERRIDE
|
||||
#endif
|
||||
|
||||
// [u]int64 are actually defined as 'long long' and gcc 64-bit
|
||||
// doesn't automatically consider them the same as 'long int'.
|
||||
// Changing the types for [u]int64 is complicated by
|
||||
// there being many definitions, so we just
|
||||
// define a 'long int' here and use it in places that would
|
||||
// otherwise confuse the compiler.
|
||||
typedef long int lint64;
|
||||
typedef unsigned long int ulint64;
|
||||
|
||||
// include nullptr_t in global namespace
|
||||
typedef decltype( nullptr ) nullptr_t;
|
||||
|
||||
#endif // else _WIN32
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Set up platform type defines.
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -433,7 +381,7 @@ FIXME: Enable this when we no longer fear change =)
|
||||
#define __i386__ 1
|
||||
#endif
|
||||
|
||||
#elif defined( POSIX ) && !defined( USE_DXVK )
|
||||
#elif POSIX
|
||||
#if defined( OSX ) && defined( CARBON_WORKAROUND )
|
||||
#define DWORD unsigned int
|
||||
#else
|
||||
@@ -448,10 +396,6 @@ typedef void * HINSTANCE;
|
||||
|
||||
#endif // defined(_WIN32) && !defined(WINDED)
|
||||
|
||||
#ifdef POSIX
|
||||
typedef unsigned int *LPDWORD;
|
||||
#endif
|
||||
|
||||
#define MAX_FILEPATH 512
|
||||
|
||||
// Defines MAX_PATH
|
||||
@@ -494,10 +438,18 @@ typedef unsigned int *LPDWORD;
|
||||
#endif
|
||||
#define DebuggerBreakIfDebugging() if ( !Plat_IsInDebugSession() ) ; else DebuggerBreak()
|
||||
|
||||
#ifdef STAGING_ONLY
|
||||
#define DebuggerBreakIfDebugging_StagingOnly() if ( !Plat_IsInDebugSession() ) ; else DebuggerBreak()
|
||||
#else
|
||||
#define DebuggerBreakIfDebugging_StagingOnly()
|
||||
#endif
|
||||
|
||||
// Allows you to specify code that should only execute if we are in a staging build. Otherwise the code noops.
|
||||
#ifdef STAGING_ONLY
|
||||
#define STAGING_ONLY_EXEC( _exec ) do { _exec; } while (0)
|
||||
#else
|
||||
#define STAGING_ONLY_EXEC( _exec ) do { } while (0)
|
||||
#endif
|
||||
|
||||
// C functions for external declarations that call the appropriate C++ methods
|
||||
#ifndef EXPORT
|
||||
@@ -524,48 +476,34 @@ typedef unsigned int *LPDWORD;
|
||||
#define DECL_ALIGN(x) /* */
|
||||
#endif
|
||||
|
||||
#if defined( GNUC )
|
||||
// gnuc has the align decoration at the end
|
||||
#define ALIGN4
|
||||
#define ALIGN8
|
||||
#define ALIGN16
|
||||
#define ALIGN32
|
||||
#define ALIGN128
|
||||
#define ALIGN_N( _align_ )
|
||||
|
||||
#undef ALIGN16_POST
|
||||
#define ALIGN4_POST DECL_ALIGN(4)
|
||||
#define ALIGN8_POST DECL_ALIGN(8)
|
||||
#define ALIGN16_POST DECL_ALIGN(16)
|
||||
#define ALIGN32_POST DECL_ALIGN(32)
|
||||
#define ALIGN128_POST DECL_ALIGN(128)
|
||||
#define ALIGN_N_POST( _align_ ) DECL_ALIGN( _align_ )
|
||||
#else
|
||||
#ifdef _MSC_VER
|
||||
// MSVC has the align at the start of the struct
|
||||
// PS3 SNC supports both
|
||||
#define ALIGN4 DECL_ALIGN(4)
|
||||
#define ALIGN8 DECL_ALIGN(8)
|
||||
#define ALIGN16 DECL_ALIGN(16)
|
||||
#define ALIGN32 DECL_ALIGN(32)
|
||||
#define ALIGN128 DECL_ALIGN(128)
|
||||
#define ALIGN_N( _align_ ) DECL_ALIGN( _align_ )
|
||||
|
||||
#define ALIGN4_POST
|
||||
#define ALIGN8_POST
|
||||
#define ALIGN16_POST
|
||||
#define ALIGN32_POST
|
||||
#define ALIGN128_POST
|
||||
#define ALIGN_N_POST( _align_ )
|
||||
#endif
|
||||
#elif defined( GNUC )
|
||||
// gnuc has the align decoration at the end
|
||||
#define ALIGN4
|
||||
#define ALIGN8
|
||||
#define ALIGN16
|
||||
#define ALIGN32
|
||||
#define ALIGN128
|
||||
|
||||
// !!! NOTE: if you get a compile error here, you are using VALIGNOF on an abstract type :NOTE !!!
|
||||
#define VALIGNOF_PORTABLE( type ) ( sizeof( AlignOf_t<type> ) - sizeof( type ) )
|
||||
|
||||
#if defined( COMPILER_GCC ) || defined( COMPILER_MSVC )
|
||||
#define VALIGNOF( type ) __alignof( type )
|
||||
#define VALIGNOF_TEMPLATE_SAFE( type ) VALIGNOF_PORTABLE( type )
|
||||
#define ALIGN4_POST DECL_ALIGN(4)
|
||||
#define ALIGN8_POST DECL_ALIGN(8)
|
||||
#define ALIGN16_POST DECL_ALIGN(16)
|
||||
#define ALIGN32_POST DECL_ALIGN(32)
|
||||
#define ALIGN128_POST DECL_ALIGN(128)
|
||||
#else
|
||||
#error "PORT: Code only tested with MSVC! Must validate with new compiler, and use built-in keyword if available."
|
||||
#error
|
||||
#endif
|
||||
|
||||
// Pull in the /analyze code annotations.
|
||||
@@ -574,7 +512,7 @@ typedef unsigned int *LPDWORD;
|
||||
//-----------------------------------------------------------------------------
|
||||
// Convert int<-->pointer, avoiding 32/64-bit compiler warnings:
|
||||
//-----------------------------------------------------------------------------
|
||||
#define INT_TO_POINTER( i ) (void *)( ( i ) + (char *)NULL )
|
||||
#define INT_TO_POINTER( i ) (void *)( ( i ) + (char *)nullptr )
|
||||
#define POINTER_TO_INT( p ) ( (int)(uintp)( p ) )
|
||||
|
||||
|
||||
@@ -583,10 +521,10 @@ typedef unsigned int *LPDWORD;
|
||||
//-----------------------------------------------------------------------------
|
||||
#if defined( GNUC )
|
||||
#define stackalloc( _size ) alloca( ALIGN_VALUE( _size, 16 ) )
|
||||
#if defined(OSX)
|
||||
#define mallocsize( _p ) ( malloc_size( _p ) )
|
||||
#elif defined(_LINUX)
|
||||
#ifdef _LINUX
|
||||
#define mallocsize( _p ) ( malloc_usable_size( _p ) )
|
||||
#elif defined(OSX)
|
||||
#define mallocsize( _p ) ( malloc_size( _p ) )
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
@@ -686,18 +624,12 @@ typedef unsigned int *LPDWORD;
|
||||
#else
|
||||
#define FORCEINLINE inline __attribute__ ((always_inline))
|
||||
#endif
|
||||
#define FORCEINLINE_TEMPLATE FORCEINLINE
|
||||
// GCC 3.4.1 has a bug in supporting forced inline of templated functions
|
||||
// this macro lets us not force inlining in that case
|
||||
#define FORCEINLINE_TEMPLATE inline
|
||||
// #define __stdcall __attribute__ ((__stdcall__))
|
||||
#endif
|
||||
|
||||
#if ( defined(__SANITIZE_ADDRESS__) && __SANITIZE_ADDRESS__ )
|
||||
#define NO_ASAN __attribute__((no_sanitize("address")))
|
||||
#define NO_ASAN_FORCEINLINE NO_ASAN inline
|
||||
#else
|
||||
#define NO_ASAN
|
||||
#define NO_ASAN_FORCEINLINE FORCEINLINE
|
||||
#endif
|
||||
|
||||
// Force a function call site -not- to inlined. (useful for profiling)
|
||||
#define DONT_INLINE(a) (((int)(a)+1)?(a):(a))
|
||||
|
||||
@@ -774,14 +706,14 @@ typedef unsigned int *LPDWORD;
|
||||
#endif
|
||||
|
||||
#ifdef LINUX
|
||||
#pragma GCC diagnostic ignored "-Wconversion-null" // passing NULL to non-pointer argument 1
|
||||
#pragma GCC diagnostic ignored "-Wpointer-arith" // NULL used in arithmetic. Ie, vpanel == NULL where VPANEL is uint.
|
||||
#pragma GCC diagnostic ignored "-Wconversion-null" // passing nullptr to non-pointer argument 1
|
||||
#pragma GCC diagnostic ignored "-Wpointer-arith" // nullptr used in arithmetic. Ie, vpanel == nullptr where VPANEL is uint.
|
||||
#pragma GCC diagnostic ignored "-Wswitch" // enumeration values not handled in switch
|
||||
#endif
|
||||
|
||||
#ifdef OSX
|
||||
#pragma GCC diagnostic ignored "-Wconversion-null" // passing NULL to non-pointer argument 1
|
||||
#pragma GCC diagnostic ignored "-Wnull-arithmetic" // NULL used in arithmetic. Ie, vpanel == NULL where VPANEL is uint.
|
||||
#pragma GCC diagnostic ignored "-Wconversion-null" // passing nullptr to non-pointer argument 1
|
||||
#pragma GCC diagnostic ignored "-Wnull-arithmetic" // nullptr used in arithmetic. Ie, vpanel == nullptr where VPANEL is uint.
|
||||
#pragma GCC diagnostic ignored "-Wswitch-enum" // enumeration values not handled in switch
|
||||
#pragma GCC diagnostic ignored "-Wswitch" // enumeration values not handled in switch
|
||||
#endif
|
||||
@@ -819,22 +751,12 @@ typedef unsigned int *LPDWORD;
|
||||
#define _unlink unlink
|
||||
#define _access access
|
||||
#define _mkdir(dir) mkdir( dir, S_IRWXU | S_IRWXG | S_IRWXO )
|
||||
#define _wtoi(arg) wcstol(arg, NULL, 10)
|
||||
#define _wtoi64(arg) wcstoll(arg, NULL, 10)
|
||||
#define _wtoi(arg) wcstol(arg, nullptr, 10)
|
||||
#define _wtoi64(arg) wcstoll(arg, nullptr, 10)
|
||||
|
||||
#define _O_RDONLY O_RDONLY
|
||||
|
||||
#define _stat stat
|
||||
#define _open open
|
||||
#define _lseek lseek
|
||||
#define _read read
|
||||
#define _close close
|
||||
|
||||
#ifndef USE_DXVK
|
||||
typedef uintp HMODULE;
|
||||
typedef void *HANDLE;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// fsel
|
||||
@@ -980,7 +902,7 @@ inline T WordSwapC( T w )
|
||||
{
|
||||
uint16 temp;
|
||||
|
||||
COMPILE_TIME_ASSERT( sizeof( T ) == sizeof(uint16) );
|
||||
static_assert(sizeof(T) == sizeof(uint16));
|
||||
|
||||
temp = ((*((uint16 *)&w) & 0xff00) >> 8);
|
||||
temp |= ((*((uint16 *)&w) & 0x00ff) << 8);
|
||||
@@ -993,7 +915,7 @@ inline T DWordSwapC( T dw )
|
||||
{
|
||||
uint32 temp;
|
||||
|
||||
COMPILE_TIME_ASSERT( sizeof( T ) == sizeof(uint32) );
|
||||
static_assert(sizeof(T) == sizeof(uint32));
|
||||
|
||||
temp = *((uint32 *)&dw) >> 24;
|
||||
temp |= ((*((uint32 *)&dw) & 0x00FF0000) >> 8);
|
||||
@@ -1009,7 +931,7 @@ inline T QWordSwapC( T dw )
|
||||
// Assert sizes passed to this are already correct, otherwise
|
||||
// the cast to uint64 * below is unsafe and may have wrong results
|
||||
// or even crash.
|
||||
COMPILE_TIME_ASSERT( sizeof( dw ) == sizeof(uint64) );
|
||||
static_assert(sizeof(T) == sizeof(uint64));
|
||||
|
||||
uint64 temp;
|
||||
|
||||
@@ -1029,33 +951,76 @@ inline T QWordSwapC( T dw )
|
||||
// Fast swaps
|
||||
//-------------------------------------
|
||||
|
||||
#if defined _MSC_VER // MSVC (What about MinGW and Clang for Windows)
|
||||
#if defined( _X360 )
|
||||
|
||||
#define WordSwap(d) _byteswap_ushort(d)
|
||||
#define DWordSwap(d) ((uint32)(_byteswap_ulong( (unsigned long) d)))
|
||||
#define QWordSwap(d) _byteswap_uint64(d)
|
||||
#define WordSwap WordSwap360Intr
|
||||
#define DWordSwap DWordSwap360Intr
|
||||
|
||||
#elif defined __GNUC__ // GCC or Clang
|
||||
template <typename T>
|
||||
inline T WordSwap360Intr( T w )
|
||||
{
|
||||
T output;
|
||||
__storeshortbytereverse( w, 0, &output );
|
||||
return output;
|
||||
}
|
||||
|
||||
#define WordSwap(d) __builtin_bswap16(d)
|
||||
#define DWordSwap(d) __builtin_bswap32(d)
|
||||
#define QWordSwap(d) __builtin_bswap64(d)
|
||||
template <typename T>
|
||||
inline T DWordSwap360Intr( T dw )
|
||||
{
|
||||
T output;
|
||||
__storewordbytereverse( dw, 0, &output );
|
||||
return output;
|
||||
}
|
||||
|
||||
#else // N/A, native code
|
||||
#elif defined( _MSC_VER ) && !defined( PLATFORM_WINDOWS_PC64 )
|
||||
|
||||
#pragma message( "TODO: Using non-intrinsic byteswap functions..." )
|
||||
#define WordSwap WordSwapAsm
|
||||
#define DWordSwap DWordSwapAsm
|
||||
|
||||
#define WordSwap WordSwapC
|
||||
#define DWordSwap DWordSwapC
|
||||
#define QWordSwap QWordSwapC
|
||||
#pragma warning(push)
|
||||
#pragma warning (disable:4035) // no return value
|
||||
|
||||
template <typename T>
|
||||
inline T WordSwapAsm( T w )
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov ax, w
|
||||
xchg al, ah
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T DWordSwapAsm( T dw )
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, dw
|
||||
bswap eax
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning(pop)
|
||||
|
||||
#else
|
||||
|
||||
#define WordSwap WordSwapC
|
||||
#define DWordSwap DWordSwapC
|
||||
|
||||
#endif
|
||||
|
||||
// No ASM implementation for this yet
|
||||
#define QWordSwap QWordSwapC
|
||||
|
||||
//-------------------------------------
|
||||
// The typically used methods.
|
||||
//-------------------------------------
|
||||
|
||||
#if defined( _SGI_SOURCE ) || defined( _X360 )
|
||||
#define VALVE_BIG_ENDIAN 1
|
||||
#elif !defined(VALVE_LITTLE_ENDIAN)
|
||||
#define VALVE_LITTLE_ENDIAN 1
|
||||
#endif
|
||||
|
||||
// If a swapped float passes through the fpu, the bytes may get changed.
|
||||
// Prevent this by swapping floats as DWORDs.
|
||||
@@ -1140,26 +1105,17 @@ FORCEINLINE void StoreLittleDWord( unsigned long *base, unsigned int dwordIndex,
|
||||
__storewordbytereverse( dword, dwordIndex<<2, base );
|
||||
}
|
||||
#else
|
||||
FORCEINLINE uint32 LoadLittleDWord( uint32 *base, unsigned int dwordIndex )
|
||||
FORCEINLINE uint32 LoadLittleDWord( const uint32 *base, unsigned int dwordIndex )
|
||||
{
|
||||
return LittleDWord( base[dwordIndex] );
|
||||
}
|
||||
|
||||
FORCEINLINE void StoreLittleDWord( uint32 *base, unsigned int dwordIndex, uint32 dword )
|
||||
FORCEINLINE void StoreLittleDWord( uint32 *base, unsigned int dwordIndex, unsigned long dword )
|
||||
{
|
||||
base[dwordIndex] = LittleDWord(dword);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline uint64 CastPtrToUint64( const void* p )
|
||||
{
|
||||
return (uint64) ( (uintp) p );
|
||||
}
|
||||
|
||||
inline int64 CastPtrToInt64( const void* p )
|
||||
{
|
||||
return (int64) ( (uintp) p );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// DLL export for platform utilities
|
||||
@@ -1184,8 +1140,6 @@ inline int64 CastPtrToInt64( const void* p )
|
||||
|
||||
#endif // BUILD_AS_DLL
|
||||
|
||||
typedef class CSysModule* PlatModule_t;
|
||||
#define PLAT_MODULE_INVALID ((PlatModule_t)0)
|
||||
|
||||
// When in benchmark mode, the timer returns a simple incremented value each time you call it.
|
||||
//
|
||||
@@ -1203,23 +1157,11 @@ PLATFORM_INTERFACE void Plat_GetModuleFilename( char *pOut, int nMaxBytes );
|
||||
|
||||
PLATFORM_INTERFACE void Plat_ExitProcess( int nCode );
|
||||
|
||||
typedef uint32 strlen_t;
|
||||
|
||||
PLATFORM_INTERFACE void Plat_getwd( char *pWorkingDirectory, strlen_t nBufLen );
|
||||
|
||||
PLATFORM_INTERFACE void Plat_chdir( const char *pDir );
|
||||
|
||||
PLATFORM_INTERFACE char const * Plat_GetEnv( char const *pEnvVarName );
|
||||
|
||||
PLATFORM_INTERFACE bool Plat_GetExecutablePath( char *pBuff, strlen_t nBuff );
|
||||
|
||||
PLATFORM_INTERFACE bool Plat_FileExists( const char *pFileName );
|
||||
|
||||
//called to exit the process due to a fatal error. This allows for the application to handle providing a hook as well which can be called
|
||||
//before exiting
|
||||
PLATFORM_INTERFACE void Plat_ExitProcessWithError( int nCode, bool bGenerateMinidump = false );
|
||||
|
||||
//sets the callback that will be triggered by Plat_ExitProcessWithError. NULL is valid. The return value true indicates that
|
||||
//sets the callback that will be triggered by Plat_ExitProcessWithError. nullptr is valid. The return value true indicates that
|
||||
//the exit has been handled and no further processing should be performed. False will cause a minidump to be generated, and the process
|
||||
//to be terminated
|
||||
typedef bool (*ExitProcessWithErrorCBFn)( int nCode );
|
||||
@@ -1294,34 +1236,21 @@ struct CPUInformation
|
||||
|
||||
uint8 m_nLogicalProcessors; // Number op logical processors.
|
||||
uint8 m_nPhysicalProcessors; // Number of physical processors
|
||||
|
||||
|
||||
bool m_bSSE3 : 1,
|
||||
m_bSSSE3 : 1,
|
||||
m_bSSE4a : 1,
|
||||
m_bSSE41 : 1,
|
||||
m_bSSE42 : 1,
|
||||
m_bAVX : 1; // Is AVX supported?
|
||||
m_bSSE42 : 1;
|
||||
|
||||
int64 m_Speed; // In cycles per second.
|
||||
|
||||
char* m_szProcessorID; // Processor vendor Identification.
|
||||
tchar* m_szProcessorID; // Processor vendor Identification.
|
||||
|
||||
uint32 m_nModel;
|
||||
uint32 m_nFeatures[ 3 ];
|
||||
uint32 m_nFeatures[3];
|
||||
|
||||
char* m_szProcessorBrand; // Processor brand string, if available
|
||||
|
||||
uint32 m_nL1CacheSizeKb;
|
||||
uint32 m_nL1CacheDesc;
|
||||
uint32 m_nL2CacheSizeKb;
|
||||
uint32 m_nL2CacheDesc;
|
||||
uint32 m_nL3CacheSizeKb;
|
||||
uint32 m_nL3CacheDesc;
|
||||
|
||||
CPUInformation()
|
||||
{
|
||||
memset( this, 0, sizeof( *this ) );
|
||||
}
|
||||
CPUInformation(): m_Size(0){}
|
||||
};
|
||||
|
||||
// Have to return a pointer, not a reference, because references are not compatible with the
|
||||
@@ -1354,12 +1283,6 @@ PLATFORM_INTERFACE float GetCPUUsage();
|
||||
|
||||
PLATFORM_INTERFACE void GetCurrentDate( int *pDay, int *pMonth, int *pYear );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// D3DX
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define DXABSTRACT_BREAK_ON_ERROR() DebuggerBreak()
|
||||
|
||||
// ---------------------------------------------------------------------------------- //
|
||||
// Performance Monitoring Events - L2 stats etc...
|
||||
// ---------------------------------------------------------------------------------- //
|
||||
@@ -1536,6 +1459,22 @@ public:
|
||||
// Methods to invoke the constructor, copy constructor, and destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
template <class T, typename... Args>
|
||||
inline T* Construct( T* pMemory, Args&&... args )
|
||||
{
|
||||
#ifdef PVK2_DLL
|
||||
if constexpr ( sizeof...( Args ) == 0 ) {
|
||||
return ::new( pMemory ) T;
|
||||
}
|
||||
else {
|
||||
return ::new( pMemory ) T( std::forward<Args>( args )... );
|
||||
}
|
||||
#else
|
||||
return ::new( pMemory ) T( std::forward<Args>( args )... );
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
template <class T>
|
||||
inline T* Construct( T* pMemory )
|
||||
{
|
||||
@@ -1571,6 +1510,7 @@ inline T* Construct( T* pMemory, ARG1 a1, ARG2 a2, ARG3 a3, ARG4 a4, ARG5 a5 )
|
||||
{
|
||||
return reinterpret_cast<T*>(::new( pMemory ) T( a1, a2, a3, a4, a5 ));
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class T, class P>
|
||||
inline void ConstructOneArg( T* pMemory, P const& arg)
|
||||
@@ -1621,49 +1561,6 @@ inline void Destruct( T (*pMemory)[N] )
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T> struct RemoveReference_ { using Type = T; };
|
||||
template <typename T> struct RemoveReference_<T&> { using Type = T; };
|
||||
template <typename T> struct RemoveReference_<T&&> { using Type = T; };
|
||||
|
||||
template <typename T>
|
||||
using RemoveReference = typename RemoveReference_<T>::Type;
|
||||
|
||||
template <typename T>
|
||||
constexpr RemoveReference<T>&& Move(T&& arg)
|
||||
{
|
||||
return static_cast<RemoveReference<T>&&>(arg);
|
||||
}
|
||||
|
||||
// misyl: Shamelessly nicked from Source 2 =)
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// RunCodeAtScopeExit
|
||||
//
|
||||
// Example:
|
||||
// int *x = new int;
|
||||
// RunCodeAtScopeExit( delete x )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template <typename LambdaType>
|
||||
class CScopeGuardLambdaImpl
|
||||
{
|
||||
public:
|
||||
explicit CScopeGuardLambdaImpl( LambdaType&& lambda ) : m_lambda( Move( lambda ) ) { }
|
||||
~CScopeGuardLambdaImpl() { m_lambda(); }
|
||||
private:
|
||||
LambdaType m_lambda;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template <typename LambdaType>
|
||||
CScopeGuardLambdaImpl< LambdaType > MakeScopeGuardLambda( LambdaType&& lambda )
|
||||
{
|
||||
return CScopeGuardLambdaImpl< LambdaType >( Move( lambda ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define RunLambdaAtScopeExit2( VarName, ... ) const auto VarName( MakeScopeGuardLambda( __VA_ARGS__ ) ); (void)VarName
|
||||
#define RunLambdaAtScopeExit( ... ) RunLambdaAtScopeExit2( UNIQUE_ID, __VA_ARGS__ )
|
||||
#define RunCodeAtScopeExit( ... ) RunLambdaAtScopeExit( [&]() { __VA_ARGS__ ; } )
|
||||
|
||||
//
|
||||
// GET_OUTER()
|
||||
@@ -1809,7 +1706,7 @@ template <typename FUNCPTR_TYPE>
|
||||
class CDynamicFunction
|
||||
{
|
||||
public:
|
||||
CDynamicFunction( const char *pszModule, const char *pszName, FUNCPTR_TYPE pfnFallback = NULL )
|
||||
CDynamicFunction( const char *pszModule, const char *pszName, FUNCPTR_TYPE pfnFallback = nullptr )
|
||||
{
|
||||
m_pfn = pfnFallback;
|
||||
void *pAddr = Plat_GetProcAddress( pszModule, pszName );
|
||||
@@ -1819,7 +1716,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
operator bool() { return m_pfn != NULL; }
|
||||
operator bool() { return m_pfn != nullptr; }
|
||||
bool operator !() { return !m_pfn; }
|
||||
operator FUNCPTR_TYPE() { return m_pfn; }
|
||||
|
||||
@@ -1842,57 +1739,34 @@ PLATFORM_INTERFACE int Plat_GetWatchdogTime( void );
|
||||
typedef void (*Plat_WatchDogHandlerFunction_t)(void);
|
||||
PLATFORM_INTERFACE void Plat_SetWatchdogHandlerFunction( Plat_WatchDogHandlerFunction_t function );
|
||||
|
||||
/// Get some random bytes from a secure source of high entropy
|
||||
PLATFORM_INTERFACE void SecureRandomBytes( void *pDest, size_t cbSize );
|
||||
|
||||
// Use ValidateAlignment to sanity-check alignment usage when allocating arrays of an aligned type
|
||||
#define ALIGN_ASSERT( pred ) { COMPILE_TIME_ASSERT( pred ); }
|
||||
template< class T, int ALIGN >
|
||||
inline void ValidateAlignmentExplicit(void)
|
||||
{
|
||||
// Alignment must be a power of two
|
||||
ALIGN_ASSERT((ALIGN & (ALIGN - 1)) == 0);
|
||||
// Alignment must not imply gaps in the array (which the CUtlMemory pattern does not allow for)
|
||||
ALIGN_ASSERT(ALIGN <= sizeof(T));
|
||||
// Alignment must be a multiple of the size of the object type, or elements will *NOT* be aligned!
|
||||
ALIGN_ASSERT((sizeof(T) % ALIGN) == 0);
|
||||
// Alignment should be a multiple of the base alignment of T
|
||||
// ALIGN_ASSERT((ALIGN % VALIGNOF(T)) == 0);
|
||||
// Alignment must not be bigger than the maximum declared alignment used by DECLARE_ALIGNED_BYTE_ARRAY
|
||||
// (if you hit this, just add more powers of 2 below and increase this limit)
|
||||
ALIGN_ASSERT( ALIGN <= 128 );
|
||||
}
|
||||
template< class T > inline void ValidateAlignment(void) { ValidateAlignmentExplicit<T, VALIGNOF(T)>(); }
|
||||
|
||||
// Portable alternative to __alignof
|
||||
template<class T> struct AlignOf_t { AlignOf_t(){} AlignOf_t & operator=(const AlignOf_t &) { return *this; } byte b; T t; };
|
||||
|
||||
template < size_t NUM, class T, int ALIGN > struct AlignedByteArrayExplicit_t{};
|
||||
template < size_t NUM, class T > struct AlignedByteArray_t : public AlignedByteArrayExplicit_t< NUM, T, VALIGNOF_TEMPLATE_SAFE(T) > {};
|
||||
|
||||
#define DECLARE_ALIGNED_BYTE_ARRAY( ALIGN ) \
|
||||
template < size_t NUM, class T > \
|
||||
struct ALIGN_N( ALIGN ) AlignedByteArrayExplicit_t< NUM, T, ALIGN > \
|
||||
{ \
|
||||
/* NOTE: verify alignment in the constructor (which may be wrong if this is heap-allocated, for ALIGN > MEMALLOC_MAX_AUTO_ALIGN) */ \
|
||||
AlignedByteArrayExplicit_t() { if ( (ALIGN-1) & (size_t)this ) DebuggerBreakIfDebugging(); } \
|
||||
T * Base( void ) { ValidateAlignmentExplicit<T,ALIGN>(); return (T *)&m_Data; } \
|
||||
const T * Base( void ) const { ValidateAlignmentExplicit<T,ALIGN>(); return (const T *)&m_Data; } \
|
||||
private: \
|
||||
byte m_Data[ NUM*sizeof( T ) ]; \
|
||||
} ALIGN_N_POST( ALIGN );
|
||||
|
||||
DECLARE_ALIGNED_BYTE_ARRAY(1);
|
||||
DECLARE_ALIGNED_BYTE_ARRAY(2);
|
||||
DECLARE_ALIGNED_BYTE_ARRAY(4);
|
||||
DECLARE_ALIGNED_BYTE_ARRAY(8);
|
||||
DECLARE_ALIGNED_BYTE_ARRAY(16);
|
||||
DECLARE_ALIGNED_BYTE_ARRAY(32);
|
||||
DECLARE_ALIGNED_BYTE_ARRAY(64);
|
||||
DECLARE_ALIGNED_BYTE_ARRAY(128);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
enum PlatMessageBoxType
|
||||
{
|
||||
PlatMsgBoxType_OK,
|
||||
PlatMsgBoxType_OKCANCEL,
|
||||
PlatMsgBoxType_YESNO,
|
||||
};
|
||||
|
||||
enum PlatMessageBoxSeverity
|
||||
{
|
||||
PlatMsgBoxSeverity_Info,
|
||||
PlatMsgBoxSeverity_Warn,
|
||||
PlatMsgBoxSeverity_Error
|
||||
};
|
||||
|
||||
enum PlatMessageBoxReturnValue
|
||||
{
|
||||
PlatMsgBoxRet_Invalid = -1,
|
||||
PlatMsgBoxRet_OK = 0,
|
||||
PlatMsgBoxRet_Cancel = 1,
|
||||
PlatMsgBoxRet_Yes = 2,
|
||||
PlatMsgBoxRet_No = 3
|
||||
};
|
||||
|
||||
PLATFORM_INTERFACE int Plat_MessageBox( const char *pTitle, const char *pMessage, PlatMessageBoxType type, PlatMessageBoxSeverity severity );
|
||||
|
||||
#include "tier0/valve_on.h"
|
||||
|
||||
#if defined(TIER0_DLL_EXPORT)
|
||||
@@ -1903,10 +1777,5 @@ extern "C" int V_tier0_stricmp(const char *s1, const char *s2 );
|
||||
#define strcmpi(s1,s2) V_tier0_stricmp( s1, s2 )
|
||||
#endif
|
||||
|
||||
// misyl: Pad the lightmap atlas so we can do r_lightmap_bicubic and have bicubic sampling as an option.
|
||||
// I am so evil I put it in platform.h, but a few places need this define and I didn't want to think too
|
||||
// hard about it.
|
||||
// >:)
|
||||
#define PAD_LIGHTMAP_ATLAS 1
|
||||
|
||||
#endif /* PLATFORM_H */
|
||||
|
||||
+33
-37
@@ -26,13 +26,13 @@
|
||||
#include "Color.h"
|
||||
|
||||
#define FOR_EACH_SUBKEY( kvRoot, kvSubKey ) \
|
||||
for ( KeyValues * kvSubKey = kvRoot->GetFirstSubKey(); kvSubKey != NULL; kvSubKey = kvSubKey->GetNextKey() )
|
||||
for ( KeyValues * kvSubKey = kvRoot->GetFirstSubKey(); kvSubKey != nullptr; kvSubKey = kvSubKey->GetNextKey() )
|
||||
|
||||
#define FOR_EACH_TRUE_SUBKEY( kvRoot, kvSubKey ) \
|
||||
for ( KeyValues * kvSubKey = kvRoot->GetFirstTrueSubKey(); kvSubKey != NULL; kvSubKey = kvSubKey->GetNextTrueSubKey() )
|
||||
for ( KeyValues * kvSubKey = kvRoot->GetFirstTrueSubKey(); kvSubKey != nullptr; kvSubKey = kvSubKey->GetNextTrueSubKey() )
|
||||
|
||||
#define FOR_EACH_VALUE( kvRoot, kvValue ) \
|
||||
for ( KeyValues * kvValue = kvRoot->GetFirstValue(); kvValue != NULL; kvValue = kvValue->GetNextValue() )
|
||||
for ( KeyValues * kvValue = kvRoot->GetFirstValue(); kvValue != nullptr; kvValue = kvValue->GetNextValue() )
|
||||
|
||||
class IBaseFileSystem;
|
||||
class CUtlBuffer;
|
||||
@@ -83,8 +83,8 @@ public:
|
||||
//
|
||||
// AutoDelete class to automatically free the keyvalues.
|
||||
// Simply construct it with the keyvalues you allocated and it will free them when falls out of scope.
|
||||
// When you decide that keyvalues shouldn't be deleted call Assign(NULL) on it.
|
||||
// If you constructed AutoDelete(NULL) you can later assign the keyvalues to be deleted with Assign(pKeyValues).
|
||||
// When you decide that keyvalues shouldn't be deleted call Assign(nullptr) on it.
|
||||
// If you constructed AutoDelete(nullptr) you can later assign the keyvalues to be deleted with Assign(pKeyValues).
|
||||
// You can also pass temporary KeyValues object as an argument to a function by wrapping it into KeyValues::AutoDelete
|
||||
// instance: call_my_function( KeyValues::AutoDelete( new KeyValues( "test" ) ) )
|
||||
//
|
||||
@@ -120,14 +120,14 @@ public:
|
||||
// File access. Set UsesEscapeSequences true, if resource file/buffer uses Escape Sequences (eg \n, \t)
|
||||
void UsesEscapeSequences(bool state); // default false
|
||||
void UsesConditionals(bool state); // default true
|
||||
bool LoadFromFile( IBaseFileSystem *filesystem, const char *resourceName, const char *pathID = NULL, bool refreshCache = false );
|
||||
bool SaveToFile( IBaseFileSystem *filesystem, const char *resourceName, const char *pathID = NULL, bool sortKeys = false, bool bAllowEmptyString = false, bool bCacheResult = false );
|
||||
bool LoadFromFile( IBaseFileSystem *filesystem, const char *resourceName, const char *pathID = nullptr, bool refreshCache = false );
|
||||
bool SaveToFile( IBaseFileSystem *filesystem, const char *resourceName, const char *pathID = nullptr, bool sortKeys = false, bool bAllowEmptyString = false, bool bCacheResult = false );
|
||||
|
||||
// Read from a buffer... Note that the buffer must be null terminated
|
||||
bool LoadFromBuffer( char const *resourceName, const char *pBuffer, IBaseFileSystem* pFileSystem = NULL, const char *pPathID = NULL );
|
||||
bool LoadFromBuffer( char const *resourceName, const char *pBuffer, IBaseFileSystem* pFileSystem = nullptr, const char *pPathID = nullptr );
|
||||
|
||||
// Read from a utlbuffer...
|
||||
bool LoadFromBuffer( char const *resourceName, CUtlBuffer &buf, IBaseFileSystem* pFileSystem = NULL, const char *pPathID = NULL );
|
||||
bool LoadFromBuffer( char const *resourceName, CUtlBuffer &buf, IBaseFileSystem* pFileSystem = nullptr, const char *pPathID = nullptr );
|
||||
|
||||
// Find a keyValue, create it if it is not found.
|
||||
// Set bCreate to true to create the key if it doesn't already exist (which ensures a valid pointer will be returned)
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
const KeyValues *GetNextKey() const { return m_pPeer; } // returns the next subkey
|
||||
|
||||
void SetNextKey( KeyValues * pDat);
|
||||
KeyValues *FindLastSubKey(); // returns the LAST subkey in the list. This requires a linked list iteration to find the key. Returns NULL if we don't have any children
|
||||
KeyValues *FindLastSubKey(); // returns the LAST subkey in the list. This requires a linked list iteration to find the key. Returns nullptr if we don't have any children
|
||||
|
||||
//
|
||||
// These functions can be used to treat it like a true key/values tree instead of
|
||||
@@ -165,20 +165,20 @@ public:
|
||||
KeyValues* GetFirstTrueSubKey();
|
||||
KeyValues* GetNextTrueSubKey();
|
||||
|
||||
KeyValues* GetFirstValue(); // When you get a value back, you can use GetX and pass in NULL to get the value.
|
||||
KeyValues* GetFirstValue(); // When you get a value back, you can use GetX and pass in nullptr to get the value.
|
||||
KeyValues* GetNextValue();
|
||||
|
||||
|
||||
// Data access
|
||||
int GetInt( const char *keyName = NULL, int defaultValue = 0 );
|
||||
uint64 GetUint64( const char *keyName = NULL, uint64 defaultValue = 0 );
|
||||
float GetFloat( const char *keyName = NULL, float defaultValue = 0.0f );
|
||||
const char *GetString( const char *keyName = NULL, const char *defaultValue = "" );
|
||||
const wchar_t *GetWString( const char *keyName = NULL, const wchar_t *defaultValue = L"" );
|
||||
void *GetPtr( const char *keyName = NULL, void *defaultValue = (void*)0 );
|
||||
bool GetBool( const char *keyName = NULL, bool defaultValue = false, bool* optGotDefault = NULL );
|
||||
Color GetColor( const char *keyName = NULL /* default value is all black */);
|
||||
bool IsEmpty(const char *keyName = NULL);
|
||||
int GetInt( const char *keyName = nullptr, int defaultValue = 0 );
|
||||
uint64 GetUint64( const char *keyName = nullptr, uint64 defaultValue = 0 );
|
||||
float GetFloat( const char *keyName = nullptr, float defaultValue = 0.0f );
|
||||
const char *GetString( const char *keyName = nullptr, const char *defaultValue = "" );
|
||||
const wchar_t *GetWString( const char *keyName = nullptr, const wchar_t *defaultValue = L"" );
|
||||
void *GetPtr( const char *keyName = nullptr, void *defaultValue = (void*)0 );
|
||||
bool GetBool( const char *keyName = nullptr, bool defaultValue = false, bool* optGotDefault = nullptr );
|
||||
Color GetColor( const char *keyName = nullptr /* default value is all black */);
|
||||
bool IsEmpty(const char *keyName = nullptr);
|
||||
|
||||
// Data access
|
||||
int GetInt( int keySymbol, int defaultValue = 0 );
|
||||
@@ -242,7 +242,7 @@ public:
|
||||
TYPE_UINT64,
|
||||
TYPE_NUMTYPES,
|
||||
};
|
||||
types_t GetDataType(const char *keyName = NULL);
|
||||
types_t GetDataType(const char *keyName = nullptr);
|
||||
|
||||
// Virtual deletion function - ensures that KeyValues object is deleted from correct heap
|
||||
void deleteThis();
|
||||
@@ -263,14 +263,13 @@ public:
|
||||
|
||||
void AddSubkeyUsingKnownLastChild( KeyValues *pSubKey, KeyValues *pLastChild );
|
||||
|
||||
KeyValues* CreateKey( const char *keyName );
|
||||
|
||||
private:
|
||||
KeyValues( KeyValues& ); // prevent copy constructor being used
|
||||
|
||||
// prevent delete being called except through deleteThis()
|
||||
~KeyValues();
|
||||
|
||||
KeyValues* CreateKey( const char *keyName );
|
||||
|
||||
/// Create a child key, given that we know which child is currently the last child.
|
||||
/// This avoids the O(N^2) behaviour when adding children in sequence to KV,
|
||||
@@ -341,7 +340,6 @@ private:
|
||||
// Function pointers that will determine which mode we are in
|
||||
static int (*s_pfGetSymbolForString)( const char *name, bool bCreate );
|
||||
static const char *(*s_pfGetStringForSymbol)( int symbol );
|
||||
static CKeyValuesGrowableStringTable *s_pGrowableStringTable;
|
||||
|
||||
public:
|
||||
// Functions that invoke the default behavior
|
||||
@@ -372,7 +370,7 @@ enum KeyValuesUnpackDestinationTypes_t
|
||||
|
||||
#define UNPACK_FIXED( kname, kdefault, dtype, ofs ) { kname, kdefault, dtype, ofs, 0 }
|
||||
#define UNPACK_VARIABLE( kname, kdefault, dtype, ofs, sz ) { kname, kdefault, dtype, ofs, sz }
|
||||
#define UNPACK_END_MARKER { NULL, NULL, UNPACK_TYPE_FLOAT, 0 }
|
||||
#define UNPACK_END_MARKER { nullptr, nullptr, UNPACK_TYPE_FLOAT, 0 }
|
||||
|
||||
struct KeyValuesUnpackStructure
|
||||
{
|
||||
@@ -389,31 +387,31 @@ struct KeyValuesUnpackStructure
|
||||
inline int KeyValues::GetInt( int keySymbol, int defaultValue )
|
||||
{
|
||||
KeyValues *dat = FindKey( keySymbol );
|
||||
return dat ? dat->GetInt( (const char *)NULL, defaultValue ) : defaultValue;
|
||||
return dat ? dat->GetInt( (const char *)nullptr, defaultValue ) : defaultValue;
|
||||
}
|
||||
|
||||
inline float KeyValues::GetFloat( int keySymbol, float defaultValue )
|
||||
{
|
||||
KeyValues *dat = FindKey( keySymbol );
|
||||
return dat ? dat->GetFloat( (const char *)NULL, defaultValue ) : defaultValue;
|
||||
return dat ? dat->GetFloat( (const char *)nullptr, defaultValue ) : defaultValue;
|
||||
}
|
||||
|
||||
inline const char *KeyValues::GetString( int keySymbol, const char *defaultValue )
|
||||
{
|
||||
KeyValues *dat = FindKey( keySymbol );
|
||||
return dat ? dat->GetString( (const char *)NULL, defaultValue ) : defaultValue;
|
||||
return dat ? dat->GetString( (const char *)nullptr, defaultValue ) : defaultValue;
|
||||
}
|
||||
|
||||
inline const wchar_t *KeyValues::GetWString( int keySymbol, const wchar_t *defaultValue )
|
||||
{
|
||||
KeyValues *dat = FindKey( keySymbol );
|
||||
return dat ? dat->GetWString( (const char *)NULL, defaultValue ) : defaultValue;
|
||||
return dat ? dat->GetWString( (const char *)nullptr, defaultValue ) : defaultValue;
|
||||
}
|
||||
|
||||
inline void *KeyValues::GetPtr( int keySymbol, void *defaultValue )
|
||||
{
|
||||
KeyValues *dat = FindKey( keySymbol );
|
||||
return dat ? dat->GetPtr( (const char *)NULL, defaultValue ) : defaultValue;
|
||||
return dat ? dat->GetPtr( (const char *)nullptr, defaultValue ) : defaultValue;
|
||||
}
|
||||
|
||||
inline Color KeyValues::GetColor( int keySymbol )
|
||||
@@ -429,8 +427,6 @@ inline bool KeyValues::IsEmpty( int keySymbol )
|
||||
return dat ? dat->IsEmpty( ) : true;
|
||||
}
|
||||
|
||||
bool IsSteamDeck( bool bTrulyHardwareOnly = false );
|
||||
|
||||
bool EvaluateConditional( const char *str );
|
||||
|
||||
class CUtlSortVectorKeyValuesByName
|
||||
@@ -457,9 +453,9 @@ public:
|
||||
class IKeyValuesDumpContextAsText : public IKeyValuesDumpContext
|
||||
{
|
||||
public:
|
||||
virtual bool KvBeginKey( KeyValues *pKey, int nIndentLevel );
|
||||
virtual bool KvWriteValue( KeyValues *pValue, int nIndentLevel );
|
||||
virtual bool KvEndKey( KeyValues *pKey, int nIndentLevel );
|
||||
bool KvBeginKey( KeyValues *pKey, int nIndentLevel ) override;
|
||||
bool KvWriteValue( KeyValues *pValue, int nIndentLevel ) override;
|
||||
bool KvEndKey( KeyValues *pKey, int nIndentLevel ) override;
|
||||
|
||||
public:
|
||||
virtual bool KvWriteIndent( int nIndentLevel );
|
||||
@@ -473,8 +469,8 @@ public:
|
||||
CKeyValuesDumpContextAsDevMsg( int nDeveloperLevel = 1 ) : m_nDeveloperLevel( nDeveloperLevel ) {}
|
||||
|
||||
public:
|
||||
virtual bool KvBeginKey( KeyValues *pKey, int nIndentLevel );
|
||||
virtual bool KvWriteText( char const *szText );
|
||||
bool KvBeginKey( KeyValues *pKey, int nIndentLevel ) override;
|
||||
bool KvWriteText( char const *szText ) override;
|
||||
|
||||
protected:
|
||||
int m_nDeveloperLevel;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//======= Copyright © 2005, , Valve Corporation, All rights reserved. =========
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Variant Pearson Hash general purpose hashing algorithm described
|
||||
// by Cargill in C++ Report 1994. Generates a 16-bit result.
|
||||
@@ -37,31 +37,6 @@ FORCEINLINE uint32 HashIntAlternate( uint32 n)
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
inline uint64 HashUint64( uint64 s )
|
||||
{
|
||||
// Thomas Wang hash, http://www.concentric.net/~ttwang/tech/inthash.htm
|
||||
s = ( ~s ) + ( s << 21 ); // s = (s << 21) - s - 1;
|
||||
s = s ^ ( s >> 24 );
|
||||
s = ( s + ( s << 3 ) ) + ( s << 8 ); // s * 265
|
||||
s = s ^ ( s >> 14 );
|
||||
s = ( s + ( s << 2 ) ) + ( s << 4 ); // s * 21
|
||||
s = s ^ ( s >> 28 );
|
||||
s = s + ( s << 31 );
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
inline intp HashIntp( intp s )
|
||||
{
|
||||
#ifdef PLATFORM_64BITS
|
||||
COMPILE_TIME_ASSERT( sizeof( s ) == sizeof( uint64 ) );
|
||||
return ( intp )HashUint64( ( uint64 )s );
|
||||
#else
|
||||
return HashInt( s );
|
||||
#endif
|
||||
}
|
||||
|
||||
inline unsigned HashIntConventional( const int n ) // faster but less effective
|
||||
{
|
||||
// first byte
|
||||
@@ -124,58 +99,6 @@ template<> inline unsigned HashItem<char *>(char * const &pszKey )
|
||||
return HashString( pszKey );
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct HashMapFunctor_t
|
||||
{
|
||||
typedef uint32 TargetType;
|
||||
TargetType operator()(const T &key) const
|
||||
{
|
||||
return HashItem( key );
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(_MINIMUM_BUILD_)
|
||||
template<>
|
||||
struct HashMapFunctor_t<char *>
|
||||
{
|
||||
typedef uint32 TargetType;
|
||||
TargetType operator()(const char *key) const
|
||||
{
|
||||
return HashString( key );
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct HashMapFunctor_t<const char *>
|
||||
{
|
||||
typedef uint32 TargetType;
|
||||
TargetType operator()(const char *key) const
|
||||
{
|
||||
return HashString( key );
|
||||
}
|
||||
};
|
||||
|
||||
struct HashMapFunctor_tStringCaseless
|
||||
{
|
||||
typedef uint32 TargetType;
|
||||
TargetType operator()(const char *key) const
|
||||
{
|
||||
return HashStringCaseless( key );
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct HashMapFunctor_tUnpaddedStructure
|
||||
{
|
||||
typedef uint32 TargetType;
|
||||
TargetType operator()(const T &key) const
|
||||
{
|
||||
return HashItemAsBytes( key );
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -186,7 +109,6 @@ uint32 MurmurHash2( const void * key, int len, uint32 seed );
|
||||
|
||||
// return murmurhash2 of a downcased string
|
||||
uint32 MurmurHash2LowerCase( char const *pString, uint32 nSeed );
|
||||
uint32 MurmurHash2LowerCase( char const *pString, int len, uint32 nSeed );
|
||||
|
||||
uint64 MurmurHash64( const void * key, int len, uint32 seed );
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ public:
|
||||
const char *m_pName;
|
||||
|
||||
InterfaceReg *m_pNext; // For the global list.
|
||||
static InterfaceReg *s_pInterfaceRegs;
|
||||
};
|
||||
|
||||
// Use this to expose an interface that can have multiple instances.
|
||||
|
||||
+84
-68
@@ -104,7 +104,7 @@ public:
|
||||
|
||||
// Is element index valid?
|
||||
bool IsValidIndex( int i ) const;
|
||||
static int InvalidIndex();
|
||||
constexpr static int InvalidIndex();
|
||||
|
||||
// Adds an element, uses default constructor
|
||||
int AddToHead();
|
||||
@@ -177,12 +177,19 @@ public:
|
||||
void RemoveMultipleFromTail(int num); // removes num elements from tail
|
||||
void RemoveAll(); // doesn't deallocate memory
|
||||
|
||||
#ifdef PVK2_DLL
|
||||
void PopTail(); // Removes last element from tail, doesn't deallocate memory
|
||||
#endif
|
||||
|
||||
// Memory deallocation
|
||||
void Purge();
|
||||
|
||||
// Purges the list and calls delete on each element in it.
|
||||
void PurgeAndDeleteElements();
|
||||
|
||||
// Purges the list and calls delete[] on each element in it.
|
||||
void PurgeAndDeleteArrayElements();
|
||||
|
||||
// Compacts the vector to the number of elements actually in use
|
||||
void Compact();
|
||||
|
||||
@@ -193,7 +200,7 @@ public:
|
||||
|
||||
void Sort( int (__cdecl *pfnCompare)(const T *, const T *) );
|
||||
|
||||
void Shuffle( IUniformRandomStream* pSteam = NULL );
|
||||
void Shuffle( IUniformRandomStream* pSteam = nullptr );
|
||||
|
||||
// Call this to quickly sort non-contiguously allocated vectors
|
||||
void InPlaceQuickSort( int (__cdecl *pfnCompare)(const T *, const T *) );
|
||||
@@ -388,25 +395,25 @@ public:
|
||||
|
||||
T& operator[]( int i )
|
||||
{
|
||||
Assert( IsValidIndex( i ) );
|
||||
DevAssertFatal( IsValidIndex( i ) );
|
||||
return m_pData->m_Elements[i];
|
||||
}
|
||||
|
||||
const T& operator[]( int i ) const
|
||||
{
|
||||
Assert( IsValidIndex( i ) );
|
||||
DevAssertFatal( IsValidIndex( i ) );
|
||||
return m_pData->m_Elements[i];
|
||||
}
|
||||
|
||||
T& Element( int i )
|
||||
{
|
||||
Assert( IsValidIndex( i ) );
|
||||
DevAssertFatal( IsValidIndex( i ) );
|
||||
return m_pData->m_Elements[i];
|
||||
}
|
||||
|
||||
const T& Element( int i ) const
|
||||
{
|
||||
Assert( IsValidIndex( i ) );
|
||||
DevAssertFatal( IsValidIndex( i ) );
|
||||
return m_pData->m_Elements[i];
|
||||
}
|
||||
|
||||
@@ -474,7 +481,7 @@ public:
|
||||
|
||||
void FastRemove( int elem )
|
||||
{
|
||||
Assert( IsValidIndex(elem) );
|
||||
DevAssertFatal( IsValidIndex( elem ) );
|
||||
|
||||
// Global scope to resolve conflict with Scaleform 4.0
|
||||
::Destruct( &Element(elem) );
|
||||
@@ -667,7 +674,19 @@ inline CUtlVector<T, A>& CUtlVector<T, A>::operator=( const CUtlVector<T, A> &ot
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef STAGING_ONLY
|
||||
inline void StagingUtlVectorBoundsCheck( int i, int size )
|
||||
{
|
||||
if ( (unsigned)i >= (unsigned)size )
|
||||
{
|
||||
Msg( "Array access error: %d / %d\n", i, size );
|
||||
DebuggerBreak();
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#define StagingUtlVectorBoundsCheck( _i, _size )
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// element access
|
||||
@@ -676,7 +695,7 @@ template< typename T, class A >
|
||||
inline T& CUtlVector<T, A>::operator[]( int i )
|
||||
{
|
||||
// Do an inline unsigned check for maximum debug-build performance.
|
||||
Assert( (unsigned)i < (unsigned)m_Size );
|
||||
DevAssertFatal( (unsigned)i < (unsigned)m_Size );
|
||||
StagingUtlVectorBoundsCheck( i, m_Size );
|
||||
return m_Memory[ i ];
|
||||
}
|
||||
@@ -685,7 +704,7 @@ template< typename T, class A >
|
||||
inline const T& CUtlVector<T, A>::operator[]( int i ) const
|
||||
{
|
||||
// Do an inline unsigned check for maximum debug-build performance.
|
||||
Assert( (unsigned)i < (unsigned)m_Size );
|
||||
DevAssertFatal( (unsigned)i < (unsigned)m_Size );
|
||||
StagingUtlVectorBoundsCheck( i, m_Size );
|
||||
return m_Memory[ i ];
|
||||
}
|
||||
@@ -694,7 +713,7 @@ template< typename T, class A >
|
||||
inline T& CUtlVector<T, A>::Element( int i )
|
||||
{
|
||||
// Do an inline unsigned check for maximum debug-build performance.
|
||||
Assert( (unsigned)i < (unsigned)m_Size );
|
||||
DevAssertFatal( (unsigned)i < (unsigned)m_Size );
|
||||
StagingUtlVectorBoundsCheck( i, m_Size );
|
||||
return m_Memory[ i ];
|
||||
}
|
||||
@@ -703,7 +722,7 @@ template< typename T, class A >
|
||||
inline const T& CUtlVector<T, A>::Element( int i ) const
|
||||
{
|
||||
// Do an inline unsigned check for maximum debug-build performance.
|
||||
Assert( (unsigned)i < (unsigned)m_Size );
|
||||
DevAssertFatal( (unsigned)i < (unsigned)m_Size );
|
||||
StagingUtlVectorBoundsCheck( i, m_Size );
|
||||
return m_Memory[ i ];
|
||||
}
|
||||
@@ -711,7 +730,7 @@ inline const T& CUtlVector<T, A>::Element( int i ) const
|
||||
template< typename T, class A >
|
||||
inline T& CUtlVector<T, A>::Head()
|
||||
{
|
||||
Assert( m_Size > 0 );
|
||||
DevAssertFatal( m_Size > 0 );
|
||||
StagingUtlVectorBoundsCheck( 0, m_Size );
|
||||
return m_Memory[ 0 ];
|
||||
}
|
||||
@@ -719,7 +738,7 @@ inline T& CUtlVector<T, A>::Head()
|
||||
template< typename T, class A >
|
||||
inline const T& CUtlVector<T, A>::Head() const
|
||||
{
|
||||
Assert( m_Size > 0 );
|
||||
DevAssertFatal( m_Size > 0 );
|
||||
StagingUtlVectorBoundsCheck( 0, m_Size );
|
||||
return m_Memory[ 0 ];
|
||||
}
|
||||
@@ -727,7 +746,7 @@ inline const T& CUtlVector<T, A>::Head() const
|
||||
template< typename T, class A >
|
||||
inline T& CUtlVector<T, A>::Tail()
|
||||
{
|
||||
Assert( m_Size > 0 );
|
||||
DevAssertFatal( m_Size > 0 );
|
||||
StagingUtlVectorBoundsCheck( 0, m_Size );
|
||||
return m_Memory[ m_Size - 1 ];
|
||||
}
|
||||
@@ -735,7 +754,7 @@ inline T& CUtlVector<T, A>::Tail()
|
||||
template< typename T, class A >
|
||||
inline const T& CUtlVector<T, A>::Tail() const
|
||||
{
|
||||
Assert( m_Size > 0 );
|
||||
DevAssertFatal( m_Size > 0 );
|
||||
StagingUtlVectorBoundsCheck( 0, m_Size );
|
||||
return m_Memory[ m_Size - 1 ];
|
||||
}
|
||||
@@ -753,14 +772,14 @@ inline int CUtlVector<T, A>::Size() const
|
||||
template< typename T, class A >
|
||||
inline T& CUtlVector<T, A>::Random()
|
||||
{
|
||||
Assert( m_Size > 0 );
|
||||
DevAssertFatal( m_Size > 0 );
|
||||
return m_Memory[ RandomInt( 0, m_Size - 1 ) ];
|
||||
}
|
||||
|
||||
template< typename T, class A >
|
||||
inline const T& CUtlVector<T, A>::Random() const
|
||||
{
|
||||
Assert( m_Size > 0 );
|
||||
DevAssertFatal( m_Size > 0 );
|
||||
return m_Memory[ RandomInt( 0, m_Size - 1 ) ];
|
||||
}
|
||||
|
||||
@@ -822,7 +841,7 @@ inline bool CUtlVector<T, A>::IsValidIndex( int i ) const
|
||||
// Returns in invalid index
|
||||
//-----------------------------------------------------------------------------
|
||||
template< typename T, class A >
|
||||
inline int CUtlVector<T, A>::InvalidIndex()
|
||||
inline constexpr int CUtlVector<T, A>::InvalidIndex()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -1035,7 +1054,7 @@ template< typename T, class A >
|
||||
int CUtlVector<T, A>::InsertBefore( int elem )
|
||||
{
|
||||
// Can insert at the end
|
||||
Assert( (elem == Count()) || IsValidIndex(elem) );
|
||||
DevAssertFatal( ( elem == Count() ) || IsValidIndex( elem ) );
|
||||
|
||||
GrowVector();
|
||||
ShiftElementsRight(elem);
|
||||
@@ -1043,7 +1062,6 @@ int CUtlVector<T, A>::InsertBefore( int elem )
|
||||
return elem;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Adds an element, uses copy constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1051,7 +1069,7 @@ template< typename T, class A >
|
||||
inline int CUtlVector<T, A>::AddToHead( const T& src )
|
||||
{
|
||||
// Can't insert something that's in the list... reallocation may hose us
|
||||
Assert( (Base() == NULL) || (&src < Base()) || (&src >= (Base() + Count()) ) );
|
||||
DevAssertFatal( ( Base() == nullptr ) || ( &src < Base() ) || ( &src >= ( Base() + Count() ) ) );
|
||||
return InsertBefore( 0, src );
|
||||
}
|
||||
|
||||
@@ -1059,7 +1077,7 @@ template< typename T, class A >
|
||||
inline int CUtlVector<T, A>::AddToTail( const T& src )
|
||||
{
|
||||
// Can't insert something that's in the list... reallocation may hose us
|
||||
Assert( (Base() == NULL) || (&src < Base()) || (&src >= (Base() + Count()) ) );
|
||||
DevAssertFatal( ( Base() == nullptr ) || ( &src < Base() ) || ( &src >= ( Base() + Count() ) ) );
|
||||
return InsertBefore( m_Size, src );
|
||||
}
|
||||
|
||||
@@ -1067,7 +1085,7 @@ template< typename T, class A >
|
||||
inline int CUtlVector<T, A>::InsertAfter( int elem, const T& src )
|
||||
{
|
||||
// Can't insert something that's in the list... reallocation may hose us
|
||||
Assert( (Base() == NULL) || (&src < Base()) || (&src >= (Base() + Count()) ) );
|
||||
DevAssertFatal( ( Base() == nullptr ) || ( &src < Base() ) || ( &src >= ( Base() + Count() ) ) );
|
||||
return InsertBefore( elem + 1, src );
|
||||
}
|
||||
|
||||
@@ -1075,10 +1093,10 @@ template< typename T, class A >
|
||||
int CUtlVector<T, A>::InsertBefore( int elem, const T& src )
|
||||
{
|
||||
// Can't insert something that's in the list... reallocation may hose us
|
||||
Assert( (Base() == NULL) || (&src < Base()) || (&src >= (Base() + Count()) ) );
|
||||
DevAssertFatal( ( Base() == nullptr ) || ( &src < Base() ) || ( &src >= ( Base() + Count() ) ) );
|
||||
|
||||
// Can insert at the end
|
||||
Assert( (elem == Count()) || IsValidIndex(elem) );
|
||||
DevAssertFatal( ( elem == Count() ) || IsValidIndex( elem ) );
|
||||
|
||||
GrowVector();
|
||||
ShiftElementsRight(elem);
|
||||
@@ -1106,7 +1124,7 @@ template< typename T, class A >
|
||||
inline int CUtlVector<T, A>::AddMultipleToTail( int num, const T *pToCopy )
|
||||
{
|
||||
// Can't insert something that's in the list... reallocation may hose us
|
||||
Assert( (Base() == NULL) || !pToCopy || (pToCopy + num <= Base()) || (pToCopy >= (Base() + Count()) ) );
|
||||
DevAssertFatal( ( Base() == nullptr ) || !pToCopy || ( pToCopy + num <= Base() ) || ( pToCopy >= ( Base() + Count() ) ) );
|
||||
|
||||
return InsertMultipleBefore( m_Size, num, pToCopy );
|
||||
}
|
||||
@@ -1143,7 +1161,7 @@ template< typename T, class A >
|
||||
void CUtlVector<T, A>::CopyArray( const T *pArray, int size )
|
||||
{
|
||||
// Can't insert something that's in the list... reallocation may hose us
|
||||
Assert( (Base() == NULL) || !pArray || (Base() >= (pArray + size)) || (pArray >= (Base() + Count()) ) );
|
||||
DevAssertFatal( ( Base() == nullptr ) || !pArray || ( Base() >= ( pArray + size ) ) || ( pArray >= ( Base() + Count() ) ) );
|
||||
|
||||
SetSize( size );
|
||||
for( int i=0; i < size; i++ )
|
||||
@@ -1166,7 +1184,7 @@ void CUtlVector<T, A>::Swap( CUtlVector< T, A > &vec )
|
||||
template< typename T, class A >
|
||||
int CUtlVector<T, A>::AddVectorToTail( CUtlVector const &src )
|
||||
{
|
||||
Assert( &src != this );
|
||||
DevAssertFatal( &src != this );
|
||||
|
||||
int base = Count();
|
||||
|
||||
@@ -1190,7 +1208,7 @@ inline int CUtlVector<T, A>::InsertMultipleBefore( int elem, int num )
|
||||
return elem;
|
||||
|
||||
// Can insert at the end
|
||||
Assert( (elem == Count()) || IsValidIndex(elem) );
|
||||
DevAssertFatal( ( elem == Count() ) || IsValidIndex( elem ) );
|
||||
|
||||
GrowVector(num);
|
||||
ShiftElementsRight( elem, num );
|
||||
@@ -1211,7 +1229,7 @@ inline int CUtlVector<T, A>::InsertMultipleBefore( int elem, int num, const T *p
|
||||
return elem;
|
||||
|
||||
// Can insert at the end
|
||||
Assert( (elem == Count()) || IsValidIndex(elem) );
|
||||
DevAssertFatal( ( elem == Count() ) || IsValidIndex( elem ) );
|
||||
|
||||
GrowVector(num);
|
||||
ShiftElementsRight( elem, num );
|
||||
@@ -1293,7 +1311,7 @@ bool CUtlVector<T, A>::HasElement( const T& src ) const
|
||||
template< typename T, class A >
|
||||
void CUtlVector<T, A>::FastRemove( int elem )
|
||||
{
|
||||
Assert( IsValidIndex(elem) );
|
||||
DevAssertFatal( IsValidIndex( elem ) );
|
||||
|
||||
// Global scope to resolve conflict with Scaleform 4.0
|
||||
::Destruct( &Element(elem) );
|
||||
@@ -1341,8 +1359,8 @@ bool CUtlVector<T, A>::FindAndFastRemove( const T& src )
|
||||
template< typename T, class A >
|
||||
void CUtlVector<T, A>::RemoveMultiple( int elem, int num )
|
||||
{
|
||||
Assert( elem >= 0 );
|
||||
Assert( elem + num <= Count() );
|
||||
DevAssertFatal( elem >= 0 );
|
||||
DevAssertFatal( elem + num <= Count() );
|
||||
|
||||
// Global scope to resolve conflict with Scaleform 4.0
|
||||
for (int i = elem + num; --i >= elem; )
|
||||
@@ -1355,7 +1373,7 @@ void CUtlVector<T, A>::RemoveMultiple( int elem, int num )
|
||||
template< typename T, class A >
|
||||
void CUtlVector<T, A>::RemoveMultipleFromHead( int num )
|
||||
{
|
||||
Assert( num <= Count() );
|
||||
DevAssertFatal( num <= Count() );
|
||||
|
||||
// Global scope to resolve conflict with Scaleform 4.0
|
||||
for (int i = num; --i >= 0; )
|
||||
@@ -1368,7 +1386,7 @@ void CUtlVector<T, A>::RemoveMultipleFromHead( int num )
|
||||
template< typename T, class A >
|
||||
void CUtlVector<T, A>::RemoveMultipleFromTail( int num )
|
||||
{
|
||||
Assert( num <= Count() );
|
||||
DevAssertFatal( num <= Count() );
|
||||
|
||||
// Global scope to resolve conflict with Scaleform 4.0
|
||||
for (int i = m_Size-num; i < m_Size; i++)
|
||||
@@ -1389,6 +1407,16 @@ void CUtlVector<T, A>::RemoveAll()
|
||||
m_Size = 0;
|
||||
}
|
||||
|
||||
#ifdef PVK2_DLL
|
||||
template< typename T, class A >
|
||||
void CUtlVector<T, A>::PopTail()
|
||||
{
|
||||
DevAssertFatal( Count() > 0 );
|
||||
|
||||
::Destruct( &Element( m_Size - 1 ) );
|
||||
--m_Size;
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Memory deallocation
|
||||
@@ -1413,6 +1441,17 @@ inline void CUtlVector<T, A>::PurgeAndDeleteElements()
|
||||
Purge();
|
||||
}
|
||||
|
||||
template < typename T, class A >
|
||||
inline void CUtlVector<T, A>::PurgeAndDeleteArrayElements()
|
||||
{
|
||||
for ( int i = 0; i < m_Size; i++ )
|
||||
{
|
||||
delete[] Element(i);
|
||||
}
|
||||
|
||||
Purge();
|
||||
}
|
||||
|
||||
template< typename T, class A >
|
||||
inline void CUtlVector<T, A>::Compact()
|
||||
{
|
||||
@@ -1453,9 +1492,18 @@ public:
|
||||
|
||||
};
|
||||
|
||||
template <class T> class CUtlVectorAutoPurgeArray : public CUtlVector< T, CUtlMemory< T, int > >
|
||||
{
|
||||
public:
|
||||
~CUtlVectorAutoPurgeArray( void )
|
||||
{
|
||||
this->PurgeAndDeleteArrayElements();
|
||||
}
|
||||
};
|
||||
|
||||
// easy string list class with dynamically allocated strings. For use with V_SplitString, etc.
|
||||
// Frees the dynamic strings in destructor.
|
||||
class CUtlStringList : public CUtlVectorAutoPurge< char *>
|
||||
class CUtlStringList : public CUtlVectorAutoPurgeArray< char *>
|
||||
{
|
||||
public:
|
||||
void CopyAndAddToTail( char const *pString ) // clone the string and add to the end
|
||||
@@ -1501,17 +1549,12 @@ private:
|
||||
class CSplitString: public CUtlVector<char*, CUtlMemory<char*, int> >
|
||||
{
|
||||
public:
|
||||
CSplitString() { m_szBuffer = nullptr; }
|
||||
CSplitString(const char *pString, const char *pSeparator);
|
||||
CSplitString(const char *pString, const char **pSeparators, int nSeparators);
|
||||
~CSplitString();
|
||||
//
|
||||
// NOTE: If you want to make Construct() public and implement Purge() here, you'll have to free m_szBuffer there
|
||||
//
|
||||
|
||||
void Set( const char *pString, const char **pSeparators, int nSeparators );
|
||||
void Set( const char *pString, const char *pSeparator );
|
||||
|
||||
private:
|
||||
void Construct(const char *pString, const char **pSeparators, int nSeparators);
|
||||
void PurgeAndDeleteElements();
|
||||
@@ -1519,32 +1562,5 @@ private:
|
||||
char *m_szBuffer; // a copy of original string, with '\0' instead of separators
|
||||
};
|
||||
|
||||
inline void CSplitString::Set( const char* pString, const char* pSeparator )
|
||||
{
|
||||
Set( pString, &pSeparator, 1 );
|
||||
}
|
||||
|
||||
inline void CSplitString::Set( const char *pString, const char **pSeparators, int nSeparators )
|
||||
{
|
||||
if ( m_szBuffer )
|
||||
delete[] m_szBuffer;
|
||||
Construct( pString, pSeparators, nSeparators );
|
||||
}
|
||||
|
||||
// A fixed growable vector that's castable to CUtlVector
|
||||
template< class T, size_t FIXED_SIZE >
|
||||
class CUtlVectorFixedGrowableCompat : public CUtlVector< T >
|
||||
{
|
||||
typedef CUtlVector< T > BaseClass;
|
||||
|
||||
public:
|
||||
// constructor, destructor
|
||||
CUtlVectorFixedGrowableCompat(int growSize = 0) : BaseClass(nullptr, FIXED_SIZE, growSize)
|
||||
{
|
||||
this->m_Memory.m_pMemory = m_FixedMemory.Base();
|
||||
}
|
||||
|
||||
AlignedByteArray_t< FIXED_SIZE, T > m_FixedMemory;
|
||||
};
|
||||
|
||||
#endif // CCVECTOR_H
|
||||
|
||||
+131
-155
@@ -11,8 +11,8 @@
|
||||
#elif defined(POSIX)
|
||||
#include <wchar.h> // wcslen()
|
||||
#define _alloca alloca
|
||||
#define _wtoi(arg) wcstol(arg, NULL, 10)
|
||||
#define _wtoi64(arg) wcstoll(arg, NULL, 10)
|
||||
#define _wtoi(arg) wcstol(arg, nullptr, 10)
|
||||
#define _wtoi64(arg) wcstoll(arg, nullptr, 10)
|
||||
#endif
|
||||
|
||||
#include <KeyValues.h>
|
||||
@@ -39,7 +39,7 @@ static const char * s_LastFileLoadingFrom = "unknown"; // just needed for error
|
||||
// Statics for the growable string table
|
||||
int (*KeyValues::s_pfGetSymbolForString)( const char *name, bool bCreate ) = &KeyValues::GetSymbolForStringClassic;
|
||||
const char *(*KeyValues::s_pfGetStringForSymbol)( int symbol ) = &KeyValues::GetStringForSymbolClassic;
|
||||
CKeyValuesGrowableStringTable *KeyValues::s_pGrowableStringTable = NULL;
|
||||
static CKeyValuesGrowableStringTable *s_pGrowableStringTable = nullptr;
|
||||
|
||||
#define KEYVALUES_TOKEN_SIZE 4096
|
||||
static char s_pTokenBuf[KEYVALUES_TOKEN_SIZE];
|
||||
@@ -50,7 +50,7 @@ static char s_pTokenBuf[KEYVALUES_TOKEN_SIZE];
|
||||
|
||||
// a simple class to keep track of a stack of valid parsed symbols
|
||||
const int MAX_ERROR_STACK = 64;
|
||||
class CKeyValuesErrorStack
|
||||
static class CKeyValuesErrorStack
|
||||
{
|
||||
public:
|
||||
CKeyValuesErrorStack() : m_pFilename("NULL"), m_errorIndex(0), m_maxErrorIndex(0) {}
|
||||
@@ -231,12 +231,12 @@ class CKeyValuesGrowableStringTable
|
||||
public:
|
||||
// Constructor
|
||||
CKeyValuesGrowableStringTable() :
|
||||
m_hashLookup( 2048, 0, 0, m_Functor, m_Functor ),
|
||||
#ifdef PLATFORM_64BITS
|
||||
m_vecStrings( 0, 4 * 512 * 1024 )
|
||||
#else
|
||||
m_vecStrings( 0, 512 * 1024 )
|
||||
#endif
|
||||
, m_hashLookup( 2048, 0, 0, m_Functor, m_Functor )
|
||||
{
|
||||
m_vecStrings.AddToTail( '\0' );
|
||||
}
|
||||
@@ -285,7 +285,7 @@ private:
|
||||
class CLookupFunctor
|
||||
{
|
||||
public:
|
||||
CLookupFunctor() : m_pchCurString( NULL ), m_pchCurBase( NULL ) {}
|
||||
CLookupFunctor() : m_pchCurString( nullptr ), m_pchCurBase( nullptr ) {}
|
||||
|
||||
// Sets what we are currently inserting or looking for.
|
||||
void SetCurString( const char *pchCurString ) { m_pchCurString = pchCurString; }
|
||||
@@ -329,7 +329,7 @@ void KeyValues::SetUseGrowableStringTable( bool bUseGrowableTable )
|
||||
s_pfGetStringForSymbol = &(KeyValues::GetStringForSymbolGrowable);
|
||||
s_pfGetSymbolForString = &(KeyValues::GetSymbolForStringGrowable);
|
||||
|
||||
if ( NULL == s_pGrowableStringTable )
|
||||
if ( nullptr == s_pGrowableStringTable )
|
||||
{
|
||||
s_pGrowableStringTable = new CKeyValuesGrowableStringTable;
|
||||
}
|
||||
@@ -340,7 +340,7 @@ void KeyValues::SetUseGrowableStringTable( bool bUseGrowableTable )
|
||||
s_pfGetSymbolForString = &(KeyValues::GetSymbolForStringClassic);
|
||||
|
||||
delete s_pGrowableStringTable;
|
||||
s_pGrowableStringTable = NULL;
|
||||
s_pGrowableStringTable = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,13 +451,13 @@ void KeyValues::Init()
|
||||
m_iKeyName = INVALID_KEY_SYMBOL;
|
||||
m_iDataType = TYPE_NONE;
|
||||
|
||||
m_pSub = NULL;
|
||||
m_pPeer = NULL;
|
||||
m_pChain = NULL;
|
||||
m_pSub = nullptr;
|
||||
m_pPeer = nullptr;
|
||||
m_pChain = nullptr;
|
||||
|
||||
m_sValue = NULL;
|
||||
m_wsValue = NULL;
|
||||
m_pValue = NULL;
|
||||
m_sValue = nullptr;
|
||||
m_wsValue = nullptr;
|
||||
m_pValue = nullptr;
|
||||
|
||||
m_bHasEscapeSequences = false;
|
||||
m_bEvaluateConditionals = true;
|
||||
@@ -482,25 +482,25 @@ KeyValues::~KeyValues()
|
||||
void KeyValues::RemoveEverything()
|
||||
{
|
||||
KeyValues *dat;
|
||||
KeyValues *datNext = NULL;
|
||||
for ( dat = m_pSub; dat != NULL; dat = datNext )
|
||||
KeyValues *datNext = nullptr;
|
||||
for ( dat = m_pSub; dat != nullptr; dat = datNext )
|
||||
{
|
||||
datNext = dat->m_pPeer;
|
||||
dat->m_pPeer = NULL;
|
||||
dat->m_pPeer = nullptr;
|
||||
delete dat;
|
||||
}
|
||||
|
||||
for ( dat = m_pPeer; dat && dat != this; dat = datNext )
|
||||
{
|
||||
datNext = dat->m_pPeer;
|
||||
dat->m_pPeer = NULL;
|
||||
dat->m_pPeer = nullptr;
|
||||
delete dat;
|
||||
}
|
||||
|
||||
delete [] m_sValue;
|
||||
m_sValue = NULL;
|
||||
m_sValue = nullptr;
|
||||
delete [] m_wsValue;
|
||||
m_wsValue = NULL;
|
||||
m_wsValue = nullptr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -510,7 +510,7 @@ void KeyValues::RemoveEverything()
|
||||
|
||||
void KeyValues::RecursiveSaveToFile( CUtlBuffer& buf, int indentLevel, bool sortKeys /*= false*/, bool bAllowEmptyString /*= false*/ )
|
||||
{
|
||||
RecursiveSaveToFile( NULL, FILESYSTEM_INVALID_HANDLE, &buf, indentLevel, sortKeys, bAllowEmptyString );
|
||||
RecursiveSaveToFile( nullptr, FILESYSTEM_INVALID_HANDLE, &buf, indentLevel, sortKeys, bAllowEmptyString );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -541,14 +541,14 @@ const char *KeyValues::ReadToken( CUtlBuffer &buf, bool &wasQuoted, bool &wasCon
|
||||
wasConditional = false;
|
||||
|
||||
if ( !buf.IsValid() )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// eating white spaces and remarks loop
|
||||
while ( true )
|
||||
{
|
||||
buf.EatWhiteSpace();
|
||||
if ( !buf.IsValid() )
|
||||
return NULL; // file ends after reading whitespaces
|
||||
return nullptr; // file ends after reading whitespaces
|
||||
|
||||
// stop if it's not a comment; a new token starts here
|
||||
if ( !buf.EatCPPComment() )
|
||||
@@ -557,7 +557,7 @@ const char *KeyValues::ReadToken( CUtlBuffer &buf, bool &wasQuoted, bool &wasCon
|
||||
|
||||
const char *c = (const char*)buf.PeekGet( sizeof(char), 0 );
|
||||
if ( !c )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
// read quoted strings specially
|
||||
if ( *c == '\"' )
|
||||
@@ -653,6 +653,10 @@ bool KeyValues::LoadFromFile( IBaseFileSystem *filesystem, const char *resourceN
|
||||
Assert( IsX360() || ( IsPC() && _heapchk() == _HEAPOK ) );
|
||||
#endif
|
||||
|
||||
#ifdef STAGING_ONLY
|
||||
static bool s_bCacheEnabled = !!CommandLine()->FindParm( "-enable_keyvalues_cache" );
|
||||
const bool bUseCache = s_bCacheEnabled && ( s_pfGetSymbolForString == KeyValues::GetSymbolForStringClassic );
|
||||
#else
|
||||
/*
|
||||
People are cheating with the keyvalue cache enabled by doing the below, so disable it.
|
||||
|
||||
@@ -678,10 +682,11 @@ bool KeyValues::LoadFromFile( IBaseFileSystem *filesystem, const char *resourceN
|
||||
made of vmt files, so valve's sv_pure 1 bull is pretty redundant.
|
||||
*/
|
||||
const bool bUseCache = false;
|
||||
#endif
|
||||
|
||||
// If pathID is null, we cannot cache the result because that has a weird iterate-through-a-bunch-of-locations behavior.
|
||||
const bool bUseCacheForRead = bUseCache && !refreshCache && pathID != NULL;
|
||||
const bool bUseCacheForWrite = bUseCache && pathID != NULL;
|
||||
const bool bUseCacheForRead = bUseCache && !refreshCache && pathID != nullptr;
|
||||
const bool bUseCacheForWrite = bUseCache && pathID != nullptr;
|
||||
|
||||
COM_TimestampedLog( "KeyValues::LoadFromFile(%s%s%s): Begin", pathID ? pathID : "", pathID && resourceName ? "/" : "", resourceName ? resourceName : "" );
|
||||
|
||||
@@ -753,7 +758,7 @@ bool KeyValues::SaveToFile( IBaseFileSystem *filesystem, const char *resourceNam
|
||||
if ( bCacheResult ) {
|
||||
KeyValuesSystem()->AddFileKeyValuesToCache( this, resourceName, pathID );
|
||||
}
|
||||
RecursiveSaveToFile(filesystem, f, NULL, 0, sortKeys, bAllowEmptyString );
|
||||
RecursiveSaveToFile(filesystem, f, nullptr, 0, sortKeys, bAllowEmptyString );
|
||||
filesystem->Close(f);
|
||||
|
||||
return true;
|
||||
@@ -832,7 +837,7 @@ void KeyValues::RecursiveSaveToFile( IBaseFileSystem *filesystem, FileHandle_t f
|
||||
{
|
||||
CUtlSortVector< KeyValues*, CUtlSortVectorKeyValuesByName > vecSortedKeys;
|
||||
|
||||
for ( KeyValues *dat = m_pSub; dat != NULL; dat = dat->m_pPeer )
|
||||
for ( KeyValues *dat = m_pSub; dat != nullptr; dat = dat->m_pPeer )
|
||||
{
|
||||
vecSortedKeys.InsertNoSort(dat);
|
||||
}
|
||||
@@ -845,7 +850,7 @@ void KeyValues::RecursiveSaveToFile( IBaseFileSystem *filesystem, FileHandle_t f
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( KeyValues *dat = m_pSub; dat != NULL; dat = dat->m_pPeer )
|
||||
for ( KeyValues *dat = m_pSub; dat != nullptr; dat = dat->m_pPeer )
|
||||
SaveKeyToFile( dat, filesystem, f, pBuf, indentLevel, sortKeys, bAllowEmptyString );
|
||||
}
|
||||
|
||||
@@ -967,13 +972,13 @@ void KeyValues::SaveKeyToFile( KeyValues *dat, IBaseFileSystem *filesystem, File
|
||||
//-----------------------------------------------------------------------------
|
||||
KeyValues *KeyValues::FindKey(int keySymbol) const
|
||||
{
|
||||
for (KeyValues *dat = m_pSub; dat != NULL; dat = dat->m_pPeer)
|
||||
for (KeyValues *dat = m_pSub; dat != nullptr; dat = dat->m_pPeer)
|
||||
{
|
||||
if (dat->m_iKeyName == keySymbol)
|
||||
return dat;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -983,7 +988,7 @@ KeyValues *KeyValues::FindKey(int keySymbol) const
|
||||
//-----------------------------------------------------------------------------
|
||||
KeyValues *KeyValues::FindKey(const char *keyName, bool bCreate)
|
||||
{
|
||||
// return the current key if a NULL subkey is asked for
|
||||
// return the current key if a nullptr subkey is asked for
|
||||
if (!keyName || !keyName[0])
|
||||
return this;
|
||||
|
||||
@@ -1006,13 +1011,13 @@ KeyValues *KeyValues::FindKey(const char *keyName, bool bCreate)
|
||||
if ( iSearchStr == INVALID_KEY_SYMBOL )
|
||||
{
|
||||
// not found, couldn't possibly be in key value list
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
KeyValues *lastItem = NULL;
|
||||
KeyValues *lastItem = nullptr;
|
||||
KeyValues *dat;
|
||||
// find the searchStr in the current peer list
|
||||
for (dat = m_pSub; dat != NULL; dat = dat->m_pPeer)
|
||||
for (dat = m_pSub; dat != nullptr; dat = dat->m_pPeer)
|
||||
{
|
||||
lastItem = dat; // record the last item looked at (for if we need to append to the end of the list)
|
||||
|
||||
@@ -1035,7 +1040,7 @@ KeyValues *KeyValues::FindKey(const char *keyName, bool bCreate)
|
||||
{
|
||||
// we need to create a new key
|
||||
dat = new KeyValues( searchStr );
|
||||
// Assert(dat != NULL);
|
||||
// Assert(dat != nullptr);
|
||||
|
||||
dat->UsesEscapeSequences( m_bHasEscapeSequences != 0 ); // use same format as parent
|
||||
dat->UsesConditionals( m_bEvaluateConditionals != 0 );
|
||||
@@ -1049,7 +1054,7 @@ KeyValues *KeyValues::FindKey(const char *keyName, bool bCreate)
|
||||
{
|
||||
m_pSub = dat;
|
||||
}
|
||||
dat->m_pPeer = NULL;
|
||||
dat->m_pPeer = nullptr;
|
||||
|
||||
// a key graduates to be a submsg as soon as it's m_pSub is set
|
||||
// this should be the only place m_pSub is set
|
||||
@@ -1057,7 +1062,7 @@ KeyValues *KeyValues::FindKey(const char *keyName, bool bCreate)
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1081,8 +1086,8 @@ KeyValues *KeyValues::CreateNewKey()
|
||||
int newID = 1;
|
||||
|
||||
// search for any key with higher values
|
||||
KeyValues *pLastChild = NULL;
|
||||
for (KeyValues *dat = m_pSub; dat != NULL; dat = dat->m_pPeer)
|
||||
KeyValues *pLastChild = nullptr;
|
||||
for (KeyValues *dat = m_pSub; dat != nullptr; dat = dat->m_pPeer)
|
||||
{
|
||||
// case-insensitive string compare
|
||||
int val = atoi(dat->GetName());
|
||||
@@ -1129,24 +1134,24 @@ KeyValues* KeyValues::CreateKeyUsingKnownLastChild( const char *keyName, KeyValu
|
||||
void KeyValues::AddSubkeyUsingKnownLastChild( KeyValues *pSubkey, KeyValues *pLastChild )
|
||||
{
|
||||
// Make sure the subkey isn't a child of some other keyvalues
|
||||
Assert( pSubkey != NULL );
|
||||
Assert( pSubkey->m_pPeer == NULL );
|
||||
Assert( pSubkey != nullptr );
|
||||
Assert( pSubkey->m_pPeer == nullptr );
|
||||
|
||||
// Empty child list?
|
||||
if ( pLastChild == NULL )
|
||||
if ( pLastChild == nullptr )
|
||||
{
|
||||
Assert( m_pSub == NULL );
|
||||
Assert( m_pSub == nullptr );
|
||||
m_pSub = pSubkey;
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( m_pSub != NULL );
|
||||
Assert( pLastChild->m_pPeer == NULL );
|
||||
Assert( m_pSub != nullptr );
|
||||
Assert( pLastChild->m_pPeer == nullptr );
|
||||
|
||||
// // In debug, make sure that they really do know which child is the last one
|
||||
// #ifdef _DEBUG
|
||||
// KeyValues *pTempDat = m_pSub;
|
||||
// while ( pTempDat->GetNextKey() != NULL )
|
||||
// while ( pTempDat->GetNextKey() != nullptr )
|
||||
// {
|
||||
// pTempDat = pTempDat->GetNextKey();
|
||||
// }
|
||||
@@ -1164,18 +1169,18 @@ void KeyValues::AddSubkeyUsingKnownLastChild( KeyValues *pSubkey, KeyValues *pLa
|
||||
void KeyValues::AddSubKey( KeyValues *pSubkey )
|
||||
{
|
||||
// Make sure the subkey isn't a child of some other keyvalues
|
||||
Assert( pSubkey != NULL );
|
||||
Assert( pSubkey->m_pPeer == NULL );
|
||||
Assert( pSubkey != nullptr );
|
||||
Assert( pSubkey->m_pPeer == nullptr );
|
||||
|
||||
// add into subkey list
|
||||
if ( m_pSub == NULL )
|
||||
if ( m_pSub == nullptr )
|
||||
{
|
||||
m_pSub = pSubkey;
|
||||
}
|
||||
else
|
||||
{
|
||||
KeyValues *pTempDat = m_pSub;
|
||||
while ( pTempDat->GetNextKey() != NULL )
|
||||
while ( pTempDat->GetNextKey() != nullptr )
|
||||
{
|
||||
pTempDat = pTempDat->GetNextKey();
|
||||
}
|
||||
@@ -1215,20 +1220,20 @@ void KeyValues::RemoveSubKey(KeyValues *subKey)
|
||||
}
|
||||
}
|
||||
|
||||
subKey->m_pPeer = NULL;
|
||||
subKey->m_pPeer = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Locate last child. Returns NULL if we have no children
|
||||
// Purpose: Locate last child. Returns nullptr if we have no children
|
||||
//-----------------------------------------------------------------------------
|
||||
KeyValues *KeyValues::FindLastSubKey()
|
||||
{
|
||||
|
||||
// No children?
|
||||
if ( m_pSub == NULL )
|
||||
return NULL;
|
||||
if ( m_pSub == nullptr )
|
||||
return nullptr;
|
||||
|
||||
// Scan for the last one
|
||||
KeyValues *pLastChild = m_pSub;
|
||||
@@ -1332,9 +1337,8 @@ uint64 KeyValues::GetUint64( const char *keyName, uint64 defaultValue )
|
||||
return (int)dat->m_flValue;
|
||||
case TYPE_UINT64:
|
||||
return *((uint64 *)dat->m_sValue);
|
||||
case TYPE_PTR:
|
||||
return (uint64)(uintp)dat->m_pValue;
|
||||
case TYPE_INT:
|
||||
case TYPE_PTR:
|
||||
default:
|
||||
return dat->m_iValue;
|
||||
};
|
||||
@@ -1362,7 +1366,7 @@ void *KeyValues::GetPtr( const char *keyName, void *defaultValue )
|
||||
case TYPE_INT:
|
||||
case TYPE_UINT64:
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
};
|
||||
}
|
||||
return defaultValue;
|
||||
@@ -1420,7 +1424,7 @@ const char *KeyValues::GetString( const char *keyName, const char *defaultValue
|
||||
SetString( keyName, buf );
|
||||
break;
|
||||
case TYPE_PTR:
|
||||
V_snprintf( buf, sizeof( buf ), "%lld", CastPtrToInt64( dat->m_pValue ) );
|
||||
Q_snprintf( buf, sizeof( buf ), "%lld", (int64)(size_t)dat->m_pValue );
|
||||
SetString( keyName, buf );
|
||||
break;
|
||||
case TYPE_INT:
|
||||
@@ -1522,17 +1526,15 @@ bool KeyValues::GetBool( const char *keyName, bool defaultValue, bool* optGotDef
|
||||
{
|
||||
if ( FindKey( keyName ) )
|
||||
{
|
||||
if ( optGotDefault )
|
||||
{
|
||||
*optGotDefault = false;
|
||||
if ( optGotDefault ) {
|
||||
(*optGotDefault) = false;
|
||||
}
|
||||
|
||||
return 0 != GetInt( keyName, 0 );
|
||||
}
|
||||
|
||||
if ( optGotDefault )
|
||||
{
|
||||
*optGotDefault = true;
|
||||
if ( optGotDefault ) {
|
||||
(*optGotDefault) = true;
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
@@ -1599,7 +1601,7 @@ void KeyValues::SetStringValue( char const *strValue )
|
||||
delete [] m_sValue;
|
||||
// make sure we're not storing the WSTRING - as we're converting over to STRING
|
||||
delete [] m_wsValue;
|
||||
m_wsValue = NULL;
|
||||
m_wsValue = nullptr;
|
||||
|
||||
if (!strValue)
|
||||
{
|
||||
@@ -1633,7 +1635,7 @@ void KeyValues::SetString( const char *keyName, const char *value )
|
||||
delete [] dat->m_sValue;
|
||||
// make sure we're not storing the WSTRING - as we're converting over to STRING
|
||||
delete [] dat->m_wsValue;
|
||||
dat->m_wsValue = NULL;
|
||||
dat->m_wsValue = nullptr;
|
||||
|
||||
if (!value)
|
||||
{
|
||||
@@ -1662,7 +1664,7 @@ void KeyValues::SetWString( const char *keyName, const wchar_t *value )
|
||||
delete [] dat->m_wsValue;
|
||||
// make sure we're not storing the STRING - as we're converting over to WSTRING
|
||||
delete [] dat->m_sValue;
|
||||
dat->m_sValue = NULL;
|
||||
dat->m_sValue = nullptr;
|
||||
|
||||
if (!value)
|
||||
{
|
||||
@@ -1706,7 +1708,7 @@ void KeyValues::SetUint64( const char *keyName, uint64 value )
|
||||
delete [] dat->m_sValue;
|
||||
// make sure we're not storing the WSTRING - as we're converting over to STRING
|
||||
delete [] dat->m_wsValue;
|
||||
dat->m_wsValue = NULL;
|
||||
dat->m_wsValue = nullptr;
|
||||
|
||||
dat->m_sValue = new char[sizeof(uint64)];
|
||||
*((uint64 *)dat->m_sValue) = value;
|
||||
@@ -1764,7 +1766,7 @@ void KeyValues::CopyKeyValuesFromRecursive( const KeyValues& rootSrc )
|
||||
};
|
||||
|
||||
char tmp[256];
|
||||
KeyValues* localDst = NULL;
|
||||
KeyValues* localDst = nullptr;
|
||||
|
||||
CUtlQueue<CopyStruct> nodeQ;
|
||||
nodeQ.Insert({ this, &rootSrc });
|
||||
@@ -1776,23 +1778,23 @@ void KeyValues::CopyKeyValuesFromRecursive( const KeyValues& rootSrc )
|
||||
// Process all the siblings of the current node. If anyone has a child, add it to the queue.
|
||||
while (cs.src)
|
||||
{
|
||||
Assert( (cs.src != NULL) == (cs.dst != NULL) );
|
||||
Assert( (cs.src != nullptr) == (cs.dst != nullptr) );
|
||||
|
||||
// Copy the node contents
|
||||
cs.dst->CopyKeyValue( *cs.src, sizeof(tmp), tmp );
|
||||
|
||||
// Add children to the queue to process later.
|
||||
if (cs.src->m_pSub) {
|
||||
cs.dst->m_pSub = localDst = new KeyValues( NULL );
|
||||
cs.dst->m_pSub = localDst = new KeyValues( nullptr );
|
||||
nodeQ.Insert({ localDst, cs.src->m_pSub });
|
||||
}
|
||||
|
||||
// Process siblings until we hit the end of the line.
|
||||
if (cs.src->m_pPeer) {
|
||||
cs.dst->m_pPeer = new KeyValues( NULL );
|
||||
cs.dst->m_pPeer = new KeyValues( nullptr );
|
||||
}
|
||||
else {
|
||||
cs.dst->m_pPeer = NULL;
|
||||
cs.dst->m_pPeer = nullptr;
|
||||
}
|
||||
|
||||
// Advance to the next peer.
|
||||
@@ -1830,7 +1832,7 @@ void KeyValues::CopyKeyValue( const KeyValues& src, size_t tmpBufferSizeB, char*
|
||||
case TYPE_INT:
|
||||
{
|
||||
m_iValue = src.m_iValue;
|
||||
Q_snprintf( tmpBuffer, (int)tmpBufferSizeB, "%d", m_iValue );
|
||||
Q_snprintf( tmpBuffer, tmpBufferSizeB, "%d", m_iValue );
|
||||
int len = Q_strlen(tmpBuffer) + 1;
|
||||
m_sValue = new char[len];
|
||||
Q_strncpy( m_sValue, tmpBuffer, len );
|
||||
@@ -1839,7 +1841,7 @@ void KeyValues::CopyKeyValue( const KeyValues& src, size_t tmpBufferSizeB, char*
|
||||
case TYPE_FLOAT:
|
||||
{
|
||||
m_flValue = src.m_flValue;
|
||||
Q_snprintf( tmpBuffer, (int)tmpBufferSizeB, "%f", m_flValue );
|
||||
Q_snprintf( tmpBuffer, tmpBufferSizeB, "%f", m_flValue );
|
||||
int len = Q_strlen(tmpBuffer) + 1;
|
||||
m_sValue = new char[len];
|
||||
Q_strncpy( m_sValue, tmpBuffer, len );
|
||||
@@ -1890,8 +1892,8 @@ void KeyValues::CopySubkeys( KeyValues *pParent ) const
|
||||
{
|
||||
// recursively copy subkeys
|
||||
// Also maintain ordering....
|
||||
KeyValues *pPrev = NULL;
|
||||
for ( KeyValues *sub = m_pSub; sub != NULL; sub = sub->m_pPeer )
|
||||
KeyValues *pPrev = nullptr;
|
||||
for ( KeyValues *sub = m_pSub; sub != nullptr; sub = sub->m_pPeer )
|
||||
{
|
||||
// take a copy of the subkey
|
||||
KeyValues *dat = sub->MakeCopy();
|
||||
@@ -1905,7 +1907,7 @@ void KeyValues::CopySubkeys( KeyValues *pParent ) const
|
||||
{
|
||||
pParent->m_pSub = dat;
|
||||
}
|
||||
dat->m_pPeer = NULL;
|
||||
dat->m_pPeer = nullptr;
|
||||
pPrev = dat;
|
||||
}
|
||||
}
|
||||
@@ -2006,7 +2008,7 @@ bool KeyValues::IsEmpty(const char *keyName)
|
||||
if (!dat)
|
||||
return true;
|
||||
|
||||
if (dat->m_iDataType == TYPE_NONE && dat->m_pSub == NULL)
|
||||
if (dat->m_iDataType == TYPE_NONE && dat->m_pSub == nullptr)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -2018,7 +2020,7 @@ bool KeyValues::IsEmpty(const char *keyName)
|
||||
void KeyValues::Clear( void )
|
||||
{
|
||||
delete m_pSub;
|
||||
m_pSub = NULL;
|
||||
m_pSub = nullptr;
|
||||
m_iDataType = TYPE_NONE;
|
||||
}
|
||||
|
||||
@@ -2152,14 +2154,14 @@ void KeyValues::RecursiveMergeKeyValues( KeyValues *baseKV )
|
||||
// we always want to keep our value, so nothing to do here
|
||||
|
||||
// Now merge our children
|
||||
for ( KeyValues *baseChild = baseKV->m_pSub; baseChild != NULL; baseChild = baseChild->m_pPeer )
|
||||
for ( KeyValues *baseChild = baseKV->m_pSub; baseChild != nullptr; baseChild = baseChild->m_pPeer )
|
||||
{
|
||||
// for each child in base, see if we have a matching kv
|
||||
|
||||
bool bFoundMatch = false;
|
||||
|
||||
// If we have a child by the same name, merge those keys
|
||||
for ( KeyValues *newChild = m_pSub; newChild != NULL; newChild = newChild->m_pPeer )
|
||||
for ( KeyValues *newChild = m_pSub; newChild != nullptr; newChild = newChild->m_pPeer )
|
||||
{
|
||||
if ( !Q_strcmp( baseChild->GetName(), newChild->GetName() ) )
|
||||
{
|
||||
@@ -2179,38 +2181,6 @@ void KeyValues::RecursiveMergeKeyValues( KeyValues *baseKV )
|
||||
}
|
||||
}
|
||||
|
||||
bool IsSteamDeck( bool bTrulyHardwareOnly )
|
||||
{
|
||||
static int s_nSteamDeckCached = -1;
|
||||
static int s_nGamepadUICached = -1;
|
||||
|
||||
if ( s_nGamepadUICached == -1 || s_nSteamDeckCached == -1 )
|
||||
{
|
||||
bool bIsDeck = false;
|
||||
bool bIsGamepadUI = false;
|
||||
|
||||
if ( CommandLine()->CheckParm( "-nogamepadui" ) )
|
||||
bIsGamepadUI = false;
|
||||
else if ( CommandLine()->CheckParm( "-gamepadui" ) )
|
||||
bIsGamepadUI = true;
|
||||
else
|
||||
{
|
||||
const char *deckEnv = getenv( "SteamDeck" );
|
||||
bIsDeck = deckEnv && *deckEnv && atoi( deckEnv ) != 0;
|
||||
|
||||
const char *bigPictureEnv = getenv( "SteamTenFoot" );
|
||||
bIsGamepadUI = bigPictureEnv && *bigPictureEnv && atoi( bigPictureEnv ) != 0;
|
||||
}
|
||||
|
||||
s_nSteamDeckCached = bIsDeck ? 1 : 0;
|
||||
s_nGamepadUICached = bIsGamepadUI ? 1 : 0;
|
||||
}
|
||||
|
||||
if ( bTrulyHardwareOnly )
|
||||
return s_nSteamDeckCached == 1;
|
||||
return s_nGamepadUICached == 1 || s_nSteamDeckCached == 1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Returns whether a keyvalues conditional evaluates to true or false
|
||||
// Needs more flexibility with conditionals, checking convars would be nice.
|
||||
@@ -2227,15 +2197,26 @@ bool EvaluateConditional( const char *str )
|
||||
if ( *str == '!' )
|
||||
bNot = true;
|
||||
|
||||
if ( Q_stristr( str, "$DECK" ) )
|
||||
return IsSteamDeck() ^ bNot;
|
||||
|
||||
if ( Q_stristr( str, "$X360" ) )
|
||||
return IsX360() ^ bNot;
|
||||
|
||||
if ( Q_stristr( str, "$WIN32" ) )
|
||||
return IsPC() ^ bNot; // hack hack - for now WIN32 really means IsPC
|
||||
|
||||
#ifdef PLATFORM_64BITS
|
||||
if ( V_stristr( str, "$32BIT" ) )
|
||||
return false ^ bNot;
|
||||
|
||||
if ( V_stristr( str, "$64BIT") )
|
||||
return true ^ bNot;
|
||||
#else
|
||||
if ( V_stristr( str, "$32BIT" ) )
|
||||
return true ^ bNot;
|
||||
|
||||
if ( V_stristr( str, "$64BIT") )
|
||||
return false ^ bNot;
|
||||
#endif
|
||||
|
||||
if ( Q_stristr( str, "$WINDOWS" ) )
|
||||
return IsWindows() ^ bNot;
|
||||
|
||||
@@ -2247,19 +2228,32 @@ bool EvaluateConditional( const char *str )
|
||||
|
||||
if ( Q_stristr( str, "$POSIX" ) )
|
||||
return IsPosix() ^ bNot;
|
||||
|
||||
#ifdef PVK2_DLL
|
||||
|
||||
#ifdef PVK2_DEV_VERSION
|
||||
const bool bDevBuild = true;
|
||||
#else
|
||||
const bool bDevBuild = false;
|
||||
#endif
|
||||
|
||||
if ( Q_stristr( str, "$PVK2_DEV" ) )
|
||||
return bDevBuild ^ bNot;
|
||||
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// prevent two threads from entering this at the same time and trying to share the global error reporting and parse buffers
|
||||
static CThreadFastMutex g_KVMutex;
|
||||
static CThreadFastMutexRecursive g_KVMutex;
|
||||
//-----------------------------------------------------------------------------
|
||||
// Read from a buffer...
|
||||
//-----------------------------------------------------------------------------
|
||||
bool KeyValues::LoadFromBuffer( char const *resourceName, CUtlBuffer &buf, IBaseFileSystem* pFileSystem, const char *pPathID )
|
||||
{
|
||||
AUTO_LOCK( g_KVMutex );
|
||||
KeyValues *pPreviousKey = NULL;
|
||||
KeyValues *pPreviousKey = nullptr;
|
||||
KeyValues *pCurrentKey = this;
|
||||
CUtlVector< KeyValues * > includedKeys;
|
||||
CUtlVector< KeyValues * > baseKeys;
|
||||
@@ -2351,14 +2345,14 @@ bool KeyValues::LoadFromBuffer( char const *resourceName, CUtlBuffer &buf, IBase
|
||||
{
|
||||
if ( pPreviousKey )
|
||||
{
|
||||
pPreviousKey->SetNextKey( NULL );
|
||||
pPreviousKey->SetNextKey( nullptr );
|
||||
}
|
||||
pCurrentKey->Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
pPreviousKey = pCurrentKey;
|
||||
pCurrentKey = NULL;
|
||||
pCurrentKey = nullptr;
|
||||
}
|
||||
} while ( buf.IsValid() );
|
||||
|
||||
@@ -2406,7 +2400,7 @@ bool KeyValues::LoadFromBuffer( char const *resourceName, const char *pBuffer, I
|
||||
// Translate Unicode files into UTF-8 before proceeding
|
||||
if ( nLen > 2 && (uint8)pBuffer[0] == 0xFF && (uint8)pBuffer[1] == 0xFE )
|
||||
{
|
||||
int nUTF8Len = V_UnicodeToUTF8( (wchar_t*)(pBuffer+2), NULL, 0 );
|
||||
int nUTF8Len = V_UnicodeToUTF8( (wchar_t*)(pBuffer+2), nullptr, 0 );
|
||||
char *pUTF8Buf = new char[nUTF8Len];
|
||||
V_UnicodeToUTF8( (wchar_t*)(pBuffer+2), pUTF8Buf, nUTF8Len );
|
||||
buf.AssumeMemory( pUTF8Buf, nUTF8Len, nUTF8Len, CUtlBuffer::READ_ONLY | CUtlBuffer::TEXT_BUFFER );
|
||||
@@ -2511,7 +2505,7 @@ void KeyValues::RecursiveLoadFromBuffer( char const *resourceName, CUtlBuffer &b
|
||||
if (dat->m_sValue)
|
||||
{
|
||||
delete[] dat->m_sValue;
|
||||
dat->m_sValue = NULL;
|
||||
dat->m_sValue = nullptr;
|
||||
}
|
||||
|
||||
int len = Q_strlen( value );
|
||||
@@ -2591,28 +2585,28 @@ void KeyValues::RecursiveLoadFromBuffer( char const *resourceName, CUtlBuffer &b
|
||||
}
|
||||
}
|
||||
|
||||
Assert( dat->m_pPeer == NULL );
|
||||
Assert( dat->m_pPeer == nullptr );
|
||||
if ( bAccepted )
|
||||
{
|
||||
Assert( pLastChild == NULL || pLastChild->m_pPeer == dat );
|
||||
Assert( pLastChild == nullptr || pLastChild->m_pPeer == dat );
|
||||
pLastChild = dat;
|
||||
}
|
||||
else
|
||||
{
|
||||
//this->RemoveSubKey( dat );
|
||||
if ( pLastChild == NULL )
|
||||
if ( pLastChild == nullptr )
|
||||
{
|
||||
Assert( m_pSub == dat );
|
||||
m_pSub = NULL;
|
||||
m_pSub = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( pLastChild->m_pPeer == dat );
|
||||
pLastChild->m_pPeer = NULL;
|
||||
pLastChild->m_pPeer = nullptr;
|
||||
}
|
||||
|
||||
dat->deleteThis();
|
||||
dat = NULL;
|
||||
dat = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2631,7 +2625,7 @@ bool KeyValues::WriteAsBinary( CUtlBuffer &buffer )
|
||||
// Write subkeys:
|
||||
|
||||
// loop through all our peers
|
||||
for ( KeyValues *dat = this; dat != NULL; dat = dat->m_pPeer )
|
||||
for ( KeyValues *dat = this; dat != nullptr; dat = dat->m_pPeer )
|
||||
{
|
||||
// write type
|
||||
buffer.PutUnsignedChar( dat->m_iDataType );
|
||||
@@ -2692,18 +2686,7 @@ bool KeyValues::WriteAsBinary( CUtlBuffer &buffer )
|
||||
}
|
||||
case TYPE_PTR:
|
||||
{
|
||||
#if defined( PLATFORM_64BITS )
|
||||
// We only put an int here, because 32-bit clients do not expect 64 bits. It'll cause them to read the wrong
|
||||
// amount of data and then crash. Longer term, we may bump this up in size on all platforms, but short term
|
||||
// we don't really have much of a choice other than sticking in something that appears to not be NULL.
|
||||
if ( dat->m_pValue != 0 && ( ( (int)(intp)dat->m_pValue ) == 0 ) )
|
||||
buffer.PutInt( 31337 ); // Put not 0, but not a valid number. Yuck.
|
||||
else
|
||||
buffer.PutInt( ( (int)(intp)dat->m_pValue ) );
|
||||
#else
|
||||
buffer.PutPtr( dat->m_pValue );
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
@@ -2808,14 +2791,7 @@ bool KeyValues::ReadAsBinary( CUtlBuffer &buffer, int nStackDepth )
|
||||
}
|
||||
case TYPE_PTR:
|
||||
{
|
||||
#if defined( PLATFORM_64BITS )
|
||||
// We need to ensure we only read 32 bits out of the stream because 32 bit clients only wrote
|
||||
// 32 bits of data there. The actual pointer is irrelevant, all that we really care about here
|
||||
// contractually is whether the pointer is zero or not zero.
|
||||
dat->m_pValue = ( void* )( intp )buffer.GetInt();
|
||||
#else
|
||||
dat->m_pValue = buffer.GetPtr();
|
||||
#endif
|
||||
}
|
||||
|
||||
default:
|
||||
@@ -3008,13 +2984,13 @@ bool KeyValues::ProcessResolutionKeys( const char *pResString )
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( ; pSubKey != NULL; pSubKey = pSubKey->GetNextKey() )
|
||||
for ( ; pSubKey != nullptr; pSubKey = pSubKey->GetNextKey() )
|
||||
{
|
||||
// recursively descend each sub block
|
||||
pSubKey->ProcessResolutionKeys( pResString );
|
||||
|
||||
// check to see if our substring is present
|
||||
if ( Q_stristr( pSubKey->GetName(), pResString ) != NULL )
|
||||
if ( Q_stristr( pSubKey->GetName(), pResString ) != nullptr )
|
||||
{
|
||||
char normalKeyName[128];
|
||||
V_strncpy( normalKeyName, pSubKey->GetName(), sizeof( normalKeyName ) );
|
||||
@@ -3057,7 +3033,7 @@ bool KeyValues::Dump( IKeyValuesDumpContext *pDump, int nIndentLevel /* = 0 */,
|
||||
CUtlSortVector< KeyValues*, CUtlSortVectorKeyValuesByName > vecSortedKeys;
|
||||
|
||||
// Dump values
|
||||
for ( KeyValues *val = this ? GetFirstValue() : NULL; val; val = val->GetNextValue() )
|
||||
for ( KeyValues *val = this ? GetFirstValue() : nullptr; val; val = val->GetNextValue() )
|
||||
{
|
||||
vecSortedKeys.InsertNoSort( val );
|
||||
}
|
||||
@@ -3072,7 +3048,7 @@ bool KeyValues::Dump( IKeyValuesDumpContext *pDump, int nIndentLevel /* = 0 */,
|
||||
vecSortedKeys.Purge();
|
||||
|
||||
// Dump subkeys
|
||||
for ( KeyValues *sub = this ? GetFirstTrueSubKey() : NULL; sub; sub = sub->GetNextTrueSubKey() )
|
||||
for ( KeyValues *sub = this ? GetFirstTrueSubKey() : nullptr; sub; sub = sub->GetNextTrueSubKey() )
|
||||
{
|
||||
vecSortedKeys.InsertNoSort( sub );
|
||||
}
|
||||
@@ -3087,14 +3063,14 @@ bool KeyValues::Dump( IKeyValuesDumpContext *pDump, int nIndentLevel /* = 0 */,
|
||||
else
|
||||
{
|
||||
// Dump values
|
||||
for ( KeyValues *val = this ? GetFirstValue() : NULL; val; val = val->GetNextValue() )
|
||||
for ( KeyValues *val = this ? GetFirstValue() : nullptr; val; val = val->GetNextValue() )
|
||||
{
|
||||
if ( !pDump->KvWriteValue( val, nIndentLevel + 1 ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
// Dump subkeys
|
||||
for ( KeyValues *sub = this ? GetFirstTrueSubKey() : NULL; sub; sub = sub->GetNextTrueSubKey() )
|
||||
for ( KeyValues *sub = this ? GetFirstTrueSubKey() : nullptr; sub; sub = sub->GetNextTrueSubKey() )
|
||||
{
|
||||
if ( !sub->Dump( pDump, nIndentLevel + 1 ) )
|
||||
return false;
|
||||
|
||||
+92
-29
@@ -43,7 +43,7 @@
|
||||
// ------------------------------------------------------------------------------------ //
|
||||
// InterfaceReg.
|
||||
// ------------------------------------------------------------------------------------ //
|
||||
InterfaceReg *InterfaceReg::s_pInterfaceRegs = NULL;
|
||||
static InterfaceReg *s_pInterfaceRegs = nullptr;
|
||||
|
||||
InterfaceReg::InterfaceReg( InstantiateInterfaceFn fn, const char *pName ) :
|
||||
m_pName(pName)
|
||||
@@ -69,7 +69,7 @@ void* CreateInterfaceInternal( const char *pName, int *pReturnCode )
|
||||
{
|
||||
InterfaceReg *pCur;
|
||||
|
||||
for (pCur=InterfaceReg::s_pInterfaceRegs; pCur; pCur=pCur->m_pNext)
|
||||
for (pCur=s_pInterfaceRegs; pCur; pCur=pCur->m_pNext)
|
||||
{
|
||||
if (strcmp(pCur->m_pName, pName) == 0)
|
||||
{
|
||||
@@ -85,7 +85,7 @@ void* CreateInterfaceInternal( const char *pName, int *pReturnCode )
|
||||
{
|
||||
*pReturnCode = IFACE_FAILED;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* CreateInterface( const char *pName, int *pReturnCode )
|
||||
@@ -101,18 +101,18 @@ void *GetModuleHandle(const char *name)
|
||||
{
|
||||
void *handle;
|
||||
|
||||
if( name == NULL )
|
||||
if( name == nullptr )
|
||||
{
|
||||
// hmm, how can this be handled under linux....
|
||||
// is it even needed?
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if( (handle=dlopen(name, RTLD_NOW))==NULL)
|
||||
if( (handle=dlopen(name, RTLD_NOW))==nullptr)
|
||||
{
|
||||
printf("DLOPEN Error:%s\n",dlerror());
|
||||
// couldn't open this file
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// read "man dlopen" for details
|
||||
@@ -176,7 +176,7 @@ static HMODULE InternalLoadLibrary( const char *pName, Sys_Flags flags )
|
||||
if ( flags & SYS_NOLOAD )
|
||||
return GetModuleHandle( pName );
|
||||
else
|
||||
return LoadLibraryEx( pName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
|
||||
return LoadLibraryEx( pName, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH );
|
||||
#endif
|
||||
}
|
||||
uintp ThreadedLoadLibraryFunc( void *pParam )
|
||||
@@ -214,6 +214,8 @@ HMODULE Sys_LoadLibrary( const char *pLibraryName, Sys_Flags flags )
|
||||
|
||||
Q_FixSlashes( str );
|
||||
|
||||
DevMsg("Attempting to load library: %s\n", str);
|
||||
|
||||
#ifdef _WIN32
|
||||
ThreadedLoadLibraryFunc_t threadFunc = GetThreadedLoadLibraryFunc();
|
||||
if ( !threadFunc )
|
||||
@@ -272,8 +274,11 @@ CSysModule *Sys_LoadModule( const char *pModuleName, Sys_Flags flags /* = SYS_NO
|
||||
// If using the Steam filesystem, either the DLL must be a minimum footprint
|
||||
// file in the depot (MFP) or a filesystem GetLocalCopy() call must be made
|
||||
// prior to the call to this routine.
|
||||
|
||||
DevMsg("Loading module %s\n", pModuleName);
|
||||
|
||||
char szCwd[1024];
|
||||
HMODULE hDLL = NULL;
|
||||
HMODULE hDLL = (HMODULE)nullptr;
|
||||
|
||||
if ( !Q_IsAbsolutePath( pModuleName ) )
|
||||
{
|
||||
@@ -293,41 +298,75 @@ CSysModule *Sys_LoadModule( const char *pModuleName, Sys_Flags flags /* = SYS_NO
|
||||
}
|
||||
|
||||
char szAbsoluteModuleName[1024];
|
||||
if ( strstr( pModuleName, PLATFORM_BIN_DIR ) != NULL )
|
||||
size_t cCwd = strlen( szCwd );
|
||||
if ( strstr( pModuleName, "bin/") == pModuleName || ( szCwd[ cCwd - 1 ] == 'n' && szCwd[ cCwd - 2 ] == 'i' && szCwd[ cCwd - 3 ] == 'b' ) )
|
||||
{
|
||||
// don't make bin/bin path
|
||||
Q_snprintf( szAbsoluteModuleName, sizeof( szAbsoluteModuleName ), "%s" CORRECT_PATH_SEPARATOR_S "%s", szCwd, pModuleName );
|
||||
Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/%s", szCwd, pModuleName );
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_snprintf( szAbsoluteModuleName, sizeof( szAbsoluteModuleName ), "%s" CORRECT_PATH_SEPARATOR_S PLATFORM_BIN_DIR CORRECT_PATH_SEPARATOR_S "%s", szCwd, pModuleName );
|
||||
#ifdef PLATFORM_64BITS
|
||||
Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/bin/x64/%s", szCwd, pModuleName );
|
||||
#else
|
||||
Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/bin/%s", szCwd, pModuleName );
|
||||
#endif
|
||||
}
|
||||
hDLL = Sys_LoadLibrary( szAbsoluteModuleName, flags );
|
||||
}
|
||||
|
||||
if ( !hDLL )
|
||||
{
|
||||
// full path failed, let LoadLibrary() try to search the PATH now
|
||||
hDLL = Sys_LoadLibrary( pModuleName, flags );
|
||||
#if defined( _DEBUG )
|
||||
if ( !hDLL )
|
||||
{
|
||||
// So you can see what the error is in the debugger...
|
||||
if (!hDLL) {
|
||||
#if defined( _WIN32 ) && !defined( _X360 )
|
||||
char *lpMsgBuf;
|
||||
char *lpMsgBuf = nullptr;
|
||||
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
nullptr,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL
|
||||
nullptr
|
||||
);
|
||||
|
||||
DevWarning("Failed to load %s: %s\n", pModuleName, lpMsgBuf);
|
||||
|
||||
LocalFree( (HLOCAL)lpMsgBuf );
|
||||
#elif defined( _X360 )
|
||||
DWORD error = GetLastError();
|
||||
Msg( "Error(%d) - Failed to load %s:\n", error, pModuleName );
|
||||
#else
|
||||
DevMsg( "Failed to load %s: %s\n", pModuleName, dlerror() );
|
||||
#endif // _WIN32
|
||||
}
|
||||
}
|
||||
|
||||
if ( !hDLL )
|
||||
{
|
||||
// full path failed, let LoadLibrary() try to search the PATH now
|
||||
DevMsg("Attempting to load module %s from PATH\n", pModuleName);
|
||||
hDLL = Sys_LoadLibrary( pModuleName, flags );
|
||||
|
||||
if ( !hDLL )
|
||||
{
|
||||
#if defined( _WIN32 ) && !defined( _X360 )
|
||||
char *lpMsgBuf = nullptr;
|
||||
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
nullptr,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
nullptr
|
||||
);
|
||||
|
||||
DevWarning("Failed to load %s: %s\n", pModuleName, lpMsgBuf);
|
||||
|
||||
LocalFree( (HLOCAL)lpMsgBuf );
|
||||
#elif defined( _X360 )
|
||||
DWORD error = GetLastError();
|
||||
@@ -336,7 +375,10 @@ CSysModule *Sys_LoadModule( const char *pModuleName, Sys_Flags flags /* = SYS_NO
|
||||
Msg( "Failed to load %s: %s\n", pModuleName, dlerror() );
|
||||
#endif // _WIN32
|
||||
}
|
||||
#endif // DEBUG
|
||||
}
|
||||
|
||||
if ( hDLL ) {
|
||||
DevMsg( "Successfully loaded %s\n", pModuleName );
|
||||
}
|
||||
|
||||
#if !defined(LINUX)
|
||||
@@ -360,7 +402,7 @@ CSysModule *Sys_LoadModule( const char *pModuleName, Sys_Flags flags /* = SYS_NO
|
||||
char chMemoryName[ MAX_PATH ];
|
||||
DebugKernelMemoryObjectName( chMemoryName );
|
||||
|
||||
(void) CreateFileMapping( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 1024, chMemoryName );
|
||||
(void) CreateFileMapping( INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, 1024, chMemoryName );
|
||||
// Created a shared memory kernel object specific to process id
|
||||
// Existence of this object indicates that we have debug modules loaded
|
||||
#endif
|
||||
@@ -422,7 +464,7 @@ void Sys_UnloadModule( CSysModule *pModule )
|
||||
CreateInterfaceFn Sys_GetFactory( CSysModule *pModule )
|
||||
{
|
||||
if ( !pModule )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
HMODULE hDLL = reinterpret_cast<HMODULE>(pModule);
|
||||
#ifdef _WIN32
|
||||
@@ -485,7 +527,7 @@ bool Sys_LoadInterface(
|
||||
return false;
|
||||
}
|
||||
|
||||
*pOutInterface = fn( pInterfaceVersionName, NULL );
|
||||
*pOutInterface = fn( pInterfaceVersionName, nullptr );
|
||||
if ( !( *pOutInterface ) )
|
||||
{
|
||||
Sys_UnloadModule( pMod );
|
||||
@@ -527,7 +569,7 @@ CreateInterfaceFn CDllDemandLoader::GetFactory()
|
||||
|
||||
if ( !m_hModule )
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return Sys_GetFactory( m_hModule );
|
||||
@@ -542,4 +584,25 @@ void CDllDemandLoader::Unload()
|
||||
}
|
||||
}
|
||||
|
||||
#if defined( STAGING_ONLY ) && defined( _WIN32 )
|
||||
|
||||
typedef USHORT( WINAPI RtlCaptureStackBackTrace_FUNC )(
|
||||
ULONG frames_to_skip,
|
||||
ULONG frames_to_capture,
|
||||
PVOID *backtrace,
|
||||
PULONG backtrace_hash );
|
||||
|
||||
extern "C" int backtrace( void **buffer, int size )
|
||||
{
|
||||
HMODULE hNTDll = GetModuleHandleA( "ntdll.dll" );
|
||||
static RtlCaptureStackBackTrace_FUNC * const pfnRtlCaptureStackBackTrace =
|
||||
( RtlCaptureStackBackTrace_FUNC * )GetProcAddress( hNTDll, "RtlCaptureStackBackTrace" );
|
||||
|
||||
if ( !pfnRtlCaptureStackBackTrace )
|
||||
return 0;
|
||||
|
||||
return (int)pfnRtlCaptureStackBackTrace( 2, size, buffer, 0 );
|
||||
}
|
||||
|
||||
#endif // STAGING_ONLY && _WIN32
|
||||
|
||||
|
||||
Reference in New Issue
Block a user