mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
initial commit
This commit is contained in:
commit
a11f93df4d
99 changed files with 7493 additions and 0 deletions
18
servatrice/src/testrandom.cpp
Normal file
18
servatrice/src/testrandom.cpp
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#include "testrandom.h"
|
||||
#include <QThread>
|
||||
|
||||
void TestRandom::init()
|
||||
{
|
||||
if (initialized)
|
||||
return;
|
||||
int seed = QDateTime::currentDateTime().toTime_t();
|
||||
qDebug(QString("%1: qsrand(%2)").arg(thread()->metaObject()->className()).arg(seed).toLatin1());
|
||||
qsrand(seed);
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
unsigned int TestRandom::getNumber(unsigned int min, unsigned int max)
|
||||
{
|
||||
int r = qrand();
|
||||
return min + (unsigned int) (((double) (max + 1 - min)) * r / (RAND_MAX + 1.0));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue