Skip to content

Commit

Permalink
fix: attribute integer not working (opentibiabr#854)
Browse files Browse the repository at this point in the history
The "is_integral" was not working, causing integer attributes not to be read.

Complement of commit: opentibiabr@46b2c5e
  • Loading branch information
dudantas authored Feb 12, 2023
1 parent 55133f8 commit a26cd9c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/items/functions/item/custom_attribute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@ class CustomAttribute {
return getDouble();
} else if constexpr (std::is_same_v<T, bool>) {
return getBool();
} else if constexpr (std::is_integral_v<T>) {
} else {
return std::clamp(
static_cast<T>(getInteger()),
std::numeric_limits<T>::min(),
std::numeric_limits<T>::max()
);
} else {
SPDLOG_ERROR("[{}] not found value", __FUNCTION__);
}
return T();
return {};
}

const int64_t &getInteger() const;
Expand Down
4 changes: 2 additions & 2 deletions src/items/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ class ItemProperties {
T getAttribute(ItemAttribute_t type) const {
if constexpr (std::is_same_v<T, std::string>) {
return getString(type);
} else if constexpr (std::is_integral_v<T>) {
} else {
return std::clamp(
static_cast<T>(getInteger(type)),
std::numeric_limits<T>::min(),
std::numeric_limits<T>::max()
);
}
return T();
return {};
}

bool hasAttribute(ItemAttribute_t type) const {
Expand Down

0 comments on commit a26cd9c

Please sign in to comment.