X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=uci.c;h=5eff8cce7f54ad93044d84addc39dabf3ed52e9b;hb=c6505b9bddf0ed2f461a473d4be40c98608d9866;hp=03c664781f833917085255397fe9cbadb0196012;hpb=446bfd706349c3e1f19916a16558a2f4f7dc8e54;p=polyglot.git diff --git a/uci.c b/uci.c index 03c6647..5eff8cc 100644 --- a/uci.c +++ b/uci.c @@ -10,6 +10,7 @@ #include "board.h" #include "engine.h" +#include "gui.h" #include "move.h" #include "move_do.h" #include "move_legal.h" @@ -18,6 +19,7 @@ #include "line.h" #include "uci.h" + // constants static const bool UseDebug = FALSE; @@ -58,6 +60,29 @@ static int mate_score (int dist); // functions + +// uci_adapt_UCI3() + +static void apply_UCI3_heuristics(option_t *opt){ + if(option_get_int(Option,"UCIVersion")>2){ + return; + } + if(!my_string_equal(opt->type,"string")){ + return; + } + if(!strncmp(opt->name,"UCI_",4)){ + return; + } + if(my_string_case_contains(opt->name,"file")){ + my_string_set(&opt->type,"file"); + return; + } + if(my_string_case_contains(opt->name,"path")){ + my_string_set(&opt->type,"path"); + return; + } +} + // uci_set_threads() void uci_set_threads(uci_t * uci, int n) { @@ -125,6 +150,11 @@ void uci_open(uci_t * uci, engine_t * engine) { do { engine_get(uci->engine,string); + // Handle the case that the engine is really a WB engine somewhat gracefully. + if((strstr(string,"Illegal") || strstr(string,"Error")) + &&strstr(string,"uci")){ + my_fatal("uci_open(): Not an UCI engine (not found).\n"); + } event = uci_parse(uci,string); } while (!engine_eof(Engine) && (event & EVENT_UCI) == 0); } @@ -271,7 +301,7 @@ bool uci_send_option(uci_t * uci, const char option[], const char format[], ...) opt=option_find(uci->option,option); if(opt){ found=TRUE; - if(!my_string_case_equal(opt->type,"button")){ + if(!IS_BUTTON(opt->type)){ if(!my_string_equal(opt->value,value)){ engine_send(uci->engine,"setoption name %s value %s", opt->name,value); @@ -308,7 +338,7 @@ int uci_parse(uci_t * uci, const char string[]) { parse_open(parse,string); if (parse_get_word(parse,command,StringSize)) { - + parse_get_string(parse,argument,StringSize); if (UseDebug) my_log("POLYGLOT COMMAND \"%s\" ARGUMENT \"%s\"\n",command,argument); @@ -805,6 +835,8 @@ static void parse_option(uci_t * uci, const char string[]) { } parse_close(parse); + + apply_UCI3_heuristics(opt); option_insert(uci->option,opt); option_free(opt);