From eef97eaabb7c5a981fd3c36f8ff2091ad0fb4fd3 Mon Sep 17 00:00:00 2001 From: Juliano Leal Goncalves Date: Mon, 8 Mar 2021 23:09:03 -0300 Subject: [PATCH] :triangular_flag_on_post: Add ini toggle for auto-equipping jewelry. Disabled by default. --- Source/diablo.cpp | 2 ++ Source/diablo.h | 3 +++ Source/inv.cpp | 4 ++++ Source/items.h | 20 ++++++++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 7501d8c22..76401ff38 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -436,6 +436,7 @@ static void SaveOptions() setIniInt("Game", "Auto Equip Armor on Pickup", sgOptions.bAutoEquipArmor); setIniInt("Game", "Auto Equip Helms on Pickup", sgOptions.bAutoEquipHelms); setIniInt("Game", "Auto Equip Shields on Pickup", sgOptions.bAutoEquipShields); + setIniInt("Game", "Auto Equip Jewelry on Pickup", sgOptions.bAutoEquipJewelry); setIniValue("Network", "Bind Address", sgOptions.szBindAddress); } @@ -486,6 +487,7 @@ static void LoadOptions() sgOptions.bAutoEquipArmor = getIniBool("Game", "Auto Equip Armor on Pickup", false); sgOptions.bAutoEquipHelms = getIniBool("Game", "Auto Equip Helms on Pickup", false); sgOptions.bAutoEquipShields = getIniBool("Game", "Auto Equip Shields on Pickup", false); + sgOptions.bAutoEquipJewelry = getIniBool("Game", "Auto Equip Jewelry on Pickup", false); getIniValue("Network", "Bind Address", sgOptions.szBindAddress, sizeof(sgOptions.szBindAddress), "0.0.0.0"); } diff --git a/Source/diablo.h b/Source/diablo.h index 09db4657e..c8a8f78ce 100644 --- a/Source/diablo.h +++ b/Source/diablo.h @@ -110,6 +110,9 @@ typedef struct Options { /** @brief Automatically attempt to equip shield-type items when picking them up. */ bool bAutoEquipShields; + /** @brief Automatically attempt to equip jewelry-type items when picking them up. */ + bool bAutoEquipJewelry; + /** @brief Optionally bind to a specific network interface. */ char szBindAddress[129]; } Options; diff --git a/Source/inv.cpp b/Source/inv.cpp index aa68b693f..f3e525240 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -824,6 +824,10 @@ bool AutoEquipEnabled(const ItemStruct &item) return sgOptions.bAutoEquipShields; } + if (item.isJewelry()) { + return sgOptions.bAutoEquipJewelry; + } + return true; } diff --git a/Source/items.h b/Source/items.h index 16c5c3744..67cd2fd57 100644 --- a/Source/items.h +++ b/Source/items.h @@ -218,6 +218,26 @@ typedef struct ItemStruct { return !this->isEmpty() && this->_itype == ITYPE_SHIELD; } + /** + * @brief Checks whether this item is a jewelry. + * @return 'True' in case the item is a jewelry and 'False' otherwise. + */ + bool isJewelry() const + { + if (this->isEmpty()) { + return false; + } + + switch (this->_itype) { + case ITYPE_AMULET: + case ITYPE_RING: + return true; + + default: + return false; + } + } + } ItemStruct; typedef struct ItemGetRecordStruct {