gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnugo-devel] arend_3_4.3: don't crash on invalid sgf-move


From: Arend Bayer
Subject: [gnugo-devel] arend_3_4.3: don't crash on invalid sgf-move
Date: Wed, 12 Jun 2002 21:53:11 +0200 (CEST)

 - Don't crash due to invalid move in .sgf-file.

Instead ignore this move and print a warning. This is btw still not what
the sgf standard says GNU Go should do. But I can't be bothered to get it
conforming -- IMHO the sgf standard should just allow undefined behaviour in
such a case.

Arend


Index: engine/interface.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/interface.c,v
retrieving revision 1.19
diff -u -r1.19 interface.c
--- engine/interface.c  3 Jun 2002 15:00:59 -0000       1.19
+++ engine/interface.c  12 Jun 2002 19:50:08 -0000
@@ -605,10 +605,17 @@
          }

        rotate(i, j, &i, &j, board_size, orientation);
-       gnugo_play_move(i, j, next);
-       sgffile_move_made(i, j, next, 0);
-       next = OTHER_COLOR(next);
-
+       if (ON_BOARD2(i,j) && board[POS(i, j)] == EMPTY) {
+         gnugo_play_move(i, j, next);
+         sgffile_move_made(i, j, next, 0);
+         next = OTHER_COLOR(next);
+       }
+       else {
+         fprintf(stderr, "WARNING: Move off board or on occupied position 
found in sgf-file.\n");
+         fprintf(stderr, "Move ignored, trying to proceed.\n");
+         return;
+       }
+
        break;

       case SGFIL:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]