/********************************************************************* v.1 find_matched_sp functions for finding players in saved files by partial matching of names... function calls should be made to find_matched_sp_quiet() to find a player without reporting multiple matches or miss to current_player find_matched_sp_verbose() to find, and inform current_player (if there is one) about multiple matches at bottom is modification to plists.c that Is Not Neccessary nor has it been throughly tested (altho it shouldnt cause any prollems) to load_player() if an exact match for a name isnt found. Licences: freely distributable and modifiable, as long as this full header kept with any distributions and any modifications to original marked plainly so. Warrenty: non, the author is in no way responsible for use, misuse, abuse, or any other actions misactions, reactions of this code, its provided as is. Author: phypor "if it breaks you get to keep both pieces" ~old linux proverb;) ********************************************************************/ saved_player *find_matched_sp_guts ( char *, int ); saved_player *find_matched_sp_quiet ( char * str ) { return find_matched_sp_guts (str, 0); } saved_player *find_matched_sp_verbose ( char * str ) { return find_matched_sp_guts (str, 1); } saved_player *find_matched_sp_guts ( char * str, int verb ) { saved_player *found; saved_player *scan; saved_player **hash; int i; int h = 0; char nstr[MAX_NAME]; char hits[2048]; char *hptr; treys ("find_matched_sp"); if (!*str || strlen (str) < 2 || !isalpha (*str)) { if (current_player && verb) ez_tell_player (current_player, " No match of the name " "'%s' found in files.\n", str); return (saved_player *) NULL; } memset (hits, 0, 2048); hptr = hits; strncpy (nstr, str, MAX_NAME - 1); lower_case (nstr); hash = saved_hash[((int) (tolower(*str)) - (int) 'a')]; for (i = 0; i < HASH_SIZE; i++, hash++) { for (scan = *hash; scan; scan = scan->next) { if (scan->residency == BANISHD) continue; if (!strncmp (scan->lower_name, nstr, strlen (nstr))) { hptr += sprintf (hptr, "%s, ", scan->lower_name); found = scan; h++; } } } if (!h) { if (current_player && verb) ez_tell_player (current_player, " No match of the name " "'%s' found in files.\n", str); return (saved_player *) NULL; } if (h > 1) { if (current_player && verb) { hptr = end_string (hptr); hits[strlen (hits) - 2] = '.'; hits[strlen (hits) - 1] = '\0'; ez_tell_player (current_player, " Multiple matches:\n %s\n", hits); } return (saved_player *) NULL; } return found; } /************ OPTIONAL plists.c modification **************/ int load_player(player * p) { saved_player *sp; char *r; lower_case(p->lower_name); sp = find_saved_player(p->lower_name); /** add the following lines **/ if (!sp) sp = find_matched_sp_verbose (p->lower_name); /*****************************/ p->saved = sp; if (!sp) return 0;