mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-22 00:48:44 +00:00
Fix an issue where item in groups could not be moved
Multiple group move would result in some item beeing incorrectly marked as equipped --HG-- branch : fix_item_group
This commit is contained in:
parent
6c01ded28d
commit
7e1556520f
2 changed files with 34 additions and 2 deletions
|
@ -488,8 +488,9 @@ bool CItemGroupManager::moveGroup(std::string name, INVENTORIES::TInventory dst)
|
|||
for(int i=0;i<items.size();i++)
|
||||
{
|
||||
CInventoryItem item = items[i];
|
||||
//If an item is currently equipped, don't move it (or else crash !!)
|
||||
if(pIM->isBagItemWeared(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<CInventoryItem> CItemGroupManager::matchingItems(CItemGroup *group, INVENTORIES::TInventory inventory)
|
||||
{
|
||||
//Not very clean, but no choice, it's ugly time
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue