diff options
| author | John Schoenick <[email protected]> | 2015-09-09 18:35:41 -0700 |
|---|---|---|
| committer | John Schoenick <[email protected]> | 2015-09-09 18:35:41 -0700 |
| commit | 0d8dceea4310fde5706b3ce1c70609d72a38efdf (patch) | |
| tree | c831ef32c2c801a5c5a80401736b52c7b5a528ec /mp/src/public/vstdlib | |
| parent | Updated the SDK with the latest code from the TF and HL2 branches. (diff) | |
| download | source-sdk-2013-master.tar.xz source-sdk-2013-master.zip | |
Diffstat (limited to 'mp/src/public/vstdlib')
| -rw-r--r-- | mp/src/public/vstdlib/IKeyValuesSystem.h | 9 | ||||
| -rw-r--r-- | mp/src/public/vstdlib/random.h | 16 |
2 files changed, 23 insertions, 2 deletions
diff --git a/mp/src/public/vstdlib/IKeyValuesSystem.h b/mp/src/public/vstdlib/IKeyValuesSystem.h index 1bd5a8ab..e999dd81 100644 --- a/mp/src/public/vstdlib/IKeyValuesSystem.h +++ b/mp/src/public/vstdlib/IKeyValuesSystem.h @@ -16,6 +16,9 @@ typedef int HKeySymbol; #define INVALID_KEY_SYMBOL (-1) +class IBaseFileSystem; +class KeyValues; + //----------------------------------------------------------------------------- // Purpose: Interface to shared data repository for KeyValues (included in vgui_controls.lib) // allows for central data storage point of KeyValues symbol table @@ -39,6 +42,12 @@ public: // for debugging, adds KeyValues record into global list so we can track memory leaks virtual void AddKeyValuesToMemoryLeakList(void *pMem, HKeySymbol name) = 0; virtual void RemoveKeyValuesFromMemoryLeakList(void *pMem) = 0; + + // maintain a cache of KeyValues we load from disk. This saves us quite a lot of time on app startup. + virtual void AddFileKeyValuesToCache( const KeyValues* _kv, const char *resourceName, const char *pathID ) = 0; + virtual bool LoadFileKeyValuesFromCache( KeyValues* _outKv, const char *resourceName, const char *pathID, IBaseFileSystem *filesystem ) const = 0; + virtual void InvalidateCache( ) = 0; + virtual void InvalidateCacheForFile( const char *resourceName, const char *pathID ) = 0; }; VSTDLIB_INTERFACE IKeyValuesSystem *KeyValuesSystem(); diff --git a/mp/src/public/vstdlib/random.h b/mp/src/public/vstdlib/random.h index 88188031..fdfd09c6 100644 --- a/mp/src/public/vstdlib/random.h +++ b/mp/src/public/vstdlib/random.h @@ -22,9 +22,11 @@ //----------------------------------------------------------------------------- // A generator of uniformly distributed random numbers //----------------------------------------------------------------------------- -class IUniformRandomStream +class VSTDLIB_CLASS IUniformRandomStream { public: + //virtual ~IUniformRandomStream() { } + // Sets the seed of the random number generator virtual void SetSeed( int iSeed ) = 0; @@ -86,7 +88,6 @@ private: CThreadFastMutex m_mutex; }; - //----------------------------------------------------------------------------- // A couple of convenience functions to access the library's global uniform stream //----------------------------------------------------------------------------- @@ -96,6 +97,17 @@ VSTDLIB_INTERFACE float RandomFloatExp( float flMinVal = 0.0f, float flMaxVal = VSTDLIB_INTERFACE int RandomInt( int iMinVal, int iMaxVal ); VSTDLIB_INTERFACE float RandomGaussianFloat( float flMean = 0.0f, float flStdDev = 1.0f ); +//----------------------------------------------------------------------------- +// IUniformRandomStream interface for free functions +//----------------------------------------------------------------------------- +class VSTDLIB_CLASS CDefaultUniformRandomStream : public IUniformRandomStream +{ +public: + virtual void SetSeed( int iSeed ) OVERRIDE { RandomSeed( iSeed ); } + virtual float RandomFloat( float flMinVal, float flMaxVal ) OVERRIDE { return ::RandomFloat( flMinVal, flMaxVal ); } + virtual int RandomInt( int iMinVal, int iMaxVal ) OVERRIDE { return ::RandomInt( iMinVal, iMaxVal ); } + virtual float RandomFloatExp( float flMinVal, float flMaxVal, float flExponent ) OVERRIDE { return ::RandomFloatExp( flMinVal, flMaxVal, flExponent ); } +}; //----------------------------------------------------------------------------- // Installs a global random number generator, which will affect the Random functions above |