diff options
Diffstat (limited to 'src/map/itemdb.c')
-rw-r--r-- | src/map/itemdb.c | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 5e447d4c0..8caf88a4e 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -27,6 +27,7 @@ #include "map/map.h" #include "map/mob.h" // MAX_MOB_DB #include "map/pc.h" // W_MUSICAL, W_WHIP +#include "map/refine.h" #include "map/script.h" // item script processing #include "common/HPM.h" #include "common/conf.h" @@ -1700,7 +1701,12 @@ static int itemdb_validate_entry(struct item_data *entry, int n, const char *sou nullpo_ret(entry); nullpo_ret(source); +#if PACKETVER_MAIN_NUM >= 20181121 || PACKETVER_RE_NUM >= 20180704 || PACKETVER_ZERO_NUM >= 20181114 if (entry->nameid <= 0 || entry->nameid > MAX_ITEM_ID) { +#else + if (entry->nameid <= 0) { +#endif + // item id wrong for any packet versions ShowWarning("itemdb_validate_entry: Invalid item ID %d in entry %d of '%s', allowed values 0 < ID < %d (MAX_ITEM_ID), skipping.\n", entry->nameid, n, source, MAX_ITEM_ID); if (entry->script) { @@ -1716,7 +1722,14 @@ static int itemdb_validate_entry(struct item_data *entry, int n, const char *sou entry->unequip_script = NULL; } return 0; +#if PACKETVER_MAIN_NUM >= 20181121 || PACKETVER_RE_NUM >= 20180704 || PACKETVER_ZERO_NUM >= 20181114 } +#else + } else if (entry->nameid > MAX_ITEM_ID) { + // item id too big for packet version before item id in 4 bytes + entry->view_id = UNKNOWN_ITEM_ID; + } +#endif { const char *c = entry->name; @@ -2434,6 +2447,10 @@ static void itemdb_read(bool minimal) } } + itemdb->other->foreach(itemdb->other, itemdb->addname_sub); + + itemdb->read_options(); + if (minimal) return; @@ -2443,8 +2460,23 @@ static void itemdb_read(bool minimal) itemdb->read_groups(); itemdb->read_chains(); itemdb->read_packages(); - itemdb->read_options(); - clif->stylist_read_db_libconfig(); +} + +/** + * 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; } /** @@ -2676,7 +2708,6 @@ static void do_final_itemdb(void) itemdb->destroy_item_data(&itemdb->dummy, 0); db_destroy(itemdb->names); VECTOR_CLEAR(clif->attendance_data); - clif->stylist_vector_clear(); } static void do_init_itemdb(bool minimal) @@ -2686,7 +2717,6 @@ static void do_init_itemdb(bool minimal) itemdb->options = idb_alloc(DB_OPT_RELEASE_DATA); itemdb->names = strdb_alloc(DB_OPT_BASE,ITEM_NAME_LENGTH); itemdb->create_dummy_data(); //Dummy data item. - clif->stylist_vector_init(); itemdb->read(minimal); if (minimal) @@ -2789,4 +2819,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; } |