From 9dc52ce7dd8378820c61f0248f80a5d1508bc823 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sun, 18 Oct 2009 17:52:12 +0000 Subject: [PATCH] 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 --- dgamelaunch.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dgamelaunch.c b/dgamelaunch.c index 95962e9..c984c61 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -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;