diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-06-06 12:08:00 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2025-02-14 10:41:29 +0100 |
commit | e8bcfa0268d473bd9cbe8d8b4f443f2c81063321 (patch) | |
tree | 2dfb7d86f2d8cbaeb7570a1b06e2a14a093f3a17 /src | |
parent | 9e61976289ac3aba1623999c33e7688ea429490c (diff) | |
download | tmwa-itemdb-code-cleanups.tar.gz tmwa-itemdb-code-cleanups.tar.bz2 tmwa-itemdb-code-cleanups.tar.xz tmwa-itemdb-code-cleanups.zip |
Some small itemdb cleanupitemdb-code-cleanups
Mostly removing unused functions and made pc_isUseitem slightly more
efficient.
Diffstat (limited to 'src')
-rw-r--r-- | src/map/itemdb.cpp | 21 | ||||
-rw-r--r-- | src/map/itemdb.hpp | 23 | ||||
-rw-r--r-- | src/map/pc.cpp | 3 |
3 files changed, 4 insertions, 43 deletions
diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp index fa675d2..fcde178 100644 --- a/src/map/itemdb.cpp +++ b/src/map/itemdb.cpp @@ -116,14 +116,9 @@ Borrowed<struct item_data> itemdb_search(ItemNameId nameid) * *------------------------------------------ */ -int itemdb_isequip(ItemNameId nameid) +bool itemdb_isequip(ItemNameId nameid) { - ItemType type = itemdb_type(nameid); - return !(type == ItemType::USE - || type == ItemType::_2 - || type == ItemType::JUNK - || type == ItemType::_6 - || type == ItemType::ARROW); + return itemdb_isequip2(itemdb_search(nameid)); } /*========================================== @@ -140,18 +135,6 @@ bool itemdb_isequip2(Borrowed<struct item_data> data) || type == ItemType::ARROW); } -/*========================================== - * - *------------------------------------------ - */ -int itemdb_isequip3(ItemNameId nameid) -{ - ItemType type = itemdb_type(nameid); - return (type == ItemType::WEAPON - || type == ItemType::ARMOR - || type == ItemType::_8); -} - bool itemdb_readdb(ZString filename) { io::LineCharReader in(filename); diff --git a/src/map/itemdb.hpp b/src/map/itemdb.hpp index 10805f5..d0ec535 100644 --- a/src/map/itemdb.hpp +++ b/src/map/itemdb.hpp @@ -70,39 +70,18 @@ Borrowed<struct item_data> itemdb_search(ItemNameId nameid); Option<Borrowed<struct item_data>> itemdb_exists(ItemNameId nameid); inline -ItemType itemdb_type(ItemNameId n) -{ - return itemdb_search(n)->type; -} -inline -ItemLook itemdb_look(ItemNameId n) -{ - return itemdb_search(n)->look; -} -inline int itemdb_weight(ItemNameId n) { return itemdb_search(n)->weight; } inline -const ScriptBuffer *itemdb_equipscript(ItemNameId n) -{ - return itemdb_search(n)->equip_script.get(); -} -inline -int itemdb_wlv(ItemNameId n) -{ - return itemdb_search(n)->wlv; -} -inline int itemdb_value_sell(ItemNameId n) { return itemdb_search(n)->value_sell; } -int itemdb_isequip(ItemNameId); +bool itemdb_isequip(ItemNameId); bool itemdb_isequip2(Borrowed<struct item_data>); -int itemdb_isequip3(ItemNameId); void itemdb_reload(void); diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 9ef70fe..d10f3c0 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -2384,9 +2384,8 @@ int pc_isUseitem(dumb_ptr<map_session_data> sd, IOff0 n) P<struct item_data> item = TRY_UNWRAP(sd->inventory_data[n], return 0); nameid = sd->status.inventory[n].nameid; - if (itemdb_type(nameid) != ItemType::USE) + if (item->type != ItemType::USE) return 0; - if (item->sex != SEX::UNSPECIFIED && sd->status.sex != item->sex) return 0; if (item->elv > 0 && sd->status.base_level < item->elv) |