Commit 1818247d authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Port away from deprecated KRandomSequence

Also do not have an instance with every MineFieldItem, instead generate
a QRandomGenerator on the fly for the one use-case in
MineFieldItem::generateField()
parent 5b34edff
......@@ -21,6 +21,7 @@
#include "kmines_debug.h"
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QRandomGenerator>
#include "cellitem.h"
#include "borderitem.h"
......@@ -129,9 +130,10 @@ void MineFieldItem::generateField(int clickedIdx)
// (it will be empty if none of surrounding items holds mine)
QList<CellItem*> neighbForClicked = adjacentItemsFor(fp.first, fp.second);
QRandomGenerator random(QRandomGenerator::global()->generate());
while(minesToPlace != 0)
{
randomIdx = m_randomSeq.getLong( m_numRows*m_numCols );
randomIdx = random.bounded( m_numRows*m_numCols );
item = m_cells.at(randomIdx);
if(!item->hasMine()
&& neighbForClicked.indexOf(item) == -1
......
......@@ -22,7 +22,6 @@
#include <QVector>
#include <QGraphicsObject>
#include <QPair>
#include <KRandomSequence>
class KGameRenderer;
class CellItem;
......@@ -197,10 +196,6 @@ private:
* Number of flagged mines
*/
int m_flaggedMinesCount;
/**
* Random sequence used to generate mine positions
*/
KRandomSequence m_randomSeq;
/**
* row and column where mouse was pressed.
* (-1,-1) if it is already released
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment