1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-07 12:54:00 +00:00
OpenMW/libs/openengine/misc/rng.cpp

30 lines
598 B
C++
Raw Normal View History

#include "rng.hpp"
#include <cstdlib>
#include <ctime>
namespace OEngine {
namespace Misc {
void Rng::init()
{
std::srand(static_cast<unsigned int>(std::time(NULL)));
}
float Rng::rollProbability()
{
return static_cast<float>(std::rand() / (static_cast<double>(RAND_MAX)+1.0));
}
float Rng::rollClosedProbability()
{
return static_cast<float>(std::rand() / static_cast<double>(RAND_MAX));
}
int Rng::rollDice(int max)
{
return static_cast<int>((std::rand() / (static_cast<double>(RAND_MAX)+1.0)) * (max));
}
}
2015-04-01 02:02:08 +00:00
}