From 8a22b23c902520efc35a49e45649ea8a3746cc95 Mon Sep 17 00:00:00 2001 From: skotlex Date: Wed, 8 Mar 2006 15:16:48 +0000 Subject: - Added functions mobdb_searchname_array and itemdb_searchname_array which return an array of matches. - Modified @iteminfo and @mobinfo to search and display various matches instead of just one. - Constant MAX_SEARCH in map.h defines the max size of search results. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5512 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/itemdb.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/map/itemdb.c') diff --git a/src/map/itemdb.c b/src/map/itemdb.c index aa4f3a622..0e7241ea8 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -61,6 +61,7 @@ int itemdb_searchjname_sub(int key,void *data,va_list ap) *dst=item; return 0; } + /*========================================== * 名前で検索 *------------------------------------------ @@ -72,6 +73,30 @@ struct item_data* itemdb_searchname(const char *str) return item; } +static int itemdb_searchname_array_sub(DBKey key,void * data,va_list ap) +{ + struct item_data *item=(struct item_data *)data; + char *str; + str=va_arg(ap,char *); + if (item == dummy_item) + return 1; //Invalid item. + if(strstr(item->jname,str)) + return 0; + if(strstr(item->name,str)) + return 0; + return strcmpi(item->jname,str); +} + +/*========================================== + * Founds up to N matches. Returns number of matches [Skotlex] + *------------------------------------------ + */ +int itemdb_searchname_array(struct item_data** data, int size, const char *str) +{ + return item_db->getall(item_db,(void**)data,size,itemdb_searchname_array_sub,str); +} + + /*========================================== * 箱系アイテム検索 *------------------------------------------ -- cgit v1.2.3-70-g09d2