forked from mirror/openmw-tes3mp
Merge remote-tracking branch 'dteviot/Rng'
This commit is contained in:
commit
9ab25dbf6b
1 changed files with 3 additions and 3 deletions
|
@ -12,6 +12,8 @@
|
||||||
#include "runtime.hpp"
|
#include "runtime.hpp"
|
||||||
#include "defines.hpp"
|
#include "defines.hpp"
|
||||||
|
|
||||||
|
#include <openengine/misc/rng.hpp>
|
||||||
|
|
||||||
namespace Interpreter
|
namespace Interpreter
|
||||||
{
|
{
|
||||||
inline std::string formatMessage (const std::string& message, Runtime& runtime)
|
inline std::string formatMessage (const std::string& message, Runtime& runtime)
|
||||||
|
@ -140,15 +142,13 @@ namespace Interpreter
|
||||||
|
|
||||||
virtual void execute (Runtime& runtime)
|
virtual void execute (Runtime& runtime)
|
||||||
{
|
{
|
||||||
double r = static_cast<double> (std::rand()) / RAND_MAX; // [0, 1)
|
|
||||||
|
|
||||||
Type_Integer limit = runtime[0].mInteger;
|
Type_Integer limit = runtime[0].mInteger;
|
||||||
|
|
||||||
if (limit<0)
|
if (limit<0)
|
||||||
throw std::runtime_error (
|
throw std::runtime_error (
|
||||||
"random: argument out of range (Don't be so negative!)");
|
"random: argument out of range (Don't be so negative!)");
|
||||||
|
|
||||||
Type_Integer value = static_cast<Type_Integer> (r*limit); // [o, limit)
|
Type_Integer value = OEngine::Misc::Rng::rollDice(limit); // [o, limit)
|
||||||
|
|
||||||
runtime[0].mInteger = value;
|
runtime[0].mInteger = value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue