mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 16:44:48 -07:00
minor improvements
This commit is contained in:
parent
a429a4a004
commit
792a400a3d
30 changed files with 1022 additions and 829 deletions
18
servatrice/src/random.cpp
Normal file
18
servatrice/src/random.cpp
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#include "random.h"
|
||||
#include <QThread>
|
||||
|
||||
void Random::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 Random::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