Browse Source

Refactor: simplify logic in items.h

Currently some of the "isItem" functions add an unnecessary check of
isEmpty which is redundant, because a few lines lower they also check
for item type inside the same object.

This patch removes those unnecessary checks.
pull/6700/head
tetektoza 3 years ago committed by Anders Jenbo
parent
commit
a387f73aa7
  1. 16
      Source/items.h

16
Source/items.h

@ -303,10 +303,6 @@ struct Item {
*/
bool isWeapon() const
{
if (this->isEmpty()) {
return false;
}
switch (this->_itype) {
case ItemType::Axe:
case ItemType::Bow:
@ -326,10 +322,6 @@ struct Item {
*/
bool isArmor() const
{
if (this->isEmpty()) {
return false;
}
switch (this->_itype) {
case ItemType::HeavyArmor:
case ItemType::LightArmor:
@ -347,7 +339,7 @@ struct Item {
*/
bool isHelm() const
{
return !this->isEmpty() && this->_itype == ItemType::Helm;
return this->_itype == ItemType::Helm;
}
/**
@ -356,7 +348,7 @@ struct Item {
*/
bool isShield() const
{
return !this->isEmpty() && this->_itype == ItemType::Shield;
return this->_itype == ItemType::Shield;
}
/**
@ -365,10 +357,6 @@ struct Item {
*/
bool isJewelry() const
{
if (this->isEmpty()) {
return false;
}
switch (this->_itype) {
case ItemType::Amulet:
case ItemType::Ring:

Loading…
Cancel
Save