diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-01-03 00:08:48 -0700 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-01-03 00:08:48 -0700 |
commit | 8b9a15a755ebc6681ff6be808615e375cb567080 (patch) | |
tree | c836f3a7a338e6bcc1fe88fe1207819005b92a83 /src/functionrandom.cpp | |
parent | 340de5ebabbc60727b2aeb85b9faa72a75f1628b (diff) | |
download | stage-8b9a15a755ebc6681ff6be808615e375cb567080.tar.gz stage-8b9a15a755ebc6681ff6be808615e375cb567080.tar.bz2 stage-8b9a15a755ebc6681ff6be808615e375cb567080.tar.xz stage-8b9a15a755ebc6681ff6be808615e375cb567080.zip |
New functions, fixes, and a working bloodfields.
Diffstat (limited to 'src/functionrandom.cpp')
-rw-r--r-- | src/functionrandom.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/functionrandom.cpp b/src/functionrandom.cpp index 2665a14..ec302b3 100644 --- a/src/functionrandom.cpp +++ b/src/functionrandom.cpp | |||
@@ -20,10 +20,17 @@ void FunctionRandom::call( class GameState &gState ) | |||
20 | if( vHigh.getType() != vLow.getType() ) | 20 | if( vHigh.getType() != vLow.getType() ) |
21 | throw Bu::ExceptionBase("Different types in random!"); | 21 | throw Bu::ExceptionBase("Different types in random!"); |
22 | 22 | ||
23 | double dRand = random()/(double)(RAND_MAX-1); | ||
23 | if( vLow.getType() == Variable::tInt ) | 24 | if( vLow.getType() == Variable::tInt ) |
24 | { | 25 | { |
25 | gState.push( Variable( (int64_t)( | 26 | gState.push( Variable( (int64_t)( |
26 | (random()%(vHigh.getInt()-vLow.getInt()+1ll))+vLow.getInt() | 27 | (dRand*(vHigh.getInt()-vLow.getInt()+1ll))+vLow.getInt() |
28 | ) ) ); | ||
29 | } | ||
30 | else if( vLow.getType() == Variable::tFloat ) | ||
31 | { | ||
32 | gState.push( Variable( (double)( | ||
33 | (dRand*(vHigh.getFloat()-vLow.getFloat()))+vLow.getFloat() | ||
27 | ) ) ); | 34 | ) ) ); |
28 | } | 35 | } |
29 | } | 36 | } |