1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2025-01-03 16:13:22 +08:00

Mass header update from Insurgency itself, hl2sdk-csgo, and hl2sdk-2013.

This commit is contained in:
Nicholas Hastings 2013-10-08 13:56:30 -04:00
parent 75fdf22c20
commit 71e5d70a47
19 changed files with 421 additions and 151 deletions

View File

@ -24,6 +24,8 @@ public:
int m_SerialNumber;
CEntInfo *m_pPrev;
CEntInfo *m_pNext;
string_t m_iName;
string_t m_iClassName;
void ClearLinks();
};

View File

@ -29,6 +29,7 @@ BEGIN_SIMPLE_DATADESC( CTakeDamageInfo )
DEFINE_FIELD( m_iDamageStats, FIELD_INTEGER),
DEFINE_FIELD( m_iAmmoType, FIELD_INTEGER),
DEFINE_FIELD( m_flRadius, FIELD_FLOAT),
DEFINE_FIELD( m_iDamagedOtherPlayers, FIELD_INTEGER),
END_DATADESC()
void CTakeDamageInfo::Init( CBaseEntity *pInflictor, CBaseEntity *pAttacker, CBaseEntity *pWeapon, const Vector &damageForce, const Vector &damagePosition, const Vector &reportedPosition, float flDamage, int bitsDamageType, int iCustomDamage )

View File

@ -117,6 +117,12 @@ protected:
int m_iAmmoType; // AmmoType of the weapon used to cause this damage, if any
float m_flRadius;
// CS:GO
int m_iDamagedOtherPlayers;
int m_iObjectsPenetrated;
uint32 m_uiBulletID;
uint8 m_uiRecoilIndex;
DECLARE_SIMPLE_DATADESC();
};

View File

@ -179,6 +179,9 @@ public:
// Player instantaneous view angles.
QAngle viewangles;
Vector aimdirection;
// Intended velocities
// forward velocity.
float forwardmove;
@ -224,6 +227,10 @@ public:
Vector skill_dest;
short skill_dest_ent;
#endif
QAngle freeaimangles;
QAngle muzzleangles;
Vector muzzleposition;
};
void ReadUsercmd( bf_read *buf, CUserCmd *move, CUserCmd *from );

View File

@ -98,8 +98,6 @@ typedef struct player_info_s
bool fakeplayer;
// true if player is the HLTV proxy
bool ishltv;
// true if player is the Replay proxy
bool isreplay;
// custom files CRC for this player
CRC32_t customFiles[MAX_CUSTOM_FILES];
// this counter increases each time the server downloaded a new file

View File

@ -277,7 +277,7 @@ private:
inline int SendProp::GetOffset() const
{
return m_Offset;
return m_Offset & 0xFFFFF;
}
inline void SendProp::SetOffset( int i )

View File

@ -49,6 +49,7 @@ public:
// Current map
string_t mapname;
string_t mapGroupName;
int mapversion;
string_t startspot;
MapLoadType_t eLoadType; // How the current map was loaded

View File

@ -16,6 +16,7 @@
#include "convar.h"
#include "icvar.h"
#include "edict.h"
#include "iclient.h"
#include "mathlib/vplane.h"
#include "iserverentity.h"
#include "engine/ivmodelinfo.h"
@ -72,7 +73,7 @@ typedef struct player_info_s player_info_t;
#define DLLEXPORT /* */
#endif
#define INTERFACEVERSION_VENGINESERVER "VEngineServer022"
#define INTERFACEVERSION_VENGINESERVER "VEngineServer023"
struct bbox_t
{
@ -353,6 +354,9 @@ public:
// Cleans up the cluster list
virtual void CleanUpEntityClusterList( PVSInfo_t *pPVSInfo ) = 0;
virtual void SetAchievementMgr( IAchievementMgr * ) = 0;
virtual IAchievementMgr* GetAchievementMgr() = 0;
virtual int GetAppID() = 0;
virtual bool IsLowViolence() = 0;
@ -404,6 +408,7 @@ public:
virtual bool IsCreatingReslist() = 0;
virtual bool IsCreatingXboxReslist() = 0;
virtual bool IsDedicatedServerForXbox() = 0;
virtual bool IsDedicatedServerForPS3() = 0;
virtual void Pause( bool bPause, bool bForce = false ) = 0;
@ -431,7 +436,7 @@ public:
// Calls ShootPaintSphere
virtual bool SpherePaintSurface( const model_t *pModel, const Vector &, unsigned char, float, float ) = 0;
virtual void SphereTracePaintSurface( const model_t *pModel, const Vector &, const Vector &, float, CUtlVector<unsigned char, CUtlMemory<unsigned char, int>> & ) = 0;
virtual void SphereTracePaintSurface( const model_t *pModel, const Vector &, const Vector &, float, CUtlVector<unsigned char> & ) = 0;
virtual void RemoveAllPaint() = 0;
@ -448,13 +453,17 @@ public:
virtual void SetNoClipEnabled( bool bEnabled ) = 0;
virtual void GetPaintmapDataRLE( CUtlVector<unsigned int, CUtlMemory<unsigned int, int>> &mapdata ) = 0;
virtual void LoadPaintmapDataRLE( CUtlVector<unsigned int, CUtlMemory<unsigned int, int>> &mapdata ) = 0;
virtual void GetPaintmapDataRLE( CUtlVector<unsigned int> &mapdata ) = 0;
virtual void LoadPaintmapDataRLE( CUtlVector<unsigned int> &mapdata ) = 0;
virtual void SendPaintmapDataToClient( edict_t *pEdict ) = 0;
virtual float GetLatencyForChoreoSounds() = 0;
virtual int GetClientCrossPlayPlatform( int client_index ) = 0;
virtual CrossPlayPlatform_t GetClientCrossPlayPlatform( int ent_num ) = 0;
virtual void EnsureInstanceBaseline( int ent_num ) = 0;
virtual bool ReserveServerForQueuedGame( const char *szReservationPayload ) = 0;
};
#define INTERFACEVERSION_SERVERGAMEDLL "ServerGameDLL005"
@ -578,6 +587,14 @@ public:
virtual void ServerHibernationUpdate( bool bHibernating ) = 0;
virtual bool ShouldPreferSteamAuth() = 0;
virtual bool ShouldAllowDirectConnect() = 0;
virtual bool FriendsReqdForDirectConnect() = 0;
virtual bool IsLoadTestServer() = 0;
virtual bool IsValveDS() = 0;
virtual KeyValues *GetExtendedServerInfoForNewClient() = 0;
virtual void UpdateGCInformation() = 0;
virtual void ReportGCQueuedMatchStart( int32 iReservationStage, uint32 *puiConfirmedAccounts, int numConfirmedAccounts ) = 0;
};
//-----------------------------------------------------------------------------

View File

@ -5,6 +5,19 @@
// $NoKeywords: $
//===========================================================================//
#include <limits.h>
#include "tier0/threadtools.h"
#include "tier0/memalloc.h"
#include "tier1/interface.h"
#include "tier1/utlsymbol.h"
#include "tier1/utlstring.h"
#include "appframework/IAppSystem.h"
#include "tier1/checksum_crc.h"
#include "tier1/checksum_md5.h"
#include "tier1/refcount.h"
#include "tier2/tier2.h"
#ifndef FILESYSTEM_H
#define FILESYSTEM_H
@ -12,20 +25,6 @@
#pragma once
#endif
#include <limits.h>
#include "tier0/threadtools.h"
#include "tier0/memalloc.h"
#include "tier0/tslist.h"
#include "tier1/interface.h"
#include "tier1/utlsymbol.h"
#include "tier1/utlstring.h"
//#include "tier1/functors.h"
#include "tier1/checksum_crc.h"
#include "tier1/utlqueue.h"
#include "appframework/IAppSystem.h"
#include "tier2/tier2.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
@ -33,8 +32,11 @@
class CUtlBuffer;
class KeyValues;
class IFileList;
class IThreadPool;
class CMemoryFileBacking;
typedef void * FileHandle_t;
typedef void * FileCacheHandle_t;
typedef int FileFindHandle_t;
typedef void (*FileSystemLoggingFunc_t)( const char *fileName, const char *accessType );
typedef int WaitForResourcesHandle_t;
@ -43,6 +45,40 @@ typedef int WaitForResourcesHandle_t;
typedef void* HANDLE;
#endif
#define USE_CRC_FILE_TRACKING 0
// Turn on some extra pure server debug spew in certain builds.
// WARNING: This spew can be used by hackers to locate places to hack
// the code to bypas sv_pure! Be careful!
#if defined( _DEBUG ) || defined( STAGING_ONLY )
#define PURE_SERVER_DEBUG_SPEW
#endif
/// How strict will the pure server be for a particular set of files
enum EPureServerFileClass
{
ePureServerFileClass_Unknown = -1, // dummy debugging value
ePureServerFileClass_Any = 0,
ePureServerFileClass_AnyTrusted,
ePureServerFileClass_CheckHash,
};
class IPureServerWhitelist
{
public:
// Reference counting
virtual void AddRef() = 0;
virtual void Release() = 0;
// What should we do with a particular file?
virtual EPureServerFileClass GetFileClass( const char *pszFilename ) = 0;
// Access list of trusted keys which we will allow to set trusted content
virtual int GetTrustedKeyCount() const = 0;
virtual const byte *GetTrustedKey( int iKeyIndex, int *nKeySize ) const = 0;
};
//-----------------------------------------------------------------------------
// Enums used by the interface
//-----------------------------------------------------------------------------
@ -103,19 +139,18 @@ enum
PATH_IS_NORMAL = 0x00, // normal path, not pack based
PATH_IS_PACKFILE = 0x01, // path is a pack file
PATH_IS_MAPPACKFILE = 0x02, // path is a map pack file
PATH_IS_DVDDEV = 0x04, // path is the dvddev cache
PATH_IS_REMOTE = 0x04, // path is the remote filesystem
};
typedef uint32 PathTypeQuery_t;
#define IS_PACKFILE( n ) ( n & ( PATH_IS_PACKFILE | PATH_IS_MAPPACKFILE ) )
#define IS_DVDDEV( n ) ( n & PATH_IS_DVDDEV )
#define IS_REMOTE( n ) ( n & PATH_IS_REMOTE )
enum DVDMode_t
{
DVDMODE_OFF = 0, // not using dvd
DVDMODE_STRICT = 1, // dvd device only
DVDMODE_DEV = 2, // dev mode, mutiple devices ok
DVDMODE_DEV_VISTA = 3, // dev mode from a vista host, mutiple devices ok
};
// In non-retail builds, enable the file blocking access tracking stuff...
@ -277,6 +312,8 @@ const FSAsyncFile_t FS_INVALID_ASYNC_FILE = (FSAsyncFile_t)(0x0000ffff);
//---------------------------------------------------------
enum FSAsyncStatus_t
{
FSASYNC_ERR_NOT_MINE = -8, // Filename not part of the specified file system, try a different one. (Used internally to find the right filesystem)
FSASYNC_ERR_RETRY_LATER = -7, // Failure for a reason that might be temporary. You might retry, but not immediately. (E.g. Network problems)
FSASYNC_ERR_ALIGNMENT = -6, // read parameters invalid for unbuffered IO
FSASYNC_ERR_FAILURE = -5, // hard subsystem failure
FSASYNC_ERR_READING = -4, // read error on file
@ -307,7 +344,8 @@ enum FSAsyncFlags_t
enum EFileCRCStatus
{
k_eFileCRCStatus_CantOpenFile, // We don't have this file.
k_eFileCRCStatus_GotCRC
k_eFileCRCStatus_GotCRC,
k_eFileCRCStatus_FileInVPK
};
// Used in CacheFileCRCs.
@ -326,13 +364,6 @@ enum ECacheCRCType
struct FileAsyncRequest_t;
typedef void (*FSAsyncCallbackFunc_t)(const FileAsyncRequest_t &request, int nBytesRead, FSAsyncStatus_t err);
//-----------------------------------------------------------------------------
// Used to add results from async directory scans
//-----------------------------------------------------------------------------
typedef void (*FSAsyncScanAddFunc_t)( void* pContext, char* pFoundPath, char* pFoundFile );
typedef void (*FSAsyncScanCompleteFunc_t)( void* pContext, FSAsyncStatus_t err );
//---------------------------------------------------------
// Description of an async request
//---------------------------------------------------------
@ -353,6 +384,52 @@ struct FileAsyncRequest_t
};
struct FileHash_t
{
enum EFileHashType_t
{
k_EFileHashTypeUnknown = 0,
k_EFileHashTypeEntireFile = 1,
k_EFileHashTypeIncompleteFile = 2,
};
FileHash_t()
{
m_eFileHashType = FileHash_t::k_EFileHashTypeUnknown;
m_cbFileLen = 0;
m_PackFileID = 0;
m_nPackFileNumber = 0;
}
int m_eFileHashType;
CRC32_t m_crcIOSequence;
MD5Value_t m_md5contents;
int m_cbFileLen;
int m_PackFileID;
int m_nPackFileNumber;
bool operator==( const FileHash_t &src ) const
{
return m_crcIOSequence == src.m_crcIOSequence &&
m_md5contents == src.m_md5contents &&
m_eFileHashType == src.m_eFileHashType;
}
bool operator!=( const FileHash_t &src ) const
{
return m_crcIOSequence != src.m_crcIOSequence ||
m_md5contents != src.m_md5contents ||
m_eFileHashType != src.m_eFileHashType;
}
};
class CUnverifiedFileHash
{
public:
char m_PathID[MAX_PATH];
char m_Filename[MAX_PATH];
int m_nFileFraction;
FileHash_t m_FileHash;
};
class CUnverifiedCRCFile
{
public:
@ -361,6 +438,13 @@ public:
CRC32_t m_CRC;
};
class CUnverifiedMD5File
{
public:
char m_PathID[MAX_PATH];
char m_Filename[MAX_PATH];
unsigned char bits[MD5_DIGEST_LENGTH];
};
// Spew flags for SetWhitelistSpewFlags (set with the fs_whitelist_spew_flags cvar).
// Update the comment for the fs_whitelist_spew_flags cvar if you change these.
@ -368,22 +452,44 @@ public:
#define WHITELIST_SPEW_RELOAD_FILES 0x0002 // show files the filesystem is telling the engine to reload
#define WHITELIST_SPEW_DONT_RELOAD_FILES 0x0004 // show files the filesystem is NOT telling the engine to reload
//-----------------------------------------------------------------------------
// Interface to fetch a file asynchronously from any source. This is used
// as a hook
//-----------------------------------------------------------------------------
abstract_class IAsyncFileFetch {
public:
typedef void *Handle;
// DLC license mask flags is 32 publisher defined bits
// MSW 16 bits in 8.8: Type.SubVersion
// LSW 16 bits: Flags
/// Initiate a request. Returns error status, or on success
/// returns an opaque handle used to terminate the job
///
/// Should return FSASYNC_ERR_NOT_MINE if the filename isn't
/// handled by this interface
///
/// The callback is required, and is the only mechanism to communicate
/// status. (No polling.) The request is automatically destroyed anytime
/// after the callback is executed.
virtual FSAsyncStatus_t Start( const FileAsyncRequest_t &request, Handle *pOutHandle, IThreadPool *pThreadPool ) = 0;
// return id component
#define DLC_LICENSE_ID( x ) ( ( ( (unsigned int)( x ) ) >> 24 ) & 0x000000FF )
// returns minor version component (not generally used, i.e. we dont rev dlc's yet)
#define DLC_LICENSE_MINORVERSION( x ) ( ( ( (unsigned int)( x ) ) >> 16 ) & 0x000000FF )
// returns license flags
#define DLC_LICENSE_FLAGS( x ) ( ( ( (unsigned int)( x ) ) & 0x0000FFFF ) )
#define DLCFLAGS_PRESENCE_ONLY 0x0001 // causes no search path loadout
/// Attempt to complete any active work, returning status. The callback WILL
/// be executed (this is necessary in case we allocated the buffer).
/// Afterwards, the request is automatically destroyed.
virtual FSAsyncStatus_t FinishSynchronous( Handle hControl ) = 0;
/// Terminate any active work and destroy all resources and bookkeeping info.
/// The callback will NOT be executed.
virtual FSAsyncStatus_t Abort( Handle hControl ) = 0;
};
// This interface is for VPK files to communicate with FileTracker
abstract_class IThreadedFileMD5Processor
{
public:
virtual int SubmitThreadedMD5Request( uint8 *pubBuffer, int cubBuffer, int PackFileID, int nPackFileNumber, int nPackFileFraction ) = 0;
virtual bool BlockUntilMD5RequestComplete( int iRequest, MD5Value_t *pMd5ValueOut ) = 0;
virtual bool IsMD5RequestComplete( int iRequest, MD5Value_t *pMd5ValueOut ) = 0;
};
//-----------------------------------------------------------------------------
// Base file system interface
@ -538,12 +644,6 @@ public:
FileFindHandle_t *pHandle
) = 0;
virtual void FindFileAbsoluteList(
CUtlVector<CUtlString> &output,
const char *pWildCard,
const char *pPathID
) = 0;
//--------------------------------------------------------
// File name and directory operations
//--------------------------------------------------------
@ -583,6 +683,12 @@ public:
virtual bool AsyncSuspend() = 0;
virtual bool AsyncResume() = 0;
/// Add async fetcher interface. This gives apps a hook to intercept async requests and
/// pull the data from a source of their choosing. The immediate use case is to load
/// assets from the CDN via HTTP.
virtual void AsyncAddFetcher( IAsyncFileFetch *pFetcher ) = 0;
virtual void AsyncRemoveFetcher( IAsyncFileFetch *pFetcher ) = 0;
//------------------------------------
// Functions to hold a file open if planning on doing mutiple reads. Use is optional,
// and is taken only as a hint
@ -673,10 +779,13 @@ public:
NUM_PRELOAD_TYPES
};
virtual void LoadCompiledKeyValues( KeyValuesPreloadType_t type, char const *archiveFile ) = 0;
// 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 ) = 0;
virtual bool LoadKeyValues( KeyValues& head, KeyValuesPreloadType_t type, char const *filename, char const *pPathID = 0 ) = 0;
virtual bool ExtractRootKeyName( KeyValuesPreloadType_t type, char *outbuf, size_t bufsize, char const *filename, char const *pPathID = 0 ) = 0;
virtual FSAsyncStatus_t AsyncWrite(const char *pFileName, const void *pSrc, int nSrcBytes, bool bFreeMemory, bool bAppend = false, FSAsyncControl_t *pControl = NULL ) = 0;
virtual FSAsyncStatus_t AsyncWriteFile(const char *pFileName, const CUtlBuffer *pSrc, int nSrcBytes, bool bFreeMemory, bool bAppend = false, FSAsyncControl_t *pControl = NULL ) = 0;
@ -684,8 +793,6 @@ public:
FSAsyncStatus_t AsyncReadCreditAlloc( const FileAsyncRequest_t &request, const char *pszFile, int line, FSAsyncControl_t *phControl = NULL ) { return AsyncReadMultipleCreditAlloc( &request, 1, pszFile, line, phControl ); }
virtual FSAsyncStatus_t AsyncReadMultipleCreditAlloc( const FileAsyncRequest_t *pRequests, int nRequests, const char *pszFile, int line, FSAsyncControl_t *phControls = NULL ) = 0;
virtual FSAsyncStatus_t AsyncDirectoryScan( const char* pSearchSpec, bool recurseFolders, void* pContext, FSAsyncScanAddFunc_t pfnAdd, FSAsyncScanCompleteFunc_t pfnDone, FSAsyncControl_t *pControl = NULL ) = 0;
virtual bool GetFileTypeForFullPath( char const *pFullPath, wchar_t *buf, size_t bufSizeInBytes ) = 0;
//--------------------------------------------------------
@ -720,29 +827,10 @@ public:
// This should be called ONCE at startup. Multiplayer games (gameinfo.txt does not contain singleplayer_only)
// want to enable this so sv_pure works.
virtual void EnableWhitelistFileTracking( bool bEnable ) = 0;
virtual void EnableWhitelistFileTracking( bool bEnable, bool bCacheAllVPKHashes, bool bRecalculateAndCheckHashes ) = 0;
// This is called when the client connects to a server using a pure_server_whitelist.txt file.
//
// Files listed in pWantCRCList will have CRCs calculated for them IF they come off disk
// (and those CRCs will come out of GetUnverifiedCRCFiles).
//
// Files listed in pAllowFromDiskList will be allowed to load from disk. All other files will
// be forced to come from Steam.
//
// The filesystem hangs onto the whitelists you pass in here, and it will Release() them when it closes down
// or when you call this function again.
//
// NOTE: The whitelists you pass in here will be accessed from multiple threads, so make sure the
// IsFileInList function is thread safe.
//
// If pFilesToReload is non-null, the filesystem will hand back a list of files that should be reloaded because they
// are now "dirty". For example, if you were on a non-pure server and you loaded a certain model, and then you connected
// to a pure server that said that model had to come from Steam, then pFilesToReload would specify that model
// and the engine should reload it so it can come from Steam.
//
// Be sure to call Release() on pFilesToReload.
virtual void RegisterFileWhitelist( IFileList *pWantCRCList, IFileList *pAllowFromDiskList, IFileList **pFilesToReload ) = 0;
virtual void RegisterFileWhitelist( IPureServerWhitelist *pWhiteList, IFileList **pFilesToReload ) = 0;
// Called when the client logs onto a server. Any files that came off disk should be marked as
// unverified because this server may have a different set of files it wants to guarantee.
@ -751,7 +839,7 @@ public:
// As the server loads whitelists when it transitions maps, it calls this to calculate CRCs for any files marked
// with check_crc. Then it calls CheckCachedFileCRC later when it gets client requests to verify CRCs.
virtual void CacheFileCRCs( const char *pPathname, ECacheCRCType eType, IFileList *pFilter ) = 0;
virtual EFileCRCStatus CheckCachedFileCRC( const char *pPathID, const char *pRelativeFilename, CRC32_t *pCRC ) = 0;
virtual EFileCRCStatus CheckCachedFileHash( const char *pPathID, const char *pRelativeFilename, int nFileFraction, FileHash_t *pFileHash ) = 0;
// Fills in the list of files that have been loaded off disk and have not been verified.
// Returns the number of files filled in (between 0 and nMaxFiles).
@ -759,7 +847,7 @@ public:
// This also removes any files it's returning from the unverified CRC list, so they won't be
// returned from here again.
// The client sends batches of these to the server to verify.
virtual int GetUnverifiedCRCFiles( CUnverifiedCRCFile *pFiles, int nMaxFiles ) = 0;
virtual int GetUnverifiedFileHashes( CUnverifiedFileHash *pFiles, int nMaxFiles ) = 0;
// Control debug message output.
// Pass a combination of WHITELIST_SPEW_ flags.
@ -769,37 +857,61 @@ public:
// Installs a callback used to display a dirty disk dialog
virtual void InstallDirtyDiskReportFunc( FSDirtyDiskReportFunc_t func ) = 0;
virtual bool IsLaunchedFromXboxHDD() = 0;
virtual bool IsInstalledToXboxHDDCache() = 0;
virtual bool IsDVDHosted() = 0;
virtual bool IsInstallAllowed() = 0;
//--------------------------------------------------------
// Low-level file caching. Cached files are loaded into memory and used
// to satisfy read requests (sync and async) until the cache is destroyed.
// NOTE: this could defeat file whitelisting, if a file were loaded in
// a non-whitelisted environment and then reused. Clients should not cache
// files across moves between pure/non-pure environments.
//--------------------------------------------------------
virtual FileCacheHandle_t CreateFileCache() = 0;
virtual void AddFilesToFileCache( FileCacheHandle_t cacheId, const char **ppFileNames, int nFileNames, const char *pPathID ) = 0;
virtual bool IsFileCacheFileLoaded( FileCacheHandle_t cacheId, const char* pFileName ) = 0;
virtual bool IsFileCacheLoaded( FileCacheHandle_t cacheId ) = 0;
virtual void DestroyFileCache( FileCacheHandle_t cacheId ) = 0;
virtual int GetSearchPathID( char *pPath, int nMaxLen ) = 0;
virtual bool FixupSearchPathsAfterInstall() = 0;
// XXX For now, we assume that all path IDs are "GAME", never cache files
// outside of the game search path, and preferentially return those files
// whenever anyone searches for a match even if an on-disk file in another
// folder would have been found first in a traditional search. extending
// the memory cache to cover non-game files isn't necessary right now, but
// should just be a matter of defining a more complex key type. (henryg)
virtual FSDirtyDiskReportFunc_t GetDirtyDiskReportFunc() = 0;
// Register a CMemoryFileBacking; must balance with UnregisterMemoryFile.
// Returns false and outputs an ref-bumped pointer to the existing entry
// if the same file has already been registered by someone else; this must
// be Unregistered to maintain the balance.
virtual bool RegisterMemoryFile( CMemoryFileBacking *pFile, CMemoryFileBacking **ppExistingFileWithRef ) = 0;
virtual void AddVPKFile( char const *pszName, SearchPathAdd_t addType = PATH_ADD_TO_TAIL ) = 0;
virtual void RemoveVPKFile( char const *pszName ) = 0;
virtual void GetVPKFileNames( CUtlVector<CUtlString> &destVector ) = 0;
virtual void RemoveAllMapSearchPaths() = 0;
virtual void SyncDvdDevCache() = 0;
// Unregister a CMemoryFileBacking; must balance with RegisterMemoryFile.
virtual void UnregisterMemoryFile( CMemoryFileBacking *pFile ) = 0;
virtual bool GetStringFromKVPool( CRC32_t poolKey, unsigned int key, char *pOutBuff, int buflen ) = 0;
virtual void CacheAllVPKFileHashes( bool bCacheAllVPKHashes, bool bRecalculateAndCheckHashes ) = 0;
virtual bool CheckVPKFileHash( int PackFileID, int nPackFileNumber, int nFileFraction, MD5Value_t &md5Value ) = 0;
virtual bool DiscoverDLC( int iController ) = 0;
virtual int IsAnyDLCPresent( bool *pbDLCSearchPathMounted = NULL ) = 0;
virtual bool GetAnyDLCInfo( int iDLC, unsigned int *pLicenseMask, wchar_t *pTitleBuff, int nOutTitleSize ) = 0;
virtual int IsAnyCorruptDLC() = 0;
virtual bool GetAnyCorruptDLCInfo( int iCorruptDLC, wchar_t *pTitleBuff, int nOutTitleSize ) = 0;
virtual bool AddDLCSearchPaths() = 0;
virtual bool IsSpecificDLCPresent( unsigned int nDLCPackage ) = 0;
// Called when we unload a file, to remove that file's info for pure server purposes.
virtual void NotifyFileUnloaded( const char *pszFilename, const char *pPathId ) = 0;
};
// call this to look for CPU-hogs during loading processes. When you set this, a breakpoint
// will be issued whenever the indicated # of seconds go by without an i/o request. Passing
// 0.0 will turn off the functionality.
virtual void SetIODelayAlarm( float flThreshhold ) = 0;
//-----------------------------------------------------------------------------
// Memory file backing, which you can use to fake out the filesystem, caching data
// in memory and have it associated with a file
//-----------------------------------------------------------------------------
class CMemoryFileBacking : public CRefCounted<CRefCountServiceMT>
{
public:
CMemoryFileBacking( IFileSystem* pFS ) : m_pFS( pFS ), m_nRegistered( 0 ), m_pFileName( NULL ), m_pData( NULL ), m_nLength( 0 ) { }
~CMemoryFileBacking() { free( (char*) m_pFileName ); if ( m_pData ) m_pFS->FreeOptimalReadBuffer( (char*) m_pData ); }
IFileSystem* m_pFS;
int m_nRegistered;
const char* m_pFileName;
const char* m_pData;
int m_nLength;
private:
CMemoryFileBacking( const CMemoryFileBacking& ); // not defined
CMemoryFileBacking& operator=( const CMemoryFileBacking& ); // not defined
};
//-----------------------------------------------------------------------------

View File

@ -134,7 +134,6 @@ public:
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 AsyncDirectoryScan( const char* pSearchSpec, bool recurseFolders, void* pContext, FSAsyncScanAddFunc_t pfnAdd, FSAsyncScanCompleteFunc_t pfnDone, FSAsyncControl_t *pControl = NULL ) { return m_pFileSystemPassThru->AsyncDirectoryScan( pSearchSpec, recurseFolders, pContext, pfnAdd, pfnDone, pControl ); }
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 ); }
@ -144,6 +143,8 @@ public:
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,
@ -165,11 +166,6 @@ public:
const char *pPathID,
FileFindHandle_t *pHandle
) { return m_pFileSystemPassThru->FindFirstEx( pWildCard, pPathID, pHandle ); }
virtual void FindFileAbsoluteList(
CUtlVector<CUtlString> &output,
const char *pWildCard,
const char *pPathID
) { m_pFileSystemPassThru->FindFileAbsoluteList( output, pWildCard, pPathID ); }
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); }
@ -197,10 +193,13 @@ public:
virtual void SetupPreloadData() {}
virtual void DiscardPreloadData() {}
virtual void LoadCompiledKeyValues( KeyValuesPreloadType_t type, char const *archiveFile ) { 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 ); }
virtual bool GetFileTypeForFullPath( char const *pFullPath, wchar_t *buf, size_t bufSizeInBytes ) { return m_pFileSystemPassThru->GetFileTypeForFullPath( pFullPath, buf, bufSizeInBytes ); }
@ -218,51 +217,38 @@ public:
virtual DVDMode_t GetDVDMode() { return m_pFileSystemPassThru->GetDVDMode(); }
virtual void EnableWhitelistFileTracking( bool bEnable )
{ m_pFileSystemPassThru->EnableWhitelistFileTracking( bEnable ); }
virtual void RegisterFileWhitelist( IFileList *pForceMatchList, IFileList *pAllowFromDiskList, IFileList **pFilesToReload )
{ m_pFileSystemPassThru->RegisterFileWhitelist( pForceMatchList, pAllowFromDiskList, pFilesToReload ); }
virtual void EnableWhitelistFileTracking( bool bEnable, bool bCacheAllVPKHashes, bool bRecalculateAndCheckHashes )
{ m_pFileSystemPassThru->EnableWhitelistFileTracking( bEnable, bCacheAllVPKHashes, bRecalculateAndCheckHashes ); }
virtual void RegisterFileWhitelist( IPureServerWhitelist *pWhiteList, IFileList **ppFilesToReload )
{ m_pFileSystemPassThru->RegisterFileWhitelist( pWhiteList, ppFilesToReload ); }
virtual void MarkAllCRCsUnverified()
{ m_pFileSystemPassThru->MarkAllCRCsUnverified(); }
virtual void CacheFileCRCs( const char *pPathname, ECacheCRCType eType, IFileList *pFilter )
{ return m_pFileSystemPassThru->CacheFileCRCs( pPathname, eType, pFilter ); }
virtual EFileCRCStatus CheckCachedFileCRC( const char *pPathID, const char *pRelativeFilename, CRC32_t *pCRC )
{ return m_pFileSystemPassThru->CheckCachedFileCRC( pPathID, pRelativeFilename, pCRC ); }
virtual int GetUnverifiedCRCFiles( CUnverifiedCRCFile *pFiles, int nMaxFiles )
{ return m_pFileSystemPassThru->GetUnverifiedCRCFiles( pFiles, nMaxFiles ); }
virtual EFileCRCStatus CheckCachedFileHash( const char *pPathID, const char *pRelativeFilename, int nFileFraction, FileHash_t *pFileHash )
{ return m_pFileSystemPassThru->CheckCachedFileHash( pPathID, pRelativeFilename, nFileFraction, pFileHash ); }
virtual int GetUnverifiedFileHashes( CUnverifiedFileHash *pFiles, int nMaxFiles )
{ return m_pFileSystemPassThru->GetUnverifiedFileHashes( pFiles, nMaxFiles ); }
virtual int GetWhitelistSpewFlags()
{ return m_pFileSystemPassThru->GetWhitelistSpewFlags(); }
virtual void SetWhitelistSpewFlags( int spewFlags )
{ m_pFileSystemPassThru->SetWhitelistSpewFlags( spewFlags ); }
virtual void InstallDirtyDiskReportFunc( FSDirtyDiskReportFunc_t func ) { m_pFileSystemPassThru->InstallDirtyDiskReportFunc( func ); }
virtual bool IsLaunchedFromXboxHDD() { return m_pFileSystemPassThru->IsLaunchedFromXboxHDD(); }
virtual bool IsInstalledToXboxHDDCache() { return m_pFileSystemPassThru->IsInstalledToXboxHDDCache(); }
virtual bool IsDVDHosted() { return m_pFileSystemPassThru->IsDVDHosted(); }
virtual bool IsInstallAllowed() { return m_pFileSystemPassThru->IsInstallAllowed(); }
virtual int GetSearchPathID( char *pPath, int nMaxLen ) { return m_pFileSystemPassThru->GetSearchPathID( pPath, nMaxLen ); }
virtual bool FixupSearchPathsAfterInstall() { return m_pFileSystemPassThru->FixupSearchPathsAfterInstall(); }
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 ); }
virtual FSDirtyDiskReportFunc_t GetDirtyDiskReportFunc() { return m_pFileSystemPassThru->GetDirtyDiskReportFunc(); }
virtual void AddVPKFile( char const *pPkName, SearchPathAdd_t addType = PATH_ADD_TO_TAIL ) { m_pFileSystemPassThru->AddVPKFile( pPkName, addType ); }
virtual void RemoveVPKFile( char const *pPkName ) { m_pFileSystemPassThru->RemoveVPKFile( pPkName ); }
virtual void GetVPKFileNames( CUtlVector<CUtlString> &destVector ) { m_pFileSystemPassThru->GetVPKFileNames( destVector ); }
virtual void RemoveAllMapSearchPaths( void ) { m_pFileSystemPassThru->RemoveAllMapSearchPaths(); }
virtual void SyncDvdDevCache( void ) { m_pFileSystemPassThru->SyncDvdDevCache(); }
virtual bool GetStringFromKVPool( CRC32_t poolKey, unsigned int key, char *pOutBuff, int buflen ) { return m_pFileSystemPassThru->GetStringFromKVPool( poolKey, key, pOutBuff, buflen ); }
virtual bool DiscoverDLC( int iController ) { return m_pFileSystemPassThru->DiscoverDLC( iController ); }
virtual int IsAnyDLCPresent( bool *pbDLCSearchPathMounted = NULL ) { return m_pFileSystemPassThru->IsAnyDLCPresent( pbDLCSearchPathMounted ); }
virtual bool GetAnyDLCInfo( int iDLC, unsigned int *pLicenseMask, wchar_t *pTitleBuff, int nOutTitleSize ) { return m_pFileSystemPassThru->GetAnyDLCInfo( iDLC, pLicenseMask, pTitleBuff, nOutTitleSize ); }
virtual int IsAnyCorruptDLC() { return m_pFileSystemPassThru->IsAnyCorruptDLC(); }
virtual bool GetAnyCorruptDLCInfo( int iCorruptDLC, wchar_t *pTitleBuff, int nOutTitleSize ) { return m_pFileSystemPassThru->GetAnyCorruptDLCInfo( iCorruptDLC, pTitleBuff, nOutTitleSize ); }
virtual bool AddDLCSearchPaths() { return m_pFileSystemPassThru->AddDLCSearchPaths(); }
virtual bool IsSpecificDLCPresent( unsigned int nDLCPackage ) { return m_pFileSystemPassThru->IsSpecificDLCPresent( nDLCPackage ); }
virtual void SetIODelayAlarm( float flThreshhold ) { m_pFileSystemPassThru->SetIODelayAlarm( flThreshhold ); }
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 )
{ return m_pFileSystemPassThru->CacheAllVPKFileHashes( bCacheAllVPKHashes, bRecalculateAndCheckHashes ); }
virtual bool CheckVPKFileHash( int PackFileID, int nPackFileNumber, int nFileFraction, MD5Value_t &md5Value )
{ return m_pFileSystemPassThru->CheckVPKFileHash( PackFileID, nPackFileNumber, nFileFraction, md5Value ); }
virtual void NotifyFileUnloaded( const char *pszFilename, const char *pPathId )
{ m_pFileSystemPassThru->NotifyFileUnloaded( pszFilename, pPathId ); }
protected:
IFileSystem *m_pFileSystemPassThru;

View File

@ -25,6 +25,8 @@ public:
// This can be used to filter debug output or to catch the client or server in the act.
bool IsClient() const;
bool IsRemoteClient() const;
// for encoding m_flSimulationTime, m_flAnimTime
int GetNetworkBase( int nTick, int nEntity );
@ -79,6 +81,10 @@ private:
// Set to true in client code.
bool m_bClient;
public:
bool m_bRemoteClient;
private:
// 100 (i.e., tickcount is rounded down to this base and then the "delta" from this base is networked
int nTimestampNetworkingBase;
// 32 (entindex() % nTimestampRandomizeWindow ) is subtracted from gpGlobals->tickcount to set the networking basis, prevents
@ -106,4 +112,9 @@ inline bool CGlobalVarsBase::IsClient() const
return m_bClient;
}
inline bool CGlobalVarsBase::IsRemoteClient() const
{
return m_bRemoteClient;
}
#endif // GLOBALVARS_BASE_H

View File

@ -19,6 +19,15 @@ class INetMessage;
struct NetMessageCvar_t;
struct USERID_t;
enum CrossPlayPlatform_t
{
CROSSPLAYPLATFORM_UNKNOWN,
CROSSPLAYPLATFORM_PC,
CROSSPLAYPLATFORM_X360,
CROSSPLAYPLATFORM_PS3,
CROSSPLAYPLATFORM_LAST,
};
abstract_class IClient : public INetChannelHandler
{
public:
@ -76,8 +85,6 @@ public:
virtual bool IsFakeClient( void ) const = 0;
// returns true, if client is a HLTV proxy
virtual bool IsHLTV( void ) const = 0;
// returns true, if client is a Replay proxy
virtual bool IsReplay( void ) const = 0;
// returns true, if client hears this player
virtual bool IsHearingClient(int index) const = 0;
// returns true, if client hears this player by proximity
@ -99,7 +106,7 @@ public:
virtual bool IsHumanPlayer() const = 0;
virtual int GetClientPlatform() const = 0;
virtual CrossPlayPlatform_t GetClientPlatform() const = 0;
};
#endif // ICLIENT_H

View File

@ -78,12 +78,14 @@ public:
virtual uint64 GetUint64( const char *keyName = NULL, uint64 defaultValue = 0 ) = 0;
virtual float GetFloat( const char *keyName = NULL, float defaultValue = 0.0f ) = 0;
virtual const char *GetString( const char *keyName = NULL, const char *defaultValue = "" ) = 0;
virtual const wchar_t * GetWString(char const *keyName = NULL, const wchar_t *defaultValue = L"") = 0;
virtual void SetBool( const char *keyName, bool value ) = 0;
virtual void SetInt( const char *keyName, int value ) = 0;
virtual void SetUint64( const char *keyName, uint64 value ) = 0;
virtual void SetFloat( const char *keyName, float value ) = 0;
virtual void SetString( const char *keyName, const char *value ) = 0;
virtual void SetWString( const char *keyName, const wchar_t *value ) = 0;
};
#define EVENT_DEBUG_ID_INIT 42

View File

@ -18,8 +18,9 @@
#include "basehandle.h"
#endif
#ifdef _MSC_VER
#pragma warning( disable : 4284 ) // warning C4284: return type for 'CNetworkVarT<int>::operator ->' is 'int *' (ie; not a UDT or reference to a UDT. Will produce errors if applied using infix notation)
#endif
#define MyOffsetOf( type, var ) ( (int)&((type*)0)->var )

View File

@ -293,29 +293,61 @@ typedef unsigned int uint;
// Maximum and minimum representable values
#ifndef PLATFORM_OSX
#if !defined(PLATFORM_OSX) && !defined(__STDC_LIMIT_MACROS)
#ifndef INT8_MAX
#define INT8_MAX SCHAR_MAX
#endif
#ifndef INT16_MAX
#define INT16_MAX SHRT_MAX
#endif
#ifndef INT32_MAX
#define INT32_MAX LONG_MAX
#endif
#ifndef INT64_MAX
#define INT64_MAX (((int64)~0) >> 1)
#endif
#ifndef INT8_MIN
#define INT8_MIN SCHAR_MIN
#endif
#ifndef INT16_MIN
#define INT16_MIN SHRT_MIN
#endif
#ifndef INT32_MIN
#define INT32_MIN LONG_MIN
#endif
#ifndef INT64_MIN
#define INT64_MIN (((int64)1) << 63)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX ((uint8)~0)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX ((uint16)~0)
#endif
#ifndef UINT32_MAX
#define UINT32_MAX ((uint32)~0)
#endif
#ifndef UINT16_MAX
#define UINT64_MAX ((uint64)~0)
#endif
#ifndef UINT8_MIN
#define UINT8_MIN 0
#endif
#ifndef UINT16_MIN
#define UINT16_MIN 0
#endif
#ifndef UINT32_MIN
#define UINT32_MIN 0
#endif
#ifndef UINT64_MIN
#define UINT64_MIN 0
#endif
#endif // PLATFORM_OSX
#endif // !PLATFORM_OSX && !__STDC_LIMIT_MACROS
#ifndef UINT_MIN
#define UINT_MIN UINT32_MIN
@ -1127,8 +1159,19 @@ struct CPUInformation
CPUInformation(): m_Size(0){}
};
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
#endif
PLATFORM_INTERFACE const CPUInformation& GetCPUInformation();
#ifdef __clang__
#pragma clang diagnostic pop
#endif
PLATFORM_INTERFACE void GetCurrentDate( int *pDay, int *pMonth, int *pYear );
PLATFORM_INTERFACE void GetCurrentDayOfTheWeek( int *pDay ); // 0 = Sunday
PLATFORM_INTERFACE void GetCurrentDayOfTheYear( int *pDay ); // 0 = Jan 1

View File

@ -890,9 +890,22 @@ template <> struct CAutoLockTypeDeducer<sizeof(CAlignedThreadFastMutex)> { typed
#define AUTO_LOCK_( type, mutex ) \
CAutoLockT< type > UNIQUE_ID( static_cast<const type &>( mutex ) )
#define AUTO_LOCK( mutex ) \
AUTO_LOCK_( typeof(CAutoLockTypeDeducer<sizeof(mutex)>::Type_t), mutex )
#if defined(GNUC)
template<typename T> T strip_cv_quals_for_mutex(T&);
template<typename T> T strip_cv_quals_for_mutex(const T&);
template<typename T> T strip_cv_quals_for_mutex(volatile T&);
template<typename T> T strip_cv_quals_for_mutex(const volatile T&);
#define AUTO_LOCK( mutex ) \
AUTO_LOCK_( typeof(::strip_cv_quals_for_mutex(mutex)), mutex )
#else // GNUC
#define AUTO_LOCK( mutex ) \
AUTO_LOCK_( CAutoLockTypeDeducer<sizeof(mutex)>::Type_t, mutex )
#endif
#define AUTO_LOCK_FM( mutex ) \
AUTO_LOCK_( CThreadFastMutex, mutex )

View File

@ -13,6 +13,18 @@
// 16 bytes == 128 bit digest
#define MD5_DIGEST_LENGTH 16
#define MD5_BIT_LENGTH ( MD5_DIGEST_LENGTH * sizeof(unsigned char) )
struct MD5Value_t
{
unsigned char bits[MD5_DIGEST_LENGTH];
void Zero();
bool IsZero() const;
bool operator==( const MD5Value_t &src ) const;
bool operator!=( const MD5Value_t &src ) const;
};
// MD5 Hash
typedef struct
@ -28,6 +40,23 @@ void MD5Final( unsigned char digest[ MD5_DIGEST_LENGTH ], MD5Context_t *context
char *MD5_Print(unsigned char *digest, int hashlen );
/// Convenience wrapper to calculate the MD5 for a buffer, all in one step, without
/// bothering with the context object.
void MD5_ProcessSingleBuffer( const void *p, int len, MD5Value_t &md5Result );
unsigned int MD5_PseudoRandom(unsigned int nSeed);
/// Returns true if the values match.
bool MD5_Compare( const MD5Value_t &data, const MD5Value_t &compare );
inline bool MD5Value_t::operator==( const MD5Value_t &src ) const
{
return MD5_Compare( *this, src );
}
inline bool MD5Value_t::operator!=( const MD5Value_t &src ) const
{
return !MD5_Compare( *this, src );
}
#endif // CHECKSUM_MD5_H

View File

@ -371,8 +371,8 @@ public:
FnChangeCallback_t GetChangeCallback( int slot ) const { return m_pParent->m_fnChangeCallbacks[ slot ]; }
// Retrieve value
FORCEINLINE_CVAR float GetFloat( void ) const;
FORCEINLINE_CVAR int GetInt( void ) const;
virtual float GetFloat( void ) const;
virtual int GetInt( void ) const;
FORCEINLINE_CVAR Color GetColor( void ) const;
FORCEINLINE_CVAR bool GetBool() const { return !!GetInt(); }
FORCEINLINE_CVAR char const *GetString( void ) const;

View File

@ -232,7 +232,7 @@ void MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5Context_t *ctx)
MD5Transform(ctx->buf, (unsigned int *) ctx->in);
//byteReverse((unsigned char *) ctx->buf, 4);
memcpy(digest, ctx->buf, MD5_DIGEST_LENGTH);
memset(ctx, 0, sizeof(MD5Context_t)); /* In case it's sensitive */
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
}
//-----------------------------------------------------------------------------
@ -269,3 +269,37 @@ unsigned int MD5_PseudoRandom(unsigned int nSeed)
return *(unsigned int*)(digest+6); // use 4 middle bytes for random value
}
//-----------------------------------------------------------------------------
bool MD5_Compare( const MD5Value_t &data, const MD5Value_t &compare )
{
return V_memcmp( data.bits, compare.bits, MD5_DIGEST_LENGTH ) == 0;
}
//-----------------------------------------------------------------------------
void MD5Value_t::Zero()
{
V_memset( bits, 0, sizeof( bits ) );
}
//-----------------------------------------------------------------------------
bool MD5Value_t::IsZero() const
{
for ( size_t i = 0 ; i < Q_ARRAYSIZE( bits ) ; ++i )
{
if ( bits[i] != 0 )
return false;
}
return true;
}
//-----------------------------------------------------------------------------
void MD5_ProcessSingleBuffer( const void *p, int len, MD5Value_t &md5Result )
{
Assert( len >= 0 );
MD5Context_t ctx;
MD5Init( &ctx );
MD5Update( &ctx, (unsigned char const *)p, len );
MD5Final( md5Result.bits, &ctx );
}