From: Marco Costalba Date: Sat, 11 Apr 2009 11:28:51 +0000 (+0200) Subject: Restore original UCI option printing order X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=ebb0f31928621115037779ba14311d1ec8b90542;ds=sidebyside Restore original UCI option printing order For each option store its index so to be printed according to insertion order. Signed-off-by: Marco Costalba --- diff --git a/src/ucioption.cpp b/src/ucioption.cpp index 9e992be5..49e8f228 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -22,6 +22,7 @@ //// Includes //// +#include #include #include #include @@ -56,15 +57,18 @@ namespace { struct Option { - std::string defaultValue, currentValue; + std::string name, defaultValue, currentValue; OptionType type; int minValue, maxValue; ComboValues comboValues; + size_t idx; Option(); Option(const std::string& defaultValue, OptionType = STRING); Option(bool defaultValue, OptionType = CHECK); Option(int defaultValue, int minValue, int maxValue); + + bool operator<(const Option& o) { return this->idx < o.idx; } }; typedef std::map Options; @@ -142,6 +146,10 @@ namespace { o["MultiPV"] = Option(1, 1, 500); o["UCI_ShowCurrLine"] = Option(false); o["UCI_Chess960"] = Option(false); + + // Any option should know its name so to be easily printed + for (Options::iterator it = o.begin(); it != o.end(); ++it) + it->second.name = it->first; } /// @@ -240,23 +248,30 @@ void print_uci_options() { "spin", "combo", "check", "string", "button" }; + // Build up a vector out of the options map and sort it according to idx + // field, that is the chronological insertion order in options map. + std::vector