[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdegames/kmines
From:       Nicolas Roffet <nicolas-kde () roffet ! com>
Date:       2008-04-03 19:35:51
Message-ID: 1207251351.343502.32672.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 793377 by roffet:

There was a bug in KMines: the program was freezing in a custom game if you chose to \
put in the field so many mines that there was not at least 9 free positions. Now, \
it's working.

New feature: to avoid trivial games, KMines now constrains the user to let at least \
10 (-> one more than 9) positions free.

Note: I'm not sure it's a good idea to avoid to put mines on neighbor positions to \
the start position... To discuss...

CCMAIL:piacentini@kde.org
CCMAIL:dimsuz@gmail.com

 M  +1 -1      minefielditem.cpp  
 M  +6 -0      minefielditem.h  
 M  +1 -1      scene.cpp  


--- trunk/KDE/kdegames/kmines/minefielditem.cpp #793376:793377
@@ -32,7 +32,7 @@
 
 void MineFieldItem::initField( int numRows, int numCols, int numMines )
 {
-    Q_ASSERT( numMines < numRows*numCols );
+    Q_ASSERT( numMines + MINIMAL_FREE <= numRows*numCols );
 
     m_firstClick = true;
     m_gameOver = false;
--- trunk/KDE/kdegames/kmines/minefielditem.h #793376:793377
@@ -72,6 +72,12 @@
      * @return num mines in field
      */
     int minesCount() const { return m_minesCount; }
+
+    /**
+     * Minimal number of free positions on a field
+     */
+    static const int MINIMAL_FREE = 10;
+
 signals:
     void flaggedMinesCountChanged(int);
     void firstClickDone();
--- trunk/KDE/kdegames/kmines/scene.cpp #793376:793377
@@ -71,7 +71,7 @@
 
 void KMinesScene::startNewGame(int rows, int cols, int numMines)
 {
-    if(numMines >= rows*cols)
+    if(numMines + MineFieldItem::MINIMAL_FREE > rows*cols)
     {
         m_messageItem->showMessage(i18n("Custom game can not be started.<br />Number \
of mines is too big for current field."), KGamePopupItem::BottomLeft);  return;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic