Warnings: be explicit about values we are using.
[gnushogi.git] / gnushogi / rawdsp.c
index 5f04dca..033d93b 100644 (file)
@@ -111,10 +111,15 @@ Raw_ShowLine(unsigned short *bstline)
 
 
 static void
-Raw_ShowMessage(char *s)
+Raw_ShowMessage(char *format, ...)
 {
-    if (!XSHOGI)
-        printf("%s\n", s);
+    if (XSHOGI)
+        return;
+    va_list ap;
+    va_start(ap, format);
+    vprintf(format, ap);
+    printf("\n");
+    va_end(ap);
 }
 
 
@@ -521,12 +526,15 @@ Raw_OutputMove(void)
     if (mvstr[0][0] == '\0')
         goto nomove;
 
-    if (XSHOGI)
+    mycnt1++;
+    if (XSHOGI && xboard) /* xboard: print move in XBoard format, with 'move' prefix */
+        printf("move %s\n", mvstr[0]);
+    else if (XSHOGI)
         /* add remaining time in milliseconds to xshogi */
-        printf("%d. ... %s %ld\n", ++mycnt1, mvstr[0],
+        printf("%d. ... %s %ld\n", mycnt1, mvstr[0],
                (TimeControl.clock[player] - et) * 10);
     else
-        printf("%d. ... %s\n", ++mycnt1, mvstr[0]);
+        printf("%d. ... %s\n", mycnt1, mvstr[0]);
 
  nomove:
     if ((root->flags & draw) || (root->score == -(SCORE_LIMIT + 999))
@@ -750,8 +758,8 @@ Raw_SelectLevel(char *sx)
     } else {
         int min, sec=0, inc, mps;
         /* parse regular "level MPS TC INC" command of WB protocol */
-        sscanf(sx, "%d %d %d", &mps, &min, &inc) == 3 ||
-        sscanf(sx, "%d %d:%d %d", &mps, &min, &sec, &inc);
+        if (sscanf(sx, "%d %d %d", &mps, &min, &inc) != 3)
+            sscanf(sx, "%d %d:%d %d", &mps, &min, &sec, &inc);
         TCminutes = min; TCseconds = sec;
         TCadd = inc*100; TCmoves = mps ? mps : 50;
         MaxResponseTime = 0; TCflag = true;