/* 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
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));
pprintf(p, "ERROR: Sorry, all available slots for seek are closed.\n");
return COM_OK;
}
- 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 (category[0]) {
+ if (!board[0] && strcmp(category,"bughouse")) {
+ pprintf(p, "You must specify a board and a category.\n");
+ return COM_OK;
+
+ } else if (board[0]) { /* not bughouse */
+ char fname[MAX_FILENAME_SIZE];
+
+ sprintf(fname, "%s/%s/%s", BOARD_DIR, category, board);
+ if (!file_exists(fname)) {
+ pprintf(p, "No such category/board: %s/%s\n", category, board);
+ return COM_OK;
+ }
+ }
+ }
+
+ seek_globals.ads[num].status = SEEKCLOSED; // params are valid; create ad
+
+ 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
+ seek_globals.ads[num].status = SEEKCLOSED;
+
if (param[0].type == TYPE_INT)
seek_globals.ads[num].wtime = param[0].val.integer; /* White time */
else
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);
return 0;
}
+extern FILE *comlog;
+
int com_sought(int p, param_list param)
{
int i;
for (i = 0; i < seek_globals.max_ads; i++) {
if (seek_globals.ads[i].status == SEEKCLOSED) {
char *msgtxt = form_ad(&seek_globals.ads[i], i);
+if(comlog) fprintf(comlog, "msgtext = %s\n", msgtxt), fflush(comlog);
pprintf(p, "%s", msgtxt);
free(msgtxt);
}
continue;
pprintf_prompt(p1, "AD_DESTROY: %d\n", i);
}
- pprintf(p, "AD_DESTROY: %d\n", i);
+ pprintf(p, "Ads removed: %d\n", i);
FREE(seek_globals.ads[i].category);
FREE(seek_globals.ads[i].board_type);
}
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;
rating = player_globals.parray[ad->whofrom].b_stats.rating;
}
+if(comlog) fprintf(comlog, "seek %d type = %d\n", i, type), fflush(comlog);
+ 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,
ad->wtime,
ad->winc,
ad->rated?"rated":"unrated",
- TypeStrings[ad->seek_color]);
+ buf);
return final;
}