@@ -831,6 +831,10 @@ void Container::removeThing(const std::shared_ptr<Thing> &thing, uint32_t count)
831831
832832 item->resetParent ();
833833 itemlist.erase (itemlist.begin () + index);
834+
835+ if (isCorpse () && empty ()) {
836+ clearLootHighlight ();
837+ }
834838 }
835839}
836840
@@ -970,8 +974,24 @@ void Container::removeItem(const std::shared_ptr<Thing> &thing, bool sendUpdateT
970974
971975 itemlist.erase (it);
972976 itemToRemove->resetParent ();
977+
978+ if (isCorpse () && empty ()) {
979+ clearLootHighlight ();
980+ }
973981 }
974982}
983+ void Container::clearLootHighlight (const std::shared_ptr<Player> &player) {
984+ if (!isCorpse ()) {
985+ return ;
986+ }
987+
988+ if (!m_lootHighlightActive) {
989+ return ;
990+ }
991+
992+ m_lootHighlightActive = false ;
993+ sendUpdateToClient (player);
994+ }
975995
976996uint32_t Container::getOwnerId () const {
977997 uint32_t ownerId = Item::getOwnerId ();
@@ -1095,3 +1115,62 @@ size_t ContainerIterator::getCurrentIndex() const {
10951115 const auto &top = states.back ();
10961116 return top.index ;
10971117}
1118+
1119+ ContainerSpecial_t Container::getSpecialCategory (const std::shared_ptr<Player> &player) {
1120+ const auto &holdingPlayer = getHoldingPlayer ();
1121+ using enum ContainerSpecial_t;
1122+
1123+ if (isCorpse () && hasLootHighlight () && !isRewardCorpse () && !empty () && (getCorpseOwner () == static_cast <uint32_t >(std::numeric_limits<int32_t >::max ()) || (getCorpseOwner () == 0 || player->canOpenCorpse (getCorpseOwner ())))) {
1124+ return LootHighlight;
1125+ }
1126+
1127+ if (holdingPlayer == player) {
1128+ if (isQuiver () && getSlotPosition () & SLOTP_RIGHT) {
1129+ return QuiverLoot;
1130+ }
1131+
1132+ auto [lootFlags, obtainFlags] = getObjectCategoryFlags (player);
1133+ if (lootFlags != 0 || obtainFlags != 0 ) {
1134+ return Manager;
1135+ }
1136+ }
1137+
1138+ return None;
1139+ }
1140+
1141+ std::pair<uint32_t , uint32_t > Container::getObjectCategoryFlags (const std::shared_ptr<Player> &player) const {
1142+ uint32_t lootFlags = 0 ;
1143+ uint32_t obtainFlags = 0 ;
1144+ // Cycle through all containers managed by the player
1145+ for (const auto &[category, containerPair] : player->getManagedContainers ()) {
1146+ // Check if the category is valid before continuing
1147+ if (!isValidObjectCategory (category)) {
1148+ continue ;
1149+ }
1150+
1151+ // containerPair.first refers to loot containers
1152+ if (containerPair.first == static_self_cast<Container>()) {
1153+ lootFlags |= 1 << category;
1154+ }
1155+
1156+ // containerPair.second refers to the obtain containers
1157+ if (containerPair.second == static_self_cast<Container>()) {
1158+ obtainFlags |= 1 << category;
1159+ }
1160+ }
1161+
1162+ return { lootFlags, obtainFlags };
1163+ }
1164+
1165+ uint32_t Container::getAmmoAmount (const std::shared_ptr<Player> &player) const {
1166+ uint32_t ammoTotal = 0 ;
1167+ if (isQuiver ()) {
1168+ for (const auto &listItem : getItemList ()) {
1169+ if (player->getLevel () >= Item::items[listItem->getID ()].minReqLevel ) {
1170+ ammoTotal += listItem->getItemAmount ();
1171+ }
1172+ }
1173+ }
1174+
1175+ return ammoTotal;
1176+ }
0 commit comments