summaryrefslogtreecommitdiff
path: root/src/map/mob.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/mob.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/mob.c')
-rw-r--r--src/map/mob.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index 183e063ff..c17079add 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -80,6 +80,39 @@ int mobdb_searchname(const char *str)
return 0;
}
+static int mobdb_searchname_array_sub(struct mob_db* mob, const char *str)
+{
+ if (mob == mob_dummy)
+ return 1; //Invalid item.
+ if(strstr(mob->jname,str))
+ return 0;
+ if(strstr(mob->name,str))
+ return 0;
+ return strcmpi(mob->jname,str);
+}
+
+/*==========================================
+ * Founds up to N matches. Returns number of matches [Skotlex]
+ *------------------------------------------
+ */
+int mobdb_searchname_array(struct mob_db** data, int size, const char *str)
+{
+ int count = 0, i;
+ struct mob_db* mob;
+ for(i=0;i<=MAX_MOB_DB;i++){
+ mob = mob_db(i);
+ if (mob == mob_dummy)
+ continue;
+ if (!mobdb_searchname_array_sub(mob, str)) {
+ if (count < size)
+ data[count] = mob;
+ count++;
+ }
+ }
+ return count;
+}
+
+
/*==========================================
* Id Mob is checked.