X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=2f3db5ed1ba46999d21975ebf7af5048d4d25a64;hb=4b2e076784b6bfd57781000e1ec809a1dc7ba4a1;hp=c3a68e72b03232424323358a132a81e75e42178d;hpb=e30a78284219ac19697175114c16740c7aab850b;p=xboard.git diff --git a/backend.c b/backend.c index c3a68e7..2f3db5e 100644 --- a/backend.c +++ b/backend.c @@ -10935,23 +10935,27 @@ ResendOptions (ChessProgramState *cps) char buf[MSG_SIZ]; Option *opt = cps->option; for(i=0; inrOptions; i++, opt++) { + *buf = NULLCHAR; switch(opt->type) { case Spin: case Slider: case CheckBox: + if(opt->value != *(int*) (opt->name + MSG_SIZ - 104)) snprintf(buf, MSG_SIZ, "option %s=%d\n", opt->name, opt->value); break; case ComboBox: - snprintf(buf, MSG_SIZ, "option %s=%s\n", opt->name, opt->choice[opt->value]); + if(opt->value != *(int*) (opt->name + MSG_SIZ - 104)) + snprintf(buf, MSG_SIZ, "option %s=%s\n", opt->name, opt->choice[opt->value]); break; default: + if(strcmp(opt->textValue, opt->name + MSG_SIZ - 100)) snprintf(buf, MSG_SIZ, "option %s=%s\n", opt->name, opt->textValue); break; case Button: case SaveButton: continue; } - SendToProgram(buf, cps); + if(*buf) SendToProgram(buf, cps); } } @@ -15032,7 +15036,7 @@ WaitForEngine (ChessProgramState *cps, DelayedEventCallback retry) void TwoMachinesEvent P((void)) { - int i; + int i, move = forwardMostMove; char buf[MSG_SIZ]; ChessProgramState *onmove; char *bookHit = NULL; @@ -15149,8 +15153,8 @@ TwoMachinesEvent P((void)) } } - ResetClocks(); - if (!first.sendTime || !second.sendTime) { + if (!first.sendTime || !second.sendTime || move == 0) { // [HGM] first engine changed sides from Reset, so recalc time odds + ResetClocks(); timeRemaining[0][forwardMostMove] = whiteTimeRemaining; timeRemaining[1][forwardMostMove] = blackTimeRemaining; } @@ -17176,8 +17180,10 @@ StringFeature (char **p, char *name, char **loc, ChessProgramState *cps) if (strncmp((*p), name, len) == 0 && (*p)[len] == '=' && (*p)[len+1] == '\"') { (*p) += len + 2; - ASSIGN(*loc, *p); // kludge alert: assign rest of line just to be sure allocation is large enough so that sscanf below always fits - sscanf(*p, "%[^\"]", *loc); + len = strlen(*p) + 1; if(len < MSG_SIZ && !strcmp(name, "option")) len = MSG_SIZ; // make sure string options have enough space to change their value + FREE(*loc); *loc = malloc(len); + strncpy(*loc, *p, len); + sscanf(*p, "%[^\"]", *loc); // should always fit, because we allocated at least strlen(*p) while (**p && **p != '\"') (*p)++; if (**p == '\"') (*p)++; snprintf(buf, MSG_SIZ, "accepted %s\n", name); @@ -17279,6 +17285,8 @@ ParseOption (Option *opt, ChessProgramState *cps) strcat(buf, "\n"); SendToProgram(buf, cps); } + *(int*) (opt->name + MSG_SIZ - 104) = opt->value; // hide default values somewhere + if(opt->target == &opt->textValue) strncpy(opt->name + MSG_SIZ - 100, opt->textValue, 99); return TRUE; }