From 83dea32f4167f27d68e5ab10e198047add287ba0 Mon Sep 17 00:00:00 2001 From: Guillaume Dupuy Date: Thu, 16 Mar 2017 12:19:29 +0100 Subject: [PATCH] Add support for removing items before equipping an item group --HG-- branch : item_group --- code/ryzom/client/src/item_group_manager.cpp | 34 ++++++++++++++++++-- code/ryzom/client/src/item_group_manager.h | 2 ++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/code/ryzom/client/src/item_group_manager.cpp b/code/ryzom/client/src/item_group_manager.cpp index e1060a5e7..1f72eed4d 100644 --- a/code/ryzom/client/src/item_group_manager.cpp +++ b/code/ryzom/client/src/item_group_manager.cpp @@ -74,6 +74,11 @@ void CItemGroup::writeTo(xmlNodePtr node) xmlSetProp (itemNode, (const xmlChar*)"minPrice", (const xmlChar*)NLMISC::toString(item.minPrice).c_str()); xmlSetProp (itemNode, (const xmlChar*)"maxPrice", (const xmlChar*)NLMISC::toString(item.maxPrice).c_str()); } + for(int i=0;iname, "remove") == 0) + { + std::string slot; + ptrName = (char*) xmlGetProp(curNode, (xmlChar*)"slot"); + if (ptrName) NLMISC::fromString((const char*)ptrName, slot); + nlinfo("Got a slot %s", slot.c_str()); + if(SLOTTYPE::stringToSlotType(slot) != SLOTTYPE::UNDEFINED) + removeBeforeEquip.push_back(SLOTTYPE::stringToSlotType(slot)); + } + curNode = curNode->next; } @@ -320,6 +335,21 @@ bool CItemGroupManager::equipGroup(std::string name, bool pullBefore) } if(pullBefore) moveGroup(name, INVENTORIES::TInventory::bag); + //Start by unequipping all slot that user wants to unequip + for(int i=0; i < group->removeBeforeEquip.size(); i++) + { + SLOTTYPE::TSlotType slot = group->removeBeforeEquip[i]; + nlinfo("removing slot %d", slot); + std::string dbPath; + if(slot > SLOTTYPE::RIGHT_HAND) + dbPath = "LOCAL:INVENTORY:HAND:"; + else + dbPath = "LOCAL:INVENTORY:EQUIP:"; + //offset by 1 : TSlotType begins at 1 for actual items (because of UNDEFINED), whereas dbPath start at 0 + dbPath += NLMISC::toString((uint8)slot - 1); + nlinfo("Removing path %s", dbPath.c_str()); + CInventoryManager::getInstance()->unequip(dbPath); + } uint32 maxEquipTime = 0; @@ -333,7 +363,7 @@ bool CItemGroupManager::equipGroup(std::string name, bool pullBefore) }; std::vector duals; std::vector items = matchingItems(group, INVENTORIES::TInventory::bag); - for(int i=0;iasItemSheet()->ItemType; @@ -352,7 +382,7 @@ bool CItemGroupManager::equipGroup(std::string name, bool pullBefore) CInventoryManager::getInstance()->autoEquip(item.indexInBag, true); } // Manually equip dual items - for(int i=0;iasItemSheet()->ItemType; diff --git a/code/ryzom/client/src/item_group_manager.h b/code/ryzom/client/src/item_group_manager.h index 38f53f4a9..c9278d1f2 100644 --- a/code/ryzom/client/src/item_group_manager.h +++ b/code/ryzom/client/src/item_group_manager.h @@ -21,6 +21,7 @@ #include "interface_v3/inventory_manager.h" #include "interface_v3/dbctrl_sheet.h" #include "game_share/inventories.h" +#include "game_share/slot_types.h" struct CInventoryItem { public: @@ -61,6 +62,7 @@ public: std::string name; std::vector Items; + std::vector removeBeforeEquip; }; class CItemGroupManager {