diff --git a/code/ryzom/client/src/item_group_manager.cpp b/code/ryzom/client/src/item_group_manager.cpp index 8c18a6e37..97e7160f7 100644 --- a/code/ryzom/client/src/item_group_manager.cpp +++ b/code/ryzom/client/src/item_group_manager.cpp @@ -488,8 +488,9 @@ bool CItemGroupManager::moveGroup(std::string name, INVENTORIES::TInventory dst) for(int i=0;iisBagItemWeared(item.indexInBag)) continue; + //Workaround: sometimes item are marked as equipped by pIM->isBagItemWeared() even tho they aren't really + //Because of a synchronisation error between client and server + if(isItemReallyEquipped(item.pCS)) continue; CAHManager::getInstance()->runActionHandler("move_item", item.pCS, moveParams); } @@ -709,6 +710,33 @@ std::string CItemGroupManager::toDbPath(INVENTORIES::TInventory inventory) } } +bool CItemGroupManager::isItemReallyEquipped(CDBCtrlSheet* item) +{ + CDBCtrlSheet* pCS; + for (uint32 i = 0; i < MAX_EQUIPINV_ENTRIES; ++i) + { + SLOT_EQUIPMENT::TSlotEquipment slot = (SLOT_EQUIPMENT::TSlotEquipment)i; + //Instead of doing two separate for, just be a bit tricky for hand equipment + if(slot == SLOT_EQUIPMENT::HANDR) + pCS = CInventoryManager::getInstance()->getHandSheet(0); + else if(slot == SLOT_EQUIPMENT::HANDL) + pCS = CInventoryManager::getInstance()->getHandSheet(1); + else + pCS = CInventoryManager::getInstance()->getEquipSheet(i); + if(!pCS) continue; + //Can't directly compare ID (as pCS is like "ui:interface:inv_equip:content:equip:armors:feet" and item is like "ui:interface:inv_pa3:content:iil:bag_list:list:sheet57") + //Instead check inventory + slot + if((pCS->getInventoryIndex() == item->getInventoryIndex()) + && (pCS->getIndexInDB() == item->getIndexInDB())) + { + return true; + } + + } + + return false; +} + std::vector CItemGroupManager::matchingItems(CItemGroup *group, INVENTORIES::TInventory inventory) { //Not very clean, but no choice, it's ugly time diff --git a/code/ryzom/client/src/item_group_manager.h b/code/ryzom/client/src/item_group_manager.h index dae9d0e11..a4ff46c43 100644 --- a/code/ryzom/client/src/item_group_manager.h +++ b/code/ryzom/client/src/item_group_manager.h @@ -115,6 +115,10 @@ private: void validActions(); NLMISC::TGameCycle _EndInvalidAction; NLMISC::TGameCycle _StartInvalidAction; + //Workaround: sometimes item are marked as equipped by pIM->isBagItemWeared() even tho they aren't really + //Because of a synchronisation error between client and server + bool isItemReallyEquipped(CDBCtrlSheet *item); + //Used to migrate old groups ; keep for compatibility purpose bool migrateGroups();