Fix pondering in XBoard mode
[bonanza.git] / proce.c
diff --git a/proce.c b/proce.c
index a08b5d9..cb98efa 100644 (file)
--- a/proce.c
+++ b/proce.c
@@ -136,6 +136,7 @@ int all_moves[MAX_LEGAL_MOVES];
 
 int myTime, hisTime, movesPerSession, inc, plyNr;
 char xboard_mode;
+int root_pos[nsquare];
 
 int
 xboard_to_CSA( tree_t * restrict ptree, char *in, char *out, int status )
@@ -160,7 +161,7 @@ xboard_to_CSA( tree_t * restrict ptree, char *in, char *out, int status )
     int flag = (promo == '+' ? FLAG_PROMO : 0);
     piece = abs( BOARD[from] ); // this only works when not searching!
 printf("# piece from board: %d\n", piece);fflush(stdout);
-    if( status & ( flag_pondering | flag_puzzling | flag_thinking ) ) {
+    if( status & flag_thinking ) {
       int i, to = ('9' - toY)*9 + (toX - 'a'), l = (status == (flag_pondering | flag_thinking));
       piece = 0; // kludge to force illegal CSA move
       for( i = 0; l ? all_moves[i] : i < root_nmove; i++ ) { // determine the piece from the move list
@@ -172,8 +173,8 @@ printf("# piece from board: %d\n", piece);fflush(stdout);
        bonanza_move = move;
         break;
       }
+    } else if( status & ( flag_pondering | flag_puzzling ) ) piece = abs( root_pos[from] ); // we have valid copy!
 printf("# piece corrected to %d\n", piece);fflush(stdout);
-    }
     if( promo ) piece += promote;
     sprintf(out, "%c%c%c%c%s", 'a'+'9'-fromX, '1'+'9'-fromY, 'a'+'9'-toX, '1'+'9'-toY, astr_table_piece[piece]);
   }