Fix checkbox options for xboard protocol
authorFabian Fichter <ianfab@users.noreply.github.com>
Sun, 5 Jan 2020 15:11:01 +0000 (16:11 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sun, 5 Jan 2020 15:11:01 +0000 (16:11 +0100)
Use 1/0 instead of true/false.

src/uci.h
src/ucioption.cpp
src/xboard.cpp

index e900061..f4410b7 100644 (file)
--- a/src/uci.h
+++ b/src/uci.h
@@ -61,6 +61,7 @@ public:
   bool operator!=(const char*) const;
   void set_combo(std::vector<std::string> newComboValues);
   void set_default(std::string newDefault);
+  const std::string get_type() const;
 
 private:
   friend std::ostream& operator<<(std::ostream&, const OptionsMap&);
index 9d464a6..d5af534 100644 (file)
@@ -163,8 +163,10 @@ std::ostream& operator<<(std::ostream& os, const OptionsMap& om) {
                   const Option& o = it.second;
                   os << "\nfeature option=\"" << it.first << " -" << o.type;
 
-                  if (o.type == "string" || o.type == "check" || o.type == "combo")
+                  if (o.type == "string" || o.type == "combo")
                       os << " " << o.defaultValue;
+                  else if (o.type == "check")
+                      os << " " << int(o.defaultValue == "true");
 
                   if (o.type == "combo")
                       for (string value : o.comboValues)
@@ -306,4 +308,8 @@ void Option::set_default(std::string newDefault) {
     defaultValue = currentValue = newDefault;
 }
 
+const std::string Option::get_type() const {
+    return type;
+}
+
 } // namespace UCI
index 434b45e..bc65956 100644 (file)
@@ -201,7 +201,11 @@ void StateMachine::process_command(Position& pos, std::string token, std::istrin
       std::getline(is, name, '=');
       std::getline(is, value);
       if (Options.count(name))
+      {
+          if (Options[name].get_type() == "check")
+              value = value == "1" ? "true" : "false";
           Options[name] = value;
+      }
   }
   else if (token == "analyze")
   {