summaryrefslogtreecommitdiff
path: root/src/map/itemdb.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-03-08 15:16:48 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-03-08 15:16:48 +0000
commit8a22b23c902520efc35a49e45649ea8a3746cc95 (patch)
tree9dc6930ce8f0bd30e75ddee06a806216e335b461 /src/map/itemdb.c
parentcfe300e3dde5b98e44e61650a09bb587384060f8 (diff)
downloadhercules-8a22b23c902520efc35a49e45649ea8a3746cc95.tar.gz
hercules-8a22b23c902520efc35a49e45649ea8a3746cc95.tar.bz2
hercules-8a22b23c902520efc35a49e45649ea8a3746cc95.tar.xz
hercules-8a22b23c902520efc35a49e45649ea8a3746cc95.zip
- 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
Diffstat (limited to 'src/map/itemdb.c')
-rw-r--r--src/map/itemdb.c25
1 files changed, 25 insertions, 0 deletions
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);
+}
+
+
/*==========================================
* 箱系アイテム検索
*------------------------------------------