diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-06-06 12:08:00 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2025-04-02 09:27:39 +0000 |
commit | f598d61d0dc4ada0aa7800363664c9968b8659a9 (patch) | |
tree | 99ae4d519cfc2ca2af0a9fa3d8e9be79a5c4d4be | |
parent | 88dfbd91ed22ab4ad98b2b9f0243f9d9faa9b49d (diff) | |
download | tmwa-f598d61d0dc4ada0aa7800363664c9968b8659a9.tar.gz tmwa-f598d61d0dc4ada0aa7800363664c9968b8659a9.tar.bz2 tmwa-f598d61d0dc4ada0aa7800363664c9968b8659a9.tar.xz tmwa-f598d61d0dc4ada0aa7800363664c9968b8659a9.zip |
Some small itemdb cleanupitemdb-code-cleanups
Mostly removing unused functions and made pc_isUseitem slightly more
efficient.
-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) |