Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash related to on look item #456

Merged
merged 3 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/items/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1502,14 +1502,14 @@ std::string Item::parseImbuementDescription(const Item* item)
return s.str();
}

std::string Item::parseShowAttributesDescription(const Item &item, const uint16_t itemId)
std::string Item::parseShowAttributesDescription(const Item *item, const uint16_t itemId)
{
std::ostringstream itemDescription;
const ItemType& itemType = Item::items[itemId];
if (itemType.armor != 0 || (item.getArmor() != 0) || itemType.showAttributes) {
if (itemType.armor != 0 || (item && item->getArmor() != 0) || itemType.showAttributes) {
bool begin = true;

int32_t armor = (&item ? item.getArmor() : itemType.armor);
int32_t armor = (item ? item->getArmor() : itemType.armor);
if (armor != 0) {
itemDescription << " (Arm:" << armor;
begin = false;
Expand Down Expand Up @@ -2207,9 +2207,9 @@ std::string Item::getDescription(const ItemType& it, int32_t lookDistance,
}

if (it.transformEquipTo != 0) {
s << parseShowAttributesDescription(*item, it.transformEquipTo);
s << parseShowAttributesDescription(item, it.transformEquipTo);
} else {
s << parseShowAttributesDescription(*item, it.id);
s << parseShowAttributesDescription(item, it.id);
}

if (it.showCharges) {
Expand Down
2 changes: 1 addition & 1 deletion src/items/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ class Item : virtual public Thing
}

static std::string parseImbuementDescription(const Item* item);
static std::string parseShowAttributesDescription(const Item &item, const uint16_t itemId);
static std::string parseShowAttributesDescription(const Item *item, const uint16_t itemId);

static std::vector<std::pair<std::string, std::string>> getDescriptions(const ItemType& it,
const Item* item = nullptr);
Expand Down