Compare commits

...

9 Commits

Author SHA1 Message Date
Ben 5ad6cffb21 add: item groups refactor draft
- Created CEquipItem and CHotbarItem, inheriting CItem, to differentiate item type
- Overloaded methods for EquipItems (using TSlotEquipment slot) and HotbarItems (using uint16 slot)
- Separated Items array into EquipItems and HotbarItems
- New xml props <hotbar_item> and <hotbar_remove>, children of <group>

TODO:
- Revisit contains() method
- Implement hotbar compatibility to matchingItems() method
3 years ago
bensaine d6d0417419 add: hands to equip tab 3 years ago
bensaine 5676438aff Update action_handler_item.cpp 3 years ago
bensaine 7f796d86ec Update inventory_manager.cpp 3 years ago
bensaine df24bf6129 fixes 3 years ago
bensaine fe4c39b593 move hotbar index 3 years ago
bensaine 7aa639138a revert _IsHotbarSlot 3 years ago
bensaine e7dec3d6b0 add: INVENTORIES:hotbar 3 years ago
bensaine b6b67f7482 initial draft 3 years ago

@ -1079,7 +1079,6 @@ class CCanDropToExchange : public IActionHandler
};
REGISTER_ACTION_HANDLER (CCanDropToExchange, "can_drop_to_exchange");
// **********************************************************************************************************
/** Clear the selected sheet
@ -2462,6 +2461,57 @@ class CHandlerRingXpCatalyserStopUse : public IActionHandler
};
REGISTER_ACTION_HANDLER( CHandlerRingXpCatalyserStopUse, "ring_xp_catalyser_stop_use" );
// ***************************************************************************
class CHandlerUseHotbarItem : public IActionHandler
{
void execute(CCtrlBase * /* pCaller */, const std::string &sParams)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
sint64 slot;
if (!CInterfaceExpr::evalAsInt(getParam(sParams, "slot"), slot))
{
nlwarning("<CHandlerUseHotbarItem::execute> Can't retrieve counter.");
return;
}
if (slot > INVENTORIES::NbHotbarSlots) {
nlwarning("<CHandlerUseHotbarItem::execute> Slot out of range.");
return;
}
CDBCtrlSheet *pCS = getInventory().getHotbarSheet(slot);
if (!pCS)
{
nlwarning("<CHandlerUseHotbarItem::execute> Can't retrieve sheet.");
return;
}
const CItemSheet *pIS = pCS->asItemSheet();
if (!pIS)
{
nlwarning("<CHandlerUseHotbarItem::execute> Can't retrieve item.");
return;
}
ITEMFAMILY::EItemFamily fam = pIS->Family;
if (!getInventory().isUsableItem(pCS->getSheetId())) {
nlwarning("<CHandlerUseHotbarItem::execute> Item is not usable.");
return;
}
if (fam == ITEMFAMILY::ITEM_SAP_RECHARGE || fam == ITEMFAMILY::CRYSTALLIZED_SPELL)
{
sendToServerEnchantMessage((uint8)pCS->getInventoryIndex(), (uint16)pCS->getIndexInDB());
}
else if (fam == ITEMFAMILY::CONSUMABLE || fam == ITEMFAMILY::XP_CATALYSER)
{
sendMsgUseItem(uint16(pCS->getIndexInDB()));
}
}
};
REGISTER_ACTION_HANDLER( CHandlerUseHotbarItem, "use_hotbar_item" );
// ***************************************************************************
// item groups

@ -74,6 +74,7 @@ CInventoryManager *CInventoryManager::_Instance = NULL;
NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupListSheetBag, std::string, "list_sheet_bag");
NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupIconListBag, std::string, "list_icon_bag");
NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupListSheetFilterCLMSlot, std::string, "list_sheet_filter_clm_slot");
NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupListSheetFilterHotbarSlot, std::string, "list_sheet_filter_hotbar_slot");
NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupListSheetFilterExchangeable, std::string, "list_sheet_filter_exchangeable");
// ***************************************************************************
@ -314,6 +315,8 @@ CInventoryManager::CInventoryManager()
{
Hands[i] = ServerHands[i] = 0;
UIHands[i] = NULL;
UIHands2[i] = NULL;
UIHands3[i] = NULL;
}
for (i = 0; i < MAX_EQUIPINV_ENTRIES; ++i)
@ -323,6 +326,14 @@ CInventoryManager::CInventoryManager()
UIEquip2[i] = NULL;
}
for (i = 0; i < MAX_HOTBARINV_ENTRIES; ++i)
{
Hotbar[i] = ServerHotbar[i] = 0;
UIHotbar[i] = NULL;
UIHotbar2[i] = NULL;
UIHotbar3[i] = NULL;
}
for (i = 0; i < MAX_BAGINV_ENTRIES; i++)
{
BagItemEquipped[i]= false;
@ -390,6 +401,16 @@ CItemImage *CInventoryManager::getEquipItem(uint index)
return NULL;
}
// *************************************************************************************************
CItemImage *CInventoryManager::getHotbarItem(uint index)
{
nlassert(index < MAX_HOTBARINV_ENTRIES);
if (Hotbar[index] != 0)
return &Bag[Hotbar[index]];
else
return NULL;
}
// *************************************************************************************************
CDBCtrlSheet *CInventoryManager::getHandSheet(uint index)
{
@ -402,6 +423,11 @@ CDBCtrlSheet *CInventoryManager::getEquipSheet(uint index)
return UIEquip[index];
}
// *************************************************************************************************
CDBCtrlSheet *CInventoryManager::getHotbarSheet(uint index)
{
return UIHotbar[index];
}
// *************************************************************************************************
CItemImage &CInventoryManager::getServerBagItem(uint index)
@ -480,6 +506,7 @@ void CInventoryManager::init()
Money = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":MONEY");
initIndirection (LOCAL_INVENTORY ":HAND:", Hands, MAX_HANDINV_ENTRIES, true);
initIndirection (LOCAL_INVENTORY ":EQUIP:", Equip, MAX_EQUIPINV_ENTRIES, true);
initIndirection (LOCAL_INVENTORY ":HOTBAR:", Hotbar, MAX_HOTBARINV_ENTRIES, true);
// Init observers for auto equipment
{
for (uint i = 0; i < MAX_BAGINV_ENTRIES; ++i)
@ -527,6 +554,15 @@ void CInventoryManager::init()
UIEquip[SLOT_EQUIPMENT::LEGS] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMOR_LEGS));
UIEquip[SLOT_EQUIPMENT::HANDS] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMOR_HANDS));
UIHotbar[0] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HOTBAR_1));
UIHotbar[1] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HOTBAR_2));
UIHotbar[2] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HOTBAR_3));
UIHotbar[3] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HOTBAR_4));
UIHotbar[4] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HOTBAR_5));
UIHands2[0] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND2_RIGHT));
UIHands2[1] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND2_LEFT));
UIEquip2[SLOT_EQUIPMENT::HEADDRESS] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_HEADDRESS));
UIEquip2[SLOT_EQUIPMENT::EARL] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_EARING_LEFT));
UIEquip2[SLOT_EQUIPMENT::EARR] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_EARING_RIGHT));
@ -545,6 +581,20 @@ void CInventoryManager::init()
UIEquip2[SLOT_EQUIPMENT::LEGS] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMR2_LEGS));
UIEquip2[SLOT_EQUIPMENT::HANDS] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMR2_HANDS));
UIHotbar2[0] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HOTBAR2_1));
UIHotbar2[1] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HOTBAR2_2));
UIHotbar2[2] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HOTBAR2_3));
UIHotbar2[3] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HOTBAR2_4));
UIHotbar2[4] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HOTBAR2_5));
UIHands3[0] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND3_RIGHT));
UIHands3[1] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND3_LEFT));
UIHotbar3[0] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HOTBAR3_1));
UIHotbar3[1] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HOTBAR3_2));
UIHotbar3[2] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HOTBAR3_3));
UIHotbar3[3] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HOTBAR3_4));
UIHotbar3[4] = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(CTRL_HOTBAR3_5));
// Init ItemInfoObservers
{
@ -658,6 +708,14 @@ std::string CInventoryManager::getDBIndexPath(CDBCtrlSheet *pCS)
{
return string(LOCAL_INVENTORY) + ":HAND:" + toString(i);
}
if (UIHands2[i] == pCS)
{
return string(LOCAL_INVENTORY) + ":HAND:" + toString(i);
}
if (UIHands3[i] == pCS)
{
return string(LOCAL_INVENTORY) + ":HAND:" + toString(i);
}
}
for (i = 0; i < MAX_EQUIPINV_ENTRIES; ++i)
@ -671,6 +729,23 @@ std::string CInventoryManager::getDBIndexPath(CDBCtrlSheet *pCS)
return string(LOCAL_INVENTORY) + ":EQUIP:" + toString(i);
}
}
for (i = 0; i < MAX_HOTBARINV_ENTRIES; ++i)
{
if (UIHotbar[i] == pCS)
{
return string(LOCAL_INVENTORY) + ":HOTBAR:" + toString(i);
}
if (UIHotbar2[i] == pCS)
{
return string(LOCAL_INVENTORY) + ":HOTBAR:" + toString(i);
}
if (UIHotbar3[i] == pCS)
{
return string(LOCAL_INVENTORY) + ":HOTBAR:" + toString(i);
}
}
return "";
}
@ -758,6 +833,20 @@ bool CInventoryManager::isForageToolItem(uint32 sheetID)
return result;
}
// ***************************************************************************
bool CInventoryManager::isUsableItem(uint32 sheetID)
{
bool result = false;
CEntitySheet *sheet= SheetMngr.get(CSheetId(sheetID));
if(sheet && sheet->type()== CEntitySheet::ITEM)
{
CItemSheet *item= (CItemSheet*)sheet;
if( ITEMFAMILY::isUsable(item->Family) )
result = true;
}
return result;
}
// ***************************************************************************
uint32 CInventoryManager::getHandItemSheet( bool rightHand ) const
{
@ -957,6 +1046,11 @@ void CInventoryManager::equip(const std::string &bagPath, const std::string &inv
inventory = INVENTORIES::equipment;
fromString(invPath.substr(22,invPath.size()), invSlot);
}
else if (strnicmp(invPath.c_str(),"LOCAL:INVENTORY:HOTBAR",22) == 0)
{
inventory = INVENTORIES::hotbar;
fromString(invPath.substr(23,invPath.size()), invSlot);
}
// Hands management : check if we have to unequip left hand because of incompatibility with right hand item
sint16 oldRightIndexInBag = NLGUI::CDBManager::getInstance()->getDbProp(invPath + ":INDEX_IN_BAG")->getValue16();
@ -1090,6 +1184,11 @@ void CInventoryManager::unequip(const std::string &invPath)
inventory = INVENTORIES::equipment;
fromString(invPath.substr(22,invPath.size()), invSlot);
}
else if (strnicmp(invPath.c_str(),"LOCAL:INVENTORY:HOTBAR",22) == 0)
{
inventory = INVENTORIES::hotbar;
fromString(invPath.substr(23,invPath.size()), invSlot);
}
// Hands management : check if we have to unequip left hand because of incompatibility with right hand item
if (inventory == INVENTORIES::handling && invSlot == 0)
@ -1176,7 +1275,7 @@ void CInventoryManager::CDBEquipObs::update(ICDBNode* node)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
string sTmp = node->getFullName();
string sIE, sIE2; // Interface Element
string sIE, sIE2, sIE3; // Interface Element
CCDBNodeLeaf *pNL = dynamic_cast<CCDBNodeLeaf*>(node);
if (pNL == NULL) return;
if (strnicmp(sTmp.c_str(),"LOCAL:INVENTORY:HAND",20) == 0)
@ -1186,10 +1285,16 @@ void CInventoryManager::CDBEquipObs::update(ICDBNode* node)
sTmp = sTmp.substr(0,sTmp.rfind(':'));
sint index;
fromString(sTmp, index);
if (index == 0)
if (index == 0) {
sIE = CTRL_HAND_RIGHT;
else
sIE2 = CTRL_HAND2_RIGHT;
sIE3 = CTRL_HAND3_RIGHT;
}
else {
sIE = CTRL_HAND_LEFT;
sIE2 = CTRL_HAND2_LEFT;
sIE3 = CTRL_HAND3_LEFT;
}
// update Hands.
getInventory().Hands[index]= pNL->getValue16();
}
@ -1245,11 +1350,49 @@ void CInventoryManager::CDBEquipObs::update(ICDBNode* node)
// update Equips.
getInventory().Equip[index]= pNL->getValue16();
}
else if (strnicmp(sTmp.c_str(),"LOCAL:INVENTORY:HOTBAR",22) == 0)
{
// Coming from hand
sTmp = sTmp.substr(23,sTmp.size());
sTmp = sTmp.substr(0,sTmp.rfind(':'));
sint index;
fromString(sTmp, index);
switch (index) {
case 0:
sIE = CTRL_HOTBAR_1;
sIE2 = CTRL_HOTBAR2_1;
sIE3 = CTRL_HOTBAR3_1;
break;
case 1:
sIE = CTRL_HOTBAR_2;
sIE2 = CTRL_HOTBAR2_2;
sIE3 = CTRL_HOTBAR3_2;
break;
case 2:
sIE = CTRL_HOTBAR_3;
sIE2 = CTRL_HOTBAR2_3;
sIE3 = CTRL_HOTBAR3_3;
break;
case 3:
sIE = CTRL_HOTBAR_4;
sIE2 = CTRL_HOTBAR2_4;
sIE3 = CTRL_HOTBAR3_4;
break;
case 4:
sIE = CTRL_HOTBAR_5;
sIE2 = CTRL_HOTBAR2_5;
sIE3 = CTRL_HOTBAR3_5;
break;
}
// update Hotbar.
getInventory().Hotbar[index]= pNL->getValue16();
}
else return;
// Set database for wearing the right item
CDBCtrlSheet *pCS = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(sIE));
CDBCtrlSheet *pCS2 = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(sIE2));
CDBCtrlSheet *pCS3 = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getElementFromId(sIE3));
// Remove Last reference and update database
sint16 oldVal = pNL->getOldValue16();
@ -1268,12 +1411,14 @@ void CInventoryManager::CDBEquipObs::update(ICDBNode* node)
{
if (pCS != NULL) pCS->setSheet("");
if (pCS2 != NULL) pCS2->setSheet("");
if (pCS3 != NULL) pCS3->setSheet("");
}
}
else
{
if (pCS != NULL) pCS->setSheet(LOCAL_INVENTORY ":BAG:"+ toString(newVal-1));
if (pCS2 != NULL) pCS2->setSheet(LOCAL_INVENTORY ":BAG:"+ toString(newVal-1));
if (pCS3 != NULL) pCS3->setSheet(LOCAL_INVENTORY ":BAG:"+ toString(newVal-1));
}
// Hands management
@ -1405,6 +1550,7 @@ void CInventoryManager::CDBEquipObs::update(ICDBNode* node)
{
if (pCS != NULL) pCS->setSheet("");
if (pCS2 != NULL) pCS2->setSheet("");
if (pCS3 != NULL) pCS3->setSheet("");
}
}
}
@ -2608,6 +2754,42 @@ bool CDBGroupListSheetFilterCLMSlot::CSheetChildFilter::isSheetValid(CDBGroupLis
return false;
}
// ***************************************************************************
// CDBGroupListSheetFilterHotbarSlot
// ***************************************************************************
// ***************************************************************************
bool CDBGroupListSheetFilterHotbarSlot::CSheetChildFilter::isSheetValid(CDBGroupListSheet *pFather)
{
if (CSheetChild::isSheetValid(pFather))
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CDBCtrlSheet *clmCtrl = dynamic_cast<CDBCtrlSheet*>(CWidgetManager::getInstance()->getCtrlLaunchingModal());
if (!clmCtrl || !Ctrl) return false;
if (clmCtrl->getInventoryIndex() == INVENTORIES::exchange &&
Ctrl->getInventoryIndex() == INVENTORIES::exchange)
{
return false;
}
if ((clmCtrl->getType() == CCtrlSheetInfo::SheetType_Item) &&
(Ctrl->getType() == CCtrlSheetInfo::SheetType_Item) )
{
// Ok if we can put in the slot Ctrl in clmCtrl
if ( clmCtrl->canDropItem(Ctrl))
{
string sTmp = Ctrl->getSheet();
// Look if the source is locked
sTmp = sTmp.substr(sTmp.rfind(':')+1,sTmp.size());
sint32 nTmp;
fromString(sTmp, nTmp);
if (!getInventory().isBagItemWeared(nTmp) && getInventory().isUsableItem(Ctrl->getSheetId()) && Ctrl->getLockedByOwner() == 0)
return true;
}
}
}
return false;
}
// ***************************************************************************
// CDBGroupListSheetFilterExchangeable
// ***************************************************************************
@ -2960,7 +3142,7 @@ class CHandlerInvDropTo : public IActionHandler
{
CInterfaceGroup *pIG = CWidgetManager::getInstance()->getModalWindow();
if (pIG == NULL) return;
if (pIG->getId() != "ui:interface:bag_choose") return;
if (pIG->getId() != "ui:interface:bag_choose" && pIG->getId() != "ui:interface:hotbar_choose") return;
getInventory().beginDrag(NULL, CInventoryManager::TextList);
// Special case for choose in bag dialog
@ -3121,7 +3303,6 @@ class CHandlerInvCannotDrop : public IActionHandler
// Is the dragged sheet comes from a slot
if (!getInventory().isDraggingFromTextList())
{
// Unequip
CDBCtrlSheet *pCSDst = dynamic_cast<CDBCtrlSheet*>(pCaller);
string invPath = getInventory().getDBIndexPath(pCSDst);
getInventory().unequip(invPath);
@ -3131,6 +3312,75 @@ class CHandlerInvCannotDrop : public IActionHandler
};
REGISTER_ACTION_HANDLER( CHandlerInvCannotDrop, "inv_cannot_drop" );
// **********************************************************************************************************
class CCanDropToHotbar : public IActionHandler
{
virtual void execute (CCtrlBase *pCaller, const string &Params)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
string src = getParam(Params, "src");
CInterfaceElement *pElt = CWidgetManager::getInstance()->getElementFromId(src);
CDBCtrlSheet *pCSSrc = dynamic_cast<CDBCtrlSheet*>(pElt);
CDBCtrlSheet *pCSDst = dynamic_cast<CDBCtrlSheet*>(pCaller);
if (!pCSSrc || !pCSDst) return;
// Exchange can only be done from bag to exchange inventories
uint32 srcInventory = pCSSrc->getSecondIndexInDB();
if (
srcInventory == INVENTORIES::bag
&& getInventory().isInventoryAvailable((INVENTORIES::TInventory) pCSSrc->getSecondIndexInDB())
&& getInventory().isUsableItem(pCSSrc->getSheetId())
)
{
pCSDst->setCanDrop ( true );
}
}
};
REGISTER_ACTION_HANDLER (CCanDropToHotbar, "can_drop_to_hotbar");
// **********************************************************************************************************
class CHotbarLeftClickOnSlotHandler : public IActionHandler
{
virtual void execute (CCtrlBase *pCaller, const string &/* Params */)
{
CDBCtrlSheet *sheet = dynamic_cast<CDBCtrlSheet *>(pCaller);
if (!sheet) return;
if (sheet->getSheetId() == 0)
{
// is there's no item that is not worn, can't choose any item)
bool isThereObjectNotWorn = false;
for(uint k = 0; k < MAX_BAGINV_ENTRIES; ++k)
{
uint32 sheetid = getInventory().getBagItem(k).getSheetID();
if (sheetid != 0)
{
if (!getInventory().isBagItemWeared(k))
{
CEntitySheet *pES = SheetMngr.get(CSheetId(sheetid));
if (pES && pES->type()== CEntitySheet::ITEM)
{
CItemSheet *pIS = (CItemSheet*)pES;
if (getInventory().isUsableItem(sheetid))
{
isThereObjectNotWorn = true;
break;
}
}
}
}
}
if (!isThereObjectNotWorn)
{
// every object are worn, so there's no use to display an empty list -> no-op
return;
}
}
CInterfaceManager *im = CInterfaceManager::getInstance();
CWidgetManager::getInstance()->pushModalWindow(pCaller, "ui:interface:hotbar_choose");
}
};
REGISTER_ACTION_HANDLER(CHotbarLeftClickOnSlotHandler, "hotbar_left_click_on_slot");
// ***************************************************************************
class CHandlerInvAutoEquip : public IActionHandler

@ -41,6 +41,7 @@ const uint MAX_TEMPINV_ENTRIES = INVENTORIES::NbTempInvSlots;
const uint MAX_BAGINV_ENTRIES = INVENTORIES::NbBagSlots;
const uint MAX_HANDINV_ENTRIES = 2;
const uint MAX_EQUIPINV_ENTRIES = 19;
const uint MAX_HOTBARINV_ENTRIES = INVENTORIES::NbHotbarSlots;
const uint MAX_ANIMALINV_ENTRIES = INVENTORIES::NbPackerSlots;
const uint MAX_GUILDINV_ENTRIES = INVENTORIES::NbGuildSlots;
const uint MAX_ROOMINV_ENTRIES = INVENTORIES::NbRoomSlots;
@ -193,10 +194,14 @@ public:
CItemImage *getHandItem(uint index);
// get equip item (local inventory)
CItemImage *getEquipItem(uint index);
// get hotbar item (local inventory)
CItemImage *getHotbarItem(uint index);
// get hand item (local inventory)
CDBCtrlSheet *getHandSheet(uint index);
// get equip item (local inventory)
CDBCtrlSheet *getEquipSheet(uint index);
// get hotbar item (local inventory)
CDBCtrlSheet *getHotbarSheet(uint index);
// get/set money
uint64 getMoney() const;
void setMoney(uint64 value);
@ -250,6 +255,8 @@ public:
bool isSword(uint32 sheetID);
// Check if an item is a forage tool
bool isForageToolItem(uint32 sheetID);
// Check if an item is usable
bool isUsableItem(uint32 sheetID);
// Get the Hand item sheet
uint32 getRightHandItemSheet() const { return getHandItemSheet(true); }
uint32 getLeftHandItemSheet() const { return getHandItemSheet(false); }
@ -333,9 +340,15 @@ private:
CItemImage TempInv[MAX_TEMPINV_ENTRIES];
sint32 Hands[MAX_HANDINV_ENTRIES];
CDBCtrlSheet *UIHands[MAX_HANDINV_ENTRIES];
CDBCtrlSheet *UIHands2[MAX_HANDINV_ENTRIES];
CDBCtrlSheet *UIHands3[MAX_HANDINV_ENTRIES];
sint32 Equip[MAX_EQUIPINV_ENTRIES];
CDBCtrlSheet *UIEquip[MAX_EQUIPINV_ENTRIES];
CDBCtrlSheet *UIEquip2[MAX_EQUIPINV_ENTRIES];
sint32 Hotbar[MAX_HOTBARINV_ENTRIES];
CDBCtrlSheet *UIHotbar[MAX_HOTBARINV_ENTRIES];
CDBCtrlSheet *UIHotbar2[MAX_HOTBARINV_ENTRIES];
CDBCtrlSheet *UIHotbar3[MAX_HOTBARINV_ENTRIES];
NLMISC::CCDBNodeLeaf *Money;
CItemImage PAInv[MAX_INVENTORY_ANIMAL][MAX_ANIMALINV_ENTRIES];
// SERVER INVENTORY
@ -343,6 +356,7 @@ private:
CItemImage ServerTempInv[MAX_TEMPINV_ENTRIES];
sint32 ServerHands[MAX_HANDINV_ENTRIES];
sint32 ServerEquip[MAX_EQUIPINV_ENTRIES];
sint32 ServerHotbar[MAX_EQUIPINV_ENTRIES];
NLMISC::CCDBNodeLeaf *ServerMoney;
CItemImage ServerPAInv[MAX_INVENTORY_ANIMAL][MAX_ANIMALINV_ENTRIES];
// Drag'n'Drop
@ -745,6 +759,25 @@ public:
};
};
// ***************************************************************************
/**
* Special list for filtering items which are usable
*/
class CDBGroupListSheetFilterHotbarSlot : public CDBGroupListSheet
{
public:
CDBGroupListSheetFilterHotbarSlot (const TCtorParam &param)
: CDBGroupListSheet(param)
{}
virtual CSheetChild *createSheetChild() { return new CSheetChildFilter; }
// A child node
struct CSheetChildFilter : public CDBGroupListSheet::CSheetChild
{
virtual bool isSheetValid(CDBGroupListSheet *pFather);
};
};
// ***************************************************************************
/**
@ -840,8 +873,6 @@ private:
#define CTRL_HAND_RIGHT "ui:interface:gestionsets:hands:handr"
#define CTRL_HAND_LEFT "ui:interface:gestionsets:hands:handl"
#define CTRL_HAND_LEFT_2HAND "ui:interface:gestionsets:hands:handl_2h"
#define CTRL_HAND_LEFT_AMMO "ui:interface:gestionsets:hands:handl_ammo"
#define CTRL_JEWEL_EARING_LEFT "ui:interface:inv_equip:content:equip:jewelry:earing_l"
#define CTRL_JEWEL_BRACELET_LEFT "ui:interface:inv_equip:content:equip:jewelry:bracelet_l"
@ -861,6 +892,15 @@ private:
#define CTRL_ARMOR_ARMS "ui:interface:inv_equip:content:equip:armors:arms"
#define CTRL_ARMOR_HANDS "ui:interface:inv_equip:content:equip:armors:hands"
#define CTRL_HOTBAR_1 "ui:interface:inv_equip:content:equip:hotbar_c:hotbar:hotbar1"
#define CTRL_HOTBAR_2 "ui:interface:inv_equip:content:equip:hotbar_c:hotbar:hotbar2"
#define CTRL_HOTBAR_3 "ui:interface:inv_equip:content:equip:hotbar_c:hotbar:hotbar3"
#define CTRL_HOTBAR_4 "ui:interface:inv_equip:content:equip:hotbar_c:hotbar:hotbar4"
#define CTRL_HOTBAR_5 "ui:interface:inv_equip:content:equip:hotbar_c:hotbar:hotbar5"
#define CTRL_HAND2_RIGHT "ui:interface:inv_equip:content:equip:hands:handr"
#define CTRL_HAND2_LEFT "ui:interface:inv_equip:content:equip:hands:handl"
#define CTRL_JEWL2_EARING_LEFT "ui:interface:inventory:content:equip:jewelry:earing_l"
#define CTRL_JEWL2_BRACELET_LEFT "ui:interface:inventory:content:equip:jewelry:bracelet_l"
#define CTRL_JEWL2_RING_LEFT "ui:interface:inventory:content:equip:jewelry:ring_l"
@ -879,6 +919,21 @@ private:
#define CTRL_ARMR2_ARMS "ui:interface:inventory:content:equip:armors:arms"
#define CTRL_ARMR2_HANDS "ui:interface:inventory:content:equip:armors:hands"
#define CTRL_HOTBAR2_1 "ui:interface:inventory:content:equip:hotbar_c:hotbar:hotbar1"
#define CTRL_HOTBAR2_2 "ui:interface:inventory:content:equip:hotbar_c:hotbar:hotbar2"
#define CTRL_HOTBAR2_3 "ui:interface:inventory:content:equip:hotbar_c:hotbar:hotbar3"
#define CTRL_HOTBAR2_4 "ui:interface:inventory:content:equip:hotbar_c:hotbar:hotbar4"
#define CTRL_HOTBAR2_5 "ui:interface:inventory:content:equip:hotbar_c:hotbar:hotbar5"
#define CTRL_HAND3_RIGHT "ui:interface:inventory:content:equip:hands:handr"
#define CTRL_HAND3_LEFT "ui:interface:inventory:content:equip:hands:handl"
#define CTRL_HOTBAR3_1 "ui:interface:inv_hotbar:content:hot:hotbar:hotbar1"
#define CTRL_HOTBAR3_2 "ui:interface:inv_hotbar:content:hot:hotbar:hotbar2"
#define CTRL_HOTBAR3_3 "ui:interface:inv_hotbar:content:hot:hotbar:hotbar3"
#define CTRL_HOTBAR3_4 "ui:interface:inv_hotbar:content:hot:hotbar:hotbar4"
#define CTRL_HOTBAR3_5 "ui:interface:inv_hotbar:content:hot:hotbar:hotbar5"
#endif // RY_INVENTORY_MANAGER_H
/* End of inventory_manager.h */

@ -46,14 +46,43 @@ CItemGroup::CItemGroup()
bool CItemGroup::contains(CDBCtrlSheet *other)
{
SLOT_EQUIPMENT::TSlotEquipment slot = SLOT_EQUIPMENT::UNDEFINED;
return contains(other, slot);
return contains(other, slot) || contains(other, -1);
}
// TODO: review redundancy of slot parameter
bool CItemGroup::contains(CDBCtrlSheet *other, SLOT_EQUIPMENT::TSlotEquipment &slot)
{
slot = SLOT_EQUIPMENT::UNDEFINED;
for(int i=0;i<Items.size();i++)
for(int i=0;i<EquipItems.size();i++)
{
CItem item = EquipItems[i];
if(item.useCreateTime() && item.createTime == other->getItemCreateTime() && item.serial == other->getItemSerial())
{
slot = item.slot;
return true;
}
// Present for compatibility reasons
NLMISC::CSheetId sheet = NLMISC::CSheetId(other->getSheetId());
if (sheet.toString() == item.sheetName && other->getQuality() == item.quality &&
other->getItemWeight() == item.weight && other->getItemColor() == item.color &&
(!item.usePrice || (other->getItemPrice() >= item.minPrice && other->getItemPrice() <= item.maxPrice))
)
{
CItem item = Items[i];
slot = item.slot;
return true;
}
}
return false;
}
// TODO: review redundancy of slot parameter
bool CItemGroup::contains(CDBCtrlSheet *other, uint16 &slot)
{
slot = -1;
for(int i=0;i<HotbarItems.size();i++)
{
CItem item = HotbarItems[i];
if(item.useCreateTime() && item.createTime == other->getItemCreateTime() && item.serial == other->getItemSerial())
{
slot = item.slot;
@ -79,19 +108,25 @@ void CItemGroup::addItem(sint32 createTime, sint32 serial, SLOT_EQUIPMENT::TSlot
//Don't add an item if it already exists, this could cause issue
// It's happening either if we are creating a group with a 2 hands items (and the item is found both in handR and handL)
// Or if an user incorrectly edit his group file
for(int i=0; i<Items.size(); i++)
for(int i=0; i<EquipItems.size(); i++)
{
if( Items[i].createTime == createTime && Items[i].serial == serial)
if( EquipItems[i].createTime == createTime && EquipItems[i].serial == serial)
{
nldebug("Not adding duplicate item, createTime: %d, serial: %d", createTime, serial);
//In this case, we are adding the duplicate item for a 2 hands item
//If it's saved as a left hand item, save it as a right hand item instead (so we have only 1 correct item)
if(Items[i].slot == SLOT_EQUIPMENT::HANDL && slot == SLOT_EQUIPMENT::HANDR)
Items[i].slot = SLOT_EQUIPMENT::HANDR;
if(EquipItems[i].slot == SLOT_EQUIPMENT::HANDL && slot == SLOT_EQUIPMENT::HANDR)
EquipItems[i].slot = SLOT_EQUIPMENT::HANDR;
return;
}
}
Items.push_back(CItem(createTime, serial, slot));
EquipItems.push_back(CEquipItem(createTime, serial, slot));
}
// used for hotbar
void CItemGroup::addItem(sint32 createTime, sint32 serial, uint16 slot)
{
HotbarItems.push_back(CHotbarItem(createTime, serial, slot));
}
void CItemGroup::addRemove(std::string slotName)
@ -106,13 +141,19 @@ void CItemGroup::addRemove(SLOT_EQUIPMENT::TSlotEquipment slot)
removeBeforeEquip.push_back(slot);
}
// used for hotbar
void CItemGroup::addRemove(uint16 slot)
{
removeHotbar.push_back(slot);
}
void CItemGroup::writeTo(xmlNodePtr node)
{
xmlNodePtr groupNode = xmlNewChild (node, NULL, (const xmlChar*)"group", NULL );
xmlSetProp(groupNode, (const xmlChar*)"name", (const xmlChar*)name.c_str());
for(int i=0;i<Items.size();i++)
for(int i=0;i<EquipItems.size();i++)
{
CItem item = Items[i];
CItem item = EquipItems[i];
xmlNodePtr itemNode = xmlNewChild(groupNode, NULL, (const xmlChar*)"item", NULL);
if(item.useCreateTime())
{
@ -133,11 +174,37 @@ void CItemGroup::writeTo(xmlNodePtr node)
//if(item.slot == SLOT_EQUIPMENT::HANDL || item.slot == SLOT_EQUIPMENT::HANDR)
xmlSetProp(itemNode, (const xmlChar*)"slot", (const xmlChar*)SLOT_EQUIPMENT::toString(item.slot).c_str());
}
for(int i=0;i<HotbarItems.size();i++)
{
CItem item = HotbarItems[i];
xmlNodePtr itemNode = xmlNewChild(groupNode, NULL, (const xmlChar*)"hotbar_item", NULL);
if(item.useCreateTime())
{
xmlSetProp (itemNode, (const xmlChar*)"createTime", (const xmlChar*)NLMISC::toString(item.createTime).c_str());
xmlSetProp (itemNode, (const xmlChar*)"serial", (const xmlChar*)NLMISC::toString(item.serial).c_str());
}
// Present for compatibility reasons
else
{
xmlSetProp (itemNode, (const xmlChar*)"sheetName", (const xmlChar*)item.sheetName.c_str());
xmlSetProp (itemNode, (const xmlChar*)"quality", (const xmlChar*)NLMISC::toString(item.quality).c_str());
xmlSetProp (itemNode, (const xmlChar*)"weight", (const xmlChar*)NLMISC::toString(item.weight).c_str());
xmlSetProp (itemNode, (const xmlChar*)"color", (const xmlChar*)NLMISC::toString(item.color).c_str());
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());
}
xmlSetProp(itemNode, (const xmlChar*)"slot", (const xmlChar*)NLMISC::toString(item.slot).c_str());
}
for(int i=0;i<removeBeforeEquip.size();i++)
{
xmlNodePtr removeNode = xmlNewChild(groupNode, NULL, (const xmlChar*)"remove", NULL);
xmlSetProp(removeNode, (const xmlChar*)"slot", (xmlChar*)SLOT_EQUIPMENT::toString(removeBeforeEquip[i]).c_str());
}
for(int i=0;i<removeHotbar.size();i++)
{
xmlNodePtr removeNode = xmlNewChild(groupNode, NULL, (const xmlChar*)"hotbar_remove", NULL);
xmlSetProp(removeNode, (const xmlChar*)"slot", (xmlChar*)NLMISC::toString(removeHotbar[i]).c_str());
}
}
@ -152,8 +219,7 @@ void CItemGroup::readFrom(xmlNodePtr node)
{
if (strcmp((char*)curNode->name, "item") == 0)
{
CItem item;
CEquipItem item;
ptrName = (char*) xmlGetProp(curNode, (xmlChar*)"createTime");
if (ptrName) NLMISC::fromString((const char*)ptrName, item.createTime);
ptrName = (char*) xmlGetProp(curNode, (xmlChar*)"serial");
@ -183,7 +249,40 @@ void CItemGroup::readFrom(xmlNodePtr node)
// Old load : keep for compatibility / migration reasons
else
{
Items.push_back(item);
EquipItems.push_back(item);
}
}
if (strcmp((char*)curNode->name, "hotbar_item") == 0)
{
CHotbarItem item;
ptrName = (char*) xmlGetProp(curNode, (xmlChar*)"createTime");
if (ptrName) NLMISC::fromString((const char*)ptrName, item.createTime);
ptrName = (char*) xmlGetProp(curNode, (xmlChar*)"serial");
if (ptrName) NLMISC::fromString((const char*)ptrName, item.serial);
ptrName = (char*) xmlGetProp(curNode, (xmlChar*)"slot");
if (ptrName) NLMISC::fromString((const char*)ptrName, item.slot);
// Old read, keep for compatibility reasons
ptrName = (char*) xmlGetProp(curNode, (xmlChar*)"sheetName");
if (ptrName) NLMISC::fromString((const char*)ptrName, item.sheetName);
ptrName = (char*) xmlGetProp(curNode, (xmlChar*)"quality");
if (ptrName) NLMISC::fromString((const char*)ptrName, item.quality);
ptrName = (char*) xmlGetProp(curNode, (xmlChar*)"weight");
if (ptrName) NLMISC::fromString((const char*)ptrName, item.weight);
ptrName = (char*) xmlGetProp(curNode, (xmlChar*)"color");
if (ptrName) NLMISC::fromString((const char*)ptrName, item.color);
ptrName = (char*) xmlGetProp(curNode, (xmlChar*)"minPrice");
if (ptrName) NLMISC::fromString((const char*)ptrName, item.minPrice);
ptrName = (char*) xmlGetProp(curNode, (xmlChar*)"maxPrice");
if (ptrName) NLMISC::fromString((const char*)ptrName, item.maxPrice);
item.usePrice = (item.minPrice != 0 || item.maxPrice != std::numeric_limits<uint32>::max());
if(item.createTime != 0)
{
addItem(item.createTime, item.serial, item.slot);
}
// Old load : keep for compatibility / migration reasons
else
{
HotbarItems.push_back(item);
}
}
if (strcmp((char*)curNode->name, "remove") == 0)
@ -193,6 +292,13 @@ void CItemGroup::readFrom(xmlNodePtr node)
if (ptrName) NLMISC::fromString((const char*)ptrName, slot);
addRemove(slot);
}
if (strcmp((char*)curNode->name, "hotbar_remove") == 0)
{
uint16 slot;
ptrName = (char*) xmlGetProp(curNode, (xmlChar*)"slot");
if (ptrName) NLMISC::fromString((const char*)ptrName, slot);
addRemove(slot);
}
curNode = curNode->next;
}
@ -381,7 +487,7 @@ bool CItemGroupManager::migrateGroups()
{
CItemGroup group = _Groups[i];
//Migrate the group only if there is items inside, and the first one hasn't been migrated
bool needMigration = group.Items.size() > 0 && !group.Items[0].useCreateTime();
bool needMigration = group.EquipItems.size() > 0 && !group.EquipItems[0].useCreateTime();
if(!needMigration)
{
newGroups.push_back(group);
@ -555,6 +661,13 @@ bool CItemGroupManager::equipGroup(std::string name, bool pullBefore)
dbPath = "LOCAL:INVENTORY:EQUIP:" + NLMISC::toString((uint32)slot);
CInventoryManager::getInstance()->unequip(dbPath);
}
// unequip hotbar
for(int i=0; i < group->removeHotbar.size(); i++)
{
uint16 slot = group->removeHotbar[i];
std::string dbPath = "LOCAL:INVENTORY:HOTBAR:" + NLMISC::toString(slot);
CInventoryManager::getInstance()->unequip(dbPath);
}
uint32 maxEquipTime = 0;
@ -669,6 +782,19 @@ bool CItemGroupManager::createGroup(std::string name, bool removeUnequiped)
group.addRemove(slot);
}
}
for (i = 0; i < MAX_HOTBARINV_ENTRIES; ++i)
{
pCS = CInventoryManager::getInstance()->getHotbarSheet(i);
if(!pCS) continue;
if(pCS->isSheetValid())
{
group.addItem(pCS->getItemCreateTime(), pCS->getItemSerial(), (uint16) i);
}
else if(removeUnequiped)
{
group.addRemove(i);
}
}
_Groups.push_back(group);
return true;
@ -701,7 +827,7 @@ void CItemGroupManager::listGroup()
//Use utf-8 string because group name can contain accentued characters (and stuff like that)
string nameUC = group.name;
NLMISC::strFindReplace(msg, "%name", nameUC);
NLMISC::strFindReplace(msg, "%size", NLMISC::toString(group.Items.size()));
NLMISC::strFindReplace(msg, "%size", NLMISC::toString(group.EquipItems.size() + group.HotbarItems.size()));
pIM->displaySystemInfo(msg);
}
}
@ -779,12 +905,22 @@ bool CItemGroupManager::isItemReallyEquipped(CDBCtrlSheet* item)
{
return true;
}
}
for (uint32 i = 0; i < MAX_HOTBARINV_ENTRIES; ++i)
{
pCS = CInventoryManager::getInstance()->getHotbarSheet(i);
if(!pCS) continue;
if((pCS->getInventoryIndex() == item->getInventoryIndex())
&& (pCS->getIndexInDB() == item->getIndexInDB()))
{
return true;
}
}
return false;
}
// TODO: review this function
std::vector<CInventoryItem> CItemGroupManager::matchingItems(CItemGroup *group, INVENTORIES::TInventory inventory)
{
//Not very clean, but no choice, it's ugly time

@ -37,7 +37,6 @@ public:
class CItemGroup {
public:
struct CItem {
SLOT_EQUIPMENT::TSlotEquipment slot; // Used only for dagger (right/left hand slot)
sint32 createTime;
sint32 serial;
// Old variables, present for compatibility reasons
@ -48,32 +47,53 @@ public:
uint32 minPrice;
uint32 maxPrice;
bool usePrice;
CItem(sint32 createTime, sint32 serial, SLOT_EQUIPMENT::TSlotEquipment slot = SLOT_EQUIPMENT::UNDEFINED) :
CItem(sint32 createTime, sint32 serial) :
createTime(createTime), serial(serial), slot(slot) {}
//Old constructor, present for compatibility reasons
CItem(std::string sheetName = "", uint16 quality = 0, uint32 weight = 0, uint8 color = 0, sint32 createTime = 0, sint32 serial = 0, SLOT_EQUIPMENT::TSlotEquipment slot = SLOT_EQUIPMENT::UNDEFINED, uint32 minPrice = 0, uint32 maxPrice = std::numeric_limits<uint32>::max(), bool usePrice = false) :
CItem(std::string sheetName = "", uint16 quality = 0, uint32 weight = 0, uint8 color = 0, sint32 createTime = 0, sint32 serial = 0, uint32 minPrice = 0, uint32 maxPrice = std::numeric_limits<uint32>::max(), bool usePrice = false) :
sheetName(sheetName), quality(quality), weight(weight), color(color), createTime(createTime), serial(serial), slot(slot), minPrice(minPrice), maxPrice(maxPrice), usePrice(usePrice) {}
//present for compatibility reasons
bool useCreateTime() const { return createTime != 0 && serial != 0;}
};
struct CEquipItem : CItem {
SLOT_EQUIPMENT::TSlotEquipment slot; // Used only for dagger (right/left hand slot)
CEquipItem(sint32 createTime, sint32 serial, SLOT_EQUIPMENT::TSlotEquipment slot = SLOT_EQUIPMENT::UNDEFINED) :
CItem(createTime, serial), slot(slot) {}
CEquipItem(std::string sheetName = "", uint16 quality = 0, uint32 weight = 0, uint8 color = 0, sint32 createTime = 0, sint32 serial = 0, SLOT_EQUIPMENT::TSlotEquipment slot = SLOT_EQUIPMENT::UNDEFINED, uint32 minPrice = 0, uint32 maxPrice = std::numeric_limits<uint32>::max(), bool usePrice = false) :
CItem(sheetName, quality, weight, color, createTime, slot, minPrice, maxPrice, usePrice), slot(slot) {}
};
struct CHotbarItem : CItem {
SLOT_EQUIPMENT::TSlotEquipment slot; // Used only for dagger (right/left hand slot)
CHotbarItem(sint32 createTime, sint32 serial, uint16 slot) :
CItem(createTime, serial), slot(slot) {}
CHotbarItem(std::string sheetName = "", uint16 quality = 0, uint32 weight = 0, uint8 color = 0, sint32 createTime = 0, sint32 serial = 0, uint16 slot, uint32 minPrice = 0, uint32 maxPrice = std::numeric_limits<uint32>::max(), bool usePrice = false) :
CItem(sheetName, quality, weight, color, createTime, slot, minPrice, maxPrice, usePrice), slot(slot) {}
};
public:
CItemGroup();
// return true if any item in the group match the parameter ; slot is UNDEFINED unless the item has been found in the group
bool contains(CDBCtrlSheet *other);
bool contains(CDBCtrlSheet* other, SLOT_EQUIPMENT::TSlotEquipment &slot);
bool contains(CDBCtrlSheet* other, uint16 &slot);
void addItem(sint32 createTime, sint32 serial, SLOT_EQUIPMENT::TSlotEquipment slot);
void addItem(sint32 createTime, sint32 serial, uint16 slot);
void addRemove(std::string slotName);
void addRemove(SLOT_EQUIPMENT::TSlotEquipment slot);
void addRemove(uint16 slot);
void writeTo(xmlNodePtr node);
void readFrom(xmlNodePtr node);
// return true if no item inside
bool empty() const { return Items.size() == 0;}
bool empty() const { return EquipItems.size() == 0 && HotbarItems.size() == 0;}
std::string name;
std::vector<CItem> Items;
std::vector<CEquipItem> EquipItems;
std::vector<CHotbarItem> HotbarItems;
std::vector<SLOT_EQUIPMENT::TSlotEquipment> removeBeforeEquip;
std::vector<uint16> removeHotbar;
};
class CItemGroupManager {

@ -33,6 +33,7 @@ namespace INVENTORIES
NL_STRING_CONVERSION_TABLE_ENTRY(handling)
NL_STRING_CONVERSION_TABLE_ENTRY(temporary)
NL_STRING_CONVERSION_TABLE_ENTRY(equipment)
NL_STRING_CONVERSION_TABLE_ENTRY(hotbar)
NL_STRING_CONVERSION_TABLE_ENTRY(bag)
NL_STRING_CONVERSION_TABLE_ENTRY(pet_animal1)
NL_STRING_CONVERSION_TABLE_ENTRY(pet_animal2)
@ -94,6 +95,7 @@ namespace INVENTORIES
"TEMP", // temporary
// "", // pick-up
"EQUIP", // equipment
"HOTBAR", // hotbar
"", // bag
"", // pack_animal1
"", // pack_animal2

@ -158,8 +158,9 @@ namespace INVENTORIES
handling = 0,
temporary, // 1
equipment, // 2
bag, // 3
pet_animal, // 4 Character can have 7 pack animal
hotbar, // 3
bag, // 4
pet_animal, // 5 Character can have 7 pack animal
pet_animal1 = pet_animal, // for toString => TInventory convertion
pet_animal2,
pet_animal3,
@ -167,17 +168,17 @@ namespace INVENTORIES
pet_animal5,
pet_animal6,
pet_animal7,
max_pet_animal, // 11
NUM_INVENTORY = max_pet_animal, // 11
UNDEFINED = NUM_INVENTORY, // 11
max_pet_animal, // 12
NUM_INVENTORY = max_pet_animal, // 12
UNDEFINED = NUM_INVENTORY, // 12
exchange, // 12 This is not a bug : exchange is a fake inventory
exchange_proposition, // 13 and should not count in the number of inventory
exchange, // 13 This is not a bug : exchange is a fake inventory
exchange_proposition, // 14 and should not count in the number of inventory
// same for botChat trading.
trading, // 14
reward_sharing, // 15 fake inventory, not in database.xml. Used by the item info protocol only
guild, // 16 (warning: number stored in guild saved file)
player_room, // 17
trading, // 15
reward_sharing, // 16 fake inventory, not in database.xml. Used by the item info protocol only
guild, // 17 (warning: number stored in guild saved file)
player_room, // 18
NUM_ALL_INVENTORY // warning: distinct from NUM_INVENTORY
};
@ -262,6 +263,7 @@ namespace INVENTORIES
const uint NbRoomSlots = 1000;
const uint NbGuildSlots = 1000;
const uint NbTempInvSlots = 16;
const uint NbHotbarSlots = 5;
enum TItemPropId
{

@ -124,6 +124,16 @@ namespace ITEMFAMILY
}
bool isUsable( EItemFamily fam )
{
return
fam == ITEM_SAP_RECHARGE ||
fam == CRYSTALLIZED_SPELL ||
fam == CONSUMABLE ||
fam == XP_CATALYSER;
}
/**
* returns true if items of this family are destroyed when they are completely worned out
*/

@ -95,6 +95,8 @@ namespace ITEMFAMILY
bool isResellable( EItemFamily fam );
/// return true if this family of item can display a custom text
bool isTextCustomizable( EItemFamily fam );
/// return true if this family of item can use item (consume, execute, open, etc)
bool isUsable( EItemFamily fam );
/// is craftable
}; // ITEMFAMILY

Loading…
Cancel
Save