D26201: Port away from KRandom
Parker Coates
noreply at phabricator.kde.org
Wed Jan 8 13:45:05 GMT 2020
coates added a comment.
Using `QRandomGenerator`, but keeping `RAND_MAX` is really only a half port. Please, use `QRandomGenerator`'s convenient generation functions.
INLINE COMMENTS
> dealer.cpp:792
> // Generate a random number with an exponentional distribution averaging 1/4.
> - qreal randomExp = qMin<qreal>( -log( 1 - qreal( KRandom::random() ) / RAND_MAX ) / 4, 1 );
> + qreal randomExp = qMin<qreal>( -log( 1 - qreal( QRandomGenerator::global()->generate() ) / RAND_MAX ) / 4, 1 );
> int randomIndex = randomExp * ( hintList.size() - 1 );
qreal randomExp = qMin<qreal>( -log( 1 - QRandomGenerator::global()::generateDouble() ) / 4, 1 );
> mainwindow.cpp:422
> QList<KCardTheme> themes = KCardTheme::findAll();
> - KCardTheme theme = themes.at( KRandom::random() % themes.size() );
> + KCardTheme theme = themes.at( QRandomGenerator::global()->generate() % themes.size() );
> Settings::setCardTheme( theme.dirName() );
KCardTheme theme = themes.at( QRandomGenerator::global()->bounded( themes.size() ) );
> spider.cpp:406
> + qreal x = rect.left() + qreal(QRandomGenerator::global()->generate()) / RAND_MAX * (rect.width() - deck()->cardWidth());
> + qreal y = rect.top() + qreal(QRandomGenerator::global()->generate()) / RAND_MAX * (rect.height() - deck()->cardHeight());
> return QPointF( x, y );
qreal x = rect.left() + QRandomGenerator::global()::bounded(rect.width() - deck()->cardWidth());
qreal y = rect.top() + QRandomGenerator::global()::bounded(rect.height() - deck()->cardHeight());
REPOSITORY
R410 KPatience
REVISION DETAIL
https://phabricator.kde.org/D26201
To: nicolasfella, #kde_games, shlomif
Cc: coates, shlomif, kde-games-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-games-devel/attachments/20200108/8c939538/attachment.html>
More information about the kde-games-devel
mailing list