Browse Source

🚩 Add ini toggle for auto-equipping armor. Disabled by default.

pull/1148/head
Juliano Leal Goncalves 5 years ago committed by Anders Jenbo
parent
commit
70db53644e
  1. 2
      Source/diablo.cpp
  2. 3
      Source/diablo.h
  3. 4
      Source/inv.cpp
  4. 21
      Source/items.h

2
Source/diablo.cpp

@ -433,6 +433,7 @@ static void SaveOptions()
setIniInt("Game", "Auto Gold Pickup", sgOptions.bAutoGoldPickup);
setIniInt("Game", "Adria Refills Mana", sgOptions.bAdriaRefillsMana);
setIniInt("Game", "Auto Equip Weapons on Pickup", sgOptions.bAutoEquipWeapons);
setIniInt("Game", "Auto Equip Armor on Pickup", sgOptions.bAutoEquipArmor);
setIniValue("Network", "Bind Address", sgOptions.szBindAddress);
}
@ -480,6 +481,7 @@ static void LoadOptions()
sgOptions.bAutoGoldPickup = getIniBool("Game", "Auto Gold Pickup", false);
sgOptions.bAdriaRefillsMana = getIniBool("Game", "Adria Refills Mana", false);
sgOptions.bAutoEquipWeapons = getIniBool("Game", "Auto Equip Weapons on Pickup", true);
sgOptions.bAutoEquipArmor = getIniBool("Game", "Auto Equip Armor on Pickup", false);
getIniValue("Network", "Bind Address", sgOptions.szBindAddress, sizeof(sgOptions.szBindAddress), "0.0.0.0");
}

3
Source/diablo.h

@ -101,6 +101,9 @@ typedef struct Options {
/** @brief Automatically attempt to equip weapon-type items when picking them up. */
bool bAutoEquipWeapons;
/** @brief Automatically attempt to equip armor-type items when picking them up. */
bool bAutoEquipArmor;
/** @brief Optionally bind to a specific network interface. */
char szBindAddress[129];
} Options;

4
Source/inv.cpp

@ -812,6 +812,10 @@ bool AutoEquipEnabled(const ItemStruct &item)
return sgOptions.bAutoEquipWeapons;
}
if (item.isArmor()) {
return sgOptions.bAutoEquipArmor;
}
return true;
}

21
Source/items.h

@ -179,6 +179,27 @@ typedef struct ItemStruct {
}
}
/**
* @brief Checks whether this item is an armor.
* @return 'True' in case the item is an armor and 'False' otherwise.
*/
bool isArmor() const
{
if (this->isEmpty()) {
return false;
}
switch (this->_itype) {
case ITYPE_HARMOR:
case ITYPE_LARMOR:
case ITYPE_MARMOR:
return true;
default:
return false;
}
}
} ItemStruct;
typedef struct ItemGetRecordStruct {

Loading…
Cancel
Save