When doing '/' in watching-menu, match player names without case, and try to find the best match from the beginning of the player name.

git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@499 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
Pasi Kallinen 2009-10-18 17:52:12 +00:00
parent 857105e8b2
commit 9dc52ce7dd
1 changed files with 8 additions and 2 deletions

View File

@ -504,17 +504,23 @@ inprogressmenu (int gameid)
case '/':
{
int match = -1;
int firstmatch = -1;
int nmatches = 0;
char findname[21];
if (len <= 0) break;
findname[0] = '\0';
mvprintw ((btm+2+top_banner_hei), 1, "Watch which player? => "); /* stupid... */
mvaddstr ((btm+2+top_banner_hei), 1, "Watch which player? => ");
if ((mygetnstr(findname, 20, 1) == OK) && (strlen(findname) > 1)) {
int mlen = strlen(findname);
for (i = 0; i < len; i++)
if (!strcmp(games[i]->name, findname)) {
if (!strncasecmp(games[i]->name, findname, mlen)) {
if (firstmatch == -1) firstmatch = i;
match = i;
break;
nmatches++;
}
if (nmatches > 1)
match = firstmatch;
if (match > -1) {
if (!strcmp(games[match]->ttyrec_fn + strlen (games[match]->ttyrec_fn) - 6, ".nhext")) break;
idx = match;