Fix awareness of settings changed by -firstOption
authorH.G.Muller <hgm@hgm-xboard.(none)>
Thu, 5 Jan 2017 16:05:22 +0000 (17:05 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 13 Jan 2017 15:39:25 +0000 (16:39 +0100)
Options of the type -file and -path that were set through -firstOptions
would not get their 'current value' updated, so that XBoard would not
set them properly on a reload because of reuse=0. In addition the default
value for all option types would be remembered as the value specified
by -firstOptions, rather than the engine default, possibly preventing
their saving on Make Persistent.

backend.c

index 7cc8f9c..29b473b 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -17362,6 +17362,8 @@ ParseOption (Option *opt, ChessProgramState *cps)
            opt->type = SaveButton;
        } else return FALSE;
        *p = 0; // terminate option name
+       *(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);
        // now look if the command-line options define a setting for this engine option.
        if(cps->optionSettings && cps->optionSettings[0])
            p = strstr(cps->optionSettings, opt->name); else p = NULL;
@@ -17374,6 +17376,8 @@ ParseOption (Option *opt, ChessProgramState *cps)
                            if(!strcmp(((char**)opt->textValue)[n], q+1)) opt->value = n;
                        break;
                    case TextBox:
+                   case FileName:
+                   case PathName:
                        safeStrCpy(opt->textValue, q+1, MSG_SIZ - (opt->textValue - opt->name));
                        break;
                    case Spin:
@@ -17385,8 +17389,6 @@ 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;
 }