Skip to content

Commit

Permalink
fix: cyclopedia description (#1923)
Browse files Browse the repository at this point in the history
* double protection information was removed
* fixing speed information that showed in half

---------

Co-authored-by: Eduardo Dantas <[email protected]>
Co-authored-by: Luan Santos <[email protected]>
Co-authored-by: GitHub Actions <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Dec 29, 2023
1 parent b3a85ee commit df811d7
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions src/items/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr<Item> item /*= nullptr

if (it.abilities->speed) {
ss.str("");
ss << std::showpos << (it.abilities->speed >> 1) << std::noshowpos;
ss << std::showpos << it.abilities->speed << std::noshowpos;
descriptions.emplace_back("Speed", ss.str());
}

Expand Down Expand Up @@ -1606,7 +1606,7 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr<Item> item /*= nullptr
ss.str("");
bool skillBoost = false;
if (it.abilities->speed) {
ss << std::showpos << "speed " << (it.abilities->speed >> 1) << std::noshowpos;
ss << std::showpos << "speed " << it.abilities->speed << std::noshowpos;
skillBoost = true;
}

Expand Down Expand Up @@ -1653,14 +1653,11 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr<Item> item /*= nullptr
ss << it.abilities->skills[i];
}
ss << '%' << std::noshowpos;

skillBoost = true;
}

if (it.abilities->stats[STAT_MAGICPOINTS]) {
ss.str("");
ss << std::showpos << it.abilities->stats[STAT_MAGICPOINTS] << std::noshowpos;
descriptions.emplace_back("Magic Level", ss.str());
if (skillBoost) {
descriptions.emplace_back("Skill Boost", ss.str());
}

for (uint8_t i = 1; i <= 11; i++) {
Expand Down Expand Up @@ -1692,12 +1689,6 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr<Item> item /*= nullptr
descriptions.emplace_back("Damage Reflection", ss.str());
}

if (it.abilities->speed) {
ss.str("");
ss << std::showpos << (it.abilities->speed >> 1) << std::noshowpos;
descriptions.emplace_back("Speed", ss.str());
}

if (it.abilities->cleavePercent) {
ss.str("");
ss << std::showpos << (it.abilities->cleavePercent) << std::noshowpos << "%";
Expand Down Expand Up @@ -1728,17 +1719,6 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr<Item> item /*= nullptr
descriptions.emplace_back("Effect", ss.str());
}

for (size_t i = 0; i < COMBAT_COUNT; ++i) {
if (it.abilities->absorbPercent[i] == 0) {
continue;
}

ss.str("");
ss << getCombatName(indexToCombatType(i)) << ' '
<< std::showpos << it.abilities->absorbPercent[i] << std::noshowpos << '%';
descriptions.emplace_back("Protection", ss.str());
}

for (size_t i = 0; i < COMBAT_COUNT; ++i) {
if (it.abilities->fieldAbsorbPercent[i] == 0) {
continue;
Expand Down Expand Up @@ -2587,6 +2567,7 @@ std::string Item::getDescription(const ItemType &it, int32_t lookDistance, std::
if (!begin) {
s << ')';
}
// This block refers to the look of the weapons.
} else if (it.weaponType != WEAPON_AMMO) {
bool begin = true;

Expand All @@ -2601,6 +2582,28 @@ std::string Item::getDescription(const ItemType &it, int32_t lookDistance, std::
extraDefense = it.extraDefense;
}

if (it.isContainer() || (item && item->getContainer())) {
uint32_t volume = 0;

if (!item || !item->hasAttribute(ItemAttribute_t::UNIQUEID)) {
if (it.isContainer()) {
volume = it.maxItems;
} else if (item) {
volume = item->getContainer()->capacity();
}
}

if (volume != 0) {
if (begin) {
begin = false;
s << " (";
} else {
s << ", ";
}

s << "Vol:" << volume;
}
}
if (attack != 0) {
begin = false;
s << " (Atk:" << attack;
Expand Down

0 comments on commit df811d7

Please sign in to comment.