summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-12-19 04:48:12 +0300
committerAndrei Karas <akaras@inbox.ru>2019-01-14 19:37:28 +0300
commit3685cb9b819f4933de5adce45179238e5c790bba (patch)
tree56ccb7d52f8bd044669b991f33a6255e70666555 /src/map
parent9148085c96cc4b9273959ca8c596eeb8bba1f55b (diff)
downloadhercules-3685cb9b819f4933de5adce45179238e5c790bba.tar.gz
hercules-3685cb9b819f4933de5adce45179238e5c790bba.tar.bz2
hercules-3685cb9b819f4933de5adce45179238e5c790bba.tar.xz
hercules-3685cb9b819f4933de5adce45179238e5c790bba.zip
Fix search item by name if id bigger than MAX_ITEMDB
Diffstat (limited to 'src/map')
-rw-r--r--src/map/itemdb.c20
-rw-r--r--src/map/itemdb.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 5e447d4c0..cea7cb10e 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -2434,6 +2434,8 @@ static void itemdb_read(bool minimal)
}
}
+ itemdb->other->foreach(itemdb->other, itemdb->addname_sub);
+
if (minimal)
return;
@@ -2448,6 +2450,23 @@ static void itemdb_read(bool minimal)
}
/**
+ * Add item name with high id into map
+ * @see DBApply
+ */
+static int itemdb_addname_sub(union DBKey key, struct DBData *data, va_list ap)
+{
+ struct item_data *item = DB->data2ptr(data);
+ struct DBData prev;
+
+ if (itemdb->names->put(itemdb->names, DB->str2key(item->name), DB->ptr2data(item), &prev)) {
+ struct item_data *oldItem = DB->data2ptr(&prev);
+ ShowError("itemdb_read: duplicate AegisName '%s' in item ID %d and %d\n", item->name, item->nameid, oldItem->nameid);
+ }
+
+ return 0;
+}
+
+/**
* retrieves item_combo data by combo id
**/
static struct item_combo *itemdb_id2combo(int id)
@@ -2789,4 +2808,5 @@ void itemdb_defaults(void)
itemdb->is_item_usable = itemdb_is_item_usable;
itemdb->lookup_const = itemdb_lookup_const;
itemdb->lookup_const_mask = itemdb_lookup_const_mask;
+ itemdb->addname_sub = itemdb_addname_sub;
}
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index 0c08efbeb..315787993 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -683,6 +683,7 @@ struct itemdb_interface {
bool (*is_item_usable) (struct item_data *item);
bool (*lookup_const) (const struct config_setting_t *it, const char *name, int *value);
bool (*lookup_const_mask) (const struct config_setting_t *it, const char *name, int *value);
+ int (*addname_sub) (union DBKey key, struct DBData *data, va_list ap);
};
#ifdef HERCULES_CORE