From 8eaffd47c76dfe01d4ca194cbf6a4ffa8bd9f750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caner=20K=C4=B1l=C4=B1=C3=A7o=C4=9Flu?= Date: Tue, 25 Nov 2025 15:11:28 +0300 Subject: [PATCH] Fixed the issue where some items (hair, beard, etc.) --- Changelog.txt | 4 ++++ src/game/clients/CClientMsg.cpp | 37 +++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index eb6bead1f..0ff41e6b6 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -4077,3 +4077,7 @@ When setting a property like MORE to the a spell or skill defname, trying to rea - Changed: Object timers are now saved in worldsave files as TIMERMS, to avoid ambiguity and reliance on git build number to determine if TIMER expressed a number in seconds or milliseconds. - Changed: Added 5 seconds timeout to DNS hostname resolution at startup (avoid getting stuck when connectivity is enabled but not working). - Changed: CANMASK formatted in worldsave files as hexadecimal number, instead of decimal. + + +25-11-2025, canerksk +- Fixed: Fixed the issue where some items (hair, beard, etc.) were counted as items inside the corpse (Issue #1189). \ No newline at end of file diff --git a/src/game/clients/CClientMsg.cpp b/src/game/clients/CClientMsg.cpp index 80e81ad30..3811f5cfe 100644 --- a/src/game/clients/CClientMsg.cpp +++ b/src/game/clients/CClientMsg.cpp @@ -1226,12 +1226,37 @@ void CClient::addItemName( CItem * pItem ) size_t len = Str_CopyLimitNull( szName, pszNameFull, ARRAY_COUNT(szName) ); const CContainer* pCont = dynamic_cast(pItem); - if ( pCont != nullptr ) - { - // ??? Corpses show hair as an item !! - len += snprintf( szName+len, sizeof(szName) - len, - g_Cfg.GetDefaultMsg(DEFMSG_CONT_ITEMS), pCont->GetContentCount(), pCont->GetTotalWeight() / WEIGHT_UNITS); - } + if (pCont != nullptr) + { + + size_t iContContentTotalUnit = 0; + size_t iContContentTotalWeight = 0; + + if (pItem->IsType(IT_CORPSE)) + { + for (size_t i = 0; i < pCont->GetContentCount(); ++i) + { + CItem *pContentItem = static_cast(pCont->GetContentIndex(i)); + if (pContentItem->IsAttr(ATTR_NEWBIE | ATTR_MOVE_NEVER | ATTR_CURSED2 | ATTR_BLESSED2 | ATTR_STATIC)) + continue; + + if (pContentItem->IsType(IT_HAIR) || pContentItem->IsType(IT_BEARD)) + continue; + + ++iContContentTotalUnit; + iContContentTotalWeight += static_cast(pContentItem->GetWeight() / WEIGHT_UNITS); + } + } + else + { + iContContentTotalUnit = pCont->GetContentCount(); + iContContentTotalWeight = pCont->GetTotalWeight() / WEIGHT_UNITS; + } + //g_Log.Event(LOGM_CLIENTS_LOG, "Items=%d, Weight=%d\n", iContContentTotalUnit, iContContentTotalWeight); + // ??? Corpses show hair as an item !! + len += snprintf(szName + len, sizeof(szName) - len, g_Cfg.GetDefaultMsg(DEFMSG_CONT_ITEMS), iContContentTotalUnit, iContContentTotalWeight); + } + // obviously damaged ? else if ( pItem->IsTypeArmorWeapon())