[Kde-games-devel] A path for kreversi

Albert Astals Cid tsdgeos at terra.es
Fri Apr 25 01:24:59 CEST 2003


This is a bit longer than the previous one.

I've deleted one function void processEvent(int itemid); as it seems not to be 
used from time.

Also have modified a bit slotStatusChange as it was using board->getState() 
when the int received as parameter is exactly that.

And finally have added this -> isVisible() to the condition of the for that 
flashes the hint to the user, because if the player quitted the game (either 
with [x] or with game->quit) while there was a hint showing, the game would 
not end until all the loop was completed (this could be noticed when 
launching the game from the shell because the prompt didn't return)

Here comes the patch obtained with cvs diff

? kreversi_diff
Index: board.cpp
===================================================================
RCS file: /home/kde/kdegames/kreversi/board.cpp,v
retrieving revision 1.25
diff -u -r1.25 board.cpp
--- board.cpp	17 Apr 2003 04:37:39 -0000	1.25
+++ board.cpp	24 Apr 2003 22:22:36 -0000
@@ -347,7 +347,10 @@
     Move m = engine->ComputeMove(*game);
     setState(HINT);
     if(m.GetX() != -1) {
-      for(int flash = 0; (flash < 100) && (getState() != READY); flash++) {
+      // the isVisible condition has been added so that when the player was 
viewing
+      // a hint and quits the game window, the game must not still do all 
this looping
+      // and directly ends
+      for(int flash = 0; (flash < 100) && (getState() != READY) && this -> 
isVisible(); flash++) {
 	if(flash & 1)
 	  drawOnePiece(m.GetY() - 1, m.GetX() - 1, Score::NOBODY);
 	else
Index: kreversi.cpp
===================================================================
RCS file: /home/kde/kdegames/kreversi/kreversi.cpp,v
retrieving revision 1.4
diff -u -r1.4 kreversi.cpp
--- kreversi.cpp	17 Apr 2003 04:37:41 -0000	1.4
+++ kreversi.cpp	24 Apr 2003 22:22:37 -0000
@@ -189,24 +189,6 @@
     zoomOutAction->setEnabled(false);
 }

-void KReversi::processEvent(int itemid) {
-#ifdef HAVE_MEDIATOOL
-    if(!audioOK()) {
-      initAudio();
-      if(!audioOK()) {
-	KMessageBox::error(this,
-			   i18n("A problem with the sound server occured!\n"
-				"Cannot enable sound support."));
-	kapp->config()->writeEntry("Sound", 0);
-      } else
-	kapp->config()->writeEntry("Sound", 1);
-    } else {
-      doneAudio();
-      kapp->config()->writeEntry("Sound", 0);
-    }
-#endif
-}
-
 void KReversi::slotScore() {
   int black, white;
   QString s1, s2;
@@ -308,8 +290,8 @@
   statusBar()->changeItem(s, SB_TURN);
 }

-void KReversi::slotStatusChange(int) {
-  if(board->getState() == Board::THINKING){
+void KReversi::slotStatusChange(int status) {
+  if(status == Board::THINKING){
     kapp->setOverrideCursor(waitCursor);
     stopAction->setEnabled(true);
   }
Index: kreversi.h
===================================================================
RCS file: /home/kde/kdegames/kreversi/kreversi.h,v
retrieving revision 1.2
diff -u -r1.2 kreversi.h
--- kreversi.h	17 Apr 2003 04:37:41 -0000	1.2
+++ kreversi.h	24 Apr 2003 22:22:37 -0000
@@ -60,7 +60,6 @@
   virtual void readProperties(KConfig *);
 
 private slots:
-  void processEvent(int itemid);
   void slotScore();
   void slotGameEnded(int);
   void slotTurn(int);



More information about the kde-games-devel mailing list