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: CPU overload when loading many nested containers #2909

Merged
merged 1 commit into from
Sep 24, 2024
Merged
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
9 changes: 5 additions & 4 deletions src/items/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
}

bool Item::hasImbuementCategoryId(uint16_t categoryId) const {
for (uint8_t slotid = 0; slotid < getImbuementSlot(); slotid++) {

Check warning on line 131 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
ImbuementInfo imbuementInfo;
if (getImbuementInfo(slotid, &imbuementInfo)) {
if (const CategoryImbuement* categoryImbuement = g_imbuements().getCategoryByID(imbuementInfo.imbuement->getCategory());
Expand Down Expand Up @@ -282,7 +282,7 @@
void Item::setDefaultSubtype() {
const ItemType &it = items[id];

setItemCount(1);

Check warning on line 285 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values

auto itemCharges = it.charges;
if (itemCharges != 0) {
Expand Down Expand Up @@ -405,11 +405,11 @@
if (it.isFluidContainer() || it.isSplash()) {
setAttribute(ItemAttribute_t::FLUIDTYPE, n);
} else if (it.stackable) {
setItemCount(n);

Check warning on line 408 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
} else if (it.charges != 0) {
setAttribute(ItemAttribute_t::CHARGES, n);
} else {
setItemCount(n);

Check warning on line 412 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
}
}

Expand Down Expand Up @@ -862,97 +862,97 @@
void Item::serializeAttr(PropWriteStream &propWriteStream) const {
const ItemType &it = items[id];
if (auto timeStamp = getAttribute<int64_t>(ItemAttribute_t::STORE)) {
propWriteStream.write<uint8_t>(ATTR_STORE);

Check warning on line 865 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<int64_t>(timeStamp);
}
if (it.stackable || it.isFluidContainer() || it.isSplash()) {
propWriteStream.write<uint8_t>(ATTR_COUNT);

Check warning on line 869 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<uint8_t>(getSubType());

Check warning on line 870 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
}

if (auto charges = getAttribute<uint16_t>(ItemAttribute_t::CHARGES)) {
propWriteStream.write<uint8_t>(ATTR_CHARGES);

Check warning on line 874 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<uint16_t>(charges);
}

if (it.movable) {
if (auto actionId = getAttribute<uint16_t>(ItemAttribute_t::ACTIONID)) {
propWriteStream.write<uint8_t>(ATTR_ACTION_ID);

Check warning on line 880 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<uint16_t>(actionId);
}
}

if (const std::string &text = getString(ItemAttribute_t::TEXT);
!text.empty()) {
propWriteStream.write<uint8_t>(ATTR_TEXT);

Check warning on line 887 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.writeString(text);
}

if (const uint64_t writtenDate = getAttribute<uint64_t>(ItemAttribute_t::DATE)) {
propWriteStream.write<uint8_t>(ATTR_WRITTENDATE);

Check warning on line 892 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<uint64_t>(writtenDate);
}

const std::string &writer = getString(ItemAttribute_t::WRITER);
if (!writer.empty()) {
propWriteStream.write<uint8_t>(ATTR_WRITTENBY);

Check warning on line 898 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.writeString(writer);
}

const std::string &specialDesc = getString(ItemAttribute_t::DESCRIPTION);
if (!specialDesc.empty()) {
propWriteStream.write<uint8_t>(ATTR_DESC);

Check warning on line 904 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.writeString(specialDesc);
}

if (hasAttribute(ItemAttribute_t::DURATION)) {
propWriteStream.write<uint8_t>(ATTR_DURATION);

Check warning on line 909 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<int32_t>(getDuration());
}

if (auto decayState = getDecaying();
decayState == DECAYING_TRUE || decayState == DECAYING_PENDING) {
propWriteStream.write<uint8_t>(ATTR_DECAYING_STATE);

Check warning on line 915 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<uint8_t>(decayState);

Check warning on line 916 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
}

if (hasAttribute(ItemAttribute_t::NAME)) {
propWriteStream.write<uint8_t>(ATTR_NAME);

Check warning on line 920 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.writeString(getString(ItemAttribute_t::NAME));
}

if (hasAttribute(ItemAttribute_t::ARTICLE)) {
propWriteStream.write<uint8_t>(ATTR_ARTICLE);

Check warning on line 925 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.writeString(getString(ItemAttribute_t::ARTICLE));
}

if (hasAttribute(ItemAttribute_t::PLURALNAME)) {
propWriteStream.write<uint8_t>(ATTR_PLURALNAME);

Check warning on line 930 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.writeString(getString(ItemAttribute_t::PLURALNAME));
}

if (hasAttribute(ItemAttribute_t::WEIGHT)) {
propWriteStream.write<uint8_t>(ATTR_WEIGHT);

Check warning on line 935 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<uint32_t>(getAttribute<uint32_t>(ItemAttribute_t::WEIGHT));
}

if (hasAttribute(ItemAttribute_t::ATTACK)) {
propWriteStream.write<uint8_t>(ATTR_ATTACK);

Check warning on line 940 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<int32_t>(getAttribute<int32_t>(ItemAttribute_t::ATTACK));
}

if (hasAttribute(ItemAttribute_t::DEFENSE)) {
propWriteStream.write<uint8_t>(ATTR_DEFENSE);

Check warning on line 945 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<int32_t>(getAttribute<int32_t>(ItemAttribute_t::DEFENSE));
}

if (hasAttribute(ItemAttribute_t::EXTRADEFENSE)) {
propWriteStream.write<uint8_t>(ATTR_EXTRADEFENSE);

Check warning on line 950 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<int32_t>(getAttribute<int32_t>(ItemAttribute_t::EXTRADEFENSE));
}

if (hasAttribute(ItemAttribute_t::IMBUEMENT_SLOT)) {
propWriteStream.write<uint8_t>(ATTR_IMBUEMENT_SLOT);

Check warning on line 955 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<int32_t>(getAttribute<int32_t>(ItemAttribute_t::IMBUEMENT_SLOT));
}

Expand All @@ -962,54 +962,54 @@
}

if (hasAttribute(ItemAttribute_t::ARMOR)) {
propWriteStream.write<uint8_t>(ATTR_ARMOR);

Check warning on line 965 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<int32_t>(getAttribute<int32_t>(ItemAttribute_t::ARMOR));
}

if (hasAttribute(ItemAttribute_t::HITCHANCE)) {
propWriteStream.write<uint8_t>(ATTR_HITCHANCE);

Check warning on line 970 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<int8_t>(getAttribute<int8_t>(ItemAttribute_t::HITCHANCE));
}

if (hasAttribute(ItemAttribute_t::SHOOTRANGE)) {
propWriteStream.write<uint8_t>(ATTR_SHOOTRANGE);

Check warning on line 975 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<uint8_t>(getAttribute<uint8_t>(ItemAttribute_t::SHOOTRANGE));
}

if (hasAttribute(ItemAttribute_t::SPECIAL)) {
propWriteStream.write<uint8_t>(ATTR_SPECIAL);

Check warning on line 980 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.writeString(getString(ItemAttribute_t::SPECIAL));
}

if (hasAttribute(ItemAttribute_t::QUICKLOOTCONTAINER)) {
propWriteStream.write<uint8_t>(ATTR_QUICKLOOTCONTAINER);

Check warning on line 985 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<uint32_t>(getAttribute<uint32_t>(ItemAttribute_t::QUICKLOOTCONTAINER));
}

if (hasAttribute(ItemAttribute_t::TIER)) {
propWriteStream.write<uint8_t>(ATTR_TIER);

Check warning on line 990 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<uint8_t>(getTier());
}

if (hasAttribute(AMOUNT)) {
propWriteStream.write<uint8_t>(ATTR_AMOUNT);

Check warning on line 995 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<uint16_t>(getAttribute<uint16_t>(AMOUNT));
}

if (hasAttribute(STORE_INBOX_CATEGORY)) {
propWriteStream.write<uint8_t>(ATTR_STORE_INBOX_CATEGORY);

Check warning on line 1000 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.writeString(getString(ItemAttribute_t::STORE_INBOX_CATEGORY));
}

if (hasAttribute(OWNER)) {
propWriteStream.write<uint8_t>(ATTR_OWNER);

Check warning on line 1005 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<uint32_t>(getAttribute<uint32_t>(ItemAttribute_t::OWNER));
}

// Serialize custom attributes, only serialize if the map not is empty
if (hasCustomAttribute()) {
auto customAttributeMap = getCustomAttributeMap();
propWriteStream.write<uint8_t>(ATTR_CUSTOM);

Check warning on line 1012 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
propWriteStream.write<uint64_t>(customAttributeMap.size());
for (const auto &[attributeKey, customAttribute] : customAttributeMap) {
// Serializing custom attribute key type
Expand All @@ -1020,7 +1020,7 @@
}

if (hasAttribute(ItemAttribute_t::OBTAINCONTAINER)) {
propWriteStream.write<uint8_t>(ATTR_OBTAINCONTAINER);

Check warning on line 1023 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
auto flags = getAttribute<uint32_t>(ItemAttribute_t::OBTAINCONTAINER);
g_logger().debug("Reading flag {}, to item id {}", flags, getID());
propWriteStream.write<uint32_t>(flags);
Expand Down Expand Up @@ -1240,7 +1240,7 @@
skillBoost = true;
}

for (uint8_t i = SKILL_FIRST; i <= SKILL_FISHING; i++) {

Check warning on line 1243 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
if (!it.abilities->skills[i]) {
continue;
}
Expand Down Expand Up @@ -1293,13 +1293,13 @@
descriptions.emplace_back("Magic Level", ss.str());
}

for (uint8_t i = 1; i <= 11; i++) {

Check warning on line 1296 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
if (it.abilities->specializedMagicLevel[i]) {
ss.str("");

ss << std::showpos << it.abilities->specializedMagicLevel[i] << std::noshowpos;
std::string combatName = getCombatName(indexToCombatType(i));
combatName[0] = toupper(combatName[0]);

Check warning on line 1302 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
descriptions.emplace_back(combatName + " Magic Level", ss.str());
}
}
Expand Down Expand Up @@ -1648,7 +1648,7 @@
skillBoost = true;
}

for (uint8_t i = SKILL_FIRST; i <= SKILL_FISHING; i++) {

Check warning on line 1651 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
if (!it.abilities->skills[i]) {
continue;
}
Expand Down Expand Up @@ -1702,7 +1702,7 @@

ss << std::showpos << it.abilities->specializedMagicLevel[i] << std::noshowpos;
std::string combatName = getCombatName(indexToCombatType(i));
combatName[0] = toupper(combatName[0]);

Check warning on line 1705 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
descriptions.emplace_back(combatName + " Magic Level", ss.str());
}
}
Expand Down Expand Up @@ -1913,7 +1913,7 @@
s << std::endl
<< "Imbuements: (";

for (uint8_t slotid = 0; slotid < item->getImbuementSlot(); slotid++) {

Check warning on line 1916 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
if (slotid >= 1) {
s << ", ";
}
Expand Down Expand Up @@ -2100,7 +2100,7 @@
}

if (itemType.abilities) {
for (uint8_t i = SKILL_FIRST; i <= SKILL_FISHING; i++) {

Check warning on line 2103 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
if (!itemType.abilities->skills[i]) {
continue;
}
Expand All @@ -2115,7 +2115,7 @@
itemDescription << getSkillName(i) << ' ' << std::showpos << itemType.abilities->skills[i] << std::noshowpos;
}

for (uint8_t i = SKILL_CRITICAL_HIT_CHANCE; i <= SKILL_LAST; i++) {

Check warning on line 2118 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
auto skill = item ? item->getSkill(static_cast<skills_t>(i)) : itemType.getSkill(static_cast<skills_t>(i));
if (!skill) {
continue;
Expand Down Expand Up @@ -2150,7 +2150,7 @@
itemDescription << "magic level " << std::showpos << itemType.abilities->stats[STAT_MAGICPOINTS] << std::noshowpos;
}

for (uint8_t i = 1; i <= 11; i++) {

Check warning on line 2153 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
if (itemType.abilities->specializedMagicLevel[i]) {
if (begin) {
begin = false;
Expand Down Expand Up @@ -2398,7 +2398,7 @@
}

if (it.abilities) {
for (uint8_t i = SKILL_FIRST; i <= SKILL_FISHING; i++) {

Check warning on line 2401 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
if (!it.abilities->skills[i]) {
continue;
}
Expand All @@ -2413,7 +2413,7 @@
s << getSkillName(i) << ' ' << std::showpos << it.abilities->skills[i] << std::noshowpos;
}

for (uint8_t i = SKILL_CRITICAL_HIT_CHANCE; i <= SKILL_LAST; i++) {

Check warning on line 2416 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
auto skill = item ? item->getSkill(static_cast<skills_t>(i)) : it.getSkill(static_cast<skills_t>(i));
if (!skill) {
continue;
Expand Down Expand Up @@ -2448,7 +2448,7 @@
s << "magic level " << std::showpos << it.abilities->stats[STAT_MAGICPOINTS] << std::noshowpos;
}

for (uint8_t i = 1; i <= 11; i++) {

Check warning on line 2451 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
if (it.abilities->specializedMagicLevel[i]) {
if (begin) {
begin = false;
Expand Down Expand Up @@ -2666,7 +2666,7 @@
}

if (it.abilities) {
for (uint8_t i = SKILL_FIRST; i <= SKILL_FISHING; i++) {

Check warning on line 2669 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
if (!it.abilities->skills[i]) {
continue;
}
Expand All @@ -2681,7 +2681,7 @@
s << getSkillName(i) << ' ' << std::showpos << it.abilities->skills[i] << std::noshowpos;
}

for (uint8_t i = SKILL_CRITICAL_HIT_CHANCE; i <= SKILL_LAST; i++) {

Check warning on line 2684 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
auto skill = item ? item->getSkill(static_cast<skills_t>(i)) : it.getSkill(static_cast<skills_t>(i));
if (!skill) {
continue;
Expand Down Expand Up @@ -2716,7 +2716,7 @@
s << "magic level " << std::showpos << it.abilities->stats[STAT_MAGICPOINTS] << std::noshowpos;
}

for (uint8_t i = 1; i <= 11; i++) {

Check warning on line 2719 in src/items/item.cpp

View workflow job for this annotation

GitHub Actions / Qodana for C/C++

misra-cpp2008-5-0-11

MISRA 5-0-11: The plain char type shall only be used for the storage and use of character values
if (it.abilities->specializedMagicLevel[i]) {
if (begin) {
begin = false;
Expand Down Expand Up @@ -3160,16 +3160,17 @@
}

bool Item::canDecay() {
if (isRemoved() || isDecayDisabled()) {
const ItemType &it = Item::items[id];
if (it.decayTo < 0 || it.decayTime == 0 || isDecayDisabled()) {
return false;
}

const ItemType &it = Item::items[id];
if (it.decayTo < 0 || it.decayTime == 0) {
if (hasAttribute(ItemAttribute_t::UNIQUEID)) {
return false;
}

if (hasAttribute(ItemAttribute_t::UNIQUEID)) {
// In certain conditions, such as depth nested containers, this can overload the CPU, so it is left last.
if (isRemoved()) {
return false;
}

Expand Down
Loading