From: H.G. Muller Date: Mon, 9 Jan 2012 22:41:46 +0000 (+0100) Subject: Let seek command accept same parameters as match X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=76a192175f31fcb85ba99e354916dd78b9e5850e;p=capablanca.git Let seek command accept same parameters as match The seek command was not accepting category and board params, just 4 numeric ones. This is fixed now by letting it accept a single string, parsed by the same routine that parses the match arguuments. The category and board are now also displayed with the ad in the sought list. --- diff --git a/lasker-2.2.3/src/command_list.h b/lasker-2.2.3/src/command_list.h index 96b819b..064f961 100644 --- a/lasker-2.2.3/src/command_list.h +++ b/lasker-2.2.3/src/command_list.h @@ -119,7 +119,8 @@ static struct command_type command_list[] = { {"revert", "", com_revert, ADMIN_USER }, {"resign", "o", com_resign, ADMIN_USER }, {"say", "S", com_say, ADMIN_USER }, - {"seek", "pppp", com_seek, ADMIN_USER }, +// {"seek", "pppp", com_seek, ADMIN_USER }, + {"seek", "t", com_seek, ADMIN_USER }, // [HGM] {"unseek", "", com_unseek, ADMIN_USER }, {"set", "wT", com_set, ADMIN_USER }, {"shout", "T", com_shout, ADMIN_USER }, diff --git a/lasker-2.2.3/src/matchproc.c b/lasker-2.2.3/src/matchproc.c index f8d117e..6c2ecf5 100644 --- a/lasker-2.2.3/src/matchproc.c +++ b/lasker-2.2.3/src/matchproc.c @@ -442,7 +442,7 @@ int accept_match(struct pending *pend, int p, int p1) } /* board and category are initially empty strings */ -static int parse_match_string(int p, int* wt,int* bt,int* winc,int* binc, +int parse_match_string(int p, int* wt,int* bt,int* winc,int* binc, int* white,int* rated,char* category, char* board, char* mstring) { diff --git a/lasker-2.2.3/src/seekproc.c b/lasker-2.2.3/src/seekproc.c index e065cef..8a1b9f6 100644 --- a/lasker-2.2.3/src/seekproc.c +++ b/lasker-2.2.3/src/seekproc.c @@ -24,7 +24,7 @@ enum { SEEKOPEN = 0, SEEKCLOSED }; /* The values of the follwing enums cannot be changed as they will end up */ /* Being seen by the client- we can add values later but the ones */ /* Here, after being documented, have to be here forever */ -enum { LIGHTNING = 0, STANDARD, BLITZ, UNTIMED }; +enum { UNTIMED = 0, BLITZ, STANDARD, NONSTANDARD, WILD, LIGHTNING }; #undef BLACK #undef WHITE @@ -40,7 +40,8 @@ int com_seek(int p, param_list param) int p1, count = 0; int num; /* sought ID */ char *msgtxt; - char board[1], category[1]; + char board[100], category[100]; + int wt, bt, winc, binc, rated, white; srandom(time(0)); @@ -67,6 +68,38 @@ int com_seek(int p, param_list param) seek_globals.ads[num].status = SEEKCLOSED; seek_globals.ads[num].whofrom = p; +#if 1 + // [HGM] attempt to make seek as powerful as match + wt = bt = winc = binc = -1; + board[0] = category[0] = '\0'; + white = rated = -1; + if (param[0].type != TYPE_NULL) { + if (!parse_match_string(p, &wt,&bt,&winc,&binc,&white,&rated,category, + board,param[0].val.string)) + return COM_OK; /* couldn't parse */ + } + if(wt < 0) wt = pp->d_time; if(bt < 0) bt = wt; + if(winc < 0) winc = pp->d_inc; if(binc < 0) binc = bt; + seek_globals.ads[num].wtime = wt; + seek_globals.ads[num].btime = bt; + seek_globals.ads[num].winc = winc; + seek_globals.ads[num].binc = binc; + + if (rated != -1) { + if (!rated || !CheckPFlag(p, PFLAG_REG) || seek_globals.ads[num].wtime == 0) + seek_globals.ads[num].rated = UNRATED; /* unrated */ + else if (rated) + seek_globals.ads[num].rated = RATED; /* rated */ + } else + seek_globals.ads[num].rated = BoolCheckPFlag(p, PFLAG_RATED); + + + if (white != -1) { + seek_globals.ads[num].seek_color = white ? WHITE : BLACK; + } else + seek_globals.ads[num].seek_color = random() % 2; + +#else if (param[0].type == TYPE_INT) seek_globals.ads[num].wtime = param[0].val.integer; /* White time */ else @@ -100,6 +133,7 @@ int com_seek(int p, param_list param) category[0]='\0'; board[0]='\0'; /* FIXME- use proper values */ +#endif seek_globals.ads[num].category = strdup(category); seek_globals.ads[num].board_type = strdup(board); @@ -223,7 +257,7 @@ static int get_empty_seekslot(void) static char *form_ad(struct pending * ad, int i) { - char *final; + char *final, buf[100]; int rating, total, type; total = ad->wtime * 60 + ad->winc * 40; @@ -242,6 +276,12 @@ static char *form_ad(struct pending * ad, int i) rating = player_globals.parray[ad->whofrom].b_stats.rating; } + if(ad->category[0]) { // [HGM] print category with seek ad + sprintf(buf, " %s", ad->category); + if(ad->board_type[0] && strcmp(ad->board_type, "0")) + sprintf(buf + strlen(buf), " %s", ad->board_type); + } else strcpy(buf, TypeStrings[type]); // [HGM] replaced color by type here... + asprintf(&final, "%3u %4u %-17s %3u %3u %-7s %-10s\n", i, rating, @@ -249,7 +289,7 @@ static char *form_ad(struct pending * ad, int i) ad->wtime, ad->winc, ad->rated?"rated":"unrated", - TypeStrings[ad->seek_color]); + buf); return final; }