From: Fabian Fichter Date: Sun, 5 Jan 2020 15:11:01 +0000 (+0100) Subject: Fix checkbox options for xboard protocol X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=7e14832ffb8544c4506a47c76a9bbefc0518c3bd;p=fairystockfish.git Fix checkbox options for xboard protocol Use 1/0 instead of true/false. --- diff --git a/src/uci.h b/src/uci.h index e900061..f4410b7 100644 --- a/src/uci.h +++ b/src/uci.h @@ -61,6 +61,7 @@ public: bool operator!=(const char*) const; void set_combo(std::vector newComboValues); void set_default(std::string newDefault); + const std::string get_type() const; private: friend std::ostream& operator<<(std::ostream&, const OptionsMap&); diff --git a/src/ucioption.cpp b/src/ucioption.cpp index 9d464a6..d5af534 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -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 diff --git a/src/xboard.cpp b/src/xboard.cpp index 434b45e..bc65956 100644 --- a/src/xboard.cpp +++ b/src/xboard.cpp @@ -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") {