From f9b3d49480bbbf3200dde21ca58dcd5ae41bcfa1 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Fri, 7 Dec 2018 22:35:01 +0100 Subject: [PATCH] Parse 'difficult' commands in separate routine The parsing of (most) commands that can only be executed when not searching is now put in a separate routine DoCommand(). This in preparation for having the engine thread do this. --- UCI2WB.c | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) diff --git a/UCI2WB.c b/UCI2WB.c index e87504a..4cbf5a8 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -436,10 +436,13 @@ Move4Engine(char *m) } } +int DoCommand (char *line); +char mySide; + void GUI2Engine() { - char line[256], command[256], *p, *q, *r, mySide, type[99]; + char line[256], command[256], *p; while(1) { int i, difficult, think=0; @@ -529,6 +532,18 @@ GUI2Engine() !strcmp(command, "force") || !strcmp(command, "result")) { EPRINT((f, "# stop\n")); fflush(toE); } Sync(PAUSE); Release(); // block processing of difficult commands during thinking; send backlog left because of race } + if(DoCommand(line)) goto nomove; + } +} + +int +DoCommand (char *line) +{ + char command[256], *p, *q, *r, type[99]; + int i; + + sscanf(line, "%s", command); + if(!strcmp(command, "new")) { computer = BLACK; moveNr = 0; depth = -1; move[0][0] = 0; stm = WHITE; strcpy(iniPos, "position startpos"); frc &= ~1; @@ -585,13 +600,13 @@ GUI2Engine() } else if(!strcmp(command, ".")) { printf("stat01: %d %d %d %d 100 %s\n", statTime, statNodes, statDepth, 100-currNr, currMove); - goto nomove; + return 1; } else if(!strcmp(command+2, "clude") && collect > 2) { // include or exclude int all = !strcmp(line+8, "all"), in = command[1] == 'n'; inex = 1; line[strlen(line)-1] = sm = 0; // strip LF and clear sm flag for(i=1; i