Reorder parsing of protocol commands
authorH.G. Muller <h.g.muller@hccnet.nl>
Fri, 31 May 2013 17:41:02 +0000 (19:41 +0200)
committerH.G. Muller <h.g.muller@hccnet.nl>
Mon, 21 Oct 2013 08:40:24 +0000 (10:40 +0200)
All commands that change the position are put at the end.

hachu.c

diff --git a/hachu.c b/hachu.c
index 854c9e7..a81f25f 100644 (file)
--- a/hachu.c
+++ b/hachu.c
@@ -2341,29 +2341,13 @@ printf("in: %s\n", command);
           if(sscanf(inBuf+7, "Contempt=%d", &contemptFactor) == 1) continue;\r
           continue;\r
         }\r
-        if(!strcmp(command, "variant")) {\r
-          for(i=0; i<7; i++) {\r
-            sscanf(inBuf+8, "%s", command);\r
-            if(!strcmp(variants[i].name, command)) {\r
-              Init(curVarNr = i); stm = Setup2(NULL); break;\r
-            }\r
-         }\r
-          continue;\r
-        }\r
         if(!strcmp(command, "sd"))      { sscanf(inBuf, "sd %d", &maxDepth);    continue; }\r
         if(!strcmp(command, "st"))      { sscanf(inBuf, "st %d", &timePerMove); continue; }\r
         if(!strcmp(command, "memory"))  { SetMemorySize(atoi(inBuf+7)); continue; }\r
         if(!strcmp(command, "ping"))    { printf("pong%s", inBuf+4); continue; }\r
     //  if(!strcmp(command, ""))        { sscanf(inBuf, " %d", &); continue; }\r
-        if(!strcmp(command, "new"))     {\r
-          engineSide = BLACK; Init(V_CHESS); stm = Setup2(NULL); maxDepth = MAXPLY; randomize = OFF; curVarNr = comp = 0;\r
-          continue;\r
-        }\r
-        if(!strcmp(command, "setboard")){ engineSide = NONE;  Init(curVarNr); stm = Setup2(inBuf+9); continue; }\r
         if(!strcmp(command, "easy"))    { ponder = OFF; continue; }\r
         if(!strcmp(command, "hard"))    { ponder = ON;  continue; }\r
-        if(!strcmp(command, "undo"))    { stm = TakeBack(1); continue; }\r
-        if(!strcmp(command, "remove"))  { stm = TakeBack(2); continue; }\r
         if(!strcmp(command, "go"))      { engineSide = stm;  continue; }\r
         if(!strcmp(command, "post"))    { postThinking = ON; continue; }\r
         if(!strcmp(command, "nopost"))  { postThinking = OFF;continue; }\r
@@ -2386,7 +2370,7 @@ printf("in: %s\n", command);
         if(!strcmp(command, "accepted")){ continue; }\r
         if(!strcmp(command, "rejected")){ continue; }\r
         if(!strcmp(command, "result"))  { continue; }\r
-        if(!strcmp(command, "hover"))   {  continue; }\r
+        if(!strcmp(command, "hover"))   { continue; }\r
         if(!strcmp(command, ""))  {  continue; }\r
         if(!strcmp(command, "usermove")){\r
           int move = ParseMove(inBuf+9);\r
@@ -2401,6 +2385,22 @@ pboard(board);
           }\r
           continue;\r
         }\r
+        if(!strcmp(command, "new"))     {\r
+          engineSide = BLACK; Init(V_CHESS); stm = Setup2(NULL); maxDepth = MAXPLY; randomize = OFF; curVarNr = comp = 0;\r
+          continue;\r
+        }\r
+        if(!strcmp(command, "variant")) {\r
+          for(i=0; i<7; i++) {\r
+            sscanf(inBuf+8, "%s", command);\r
+            if(!strcmp(variants[i].name, command)) {\r
+              Init(curVarNr = i); stm = Setup2(NULL); break;\r
+            }\r
+         }\r
+          continue;\r
+        }\r
+        if(!strcmp(command, "setboard")){ engineSide = NONE;  Init(curVarNr); stm = Setup2(inBuf+9); continue; }\r
+        if(!strcmp(command, "undo"))    { stm = TakeBack(1); continue; }\r
+        if(!strcmp(command, "remove"))  { stm = TakeBack(2); continue; }\r
         printf("Error: unknown command\n");\r
       }\r
     }\r