Skip to content

Commit

Permalink
fix: items description
Browse files Browse the repository at this point in the history
  • Loading branch information
phacUFPE committed Sep 23, 2024
1 parent bbc48f9 commit 9f9eae9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 19 deletions.
43 changes: 29 additions & 14 deletions src/items/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1182,12 +1182,17 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr<Item> item /*= nullptr
}
descriptions.emplace_back("Attack", ss.str());
} else if (!it.isRanged()) {
std::string attackDescription;
if (it.abilities && it.abilities->elementType != COMBAT_NONE && it.abilities->elementDamage != 0) {
ss.str("");
ss << attack << " physical +" << it.abilities->elementDamage << ' ' << getCombatName(it.abilities->elementType);
descriptions.emplace_back("Attack", ss.str());
} else if (it.attack != 0) {
descriptions.emplace_back("Attack", std::to_string(attack));
attackDescription = fmt::format("{} {}", it.abilities->elementDamage, getCombatName(it.abilities->elementType));
}

if (it.attack != 0) {
attackDescription = fmt::format("{} physical + {}", attack, attackDescription);
}

if (!attackDescription.empty()) {
descriptions.emplace_back("Attack", attackDescription);
}
}

Expand Down Expand Up @@ -1595,12 +1600,17 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr<Item> item /*= nullptr
}
descriptions.emplace_back("Attack", ss.str());
} else if (!it.isRanged()) {
std::string attackDescription;
if (it.abilities && it.abilities->elementType != COMBAT_NONE && it.abilities->elementDamage != 0) {
ss.str("");
ss << attack << " physical +" << it.abilities->elementDamage << ' ' << getCombatName(it.abilities->elementType);
descriptions.emplace_back("Attack", ss.str());
} else if (it.attack != 0) {
descriptions.emplace_back("Attack", std::to_string(attack));
attackDescription = fmt::format("{} {}", it.abilities->elementDamage, getCombatName(it.abilities->elementType));
}

if (it.attack != 0) {
attackDescription = fmt::format("{} physical + {}", attack, attackDescription);
}

if (!attackDescription.empty()) {
descriptions.emplace_back("Attack", attackDescription);
}
}

Expand Down Expand Up @@ -2642,14 +2652,19 @@ std::string Item::getDescription(const ItemType &it, int32_t lookDistance, std::
s << "Vol:" << volume;
}
}
if (it.abilities && it.abilities->elementType != COMBAT_NONE && it.abilities->elementDamage != 0) {
begin = false;
s << " (Atk:" << attack << " physical + " << it.abilities->elementDamage << ' ' << getCombatName(it.abilities->elementType);
} else if (attack != 0) {

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

if (it.abilities && it.abilities->elementType != COMBAT_NONE && it.abilities->elementDamage != 0 && !begin) {
s << " physical + " << it.abilities->elementDamage << ' ' << getCombatName(it.abilities->elementType);
} else if (it.abilities && it.abilities->elementType != COMBAT_NONE && it.abilities->elementDamage != 0 && begin) {
begin = false;
s << " (" << it.abilities->elementDamage << ' ' << getCombatName(it.abilities->elementType);
}

if (defense != 0 || extraDefense != 0 || it.isMissile()) {
if (begin) {
begin = false;
Expand Down
15 changes: 10 additions & 5 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5741,12 +5741,17 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) {
}
msg.addString(ss.str(), "ProtocolGame::sendMarketDetail - ss.str()");
} else if (!it.isRanged()) {

Check warning on line 5743 in src/server/network/protocol/protocolgame.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

[cppcheck] src/server/network/protocol/protocolgame.cpp#L5743

Expression is always true because 'else if' condition is opposite to previous condition at line 5719.
Raw output
src/server/network/protocol/protocolgame.cpp:5743:Expression is always true because 'else if' condition is opposite to previous condition at line 5719.
std::string attackDescription;
if (it.abilities && it.abilities->elementType != COMBAT_NONE && it.abilities->elementDamage != 0) {
std::ostringstream ss;
ss << it.attack << " physical +" << it.abilities->elementDamage << ' ' << getCombatName(it.abilities->elementType);
msg.addString(ss.str(), "ProtocolGame::sendMarketDetail - ss.str()");
} else if (it.attack != 0) {
msg.addString(std::to_string(it.attack), "ProtocolGame::sendMarketDetail - std::to_string(it.attack)");
attackDescription = fmt::format("{} {}", it.abilities->elementDamage, getCombatName(it.abilities->elementType));
}

if (it.attack != 0) {
attackDescription = fmt::format("{} physical + {}", it.attack, attackDescription);
}

if (!attackDescription.empty()) {
msg.addString(attackDescription, "ProtocolGame::sendMarketDetail - attackDescription");
}
} else {
msg.add<uint16_t>(0x00);
Expand Down

0 comments on commit 9f9eae9

Please sign in to comment.