summaryrefslogtreecommitdiff
path: root/engine/randomstream.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /engine/randomstream.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'engine/randomstream.cpp')
-rw-r--r--engine/randomstream.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/engine/randomstream.cpp b/engine/randomstream.cpp
new file mode 100644
index 0000000..7318e6e
--- /dev/null
+++ b/engine/randomstream.cpp
@@ -0,0 +1,48 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: random steam class
+//
+//===========================================================================//
+
+#include <tier0/dbg.h>
+#include <vstdlib/random.h>
+#include "cdll_int.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+//-----------------------------------------------------------------------------
+//
+// implementation of IUniformRandomStream
+//
+//-----------------------------------------------------------------------------
+class CEngineUniformRandomStream : public IUniformRandomStream
+{
+public:
+ // Sets the seed of the random number generator
+ void SetSeed( int iSeed )
+ {
+ // Never call this from the client or game!
+ Assert(0);
+ }
+
+ // Generates random numbers
+ float RandomFloat( float flMinVal = 0.0f, float flMaxVal = 1.0f )
+ {
+ return ::RandomFloat( flMinVal, flMaxVal );
+ }
+
+ float RandomFloatExp( float flMinVal = 0.0f, float flMaxVal = 1.0f, float flExponent = 1.0f )
+ {
+ return ::RandomFloatExp( flMinVal, flMaxVal, flExponent );
+ }
+
+ int RandomInt( int iMinVal, int iMaxVal )
+ {
+ return ::RandomInt( iMinVal, iMaxVal );
+ }
+};
+
+static CEngineUniformRandomStream s_EngineRandomStream;
+EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CEngineUniformRandomStream, IUniformRandomStream,
+ VENGINE_CLIENT_RANDOM_INTERFACE_VERSION, s_EngineRandomStream );