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/random.h | |
| 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/random.h')
| -rw-r--r-- | mp/src/public/vstdlib/random.h | 16 |
1 files changed, 14 insertions, 2 deletions
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 |