Fix recognition of CECP 'level' command
authorH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 10 Apr 2018 15:09:56 +0000 (17:09 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 10 Apr 2018 16:16:42 +0000 (18:16 +0200)
As the sscanf to extract the TC parameters was attempting to match the
initial keyword 'level' as well, while the first byte of the input buffer
had already been zeroed to mark the command as processed, the 'level'
command was completely ignored, and CrazyWa was always playing at its
default TC of 40 moves / 5 min.

dropper.c

index 6f12051..4bf5dff 100644 (file)
--- a/dropper.c
+++ b/dropper.c
@@ -1782,8 +1782,8 @@ printf("# command: %s\n", inBuf);
     if(!strcmp(command, "exit"))    { engineSide = NONE;    return 1; }
     if(!strcmp(command, "level"))   {
       int min, sec=0;
-      sscanf(inBuf, "level %d %d %d", &mps, &min, &inc) == 3 ||  // if this does not work, it must be min:sec format
-      sscanf(inBuf, "level %d %d:%d %d", &mps, &min, &sec, &inc);
+      sscanf(inBuf+6, "%d %d %d", &mps, &min, &inc) == 3 ||  // if this does not work, it must be min:sec format
+      sscanf(inBuf+6, "%d %d:%d %d", &mps, &min, &sec, &inc);
       timeControl = 60*min + sec; timePerMove = -1;
       return 1;
     }