diff --git a/changelog.txt b/changelog.txt index 5806a984f..1ac1ec731 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,7 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) == 10/17/2016 == Uleat: Moved namespace ItemField from item_instance.h to shareddb.cpp - the only place it is used Uleat: Separated class Inventory from item_instance files into inventory_profile files +Uleat: Renamed class Inventory to EQEmu::InventoryProfile == 10/16/2016 == Uleat: Renamed struct EQEmu::ItemBase to EQEmu::ItemData and class ItemInst to EQEmu::ItemInstance diff --git a/common/database.cpp b/common/database.cpp index 743bec9f2..66ac8495b 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -672,7 +672,7 @@ bool Database::SaveCharacterCreate(uint32 character_id, uint32 account_id, Playe } /* This only for new Character creation storing */ -bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inventory* inv) { +bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, EQEmu::InventoryProfile* inv) { uint32 charid = 0; char zone[50]; float x, y, z; diff --git a/common/database.h b/common/database.h index 69ad0c576..6f3fd0642 100644 --- a/common/database.h +++ b/common/database.h @@ -37,10 +37,14 @@ //atoi is not uint32 or uint32 safe!!!! #define atoul(str) strtoul(str, nullptr, 10) -class Inventory; class MySQLRequestResult; class Client; +namespace EQEmu +{ + class InventoryProfile; +} + struct EventLogDetails_Struct { uint32 id; char accountname[64]; @@ -109,7 +113,7 @@ public: bool SaveCharacterCreate(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp); bool SetHackerFlag(const char* accountname, const char* charactername, const char* hacked); bool SetMQDetectionFlag(const char* accountname, const char* charactername, const char* hacked, const char* zone); - bool StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inventory* inv); + bool StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, EQEmu::InventoryProfile* inv); bool UpdateName(const char* oldname, const char* newname); /* General Information Queries */ diff --git a/common/inventory_profile.cpp b/common/inventory_profile.cpp index 9e4c4fc94..c952392b1 100644 --- a/common/inventory_profile.cpp +++ b/common/inventory_profile.cpp @@ -89,9 +89,9 @@ EQEmu::ItemInstance* ItemInstQueue::peek_front() const // -// class Inventory +// class EQEmu::InventoryProfile // -Inventory::~Inventory() +EQEmu::InventoryProfile::~InventoryProfile() { for (auto iter = m_worn.begin(); iter != m_worn.end(); ++iter) { safe_delete(iter->second); @@ -119,7 +119,7 @@ Inventory::~Inventory() m_trade.clear(); } -void Inventory::CleanDirty() { +void EQEmu::InventoryProfile::CleanDirty() { auto iter = dirty_inst.begin(); while (iter != dirty_inst.end()) { delete (*iter); @@ -128,79 +128,79 @@ void Inventory::CleanDirty() { dirty_inst.clear(); } -void Inventory::MarkDirty(EQEmu::ItemInstance *inst) { +void EQEmu::InventoryProfile::MarkDirty(ItemInstance *inst) { if (inst) { dirty_inst.push_back(inst); } } // Retrieve item at specified slot; returns false if item not found -EQEmu::ItemInstance* Inventory::GetItem(int16 slot_id) const +EQEmu::ItemInstance* EQEmu::InventoryProfile::GetItem(int16 slot_id) const { - EQEmu::ItemInstance* result = nullptr; + ItemInstance* result = nullptr; // Cursor - if (slot_id == EQEmu::inventory::slotCursor) { + if (slot_id == inventory::slotCursor) { // Cursor slot result = m_cursor.peek_front(); } // Non bag slots - else if (slot_id >= EQEmu::legacy::TRADE_BEGIN && slot_id <= EQEmu::legacy::TRADE_END) { + else if (slot_id >= legacy::TRADE_BEGIN && slot_id <= legacy::TRADE_END) { result = _GetItem(m_trade, slot_id); } - else if (slot_id >= EQEmu::legacy::SHARED_BANK_BEGIN && slot_id <= EQEmu::legacy::SHARED_BANK_END) { + else if (slot_id >= legacy::SHARED_BANK_BEGIN && slot_id <= legacy::SHARED_BANK_END) { // Shared Bank slots result = _GetItem(m_shbank, slot_id); } - else if (slot_id >= EQEmu::legacy::BANK_BEGIN && slot_id <= EQEmu::legacy::BANK_END) { + else if (slot_id >= legacy::BANK_BEGIN && slot_id <= legacy::BANK_END) { // Bank slots result = _GetItem(m_bank, slot_id); } - else if ((slot_id >= EQEmu::legacy::GENERAL_BEGIN && slot_id <= EQEmu::legacy::GENERAL_END)) { + else if ((slot_id >= legacy::GENERAL_BEGIN && slot_id <= legacy::GENERAL_END)) { // Personal inventory slots result = _GetItem(m_inv, slot_id); } - else if ((slot_id >= EQEmu::legacy::EQUIPMENT_BEGIN && slot_id <= EQEmu::legacy::EQUIPMENT_END) || - (slot_id >= EQEmu::legacy::TRIBUTE_BEGIN && slot_id <= EQEmu::legacy::TRIBUTE_END) || (slot_id == EQEmu::inventory::slotPowerSource)) { + else if ((slot_id >= legacy::EQUIPMENT_BEGIN && slot_id <= legacy::EQUIPMENT_END) || + (slot_id >= legacy::TRIBUTE_BEGIN && slot_id <= legacy::TRIBUTE_END) || (slot_id == inventory::slotPowerSource)) { // Equippable slots (on body) result = _GetItem(m_worn, slot_id); } // Inner bag slots - else if (slot_id >= EQEmu::legacy::TRADE_BAGS_BEGIN && slot_id <= EQEmu::legacy::TRADE_BAGS_END) { + else if (slot_id >= legacy::TRADE_BAGS_BEGIN && slot_id <= legacy::TRADE_BAGS_END) { // Trade bag slots - EQEmu::ItemInstance* inst = _GetItem(m_trade, Inventory::CalcSlotId(slot_id)); + ItemInstance* inst = _GetItem(m_trade, InventoryProfile::CalcSlotId(slot_id)); if (inst && inst->IsClassBag()) { - result = inst->GetItem(Inventory::CalcBagIdx(slot_id)); + result = inst->GetItem(InventoryProfile::CalcBagIdx(slot_id)); } } - else if (slot_id >= EQEmu::legacy::SHARED_BANK_BAGS_BEGIN && slot_id <= EQEmu::legacy::SHARED_BANK_BAGS_END) { + else if (slot_id >= legacy::SHARED_BANK_BAGS_BEGIN && slot_id <= legacy::SHARED_BANK_BAGS_END) { // Shared Bank bag slots - EQEmu::ItemInstance* inst = _GetItem(m_shbank, Inventory::CalcSlotId(slot_id)); + ItemInstance* inst = _GetItem(m_shbank, InventoryProfile::CalcSlotId(slot_id)); if (inst && inst->IsClassBag()) { - result = inst->GetItem(Inventory::CalcBagIdx(slot_id)); + result = inst->GetItem(InventoryProfile::CalcBagIdx(slot_id)); } } - else if (slot_id >= EQEmu::legacy::BANK_BAGS_BEGIN && slot_id <= EQEmu::legacy::BANK_BAGS_END) { + else if (slot_id >= legacy::BANK_BAGS_BEGIN && slot_id <= legacy::BANK_BAGS_END) { // Bank bag slots - EQEmu::ItemInstance* inst = _GetItem(m_bank, Inventory::CalcSlotId(slot_id)); + ItemInstance* inst = _GetItem(m_bank, InventoryProfile::CalcSlotId(slot_id)); if (inst && inst->IsClassBag()) { - result = inst->GetItem(Inventory::CalcBagIdx(slot_id)); + result = inst->GetItem(InventoryProfile::CalcBagIdx(slot_id)); } } - else if (slot_id >= EQEmu::legacy::CURSOR_BAG_BEGIN && slot_id <= EQEmu::legacy::CURSOR_BAG_END) { + else if (slot_id >= legacy::CURSOR_BAG_BEGIN && slot_id <= legacy::CURSOR_BAG_END) { // Cursor bag slots - EQEmu::ItemInstance* inst = m_cursor.peek_front(); + ItemInstance* inst = m_cursor.peek_front(); if (inst && inst->IsClassBag()) { - result = inst->GetItem(Inventory::CalcBagIdx(slot_id)); + result = inst->GetItem(InventoryProfile::CalcBagIdx(slot_id)); } } - else if (slot_id >= EQEmu::legacy::GENERAL_BAGS_BEGIN && slot_id <= EQEmu::legacy::GENERAL_BAGS_END) { + else if (slot_id >= legacy::GENERAL_BAGS_BEGIN && slot_id <= legacy::GENERAL_BAGS_END) { // Personal inventory bag slots - EQEmu::ItemInstance* inst = _GetItem(m_inv, Inventory::CalcSlotId(slot_id)); + ItemInstance* inst = _GetItem(m_inv, InventoryProfile::CalcSlotId(slot_id)); if (inst && inst->IsClassBag()) { - result = inst->GetItem(Inventory::CalcBagIdx(slot_id)); + result = inst->GetItem(InventoryProfile::CalcBagIdx(slot_id)); } } @@ -208,13 +208,13 @@ EQEmu::ItemInstance* Inventory::GetItem(int16 slot_id) const } // Retrieve item at specified position within bag -EQEmu::ItemInstance* Inventory::GetItem(int16 slot_id, uint8 bagidx) const +EQEmu::ItemInstance* EQEmu::InventoryProfile::GetItem(int16 slot_id, uint8 bagidx) const { - return GetItem(Inventory::CalcSlotId(slot_id, bagidx)); + return GetItem(InventoryProfile::CalcSlotId(slot_id, bagidx)); } // Put an item snto specified slot -int16 Inventory::PutItem(int16 slot_id, const EQEmu::ItemInstance& inst) +int16 EQEmu::InventoryProfile::PutItem(int16 slot_id, const ItemInstance& inst) { // Clean up item already in slot (if exists) DeleteItem(slot_id); @@ -229,23 +229,23 @@ int16 Inventory::PutItem(int16 slot_id, const EQEmu::ItemInstance& inst) return _PutItem(slot_id, inst.Clone()); } -int16 Inventory::PushCursor(const EQEmu::ItemInstance& inst) +int16 EQEmu::InventoryProfile::PushCursor(const ItemInstance& inst) { m_cursor.push(inst.Clone()); - return EQEmu::inventory::slotCursor; + return inventory::slotCursor; } -EQEmu::ItemInstance* Inventory::GetCursorItem() +EQEmu::ItemInstance* EQEmu::InventoryProfile::GetCursorItem() { return m_cursor.peek_front(); } // Swap items in inventory -bool Inventory::SwapItem(int16 slot_a, int16 slot_b) +bool EQEmu::InventoryProfile::SwapItem(int16 slot_a, int16 slot_b) { // Temp holding areas for a and b - EQEmu::ItemInstance* inst_a = GetItem(slot_a); - EQEmu::ItemInstance* inst_b = GetItem(slot_b); + ItemInstance* inst_a = GetItem(slot_a); + ItemInstance* inst_b = GetItem(slot_b); if (inst_a) { if (!inst_a->IsSlotAllowed(slot_b)) { return false; } } if (inst_b) { if (!inst_b->IsSlotAllowed(slot_a)) { return false; } } @@ -257,10 +257,10 @@ bool Inventory::SwapItem(int16 slot_a, int16 slot_b) } // Remove item from inventory (with memory delete) -bool Inventory::DeleteItem(int16 slot_id, uint8 quantity) +bool EQEmu::InventoryProfile::DeleteItem(int16 slot_id, uint8 quantity) { // Pop item out of inventory map (or queue) - EQEmu::ItemInstance* item_to_delete = PopItem(slot_id); + ItemInstance* item_to_delete = PopItem(slot_id); // Determine if object should be fully deleted, or // just a quantity of charges of the item can be deleted @@ -277,7 +277,7 @@ bool Inventory::DeleteItem(int16 slot_id, uint8 quantity) ((item_to_delete->GetItem()->MaxCharges == 0) || item_to_delete->IsExpendable())) ) { // Item can now be destroyed - Inventory::MarkDirty(item_to_delete); + InventoryProfile::MarkDirty(item_to_delete); return true; } } @@ -287,19 +287,19 @@ bool Inventory::DeleteItem(int16 slot_id, uint8 quantity) return false; } - Inventory::MarkDirty(item_to_delete); + InventoryProfile::MarkDirty(item_to_delete); return true; } // Checks All items in a bag for No Drop -bool Inventory::CheckNoDrop(int16 slot_id) { - EQEmu::ItemInstance* inst = GetItem(slot_id); +bool EQEmu::InventoryProfile::CheckNoDrop(int16 slot_id) { + ItemInstance* inst = GetItem(slot_id); if (!inst) return false; if (!inst->GetItem()->NoDrop) return true; if (inst->GetItem()->ItemClass == 1) { - for (uint8 i = EQEmu::inventory::containerBegin; i < EQEmu::inventory::ContainerCount; i++) { - EQEmu::ItemInstance* bagitem = GetItem(Inventory::CalcSlotId(slot_id, i)); + for (uint8 i = inventory::containerBegin; i < inventory::ContainerCount; i++) { + ItemInstance* bagitem = GetItem(InventoryProfile::CalcSlotId(slot_id, i)); if (bagitem && !bagitem->GetItem()->NoDrop) return true; } @@ -309,42 +309,42 @@ bool Inventory::CheckNoDrop(int16 slot_id) { // Remove item from bucket without memory delete // Returns item pointer if full delete was successful -EQEmu::ItemInstance* Inventory::PopItem(int16 slot_id) +EQEmu::ItemInstance* EQEmu::InventoryProfile::PopItem(int16 slot_id) { - EQEmu::ItemInstance* p = nullptr; + ItemInstance* p = nullptr; - if (slot_id == EQEmu::inventory::slotCursor) { + if (slot_id == inventory::slotCursor) { p = m_cursor.pop(); } - else if ((slot_id >= EQEmu::legacy::EQUIPMENT_BEGIN && slot_id <= EQEmu::legacy::EQUIPMENT_END) || (slot_id == EQEmu::inventory::slotPowerSource)) { + else if ((slot_id >= legacy::EQUIPMENT_BEGIN && slot_id <= legacy::EQUIPMENT_END) || (slot_id == inventory::slotPowerSource)) { p = m_worn[slot_id]; m_worn.erase(slot_id); } - else if ((slot_id >= EQEmu::legacy::GENERAL_BEGIN && slot_id <= EQEmu::legacy::GENERAL_END)) { + else if ((slot_id >= legacy::GENERAL_BEGIN && slot_id <= legacy::GENERAL_END)) { p = m_inv[slot_id]; m_inv.erase(slot_id); } - else if (slot_id >= EQEmu::legacy::TRIBUTE_BEGIN && slot_id <= EQEmu::legacy::TRIBUTE_END) { + else if (slot_id >= legacy::TRIBUTE_BEGIN && slot_id <= legacy::TRIBUTE_END) { p = m_worn[slot_id]; m_worn.erase(slot_id); } - else if (slot_id >= EQEmu::legacy::BANK_BEGIN && slot_id <= EQEmu::legacy::BANK_END) { + else if (slot_id >= legacy::BANK_BEGIN && slot_id <= legacy::BANK_END) { p = m_bank[slot_id]; m_bank.erase(slot_id); } - else if (slot_id >= EQEmu::legacy::SHARED_BANK_BEGIN && slot_id <= EQEmu::legacy::SHARED_BANK_END) { + else if (slot_id >= legacy::SHARED_BANK_BEGIN && slot_id <= legacy::SHARED_BANK_END) { p = m_shbank[slot_id]; m_shbank.erase(slot_id); } - else if (slot_id >= EQEmu::legacy::TRADE_BEGIN && slot_id <= EQEmu::legacy::TRADE_END) { + else if (slot_id >= legacy::TRADE_BEGIN && slot_id <= legacy::TRADE_END) { p = m_trade[slot_id]; m_trade.erase(slot_id); } else { // Is slot inside bag? - EQEmu::ItemInstance* baginst = GetItem(Inventory::CalcSlotId(slot_id)); + ItemInstance* baginst = GetItem(InventoryProfile::CalcSlotId(slot_id)); if (baginst != nullptr && baginst->IsClassBag()) { - p = baginst->PopItem(Inventory::CalcBagIdx(slot_id)); + p = baginst->PopItem(InventoryProfile::CalcBagIdx(slot_id)); } } @@ -352,13 +352,13 @@ EQEmu::ItemInstance* Inventory::PopItem(int16 slot_id) return p; } -bool Inventory::HasSpaceForItem(const EQEmu::ItemData *ItemToTry, int16 Quantity) { +bool EQEmu::InventoryProfile::HasSpaceForItem(const ItemData *ItemToTry, int16 Quantity) { if (ItemToTry->Stackable) { - for (int16 i = EQEmu::legacy::GENERAL_BEGIN; i <= EQEmu::legacy::GENERAL_END; i++) { + for (int16 i = legacy::GENERAL_BEGIN; i <= legacy::GENERAL_END; i++) { - EQEmu::ItemInstance* InvItem = GetItem(i); + ItemInstance* InvItem = GetItem(i); if (InvItem && (InvItem->GetItem()->ID == ItemToTry->ID) && (InvItem->GetCharges() < InvItem->GetItem()->StackSize)) { @@ -372,9 +372,9 @@ bool Inventory::HasSpaceForItem(const EQEmu::ItemData *ItemToTry, int16 Quantity } if (InvItem && InvItem->IsClassBag()) { - int16 BaseSlotID = Inventory::CalcSlotId(i, EQEmu::inventory::containerBegin); + int16 BaseSlotID = InventoryProfile::CalcSlotId(i, inventory::containerBegin); uint8 BagSize = InvItem->GetItem()->BagSlots; - for (uint8 BagSlot = EQEmu::inventory::containerBegin; BagSlot < BagSize; BagSlot++) { + for (uint8 BagSlot = inventory::containerBegin; BagSlot < BagSize; BagSlot++) { InvItem = GetItem(BaseSlotID + BagSlot); @@ -393,9 +393,9 @@ bool Inventory::HasSpaceForItem(const EQEmu::ItemData *ItemToTry, int16 Quantity } } - for (int16 i = EQEmu::legacy::GENERAL_BEGIN; i <= EQEmu::legacy::GENERAL_END; i++) { + for (int16 i = legacy::GENERAL_BEGIN; i <= legacy::GENERAL_END; i++) { - EQEmu::ItemInstance* InvItem = GetItem(i); + ItemInstance* InvItem = GetItem(i); if (!InvItem) { @@ -416,11 +416,11 @@ bool Inventory::HasSpaceForItem(const EQEmu::ItemData *ItemToTry, int16 Quantity } else if (InvItem->IsClassBag() && CanItemFitInContainer(ItemToTry, InvItem->GetItem())) { - int16 BaseSlotID = Inventory::CalcSlotId(i, EQEmu::inventory::containerBegin); + int16 BaseSlotID = InventoryProfile::CalcSlotId(i, inventory::containerBegin); uint8 BagSize = InvItem->GetItem()->BagSlots; - for (uint8 BagSlot = EQEmu::inventory::containerBegin; BagSlotIsClassBag() && inst->GetItem()->BagSize >= min_size) { - if (inst->GetItem()->BagType == EQEmu::item::BagTypeQuiver && inst->GetItem()->ItemType != EQEmu::item::ItemTypeArrow) + if (inst->GetItem()->BagType == item::BagTypeQuiver && inst->GetItem()->ItemType != item::ItemTypeArrow) { continue; } - int16 base_slot_id = Inventory::CalcSlotId(i, EQEmu::inventory::containerBegin); + int16 base_slot_id = InventoryProfile::CalcSlotId(i, inventory::containerBegin); uint8 slots = inst->GetItem()->BagSlots; uint8 j; - for (j = EQEmu::inventory::containerBegin; jIsClassBag()) { - for (int16 free_slot = EQEmu::legacy::GENERAL_BEGIN; free_slot <= EQEmu::legacy::GENERAL_END; ++free_slot) { + for (int16 free_slot = legacy::GENERAL_BEGIN; free_slot <= legacy::GENERAL_END; ++free_slot) { if (!m_inv[free_slot]) return free_slot; } - return EQEmu::inventory::slotCursor; // return cursor since bags do not stack and will not fit inside other bags..yet...) + return inventory::slotCursor; // return cursor since bags do not stack and will not fit inside other bags..yet...) } // step 2: find partial room for stackables if (inst->IsStackable()) { - for (int16 free_slot = EQEmu::legacy::GENERAL_BEGIN; free_slot <= EQEmu::legacy::GENERAL_END; ++free_slot) { - const EQEmu::ItemInstance* main_inst = m_inv[free_slot]; + for (int16 free_slot = legacy::GENERAL_BEGIN; free_slot <= legacy::GENERAL_END; ++free_slot) { + const ItemInstance* main_inst = m_inv[free_slot]; if (!main_inst) continue; @@ -671,84 +671,84 @@ int16 Inventory::FindFreeSlotForTradeItem(const EQEmu::ItemInstance* inst) { return free_slot; } - for (int16 free_slot = EQEmu::legacy::GENERAL_BEGIN; free_slot <= EQEmu::legacy::GENERAL_END; ++free_slot) { - const EQEmu::ItemInstance* main_inst = m_inv[free_slot]; + for (int16 free_slot = legacy::GENERAL_BEGIN; free_slot <= legacy::GENERAL_END; ++free_slot) { + const ItemInstance* main_inst = m_inv[free_slot]; if (!main_inst) continue; if (main_inst->IsClassBag()) { // if item-specific containers already have bad items, we won't fix it here... - for (uint8 free_bag_slot = EQEmu::inventory::containerBegin; (free_bag_slot < main_inst->GetItem()->BagSlots) && (free_bag_slot < EQEmu::inventory::ContainerCount); ++free_bag_slot) { - const EQEmu::ItemInstance* sub_inst = main_inst->GetItem(free_bag_slot); + for (uint8 free_bag_slot = inventory::containerBegin; (free_bag_slot < main_inst->GetItem()->BagSlots) && (free_bag_slot < inventory::ContainerCount); ++free_bag_slot) { + const ItemInstance* sub_inst = main_inst->GetItem(free_bag_slot); if (!sub_inst) continue; if ((sub_inst->GetID() == inst->GetID()) && (sub_inst->GetCharges() < sub_inst->GetItem()->StackSize)) - return Inventory::CalcSlotId(free_slot, free_bag_slot); + return InventoryProfile::CalcSlotId(free_slot, free_bag_slot); } } } } // step 3a: find room for container-specific items (ItemClassArrow) - if (inst->GetItem()->ItemType == EQEmu::item::ItemTypeArrow) { - for (int16 free_slot = EQEmu::legacy::GENERAL_BEGIN; free_slot <= EQEmu::legacy::GENERAL_END; ++free_slot) { - const EQEmu::ItemInstance* main_inst = m_inv[free_slot]; + if (inst->GetItem()->ItemType == item::ItemTypeArrow) { + for (int16 free_slot = legacy::GENERAL_BEGIN; free_slot <= legacy::GENERAL_END; ++free_slot) { + const ItemInstance* main_inst = m_inv[free_slot]; - if (!main_inst || (main_inst->GetItem()->BagType != EQEmu::item::BagTypeQuiver) || !main_inst->IsClassBag()) + if (!main_inst || (main_inst->GetItem()->BagType != item::BagTypeQuiver) || !main_inst->IsClassBag()) continue; - for (uint8 free_bag_slot = EQEmu::inventory::containerBegin; (free_bag_slot < main_inst->GetItem()->BagSlots) && (free_bag_slot < EQEmu::inventory::ContainerCount); ++free_bag_slot) { + for (uint8 free_bag_slot = inventory::containerBegin; (free_bag_slot < main_inst->GetItem()->BagSlots) && (free_bag_slot < inventory::ContainerCount); ++free_bag_slot) { if (!main_inst->GetItem(free_bag_slot)) - return Inventory::CalcSlotId(free_slot, free_bag_slot); + return InventoryProfile::CalcSlotId(free_slot, free_bag_slot); } } } // step 3b: find room for container-specific items (ItemClassSmallThrowing) - if (inst->GetItem()->ItemType == EQEmu::item::ItemTypeSmallThrowing) { - for (int16 free_slot = EQEmu::legacy::GENERAL_BEGIN; free_slot <= EQEmu::legacy::GENERAL_END; ++free_slot) { - const EQEmu::ItemInstance* main_inst = m_inv[free_slot]; + if (inst->GetItem()->ItemType == item::ItemTypeSmallThrowing) { + for (int16 free_slot = legacy::GENERAL_BEGIN; free_slot <= legacy::GENERAL_END; ++free_slot) { + const ItemInstance* main_inst = m_inv[free_slot]; - if (!main_inst || (main_inst->GetItem()->BagType != EQEmu::item::BagTypeBandolier) || !main_inst->IsClassBag()) + if (!main_inst || (main_inst->GetItem()->BagType != item::BagTypeBandolier) || !main_inst->IsClassBag()) continue; - for (uint8 free_bag_slot = EQEmu::inventory::containerBegin; (free_bag_slot < main_inst->GetItem()->BagSlots) && (free_bag_slot < EQEmu::inventory::ContainerCount); ++free_bag_slot) { + for (uint8 free_bag_slot = inventory::containerBegin; (free_bag_slot < main_inst->GetItem()->BagSlots) && (free_bag_slot < inventory::ContainerCount); ++free_bag_slot) { if (!main_inst->GetItem(free_bag_slot)) - return Inventory::CalcSlotId(free_slot, free_bag_slot); + return InventoryProfile::CalcSlotId(free_slot, free_bag_slot); } } } // step 4: just find an empty slot - for (int16 free_slot = EQEmu::legacy::GENERAL_BEGIN; free_slot <= EQEmu::legacy::GENERAL_END; ++free_slot) { - const EQEmu::ItemInstance* main_inst = m_inv[free_slot]; + for (int16 free_slot = legacy::GENERAL_BEGIN; free_slot <= legacy::GENERAL_END; ++free_slot) { + const ItemInstance* main_inst = m_inv[free_slot]; if (!main_inst) return free_slot; } - for (int16 free_slot = EQEmu::legacy::GENERAL_BEGIN; free_slot <= EQEmu::legacy::GENERAL_END; ++free_slot) { - const EQEmu::ItemInstance* main_inst = m_inv[free_slot]; + for (int16 free_slot = legacy::GENERAL_BEGIN; free_slot <= legacy::GENERAL_END; ++free_slot) { + const ItemInstance* main_inst = m_inv[free_slot]; if (main_inst && main_inst->IsClassBag()) { - if ((main_inst->GetItem()->BagSize < inst->GetItem()->Size) || (main_inst->GetItem()->BagType == EQEmu::item::BagTypeBandolier) || (main_inst->GetItem()->BagType == EQEmu::item::BagTypeQuiver)) + if ((main_inst->GetItem()->BagSize < inst->GetItem()->Size) || (main_inst->GetItem()->BagType == item::BagTypeBandolier) || (main_inst->GetItem()->BagType == item::BagTypeQuiver)) continue; - for (uint8 free_bag_slot = EQEmu::inventory::containerBegin; (free_bag_slot < main_inst->GetItem()->BagSlots) && (free_bag_slot < EQEmu::inventory::ContainerCount); ++free_bag_slot) { + for (uint8 free_bag_slot = inventory::containerBegin; (free_bag_slot < main_inst->GetItem()->BagSlots) && (free_bag_slot < inventory::ContainerCount); ++free_bag_slot) { if (!main_inst->GetItem(free_bag_slot)) - return Inventory::CalcSlotId(free_slot, free_bag_slot); + return InventoryProfile::CalcSlotId(free_slot, free_bag_slot); } } } //return INVALID_INDEX; // everything else pushes to the cursor - return EQEmu::inventory::slotCursor; + return inventory::slotCursor; } // Opposite of below: Get parent bag slot_id from a slot inside of bag -int16 Inventory::CalcSlotId(int16 slot_id) { +int16 EQEmu::InventoryProfile::CalcSlotId(int16 slot_id) { int16 parent_slot_id = INVALID_INDEX; // this is not a bag range... using this risks over-writing existing items @@ -756,136 +756,136 @@ int16 Inventory::CalcSlotId(int16 slot_id) { // parent_slot_id = EmuConstants::BANK_BEGIN + (slot_id - EmuConstants::BANK_BEGIN) / EmuConstants::ITEM_CONTAINER_SIZE; //else if (slot_id >= 3100 && slot_id <= 3179) should be {3031..3110}..where did this range come from!!? (verified db save range) - if (slot_id >= EQEmu::legacy::GENERAL_BAGS_BEGIN && slot_id <= EQEmu::legacy::GENERAL_BAGS_END) { - parent_slot_id = EQEmu::legacy::GENERAL_BEGIN + (slot_id - EQEmu::legacy::GENERAL_BAGS_BEGIN) / EQEmu::inventory::ContainerCount; + if (slot_id >= legacy::GENERAL_BAGS_BEGIN && slot_id <= legacy::GENERAL_BAGS_END) { + parent_slot_id = legacy::GENERAL_BEGIN + (slot_id - legacy::GENERAL_BAGS_BEGIN) / inventory::ContainerCount; } - else if (slot_id >= EQEmu::legacy::CURSOR_BAG_BEGIN && slot_id <= EQEmu::legacy::CURSOR_BAG_END) { - parent_slot_id = EQEmu::inventory::slotCursor; + else if (slot_id >= legacy::CURSOR_BAG_BEGIN && slot_id <= legacy::CURSOR_BAG_END) { + parent_slot_id = inventory::slotCursor; } - else if (slot_id >= EQEmu::legacy::BANK_BAGS_BEGIN && slot_id <= EQEmu::legacy::BANK_BAGS_END) { - parent_slot_id = EQEmu::legacy::BANK_BEGIN + (slot_id - EQEmu::legacy::BANK_BAGS_BEGIN) / EQEmu::inventory::ContainerCount; + else if (slot_id >= legacy::BANK_BAGS_BEGIN && slot_id <= legacy::BANK_BAGS_END) { + parent_slot_id = legacy::BANK_BEGIN + (slot_id - legacy::BANK_BAGS_BEGIN) / inventory::ContainerCount; } - else if (slot_id >= EQEmu::legacy::SHARED_BANK_BAGS_BEGIN && slot_id <= EQEmu::legacy::SHARED_BANK_BAGS_END) { - parent_slot_id = EQEmu::legacy::SHARED_BANK_BEGIN + (slot_id - EQEmu::legacy::SHARED_BANK_BAGS_BEGIN) / EQEmu::inventory::ContainerCount; + else if (slot_id >= legacy::SHARED_BANK_BAGS_BEGIN && slot_id <= legacy::SHARED_BANK_BAGS_END) { + parent_slot_id = legacy::SHARED_BANK_BEGIN + (slot_id - legacy::SHARED_BANK_BAGS_BEGIN) / inventory::ContainerCount; } - else if (slot_id >= EQEmu::legacy::TRADE_BAGS_BEGIN && slot_id <= EQEmu::legacy::TRADE_BAGS_END) { - parent_slot_id = EQEmu::legacy::TRADE_BEGIN + (slot_id - EQEmu::legacy::TRADE_BAGS_BEGIN) / EQEmu::inventory::ContainerCount; + else if (slot_id >= legacy::TRADE_BAGS_BEGIN && slot_id <= legacy::TRADE_BAGS_END) { + parent_slot_id = legacy::TRADE_BEGIN + (slot_id - legacy::TRADE_BAGS_BEGIN) / inventory::ContainerCount; } return parent_slot_id; } // Calculate slot_id for an item within a bag -int16 Inventory::CalcSlotId(int16 bagslot_id, uint8 bagidx) { - if (!Inventory::SupportsContainers(bagslot_id)) +int16 EQEmu::InventoryProfile::CalcSlotId(int16 bagslot_id, uint8 bagidx) { + if (!InventoryProfile::SupportsContainers(bagslot_id)) return INVALID_INDEX; int16 slot_id = INVALID_INDEX; - if (bagslot_id == EQEmu::inventory::slotCursor || bagslot_id == 8000) { - slot_id = EQEmu::legacy::CURSOR_BAG_BEGIN + bagidx; + if (bagslot_id == inventory::slotCursor || bagslot_id == 8000) { + slot_id = legacy::CURSOR_BAG_BEGIN + bagidx; } - else if (bagslot_id >= EQEmu::legacy::GENERAL_BEGIN && bagslot_id <= EQEmu::legacy::GENERAL_END) { - slot_id = EQEmu::legacy::GENERAL_BAGS_BEGIN + (bagslot_id - EQEmu::legacy::GENERAL_BEGIN) * EQEmu::inventory::ContainerCount + bagidx; + else if (bagslot_id >= legacy::GENERAL_BEGIN && bagslot_id <= legacy::GENERAL_END) { + slot_id = legacy::GENERAL_BAGS_BEGIN + (bagslot_id - legacy::GENERAL_BEGIN) * inventory::ContainerCount + bagidx; } - else if (bagslot_id >= EQEmu::legacy::BANK_BEGIN && bagslot_id <= EQEmu::legacy::BANK_END) { - slot_id = EQEmu::legacy::BANK_BAGS_BEGIN + (bagslot_id - EQEmu::legacy::BANK_BEGIN) * EQEmu::inventory::ContainerCount + bagidx; + else if (bagslot_id >= legacy::BANK_BEGIN && bagslot_id <= legacy::BANK_END) { + slot_id = legacy::BANK_BAGS_BEGIN + (bagslot_id - legacy::BANK_BEGIN) * inventory::ContainerCount + bagidx; } - else if (bagslot_id >= EQEmu::legacy::SHARED_BANK_BEGIN && bagslot_id <= EQEmu::legacy::SHARED_BANK_END) { - slot_id = EQEmu::legacy::SHARED_BANK_BAGS_BEGIN + (bagslot_id - EQEmu::legacy::SHARED_BANK_BEGIN) * EQEmu::inventory::ContainerCount + bagidx; + else if (bagslot_id >= legacy::SHARED_BANK_BEGIN && bagslot_id <= legacy::SHARED_BANK_END) { + slot_id = legacy::SHARED_BANK_BAGS_BEGIN + (bagslot_id - legacy::SHARED_BANK_BEGIN) * inventory::ContainerCount + bagidx; } - else if (bagslot_id >= EQEmu::legacy::TRADE_BEGIN && bagslot_id <= EQEmu::legacy::TRADE_END) { - slot_id = EQEmu::legacy::TRADE_BAGS_BEGIN + (bagslot_id - EQEmu::legacy::TRADE_BEGIN) * EQEmu::inventory::ContainerCount + bagidx; + else if (bagslot_id >= legacy::TRADE_BEGIN && bagslot_id <= legacy::TRADE_END) { + slot_id = legacy::TRADE_BAGS_BEGIN + (bagslot_id - legacy::TRADE_BEGIN) * inventory::ContainerCount + bagidx; } return slot_id; } -uint8 Inventory::CalcBagIdx(int16 slot_id) { +uint8 EQEmu::InventoryProfile::CalcBagIdx(int16 slot_id) { uint8 index = 0; // this is not a bag range... using this risks over-writing existing items //else if (slot_id >= EmuConstants::BANK_BEGIN && slot_id <= EmuConstants::BANK_END) // index = (slot_id - EmuConstants::BANK_BEGIN) % EmuConstants::ITEM_CONTAINER_SIZE; - if (slot_id >= EQEmu::legacy::GENERAL_BAGS_BEGIN && slot_id <= EQEmu::legacy::GENERAL_BAGS_END) { - index = (slot_id - EQEmu::legacy::GENERAL_BAGS_BEGIN) % EQEmu::inventory::ContainerCount; + if (slot_id >= legacy::GENERAL_BAGS_BEGIN && slot_id <= legacy::GENERAL_BAGS_END) { + index = (slot_id - legacy::GENERAL_BAGS_BEGIN) % inventory::ContainerCount; } - else if (slot_id >= EQEmu::legacy::CURSOR_BAG_BEGIN && slot_id <= EQEmu::legacy::CURSOR_BAG_END) { - index = (slot_id - EQEmu::legacy::CURSOR_BAG_BEGIN); // % EQEmu::legacy::ITEM_CONTAINER_SIZE; - not needed since range is 10 slots + else if (slot_id >= legacy::CURSOR_BAG_BEGIN && slot_id <= legacy::CURSOR_BAG_END) { + index = (slot_id - legacy::CURSOR_BAG_BEGIN); // % inventory::ContainerCount; - not needed since range is 10 slots } - else if (slot_id >= EQEmu::legacy::BANK_BAGS_BEGIN && slot_id <= EQEmu::legacy::BANK_BAGS_END) { - index = (slot_id - EQEmu::legacy::BANK_BAGS_BEGIN) % EQEmu::inventory::ContainerCount; + else if (slot_id >= legacy::BANK_BAGS_BEGIN && slot_id <= legacy::BANK_BAGS_END) { + index = (slot_id - legacy::BANK_BAGS_BEGIN) % inventory::ContainerCount; } - else if (slot_id >= EQEmu::legacy::SHARED_BANK_BAGS_BEGIN && slot_id <= EQEmu::legacy::SHARED_BANK_BAGS_END) { - index = (slot_id - EQEmu::legacy::SHARED_BANK_BAGS_BEGIN) % EQEmu::inventory::ContainerCount; + else if (slot_id >= legacy::SHARED_BANK_BAGS_BEGIN && slot_id <= legacy::SHARED_BANK_BAGS_END) { + index = (slot_id - legacy::SHARED_BANK_BAGS_BEGIN) % inventory::ContainerCount; } - else if (slot_id >= EQEmu::legacy::TRADE_BAGS_BEGIN && slot_id <= EQEmu::legacy::TRADE_BAGS_END) { - index = (slot_id - EQEmu::legacy::TRADE_BAGS_BEGIN) % EQEmu::inventory::ContainerCount; + else if (slot_id >= legacy::TRADE_BAGS_BEGIN && slot_id <= legacy::TRADE_BAGS_END) { + index = (slot_id - legacy::TRADE_BAGS_BEGIN) % inventory::ContainerCount; } - else if (slot_id >= EQEmu::legacy::WORLD_BEGIN && slot_id <= EQEmu::legacy::WORLD_END) { - index = (slot_id - EQEmu::legacy::WORLD_BEGIN); // % EQEmu::legacy::ITEM_CONTAINER_SIZE; - not needed since range is 10 slots + else if (slot_id >= legacy::WORLD_BEGIN && slot_id <= legacy::WORLD_END) { + index = (slot_id - legacy::WORLD_BEGIN); // % inventory::ContainerCount; - not needed since range is 10 slots } return index; } -int16 Inventory::CalcSlotFromMaterial(uint8 material) +int16 EQEmu::InventoryProfile::CalcSlotFromMaterial(uint8 material) { switch (material) { - case EQEmu::textures::armorHead: - return EQEmu::inventory::slotHead; - case EQEmu::textures::armorChest: - return EQEmu::inventory::slotChest; - case EQEmu::textures::armorArms: - return EQEmu::inventory::slotArms; - case EQEmu::textures::armorWrist: - return EQEmu::inventory::slotWrist1; // there's 2 bracers, only one bracer material - case EQEmu::textures::armorHands: - return EQEmu::inventory::slotHands; - case EQEmu::textures::armorLegs: - return EQEmu::inventory::slotLegs; - case EQEmu::textures::armorFeet: - return EQEmu::inventory::slotFeet; - case EQEmu::textures::weaponPrimary: - return EQEmu::inventory::slotPrimary; - case EQEmu::textures::weaponSecondary: - return EQEmu::inventory::slotSecondary; + case textures::armorHead: + return inventory::slotHead; + case textures::armorChest: + return inventory::slotChest; + case textures::armorArms: + return inventory::slotArms; + case textures::armorWrist: + return inventory::slotWrist1; // there's 2 bracers, only one bracer material + case textures::armorHands: + return inventory::slotHands; + case textures::armorLegs: + return inventory::slotLegs; + case textures::armorFeet: + return inventory::slotFeet; + case textures::weaponPrimary: + return inventory::slotPrimary; + case textures::weaponSecondary: + return inventory::slotSecondary; default: return INVALID_INDEX; } } -uint8 Inventory::CalcMaterialFromSlot(int16 equipslot) +uint8 EQEmu::InventoryProfile::CalcMaterialFromSlot(int16 equipslot) { switch (equipslot) { - case EQEmu::inventory::slotHead: - return EQEmu::textures::armorHead; - case EQEmu::inventory::slotChest: - return EQEmu::textures::armorChest; - case EQEmu::inventory::slotArms: - return EQEmu::textures::armorArms; - case EQEmu::inventory::slotWrist1: + case inventory::slotHead: + return textures::armorHead; + case inventory::slotChest: + return textures::armorChest; + case inventory::slotArms: + return textures::armorArms; + case inventory::slotWrist1: //case SLOT_BRACER02: // non-live behavior - return EQEmu::textures::armorWrist; - case EQEmu::inventory::slotHands: - return EQEmu::textures::armorHands; - case EQEmu::inventory::slotLegs: - return EQEmu::textures::armorLegs; - case EQEmu::inventory::slotFeet: - return EQEmu::textures::armorFeet; - case EQEmu::inventory::slotPrimary: - return EQEmu::textures::weaponPrimary; - case EQEmu::inventory::slotSecondary: - return EQEmu::textures::weaponSecondary; + return textures::armorWrist; + case inventory::slotHands: + return textures::armorHands; + case inventory::slotLegs: + return textures::armorLegs; + case inventory::slotFeet: + return textures::armorFeet; + case inventory::slotPrimary: + return textures::weaponPrimary; + case inventory::slotSecondary: + return textures::weaponSecondary; default: - return EQEmu::textures::materialInvalid; + return textures::materialInvalid; } } -bool Inventory::CanItemFitInContainer(const EQEmu::ItemData *ItemToTry, const EQEmu::ItemData *Container) { +bool EQEmu::InventoryProfile::CanItemFitInContainer(const ItemData *ItemToTry, const ItemData *Container) { if (!ItemToTry || !Container) return false; @@ -893,47 +893,47 @@ bool Inventory::CanItemFitInContainer(const EQEmu::ItemData *ItemToTry, const EQ if (ItemToTry->Size > Container->BagSize) return false; - if ((Container->BagType == EQEmu::item::BagTypeQuiver) && (ItemToTry->ItemType != EQEmu::item::ItemTypeArrow)) + if ((Container->BagType == item::BagTypeQuiver) && (ItemToTry->ItemType != item::ItemTypeArrow)) return false; - if ((Container->BagType == EQEmu::item::BagTypeBandolier) && (ItemToTry->ItemType != EQEmu::item::ItemTypeSmallThrowing)) + if ((Container->BagType == item::BagTypeBandolier) && (ItemToTry->ItemType != item::ItemTypeSmallThrowing)) return false; return true; } -bool Inventory::SupportsClickCasting(int16 slot_id) +bool EQEmu::InventoryProfile::SupportsClickCasting(int16 slot_id) { // there are a few non-potion items that identify as ItemTypePotion..so, we still need to ubiquitously include the equipment range - if ((uint16)slot_id <= EQEmu::legacy::GENERAL_END || slot_id == EQEmu::inventory::slotPowerSource) + if ((uint16)slot_id <= legacy::GENERAL_END || slot_id == inventory::slotPowerSource) { return true; } - else if (slot_id >= EQEmu::legacy::GENERAL_BAGS_BEGIN && slot_id <= EQEmu::legacy::GENERAL_BAGS_END) + else if (slot_id >= legacy::GENERAL_BAGS_BEGIN && slot_id <= legacy::GENERAL_BAGS_END) { - if (EQEmu::inventory::Lookup(m_inventory_version)->AllowClickCastFromBag) + if (inventory::Lookup(m_inventory_version)->AllowClickCastFromBag) return true; } return false; } -bool Inventory::SupportsPotionBeltCasting(int16 slot_id) +bool EQEmu::InventoryProfile::SupportsPotionBeltCasting(int16 slot_id) { - if ((uint16)slot_id <= EQEmu::legacy::GENERAL_END || slot_id == EQEmu::inventory::slotPowerSource || (slot_id >= EQEmu::legacy::GENERAL_BAGS_BEGIN && slot_id <= EQEmu::legacy::GENERAL_BAGS_END)) + if ((uint16)slot_id <= legacy::GENERAL_END || slot_id == inventory::slotPowerSource || (slot_id >= legacy::GENERAL_BAGS_BEGIN && slot_id <= legacy::GENERAL_BAGS_END)) return true; return false; } // Test whether a given slot can support a container item -bool Inventory::SupportsContainers(int16 slot_id) +bool EQEmu::InventoryProfile::SupportsContainers(int16 slot_id) { - if ((slot_id == EQEmu::inventory::slotCursor) || - (slot_id >= EQEmu::legacy::GENERAL_BEGIN && slot_id <= EQEmu::legacy::GENERAL_END) || - (slot_id >= EQEmu::legacy::BANK_BEGIN && slot_id <= EQEmu::legacy::BANK_END) || - (slot_id >= EQEmu::legacy::SHARED_BANK_BEGIN && slot_id <= EQEmu::legacy::SHARED_BANK_END) || - (slot_id >= EQEmu::legacy::TRADE_BEGIN && slot_id <= EQEmu::legacy::TRADE_END) + if ((slot_id == inventory::slotCursor) || + (slot_id >= legacy::GENERAL_BEGIN && slot_id <= legacy::GENERAL_END) || + (slot_id >= legacy::BANK_BEGIN && slot_id <= legacy::BANK_END) || + (slot_id >= legacy::SHARED_BANK_BEGIN && slot_id <= legacy::SHARED_BANK_END) || + (slot_id >= legacy::TRADE_BEGIN && slot_id <= legacy::TRADE_END) ) { return true; } @@ -941,7 +941,7 @@ bool Inventory::SupportsContainers(int16 slot_id) return false; } -int Inventory::GetSlotByItemInst(EQEmu::ItemInstance *inst) { +int EQEmu::InventoryProfile::GetSlotByItemInst(ItemInstance *inst) { if (!inst) return INVALID_INDEX; @@ -971,32 +971,32 @@ int Inventory::GetSlotByItemInst(EQEmu::ItemInstance *inst) { } if (m_cursor.peek_front() == inst) { - return EQEmu::inventory::slotCursor; + return inventory::slotCursor; } return INVALID_INDEX; } -uint8 Inventory::FindBrightestLightType() +uint8 EQEmu::InventoryProfile::FindBrightestLightType() { uint8 brightest_light_type = 0; for (auto iter = m_worn.begin(); iter != m_worn.end(); ++iter) { - if ((iter->first < EQEmu::legacy::EQUIPMENT_BEGIN || iter->first > EQEmu::legacy::EQUIPMENT_END) && iter->first != EQEmu::inventory::slotPowerSource) { continue; } - if (iter->first == EQEmu::inventory::slotAmmo) { continue; } + if ((iter->first < legacy::EQUIPMENT_BEGIN || iter->first > legacy::EQUIPMENT_END) && iter->first != inventory::slotPowerSource) { continue; } + if (iter->first == inventory::slotAmmo) { continue; } auto inst = iter->second; if (inst == nullptr) { continue; } auto item = inst->GetItem(); if (item == nullptr) { continue; } - if (EQEmu::lightsource::IsLevelGreater(item->Light, brightest_light_type)) + if (lightsource::IsLevelGreater(item->Light, brightest_light_type)) brightest_light_type = item->Light; } uint8 general_light_type = 0; for (auto iter = m_inv.begin(); iter != m_inv.end(); ++iter) { - if (iter->first < EQEmu::legacy::GENERAL_BEGIN || iter->first > EQEmu::legacy::GENERAL_END) { continue; } + if (iter->first < legacy::GENERAL_BEGIN || iter->first > legacy::GENERAL_END) { continue; } auto inst = iter->second; if (inst == nullptr) { continue; } @@ -1006,17 +1006,17 @@ uint8 Inventory::FindBrightestLightType() if (!item->IsClassCommon()) { continue; } if (item->Light < 9 || item->Light > 13) { continue; } - if (EQEmu::lightsource::TypeToLevel(item->Light)) + if (lightsource::TypeToLevel(item->Light)) general_light_type = item->Light; } - if (EQEmu::lightsource::IsLevelGreater(general_light_type, brightest_light_type)) + if (lightsource::IsLevelGreater(general_light_type, brightest_light_type)) brightest_light_type = general_light_type; return brightest_light_type; } -void Inventory::dumpEntireInventory() { +void EQEmu::InventoryProfile::dumpEntireInventory() { dumpWornItems(); dumpInventory(); @@ -1026,31 +1026,31 @@ void Inventory::dumpEntireInventory() { std::cout << std::endl; } -void Inventory::dumpWornItems() { +void EQEmu::InventoryProfile::dumpWornItems() { std::cout << "Worn items:" << std::endl; dumpItemCollection(m_worn); } -void Inventory::dumpInventory() { +void EQEmu::InventoryProfile::dumpInventory() { std::cout << "Inventory items:" << std::endl; dumpItemCollection(m_inv); } -void Inventory::dumpBankItems() { +void EQEmu::InventoryProfile::dumpBankItems() { std::cout << "Bank items:" << std::endl; dumpItemCollection(m_bank); } -void Inventory::dumpSharedBankItems() { +void EQEmu::InventoryProfile::dumpSharedBankItems() { std::cout << "Shared Bank items:" << std::endl; dumpItemCollection(m_shbank); } -int Inventory::GetSlotByItemInstCollection(const std::map &collection, EQEmu::ItemInstance *inst) { +int EQEmu::InventoryProfile::GetSlotByItemInstCollection(const std::map &collection, ItemInstance *inst) { for (auto iter = collection.begin(); iter != collection.end(); ++iter) { - EQEmu::ItemInstance *t_inst = iter->second; + ItemInstance *t_inst = iter->second; if (t_inst == inst) { return iter->first; } @@ -1058,7 +1058,7 @@ int Inventory::GetSlotByItemInstCollection(const std::mapIsClassBag()) { for (auto b_iter = t_inst->_cbegin(); b_iter != t_inst->_cend(); ++b_iter) { if (b_iter->second == inst) { - return Inventory::CalcSlotId(iter->first, b_iter->first); + return InventoryProfile::CalcSlotId(iter->first, b_iter->first); } } } @@ -1067,7 +1067,7 @@ int Inventory::GetSlotByItemInstCollection(const std::map &collection) +void EQEmu::InventoryProfile::dumpItemCollection(const std::map &collection) { for (auto it = collection.cbegin(); it != collection.cend(); ++it) { auto inst = it->second; @@ -1081,18 +1081,18 @@ void Inventory::dumpItemCollection(const std::map & } } -void Inventory::dumpBagContents(EQEmu::ItemInstance *inst, std::map::const_iterator *it) +void EQEmu::InventoryProfile::dumpBagContents(ItemInstance *inst, std::map::const_iterator *it) { if (!inst || !inst->IsClassBag()) return; // Go through bag, if bag for (auto itb = inst->_cbegin(); itb != inst->_cend(); ++itb) { - EQEmu::ItemInstance* baginst = itb->second; + ItemInstance* baginst = itb->second; if (!baginst || !baginst->GetItem()) continue; - std::string subSlot = StringFormat(" Slot %d: %s (%d)", Inventory::CalcSlotId((*it)->first, itb->first), + std::string subSlot = StringFormat(" Slot %d: %s (%d)", InventoryProfile::CalcSlotId((*it)->first, itb->first), baginst->GetItem()->Name, (baginst->GetCharges() <= 0) ? 1 : baginst->GetCharges()); std::cout << subSlot << std::endl; } @@ -1100,7 +1100,7 @@ void Inventory::dumpBagContents(EQEmu::ItemInstance *inst, std::map& bucket, int16 slot_id) const +EQEmu::ItemInstance* EQEmu::InventoryProfile::_GetItem(const std::map& bucket, int16 slot_id) const { auto it = bucket.find(slot_id); if (it != bucket.end()) { @@ -1113,7 +1113,7 @@ EQEmu::ItemInstance* Inventory::_GetItem(const std::map= EQEmu::legacy::EQUIPMENT_BEGIN && slot_id <= EQEmu::legacy::EQUIPMENT_END) || (slot_id == EQEmu::inventory::slotPowerSource)) { + else if ((slot_id >= legacy::EQUIPMENT_BEGIN && slot_id <= legacy::EQUIPMENT_END) || (slot_id == inventory::slotPowerSource)) { m_worn[slot_id] = inst; result = slot_id; } - else if ((slot_id >= EQEmu::legacy::GENERAL_BEGIN && slot_id <= EQEmu::legacy::GENERAL_END)) { + else if ((slot_id >= legacy::GENERAL_BEGIN && slot_id <= legacy::GENERAL_END)) { m_inv[slot_id] = inst; result = slot_id; } - else if (slot_id >= EQEmu::legacy::TRIBUTE_BEGIN && slot_id <= EQEmu::legacy::TRIBUTE_END) { + else if (slot_id >= legacy::TRIBUTE_BEGIN && slot_id <= legacy::TRIBUTE_END) { m_worn[slot_id] = inst; result = slot_id; } - else if (slot_id >= EQEmu::legacy::BANK_BEGIN && slot_id <= EQEmu::legacy::BANK_END) { + else if (slot_id >= legacy::BANK_BEGIN && slot_id <= legacy::BANK_END) { m_bank[slot_id] = inst; result = slot_id; } - else if (slot_id >= EQEmu::legacy::SHARED_BANK_BEGIN && slot_id <= EQEmu::legacy::SHARED_BANK_END) { + else if (slot_id >= legacy::SHARED_BANK_BEGIN && slot_id <= legacy::SHARED_BANK_END) { m_shbank[slot_id] = inst; result = slot_id; } - else if (slot_id >= EQEmu::legacy::TRADE_BEGIN && slot_id <= EQEmu::legacy::TRADE_END) { + else if (slot_id >= legacy::TRADE_BEGIN && slot_id <= legacy::TRADE_END) { m_trade[slot_id] = inst; result = slot_id; } else { // Slot must be within a bag - parentSlot = Inventory::CalcSlotId(slot_id); - EQEmu::ItemInstance* baginst = GetItem(parentSlot); // Get parent bag + parentSlot = InventoryProfile::CalcSlotId(slot_id); + ItemInstance* baginst = GetItem(parentSlot); // Get parent bag if (baginst && baginst->IsClassBag()) { - baginst->_PutItem(Inventory::CalcBagIdx(slot_id), inst); + baginst->_PutItem(InventoryProfile::CalcBagIdx(slot_id), inst); result = slot_id; } } if (result == INVALID_INDEX) { - Log.Out(Logs::General, Logs::Error, "Inventory::_PutItem: Invalid slot_id specified (%i) with parent slot id (%i)", slot_id, parentSlot); - Inventory::MarkDirty(inst); // Slot not found, clean up + Log.Out(Logs::General, Logs::Error, "InventoryProfile::_PutItem: Invalid slot_id specified (%i) with parent slot id (%i)", slot_id, parentSlot); + InventoryProfile::MarkDirty(inst); // Slot not found, clean up } return result; } // Internal Method: Checks an inventory bucket for a particular item -int16 Inventory::_HasItem(std::map& bucket, uint32 item_id, uint8 quantity) +int16 EQEmu::InventoryProfile::_HasItem(std::map& bucket, uint32 item_id, uint8 quantity) { uint32 quantity_found = 0; @@ -1191,9 +1191,9 @@ int16 Inventory::_HasItem(std::map& bucket, uint32 return iter->first; } - for (int index = EQEmu::inventory::socketBegin; index < EQEmu::inventory::SocketCount; ++index) { + for (int index = inventory::socketBegin; index < inventory::SocketCount; ++index) { if (inst->GetAugmentItemID(index) == item_id && quantity <= 1) - return EQEmu::legacy::SLOT_AUGMENT; + return legacy::SLOT_AUGMENT; } if (!inst->IsClassBag()) { continue; } @@ -1205,12 +1205,12 @@ int16 Inventory::_HasItem(std::map& bucket, uint32 if (bag_inst->GetID() == item_id) { quantity_found += (bag_inst->GetCharges() <= 0) ? 1 : bag_inst->GetCharges(); if (quantity_found >= quantity) - return Inventory::CalcSlotId(iter->first, bag_iter->first); + return InventoryProfile::CalcSlotId(iter->first, bag_iter->first); } - for (int index = EQEmu::inventory::socketBegin; index < EQEmu::inventory::SocketCount; ++index) { + for (int index = inventory::socketBegin; index < inventory::SocketCount; ++index) { if (bag_inst->GetAugmentItemID(index) == item_id && quantity <= 1) - return EQEmu::legacy::SLOT_AUGMENT; + return legacy::SLOT_AUGMENT; } } } @@ -1219,7 +1219,7 @@ int16 Inventory::_HasItem(std::map& bucket, uint32 } // Internal Method: Checks an inventory queue type bucket for a particular item -int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity) +int16 EQEmu::InventoryProfile::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity) { // The downfall of this (these) queue procedure is that callers presume that when an item is // found, it is presented as being available on the cursor. In cases of a parity check, this @@ -1236,12 +1236,12 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity) if (inst->GetID() == item_id) { quantity_found += (inst->GetCharges() <= 0) ? 1 : inst->GetCharges(); if (quantity_found >= quantity) - return EQEmu::inventory::slotCursor; + return inventory::slotCursor; } - for (int index = EQEmu::inventory::socketBegin; index < EQEmu::inventory::SocketCount; ++index) { + for (int index = inventory::socketBegin; index < inventory::SocketCount; ++index) { if (inst->GetAugmentItemID(index) == item_id && quantity <= 1) - return EQEmu::legacy::SLOT_AUGMENT; + return legacy::SLOT_AUGMENT; } if (!inst->IsClassBag()) { continue; } @@ -1253,12 +1253,12 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity) if (bag_inst->GetID() == item_id) { quantity_found += (bag_inst->GetCharges() <= 0) ? 1 : bag_inst->GetCharges(); if (quantity_found >= quantity) - return Inventory::CalcSlotId(EQEmu::inventory::slotCursor, bag_iter->first); + return InventoryProfile::CalcSlotId(inventory::slotCursor, bag_iter->first); } - for (int index = EQEmu::inventory::socketBegin; index < EQEmu::inventory::SocketCount; ++index) { + for (int index = inventory::socketBegin; index < inventory::SocketCount; ++index) { if (bag_inst->GetAugmentItemID(index) == item_id && quantity <= 1) - return EQEmu::legacy::SLOT_AUGMENT; + return legacy::SLOT_AUGMENT; } } @@ -1270,7 +1270,7 @@ int16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity) } // Internal Method: Checks an inventory bucket for a particular item -int16 Inventory::_HasItemByUse(std::map& bucket, uint8 use, uint8 quantity) +int16 EQEmu::InventoryProfile::_HasItemByUse(std::map& bucket, uint8 use, uint8 quantity) { uint32 quantity_found = 0; @@ -1293,7 +1293,7 @@ int16 Inventory::_HasItemByUse(std::map& bucket, ui if (bag_inst->IsClassCommon() && bag_inst->GetItem()->ItemType == use) { quantity_found += (bag_inst->GetCharges() <= 0) ? 1 : bag_inst->GetCharges(); if (quantity_found >= quantity) - return Inventory::CalcSlotId(iter->first, bag_iter->first); + return InventoryProfile::CalcSlotId(iter->first, bag_iter->first); } } } @@ -1302,7 +1302,7 @@ int16 Inventory::_HasItemByUse(std::map& bucket, ui } // Internal Method: Checks an inventory queue type bucket for a particular item -int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity) +int16 EQEmu::InventoryProfile::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity) { uint32 quantity_found = 0; @@ -1313,7 +1313,7 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity) if (inst->IsClassCommon() && inst->GetItem()->ItemType == use) { quantity_found += (inst->GetCharges() <= 0) ? 1 : inst->GetCharges(); if (quantity_found >= quantity) - return EQEmu::inventory::slotCursor; + return inventory::slotCursor; } if (!inst->IsClassBag()) { continue; } @@ -1325,7 +1325,7 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity) if (bag_inst->IsClassCommon() && bag_inst->GetItem()->ItemType == use) { quantity_found += (bag_inst->GetCharges() <= 0) ? 1 : bag_inst->GetCharges(); if (quantity_found >= quantity) - return Inventory::CalcSlotId(EQEmu::inventory::slotCursor, bag_iter->first); + return InventoryProfile::CalcSlotId(inventory::slotCursor, bag_iter->first); } } @@ -1336,7 +1336,7 @@ int16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity) return INVALID_INDEX; } -int16 Inventory::_HasItemByLoreGroup(std::map& bucket, uint32 loregroup) +int16 EQEmu::InventoryProfile::_HasItemByLoreGroup(std::map& bucket, uint32 loregroup) { for (auto iter = bucket.begin(); iter != bucket.end(); ++iter) { auto inst = iter->second; @@ -1345,12 +1345,12 @@ int16 Inventory::_HasItemByLoreGroup(std::map& buck if (inst->GetItem()->LoreGroup == loregroup) return iter->first; - for (int index = EQEmu::inventory::socketBegin; index < EQEmu::inventory::SocketCount; ++index) { + for (int index = inventory::socketBegin; index < inventory::SocketCount; ++index) { auto aug_inst = inst->GetAugment(index); if (aug_inst == nullptr) { continue; } if (aug_inst->GetItem()->LoreGroup == loregroup) - return EQEmu::legacy::SLOT_AUGMENT; + return legacy::SLOT_AUGMENT; } if (!inst->IsClassBag()) { continue; } @@ -1360,14 +1360,14 @@ int16 Inventory::_HasItemByLoreGroup(std::map& buck if (bag_inst == nullptr) { continue; } if (bag_inst->IsClassCommon() && bag_inst->GetItem()->LoreGroup == loregroup) - return Inventory::CalcSlotId(iter->first, bag_iter->first); + return InventoryProfile::CalcSlotId(iter->first, bag_iter->first); - for (int index = EQEmu::inventory::socketBegin; index < EQEmu::inventory::SocketCount; ++index) { + for (int index = inventory::socketBegin; index < inventory::SocketCount; ++index) { auto aug_inst = bag_inst->GetAugment(index); if (aug_inst == nullptr) { continue; } if (aug_inst->GetItem()->LoreGroup == loregroup) - return EQEmu::legacy::SLOT_AUGMENT; + return legacy::SLOT_AUGMENT; } } } @@ -1376,21 +1376,21 @@ int16 Inventory::_HasItemByLoreGroup(std::map& buck } // Internal Method: Checks an inventory queue type bucket for a particular item -int16 Inventory::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup) +int16 EQEmu::InventoryProfile::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup) { for (auto iter = iqueue.cbegin(); iter != iqueue.cend(); ++iter) { auto inst = *iter; if (inst == nullptr) { continue; } if (inst->GetItem()->LoreGroup == loregroup) - return EQEmu::inventory::slotCursor; + return inventory::slotCursor; - for (int index = EQEmu::inventory::socketBegin; index < EQEmu::inventory::SocketCount; ++index) { + for (int index = inventory::socketBegin; index < inventory::SocketCount; ++index) { auto aug_inst = inst->GetAugment(index); if (aug_inst == nullptr) { continue; } if (aug_inst->GetItem()->LoreGroup == loregroup) - return EQEmu::legacy::SLOT_AUGMENT; + return legacy::SLOT_AUGMENT; } if (!inst->IsClassBag()) { continue; } @@ -1400,14 +1400,14 @@ int16 Inventory::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup) if (bag_inst == nullptr) { continue; } if (bag_inst->IsClassCommon() && bag_inst->GetItem()->LoreGroup == loregroup) - return Inventory::CalcSlotId(EQEmu::inventory::slotCursor, bag_iter->first); + return InventoryProfile::CalcSlotId(inventory::slotCursor, bag_iter->first); - for (int index = EQEmu::inventory::socketBegin; index < EQEmu::inventory::SocketCount; ++index) { + for (int index = inventory::socketBegin; index < inventory::SocketCount; ++index) { auto aug_inst = bag_inst->GetAugment(index); if (aug_inst == nullptr) { continue; } if (aug_inst->GetItem()->LoreGroup == loregroup) - return EQEmu::legacy::SLOT_AUGMENT; + return legacy::SLOT_AUGMENT; } } diff --git a/common/inventory_profile.h b/common/inventory_profile.h index 3903f9812..0f90fdea2 100644 --- a/common/inventory_profile.h +++ b/common/inventory_profile.h @@ -73,156 +73,159 @@ protected: }; // ######################################## -// Class: Inventory +// Class: EQEmu::InventoryProfile // Character inventory -class Inventory +namespace EQEmu { - friend class EQEmu::ItemInstance; -public: - /////////////////////////////// - // Public Methods - /////////////////////////////// - - Inventory() { m_inventory_version = EQEmu::versions::InventoryVersion::Unknown; m_inventory_version_set = false; } - ~Inventory(); + class InventoryProfile + { + friend class ItemInstance; + public: + /////////////////////////////// + // Public Methods + /////////////////////////////// - // inv2 creep - bool SetInventoryVersion(EQEmu::versions::InventoryVersion inventory_version) { - if (!m_inventory_version_set) { - m_inventory_version = EQEmu::versions::ValidateInventoryVersion(inventory_version); - return (m_inventory_version_set = true); + InventoryProfile() { m_inventory_version = versions::InventoryVersion::Unknown; m_inventory_version_set = false; } + ~InventoryProfile(); + + // inv2 creep + bool SetInventoryVersion(versions::InventoryVersion inventory_version) { + if (!m_inventory_version_set) { + m_inventory_version = versions::ValidateInventoryVersion(inventory_version); + return (m_inventory_version_set = true); + } + else { + return false; + } } - else { - return false; - } - } - bool SetInventoryVersion(EQEmu::versions::ClientVersion client_version) { return SetInventoryVersion(EQEmu::versions::ConvertClientVersionToInventoryVersion(client_version)); } + bool SetInventoryVersion(versions::ClientVersion client_version) { return SetInventoryVersion(versions::ConvertClientVersionToInventoryVersion(client_version)); } - EQEmu::versions::InventoryVersion InventoryVersion() { return m_inventory_version; } + versions::InventoryVersion InventoryVersion() { return m_inventory_version; } - static void CleanDirty(); - static void MarkDirty(EQEmu::ItemInstance *inst); + static void CleanDirty(); + static void MarkDirty(ItemInstance *inst); - // Retrieve a writeable item at specified slot - EQEmu::ItemInstance* GetItem(int16 slot_id) const; - EQEmu::ItemInstance* GetItem(int16 slot_id, uint8 bagidx) const; + // Retrieve a writeable item at specified slot + ItemInstance* GetItem(int16 slot_id) const; + ItemInstance* GetItem(int16 slot_id, uint8 bagidx) const; - inline std::list::const_iterator cursor_cbegin() { return m_cursor.cbegin(); } - inline std::list::const_iterator cursor_cend() { return m_cursor.cend(); } + inline std::list::const_iterator cursor_cbegin() { return m_cursor.cbegin(); } + inline std::list::const_iterator cursor_cend() { return m_cursor.cend(); } - inline int CursorSize() { return m_cursor.size(); } - inline bool CursorEmpty() { return m_cursor.empty(); } + inline int CursorSize() { return m_cursor.size(); } + inline bool CursorEmpty() { return m_cursor.empty(); } - // Retrieve a read-only item from inventory - inline const EQEmu::ItemInstance* operator[](int16 slot_id) const { return GetItem(slot_id); } + // Retrieve a read-only item from inventory + inline const ItemInstance* operator[](int16 slot_id) const { return GetItem(slot_id); } - // Add item to inventory - int16 PutItem(int16 slot_id, const EQEmu::ItemInstance& inst); + // Add item to inventory + int16 PutItem(int16 slot_id, const ItemInstance& inst); - // Add item to cursor queue - int16 PushCursor(const EQEmu::ItemInstance& inst); + // Add item to cursor queue + int16 PushCursor(const ItemInstance& inst); - // Get cursor item in front of queue - EQEmu::ItemInstance* GetCursorItem(); + // Get cursor item in front of queue + ItemInstance* GetCursorItem(); - // Swap items in inventory - bool SwapItem(int16 slot_a, int16 slot_b); + // Swap items in inventory + bool SwapItem(int16 slot_a, int16 slot_b); - // Remove item from inventory - bool DeleteItem(int16 slot_id, uint8 quantity=0); + // Remove item from inventory + bool DeleteItem(int16 slot_id, uint8 quantity = 0); - // Checks All items in a bag for No Drop - bool CheckNoDrop(int16 slot_id); + // Checks All items in a bag for No Drop + bool CheckNoDrop(int16 slot_id); - // Remove item from inventory (and take control of memory) - EQEmu::ItemInstance* PopItem(int16 slot_id); + // Remove item from inventory (and take control of memory) + ItemInstance* PopItem(int16 slot_id); - // Check whether there is space for the specified number of the specified item. - bool HasSpaceForItem(const EQEmu::ItemData *ItemToTry, int16 Quantity); + // Check whether there is space for the specified number of the specified item. + bool HasSpaceForItem(const ItemData *ItemToTry, int16 Quantity); - // Check whether item exists in inventory - // where argument specifies OR'd list of invWhere constants to look - int16 HasItem(uint32 item_id, uint8 quantity = 0, uint8 where = 0xFF); + // Check whether item exists in inventory + // where argument specifies OR'd list of invWhere constants to look + int16 HasItem(uint32 item_id, uint8 quantity = 0, uint8 where = 0xFF); - // Check whether item exists in inventory - // where argument specifies OR'd list of invWhere constants to look - int16 HasItemByUse(uint8 use, uint8 quantity=0, uint8 where=0xFF); + // Check whether item exists in inventory + // where argument specifies OR'd list of invWhere constants to look + int16 HasItemByUse(uint8 use, uint8 quantity = 0, uint8 where = 0xFF); - // Check whether item exists in inventory - // where argument specifies OR'd list of invWhere constants to look - int16 HasItemByLoreGroup(uint32 loregroup, uint8 where=0xFF); + // Check whether item exists in inventory + // where argument specifies OR'd list of invWhere constants to look + int16 HasItemByLoreGroup(uint32 loregroup, uint8 where = 0xFF); - // Locate an available inventory slot - int16 FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size = 0, bool is_arrow = false); - int16 FindFreeSlotForTradeItem(const EQEmu::ItemInstance* inst); + // Locate an available inventory slot + int16 FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size = 0, bool is_arrow = false); + int16 FindFreeSlotForTradeItem(const ItemInstance* inst); - // Calculate slot_id for an item within a bag - static int16 CalcSlotId(int16 slot_id); // Calc parent bag's slot_id - static int16 CalcSlotId(int16 bagslot_id, uint8 bagidx); // Calc slot_id for item inside bag - static uint8 CalcBagIdx(int16 slot_id); // Calc bagidx for slot_id - static int16 CalcSlotFromMaterial(uint8 material); - static uint8 CalcMaterialFromSlot(int16 equipslot); + // Calculate slot_id for an item within a bag + static int16 CalcSlotId(int16 slot_id); // Calc parent bag's slot_id + static int16 CalcSlotId(int16 bagslot_id, uint8 bagidx); // Calc slot_id for item inside bag + static uint8 CalcBagIdx(int16 slot_id); // Calc bagidx for slot_id + static int16 CalcSlotFromMaterial(uint8 material); + static uint8 CalcMaterialFromSlot(int16 equipslot); - static bool CanItemFitInContainer(const EQEmu::ItemData *ItemToTry, const EQEmu::ItemData *Container); + static bool CanItemFitInContainer(const ItemData *ItemToTry, const ItemData *Container); - // Test for valid inventory casting slot - bool SupportsClickCasting(int16 slot_id); - bool SupportsPotionBeltCasting(int16 slot_id); + // Test for valid inventory casting slot + bool SupportsClickCasting(int16 slot_id); + bool SupportsPotionBeltCasting(int16 slot_id); - // Test whether a given slot can support a container item - static bool SupportsContainers(int16 slot_id); + // Test whether a given slot can support a container item + static bool SupportsContainers(int16 slot_id); - int GetSlotByItemInst(EQEmu::ItemInstance *inst); + int GetSlotByItemInst(ItemInstance *inst); - uint8 FindBrightestLightType(); + uint8 FindBrightestLightType(); - void dumpEntireInventory(); - void dumpWornItems(); - void dumpInventory(); - void dumpBankItems(); - void dumpSharedBankItems(); + void dumpEntireInventory(); + void dumpWornItems(); + void dumpInventory(); + void dumpBankItems(); + void dumpSharedBankItems(); - void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, std::string value); - void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, int value); - void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, float value); - void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, bool value); - std::string GetCustomItemData(int16 slot_id, std::string identifier); -protected: - /////////////////////////////// - // Protected Methods - /////////////////////////////// + void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, std::string value); + void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, int value); + void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, float value); + void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, bool value); + std::string GetCustomItemData(int16 slot_id, std::string identifier); + protected: + /////////////////////////////// + // Protected Methods + /////////////////////////////// - int GetSlotByItemInstCollection(const std::map &collection, EQEmu::ItemInstance *inst); - void dumpItemCollection(const std::map &collection); - void dumpBagContents(EQEmu::ItemInstance *inst, std::map::const_iterator *it); + int GetSlotByItemInstCollection(const std::map &collection, ItemInstance *inst); + void dumpItemCollection(const std::map &collection); + void dumpBagContents(ItemInstance *inst, std::map::const_iterator *it); - // Retrieves item within an inventory bucket - EQEmu::ItemInstance* _GetItem(const std::map& bucket, int16 slot_id) const; + // Retrieves item within an inventory bucket + ItemInstance* _GetItem(const std::map& bucket, int16 slot_id) const; - // Private "put" item into bucket, without regard for what is currently in bucket - int16 _PutItem(int16 slot_id, EQEmu::ItemInstance* inst); + // Private "put" item into bucket, without regard for what is currently in bucket + int16 _PutItem(int16 slot_id, ItemInstance* inst); - // Checks an inventory bucket for a particular item - int16 _HasItem(std::map& bucket, uint32 item_id, uint8 quantity); - int16 _HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity); - int16 _HasItemByUse(std::map& bucket, uint8 use, uint8 quantity); - int16 _HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity); - int16 _HasItemByLoreGroup(std::map& bucket, uint32 loregroup); - int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup); + // Checks an inventory bucket for a particular item + int16 _HasItem(std::map& bucket, uint32 item_id, uint8 quantity); + int16 _HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity); + int16 _HasItemByUse(std::map& bucket, uint8 use, uint8 quantity); + int16 _HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity); + int16 _HasItemByLoreGroup(std::map& bucket, uint32 loregroup); + int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup); - // Player inventory - std::map m_worn; // Items worn by character - std::map m_inv; // Items in character personal inventory - std::map m_bank; // Items in character bank - std::map m_shbank; // Items in character shared bank - std::map m_trade; // Items in a trade session - ItemInstQueue m_cursor; // Items on cursor: FIFO + // Player inventory + std::map m_worn; // Items worn by character + std::map m_inv; // Items in character personal inventory + std::map m_bank; // Items in character bank + std::map m_shbank; // Items in character shared bank + std::map m_trade; // Items in a trade session + ::ItemInstQueue m_cursor; // Items on cursor: FIFO -private: - // Active inventory version - EQEmu::versions::InventoryVersion m_inventory_version; - bool m_inventory_version_set; -}; + private: + // Active inventory version + versions::InventoryVersion m_inventory_version; + bool m_inventory_version_set; + }; +} #endif /*COMMON_INVENTORY_PROFILE_H*/ diff --git a/common/item_instance.cpp b/common/item_instance.cpp index de01c0893..61b9d3243 100644 --- a/common/item_instance.cpp +++ b/common/item_instance.cpp @@ -207,12 +207,12 @@ EQEmu::ItemInstance::~ItemInstance() } // Query item type -bool EQEmu::ItemInstance::IsType(EQEmu::item::ItemClass item_class) const +bool EQEmu::ItemInstance::IsType(item::ItemClass item_class) const { // IsType() does not protect against 'm_item = nullptr' // Check usage type - if ((m_use_type == ItemInstWorldContainer) && (item_class == EQEmu::item::ItemClassBag)) + if ((m_use_type == ItemInstWorldContainer) && (item_class == item::ItemClassBag)) return true; if (!m_item) @@ -273,8 +273,8 @@ bool EQEmu::ItemInstance::IsEquipable(int16 slot_id) const // another "shouldn't do" fix..will be fixed in future updates (requires code and database work) int16 use_slot = INVALID_INDEX; - if (slot_id == EQEmu::inventory::slotPowerSource) { use_slot = EQEmu::inventory::slotGeneral1; } - if ((uint16)slot_id <= EQEmu::legacy::EQUIPMENT_END) { use_slot = slot_id; } + if (slot_id == inventory::slotPowerSource) { use_slot = inventory::slotGeneral1; } + if ((uint16)slot_id <= legacy::EQUIPMENT_END) { use_slot = slot_id; } if (use_slot != INVALID_INDEX) { if (m_item->Slots & (1 << use_slot)) @@ -289,7 +289,7 @@ bool EQEmu::ItemInstance::IsAugmentable() const if (!m_item) return false; - for (int index = EQEmu::inventory::socketBegin; index < EQEmu::inventory::SocketCount; ++index) { + for (int index = inventory::socketBegin; index < inventory::SocketCount; ++index) { if (m_item->AugSlotType[index] != 0) return true; } @@ -303,8 +303,8 @@ bool EQEmu::ItemInstance::AvailableWearSlot(uint32 aug_wear_slots) const { if (!m_item || !m_item->IsClassCommon()) return false; - int index = EQEmu::legacy::EQUIPMENT_BEGIN; - for (; index <= EQEmu::inventory::slotGeneral1; ++index) { // MainGeneral1 should be EQEmu::legacy::EQUIPMENT_END + int index = legacy::EQUIPMENT_BEGIN; + for (; index <= inventory::slotGeneral1; ++index) { // MainGeneral1 should be legacy::EQUIPMENT_END if (m_item->Slots & (1 << index)) { if (aug_wear_slots & (1 << index)) break; @@ -319,14 +319,14 @@ int8 EQEmu::ItemInstance::AvailableAugmentSlot(int32 augtype) const if (!m_item || !m_item->IsClassCommon()) return INVALID_INDEX; - int index = EQEmu::inventory::socketBegin; - for (; index < EQEmu::inventory::SocketCount; ++index) { + int index = inventory::socketBegin; + for (; index < inventory::SocketCount; ++index) { if (GetItem(index)) { continue; } if (augtype == -1 || (m_item->AugSlotType[index] && ((1 << (m_item->AugSlotType[index] - 1)) & augtype))) break; } - return (index < EQEmu::inventory::SocketCount) ? index : INVALID_INDEX; + return (index < inventory::SocketCount) ? index : INVALID_INDEX; } bool EQEmu::ItemInstance::IsAugmentSlotAvailable(int32 augtype, uint8 slot) const @@ -416,7 +416,7 @@ void EQEmu::ItemInstance::ClearByFlags(byFlagSetting is_nodrop, byFlagSetting is continue; } - const EQEmu::ItemData* item = inst->GetItem(); + const ItemData* item = inst->GetItem(); if (item == nullptr) { cur = m_contents.erase(cur); continue; @@ -469,7 +469,7 @@ uint8 EQEmu::ItemInstance::FirstOpenSlot() const return INVALID_INDEX; uint8 slots = m_item->BagSlots, i; - for (i = EQEmu::inventory::containerBegin; i < slots; i++) { + for (i = inventory::containerBegin; i < slots; i++) { if (!GetItem(i)) break; } @@ -486,7 +486,7 @@ uint8 EQEmu::ItemInstance::GetTotalItemCount() const if (m_item && !m_item->IsClassBag()) { return item_count; } - for (int index = EQEmu::inventory::containerBegin; index < m_item->BagSlots; ++index) { if (GetItem(index)) { ++item_count; } } + for (int index = inventory::containerBegin; index < m_item->BagSlots; ++index) { if (GetItem(index)) { ++item_count; } } return item_count; } @@ -496,7 +496,7 @@ bool EQEmu::ItemInstance::IsNoneEmptyContainer() if (!m_item || !m_item->IsClassBag()) return false; - for (int index = EQEmu::inventory::containerBegin; index < m_item->BagSlots; ++index) { + for (int index = inventory::containerBegin; index < m_item->BagSlots; ++index) { if (GetItem(index)) return true; } @@ -518,7 +518,7 @@ EQEmu::ItemInstance* EQEmu::ItemInstance::GetOrnamentationAug(int32 ornamentatio if (!m_item || !m_item->IsClassCommon()) { return nullptr; } if (ornamentationAugtype == 0) { return nullptr; } - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; i++) + for (int i = inventory::socketBegin; i < inventory::SocketCount; i++) { if (GetAugment(i) && m_item->AugSlotType[i] == ornamentationAugtype) { @@ -587,10 +587,10 @@ bool EQEmu::ItemInstance::UpdateOrnamentationInfo() { return ornamentSet; } -bool EQEmu::ItemInstance::CanTransform(const EQEmu::ItemData *ItemToTry, const EQEmu::ItemData *Container, bool AllowAll) { +bool EQEmu::ItemInstance::CanTransform(const ItemData *ItemToTry, const ItemData *Container, bool AllowAll) { if (!ItemToTry || !Container) return false; - if (ItemToTry->ItemType == EQEmu::item::ItemTypeArrow || strnlen(Container->CharmFile, 30) == 0) + if (ItemToTry->ItemType == item::ItemTypeArrow || strnlen(Container->CharmFile, 30) == 0) return false; if (AllowAll && strncasecmp(Container->CharmFile, "ITEMTRANSFIGSHIELD", 18) && strncasecmp(Container->CharmFile, "ITEMTransfigBow", 15)) { @@ -685,7 +685,7 @@ bool EQEmu::ItemInstance::IsAugmented() if (!m_item || !m_item->IsClassCommon()) return false; - for (int index = EQEmu::inventory::socketBegin; index < EQEmu::inventory::SocketCount; ++index) { + for (int index = inventory::socketBegin; index < inventory::SocketCount; ++index) { if (GetAugmentItemID(index)) return true; } @@ -699,7 +699,7 @@ bool EQEmu::ItemInstance::IsWeapon() const if (!m_item || !m_item->IsClassCommon()) return false; - if (m_item->ItemType == EQEmu::item::ItemTypeArrow && m_item->Damage != 0) + if (m_item->ItemType == item::ItemTypeArrow && m_item->Damage != 0) return true; else return ((m_item->Damage != 0) && (m_item->Delay != 0)); @@ -710,9 +710,9 @@ bool EQEmu::ItemInstance::IsAmmo() const if (!m_item) return false; - if ((m_item->ItemType == EQEmu::item::ItemTypeArrow) || - (m_item->ItemType == EQEmu::item::ItemTypeLargeThrowing) || - (m_item->ItemType == EQEmu::item::ItemTypeSmallThrowing) + if ((m_item->ItemType == item::ItemTypeArrow) || + (m_item->ItemType == item::ItemTypeLargeThrowing) || + (m_item->ItemType == item::ItemTypeSmallThrowing) ) { return true; } @@ -811,10 +811,10 @@ EQEmu::ItemInstance* EQEmu::ItemInstance::Clone() const bool EQEmu::ItemInstance::IsSlotAllowed(int16 slot_id) const { // 'SupportsContainers' and 'slot_id > 21' previously saw the reassigned PowerSource slot (9999 to 22) as valid if (!m_item) { return false; } - else if (Inventory::SupportsContainers(slot_id)) { return true; } + else if (InventoryProfile::SupportsContainers(slot_id)) { return true; } else if (m_item->Slots & (1 << slot_id)) { return true; } - else if (slot_id == EQEmu::inventory::slotPowerSource && (m_item->Slots & (1 << 22))) { return true; } // got lazy... - else if (slot_id != EQEmu::inventory::slotPowerSource && slot_id > EQEmu::legacy::EQUIPMENT_END) { return true; } + else if (slot_id == inventory::slotPowerSource && (m_item->Slots & (1 << 22))) { return true; } // got lazy... + else if (slot_id != inventory::slotPowerSource && slot_id > legacy::EQUIPMENT_END) { return true; } else { return false; } } @@ -966,7 +966,7 @@ int EQEmu::ItemInstance::GetItemArmorClass(bool augments) const if (item) { ac = item->AC; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) ac += GetAugment(i)->GetItemArmorClass(); } @@ -1008,7 +1008,7 @@ int EQEmu::ItemInstance::GetItemElementalDamage(int &magic, int &fire, int &cold } if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) GetAugment(i)->GetItemElementalDamage(magic, fire, cold, poison, disease, chromatic, prismatic, physical, corruption); } @@ -1025,7 +1025,7 @@ int EQEmu::ItemInstance::GetItemElementalFlag(bool augments) const return flag; if (augments) { - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) { + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) { if (GetAugment(i)) flag = GetAugment(i)->GetItemElementalFlag(); if (flag) @@ -1046,7 +1046,7 @@ int EQEmu::ItemInstance::GetItemElementalDamage(bool augments) const return damage; if (augments) { - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) { + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) { if (GetAugment(i)) damage = GetAugment(i)->GetItemElementalDamage(); if (damage) @@ -1065,7 +1065,7 @@ int EQEmu::ItemInstance::GetItemRecommendedLevel(bool augments) const level = item->RecLevel; if (augments) { - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) { + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) { int temp = 0; if (GetAugment(i)) { temp = GetAugment(i)->GetItemRecommendedLevel(); @@ -1087,7 +1087,7 @@ int EQEmu::ItemInstance::GetItemRequiredLevel(bool augments) const level = item->ReqLevel; if (augments) { - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) { + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) { int temp = 0; if (GetAugment(i)) { temp = GetAugment(i)->GetItemRequiredLevel(); @@ -1109,7 +1109,7 @@ int EQEmu::ItemInstance::GetItemWeaponDamage(bool augments) const damage = item->Damage; if (augments) { - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) damage += GetAugment(i)->GetItemWeaponDamage(); } @@ -1125,7 +1125,7 @@ int EQEmu::ItemInstance::GetItemBackstabDamage(bool augments) const damage = item->BackstabDmg; if (augments) { - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) damage += GetAugment(i)->GetItemBackstabDamage(); } @@ -1143,7 +1143,7 @@ int EQEmu::ItemInstance::GetItemBaneDamageBody(bool augments) const return body; if (augments) { - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) { body = GetAugment(i)->GetItemBaneDamageBody(); if (body) @@ -1164,7 +1164,7 @@ int EQEmu::ItemInstance::GetItemBaneDamageRace(bool augments) const return race; if (augments) { - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) { race = GetAugment(i)->GetItemBaneDamageRace(); if (race) @@ -1184,7 +1184,7 @@ int EQEmu::ItemInstance::GetItemBaneDamageBody(bodyType against, bool augments) damage += item->BaneDmgAmt; if (augments) { - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) damage += GetAugment(i)->GetItemBaneDamageBody(against); } @@ -1201,7 +1201,7 @@ int EQEmu::ItemInstance::GetItemBaneDamageRace(uint16 against, bool augments) co damage += item->BaneDmgRaceAmt; if (augments) { - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) damage += GetAugment(i)->GetItemBaneDamageRace(against); } @@ -1217,7 +1217,7 @@ int EQEmu::ItemInstance::GetItemMagical(bool augments) const return 1; if (augments) { - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i) && GetAugment(i)->GetItemMagical()) return 1; } @@ -1232,7 +1232,7 @@ int EQEmu::ItemInstance::GetItemHP(bool augments) const if (item) { hp = item->HP; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) hp += GetAugment(i)->GetItemHP(); } @@ -1246,7 +1246,7 @@ int EQEmu::ItemInstance::GetItemMana(bool augments) const if (item) { mana = item->Mana; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) mana += GetAugment(i)->GetItemMana(); } @@ -1260,7 +1260,7 @@ int EQEmu::ItemInstance::GetItemEndur(bool augments) const if (item) { endur = item->Endur; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) endur += GetAugment(i)->GetItemEndur(); } @@ -1274,7 +1274,7 @@ int EQEmu::ItemInstance::GetItemAttack(bool augments) const if (item) { atk = item->Attack; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) atk += GetAugment(i)->GetItemAttack(); } @@ -1288,7 +1288,7 @@ int EQEmu::ItemInstance::GetItemStr(bool augments) const if (item) { str = item->AStr; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) str += GetAugment(i)->GetItemStr(); } @@ -1302,7 +1302,7 @@ int EQEmu::ItemInstance::GetItemSta(bool augments) const if (item) { sta = item->ASta; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) sta += GetAugment(i)->GetItemSta(); } @@ -1316,7 +1316,7 @@ int EQEmu::ItemInstance::GetItemDex(bool augments) const if (item) { total = item->ADex; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemDex(); } @@ -1330,7 +1330,7 @@ int EQEmu::ItemInstance::GetItemAgi(bool augments) const if (item) { total = item->AAgi; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemAgi(); } @@ -1344,7 +1344,7 @@ int EQEmu::ItemInstance::GetItemInt(bool augments) const if (item) { total = item->AInt; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemInt(); } @@ -1358,7 +1358,7 @@ int EQEmu::ItemInstance::GetItemWis(bool augments) const if (item) { total = item->AWis; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemWis(); } @@ -1372,7 +1372,7 @@ int EQEmu::ItemInstance::GetItemCha(bool augments) const if (item) { total = item->ACha; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemCha(); } @@ -1386,7 +1386,7 @@ int EQEmu::ItemInstance::GetItemMR(bool augments) const if (item) { total = item->MR; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemMR(); } @@ -1400,7 +1400,7 @@ int EQEmu::ItemInstance::GetItemFR(bool augments) const if (item) { total = item->FR; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemFR(); } @@ -1414,7 +1414,7 @@ int EQEmu::ItemInstance::GetItemCR(bool augments) const if (item) { total = item->CR; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemCR(); } @@ -1428,7 +1428,7 @@ int EQEmu::ItemInstance::GetItemPR(bool augments) const if (item) { total = item->PR; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemPR(); } @@ -1442,7 +1442,7 @@ int EQEmu::ItemInstance::GetItemDR(bool augments) const if (item) { total = item->DR; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemDR(); } @@ -1456,7 +1456,7 @@ int EQEmu::ItemInstance::GetItemCorrup(bool augments) const if (item) { total = item->SVCorruption; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemCorrup(); } @@ -1470,7 +1470,7 @@ int EQEmu::ItemInstance::GetItemHeroicStr(bool augments) const if (item) { total = item->HeroicStr; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemHeroicStr(); } @@ -1484,7 +1484,7 @@ int EQEmu::ItemInstance::GetItemHeroicSta(bool augments) const if (item) { total = item->HeroicSta; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemHeroicSta(); } @@ -1498,7 +1498,7 @@ int EQEmu::ItemInstance::GetItemHeroicDex(bool augments) const if (item) { total = item->HeroicDex; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemHeroicDex(); } @@ -1512,7 +1512,7 @@ int EQEmu::ItemInstance::GetItemHeroicAgi(bool augments) const if (item) { total = item->HeroicAgi; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemHeroicAgi(); } @@ -1526,7 +1526,7 @@ int EQEmu::ItemInstance::GetItemHeroicInt(bool augments) const if (item) { total = item->HeroicInt; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemHeroicInt(); } @@ -1540,7 +1540,7 @@ int EQEmu::ItemInstance::GetItemHeroicWis(bool augments) const if (item) { total = item->HeroicWis; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemHeroicWis(); } @@ -1554,7 +1554,7 @@ int EQEmu::ItemInstance::GetItemHeroicCha(bool augments) const if (item) { total = item->HeroicCha; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemHeroicCha(); } @@ -1568,7 +1568,7 @@ int EQEmu::ItemInstance::GetItemHeroicMR(bool augments) const if (item) { total = item->HeroicMR; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemHeroicMR(); } @@ -1582,7 +1582,7 @@ int EQEmu::ItemInstance::GetItemHeroicFR(bool augments) const if (item) { total = item->HeroicFR; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemHeroicFR(); } @@ -1596,7 +1596,7 @@ int EQEmu::ItemInstance::GetItemHeroicCR(bool augments) const if (item) { total = item->HeroicCR; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemHeroicCR(); } @@ -1610,7 +1610,7 @@ int EQEmu::ItemInstance::GetItemHeroicPR(bool augments) const if (item) { total = item->HeroicPR; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemHeroicPR(); } @@ -1624,7 +1624,7 @@ int EQEmu::ItemInstance::GetItemHeroicDR(bool augments) const if (item) { total = item->HeroicDR; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemHeroicDR(); } @@ -1638,7 +1638,7 @@ int EQEmu::ItemInstance::GetItemHeroicCorrup(bool augments) const if (item) { total = item->HeroicSVCorrup; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) total += GetAugment(i)->GetItemHeroicCorrup(); } @@ -1652,7 +1652,7 @@ int EQEmu::ItemInstance::GetItemHaste(bool augments) const if (item) { total = item->Haste; if (augments) - for (int i = EQEmu::inventory::socketBegin; i < EQEmu::inventory::SocketCount; ++i) + for (int i = inventory::socketBegin; i < inventory::SocketCount; ++i) if (GetAugment(i)) { int temp = GetAugment(i)->GetItemHaste(); if (temp > total) diff --git a/common/item_instance.h b/common/item_instance.h index 2a4afdca1..90dd1403f 100644 --- a/common/item_instance.h +++ b/common/item_instance.h @@ -52,7 +52,6 @@ typedef enum { } byFlagSetting; class SharedDatabase; -class Inventory; // ######################################## // Class: EQEmu::ItemInstance @@ -61,6 +60,8 @@ class Inventory; // to an item instance (includes dye, augments, charges, etc) namespace EQEmu { + class InventoryProfile; + class ItemInstance { public: ///////////////////////// @@ -79,7 +80,7 @@ namespace EQEmu ~ItemInstance(); // Query item type - bool IsType(EQEmu::item::ItemClass item_class) const; + bool IsType(item::ItemClass item_class) const; bool IsClassCommon() const; bool IsClassBag() const; @@ -102,7 +103,7 @@ namespace EQEmu bool IsAugmentSlotAvailable(int32 augtype, uint8 slot) const; inline int32 GetAugmentType() const { return ((m_item) ? m_item->AugType : 0); } - inline bool IsExpendable() const { return ((m_item) ? ((m_item->Click.Type == EQEmu::item::ItemEffectExpendable) || (m_item->ItemType == EQEmu::item::ItemTypePotion)) : false); } + inline bool IsExpendable() const { return ((m_item) ? ((m_item->Click.Type == item::ItemEffectExpendable) || (m_item->ItemType == item::ItemTypePotion)) : false); } // // Contents @@ -133,7 +134,7 @@ namespace EQEmu bool IsAugmented(); ItemInstance* GetOrnamentationAug(int32 ornamentationAugtype) const; bool UpdateOrnamentationInfo(); - static bool CanTransform(const EQEmu::ItemData *ItemToTry, const EQEmu::ItemData *Container, bool AllowAll = false); + static bool CanTransform(const ItemData *ItemToTry, const ItemData *Container, bool AllowAll = false); // Has attack/delay? bool IsWeapon() const; @@ -211,8 +212,8 @@ namespace EQEmu int8 GetMaxEvolveLvl() const; uint32 GetKillsNeeded(uint8 currentlevel); - std::string Serialize(int16 slot_id) const { EQEmu::InternalSerializedItem_Struct s; s.slot_id = slot_id; s.inst = (const void*)this; std::string ser; ser.assign((char*)&s, sizeof(EQEmu::InternalSerializedItem_Struct)); return ser; } - void Serialize(EQEmu::OutBuffer& ob, int16 slot_id) const { EQEmu::InternalSerializedItem_Struct isi; isi.slot_id = slot_id; isi.inst = (const void*)this; ob.write((const char*)&isi, sizeof(isi)); } + std::string Serialize(int16 slot_id) const { InternalSerializedItem_Struct s; s.slot_id = slot_id; s.inst = (const void*)this; std::string ser; ser.assign((char*)&s, sizeof(InternalSerializedItem_Struct)); return ser; } + void Serialize(OutBuffer& ob, int16 slot_id) const { InternalSerializedItem_Struct isi; isi.slot_id = slot_id; isi.inst = (const void*)this; ob.write((const char*)&isi, sizeof(isi)); } inline int32 GetSerialNumber() const { return m_SerialNumber; } inline void SetSerialNumber(int32 id) { m_SerialNumber = id; } @@ -278,7 +279,7 @@ namespace EQEmu ////////////////////////// // Protected Members ////////////////////////// - friend class ::Inventory; + friend class InventoryProfile; std::map::const_iterator _cbegin() { return m_contents.cbegin(); } std::map::const_iterator _cend() { return m_contents.cend(); } @@ -299,7 +300,7 @@ namespace EQEmu int8 m_evolveLvl; bool m_activated; ItemData* m_scaledItem; - EvolveInfo* m_evolveInfo; + ::EvolveInfo* m_evolveInfo; bool m_scaling; uint32 m_ornamenticon; uint32 m_ornamentidfile; diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp index cc1744a31..6d13bb338 100644 --- a/common/patches/rof.cpp +++ b/common/patches/rof.cpp @@ -5264,7 +5264,7 @@ namespace RoF if (inst->GetOrnamentationIDFile() && inst->GetOrnamentationIcon()) { ornaIcon = inst->GetOrnamentationIcon(); - heroModel = inst->GetOrnamentHeroModel(Inventory::CalcMaterialFromSlot(slot_id_in)); + heroModel = inst->GetOrnamentHeroModel(EQEmu::InventoryProfile::CalcMaterialFromSlot(slot_id_in)); char tmp[30]; memset(tmp, 0x0, 30); sprintf(tmp, "IT%d", inst->GetOrnamentationIDFile()); diff --git a/common/patches/rof2.cpp b/common/patches/rof2.cpp index aadd0a90b..14fcdc2e6 100644 --- a/common/patches/rof2.cpp +++ b/common/patches/rof2.cpp @@ -5555,7 +5555,7 @@ namespace RoF2 if (inst->GetOrnamentationIDFile() && inst->GetOrnamentationIcon()) { ornaIcon = inst->GetOrnamentationIcon(); - heroModel = inst->GetOrnamentHeroModel(Inventory::CalcMaterialFromSlot(slot_id_in)); + heroModel = inst->GetOrnamentHeroModel(EQEmu::InventoryProfile::CalcMaterialFromSlot(slot_id_in)); char tmp[30]; memset(tmp, 0x0, 30); sprintf(tmp, "IT%d", inst->GetOrnamentationIDFile()); diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 8cd62f164..fd55b3766 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -184,7 +184,7 @@ bool SharedDatabase::SaveInventory(uint32 char_id, const EQEmu::ItemInstance* in else { // Needed to clear out bag slots that 'REPLACE' in UpdateSharedBankSlot does not overwrite..otherwise, duplication occurs // (This requires that parent then child items be sent..which should be how they are currently passed) - if (Inventory::SupportsContainers(slot_id)) + if (EQEmu::InventoryProfile::SupportsContainers(slot_id)) DeleteSharedBankSlot(char_id, slot_id); return UpdateSharedBankSlot(char_id, inst, slot_id); } @@ -195,7 +195,7 @@ bool SharedDatabase::SaveInventory(uint32 char_id, const EQEmu::ItemInstance* in // Needed to clear out bag slots that 'REPLACE' in UpdateInventorySlot does not overwrite..otherwise, duplication occurs // (This requires that parent then child items be sent..which should be how they are currently passed) - if (Inventory::SupportsContainers(slot_id)) + if (EQEmu::InventoryProfile::SupportsContainers(slot_id)) DeleteInventorySlot(char_id, slot_id); return UpdateInventorySlot(char_id, inst, slot_id); } @@ -232,12 +232,12 @@ bool SharedDatabase::UpdateInventorySlot(uint32 char_id, const EQEmu::ItemInstan auto results = QueryDatabase(query); // Save bag contents, if slot supports bag contents - if (inst->IsClassBag() && Inventory::SupportsContainers(slot_id)) + if (inst->IsClassBag() && EQEmu::InventoryProfile::SupportsContainers(slot_id)) // Limiting to bag slot count will get rid of 'hidden' duplicated items and 'Invalid Slot ID' // messages through attrition (and the modded code in SaveInventory) for (uint8 idx = EQEmu::inventory::containerBegin; idx < inst->GetItem()->BagSlots && idx < EQEmu::inventory::ContainerCount; idx++) { const EQEmu::ItemInstance* baginst = inst->GetItem(idx); - SaveInventory(char_id, baginst, Inventory::CalcSlotId(slot_id, idx)); + SaveInventory(char_id, baginst, EQEmu::InventoryProfile::CalcSlotId(slot_id, idx)); } if (!results.Success()) { @@ -278,12 +278,12 @@ bool SharedDatabase::UpdateSharedBankSlot(uint32 char_id, const EQEmu::ItemInsta auto results = QueryDatabase(query); // Save bag contents, if slot supports bag contents - if (inst->IsClassBag() && Inventory::SupportsContainers(slot_id)) { + if (inst->IsClassBag() && EQEmu::InventoryProfile::SupportsContainers(slot_id)) { // Limiting to bag slot count will get rid of 'hidden' duplicated items and 'Invalid Slot ID' // messages through attrition (and the modded code in SaveInventory) for (uint8 idx = EQEmu::inventory::containerBegin; idx < inst->GetItem()->BagSlots && idx < EQEmu::inventory::ContainerCount; idx++) { const EQEmu::ItemInstance* baginst = inst->GetItem(idx); - SaveInventory(char_id, baginst, Inventory::CalcSlotId(slot_id, idx)); + SaveInventory(char_id, baginst, EQEmu::InventoryProfile::CalcSlotId(slot_id, idx)); } } @@ -304,10 +304,10 @@ bool SharedDatabase::DeleteInventorySlot(uint32 char_id, int16 slot_id) { } // Delete bag slots, if need be - if (!Inventory::SupportsContainers(slot_id)) + if (!EQEmu::InventoryProfile::SupportsContainers(slot_id)) return true; - int16 base_slot_id = Inventory::CalcSlotId(slot_id, EQEmu::inventory::containerBegin); + int16 base_slot_id = EQEmu::InventoryProfile::CalcSlotId(slot_id, EQEmu::inventory::containerBegin); query = StringFormat("DELETE FROM inventory WHERE charid = %i AND slotid >= %i AND slotid < %i", char_id, base_slot_id, (base_slot_id+10)); results = QueryDatabase(query); @@ -330,10 +330,10 @@ bool SharedDatabase::DeleteSharedBankSlot(uint32 char_id, int16 slot_id) { } // Delete bag slots, if need be - if (!Inventory::SupportsContainers(slot_id)) + if (!EQEmu::InventoryProfile::SupportsContainers(slot_id)) return true; - int16 base_slot_id = Inventory::CalcSlotId(slot_id, EQEmu::inventory::containerBegin); + int16 base_slot_id = EQEmu::InventoryProfile::CalcSlotId(slot_id, EQEmu::inventory::containerBegin); query = StringFormat("DELETE FROM sharedbank WHERE acctid = %i " "AND slotid >= %i AND slotid < %i", account_id, base_slot_id, (base_slot_id+10)); @@ -373,7 +373,7 @@ bool SharedDatabase::SetSharedPlatinum(uint32 account_id, int32 amount_to_add) { return true; } -bool SharedDatabase::SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin_level) { +bool SharedDatabase::SetStartingItems(PlayerProfile_Struct* pp, EQEmu::InventoryProfile* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin_level) { const EQEmu::ItemData* myitem; @@ -410,7 +410,7 @@ bool SharedDatabase::SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv, // Retrieve shared bank inventory based on either account or character -bool SharedDatabase::GetSharedBank(uint32 id, Inventory *inv, bool is_charid) +bool SharedDatabase::GetSharedBank(uint32 id, EQEmu::InventoryProfile *inv, bool is_charid) { std::string query; @@ -511,7 +511,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory *inv, bool is_charid) } // Overloaded: Retrieve character inventory based on character id -bool SharedDatabase::GetInventory(uint32 char_id, Inventory *inv) +bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::InventoryProfile *inv) { // Retrieve character inventory std::string query = @@ -653,7 +653,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory *inv) } // Overloaded: Retrieve character inventory based on account_id and character name -bool SharedDatabase::GetInventory(uint32 account_id, char *name, Inventory *inv) +bool SharedDatabase::GetInventory(uint32 account_id, char *name, EQEmu::InventoryProfile *inv) { // Retrieve character inventory std::string query = diff --git a/common/shareddb.h b/common/shareddb.h index 42dfcf4ce..b58d1f138 100644 --- a/common/shareddb.h +++ b/common/shareddb.h @@ -33,7 +33,6 @@ #include class EvolveInfo; -class Inventory; struct BaseDataStruct; struct InspectMessage_Struct; struct PlayerProfile_Struct; @@ -46,6 +45,7 @@ namespace EQEmu { struct ItemData; class ItemInstance; + class InventoryProfile; class MemoryMappedFile; } @@ -74,7 +74,7 @@ class SharedDatabase : public Database uint32 GetTotalTimeEntitledOnAccount(uint32 AccountID); /* - Character Inventory + Character InventoryProfile */ bool SaveCursor(uint32 char_id, std::list::const_iterator &start, std::list::const_iterator &end); bool SaveInventory(uint32 char_id, const EQEmu::ItemInstance* inst, int16 slot_id); @@ -83,15 +83,15 @@ class SharedDatabase : public Database bool UpdateInventorySlot(uint32 char_id, const EQEmu::ItemInstance* inst, int16 slot_id); bool UpdateSharedBankSlot(uint32 char_id, const EQEmu::ItemInstance* inst, int16 slot_id); bool VerifyInventory(uint32 account_id, int16 slot_id, const EQEmu::ItemInstance* inst); - bool GetSharedBank(uint32 id, Inventory* inv, bool is_charid); + bool GetSharedBank(uint32 id, EQEmu::InventoryProfile* inv, bool is_charid); int32 GetSharedPlatinum(uint32 account_id); bool SetSharedPlatinum(uint32 account_id, int32 amount_to_add); - bool GetInventory(uint32 char_id, Inventory* inv); - bool GetInventory(uint32 account_id, char* name, Inventory* inv); + bool GetInventory(uint32 char_id, EQEmu::InventoryProfile* inv); + bool GetInventory(uint32 account_id, char* name, EQEmu::InventoryProfile* inv); std::map GetItemRecastTimestamps(uint32 char_id); uint32 GetItemRecastTimestamp(uint32 char_id, uint32 recast_type); void ClearOldRecastTimestamps(uint32 char_id); - bool SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin); + bool SetStartingItems(PlayerProfile_Struct* pp, EQEmu::InventoryProfile* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin); std::string GetBook(const char *txtfile); diff --git a/world/client.cpp b/world/client.cpp index 5614d6317..29abc5b9d 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -1399,7 +1399,7 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc) { PlayerProfile_Struct pp; ExtendedProfile_Struct ext; - Inventory inv; + EQEmu::InventoryProfile inv; time_t bday = time(nullptr); char startzone[50]={0}; uint32 i; diff --git a/world/worlddb.cpp b/world/worlddb.cpp index 65476190e..5cac4b648 100644 --- a/world/worlddb.cpp +++ b/world/worlddb.cpp @@ -96,7 +96,7 @@ void WorldDatabase::GetCharSelectInfo(uint32 accountID, EQApplicationPacket **ou for (auto row = results.begin(); row != results.end(); ++row) { CharacterSelectEntry_Struct *cse = (CharacterSelectEntry_Struct *)buff_ptr; PlayerProfile_Struct pp; - Inventory inv; + EQEmu::InventoryProfile inv; uint32 character_id = (uint32)atoi(row[0]); uint8 has_home = 0; uint8 has_bind = 0; @@ -249,7 +249,7 @@ void WorldDatabase::GetCharSelectInfo(uint32 accountID, EQApplicationPacket **ou int16 invslot = 0; for (uint32 matslot = EQEmu::textures::textureBegin; matslot < EQEmu::textures::materialCount; matslot++) { - invslot = Inventory::CalcSlotFromMaterial(matslot); + invslot = EQEmu::InventoryProfile::CalcSlotFromMaterial(matslot); if (invslot == INVALID_INDEX) { continue; } inst = inv.GetItem(invslot); if (inst == nullptr) { continue; } diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index 4ff4fbabe..760ca52dc 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -3325,7 +3325,7 @@ bool Client::CalcItemScale(uint32 slot_x, uint32 slot_y) { // TEST CODE: test for bazaar trader crashing with charm items if (Trader) if (i >= EQEmu::legacy::GENERAL_BAGS_BEGIN && i <= EQEmu::legacy::GENERAL_BAGS_END) { - EQEmu::ItemInstance* parent_item = m_inv.GetItem(Inventory::CalcSlotId(i)); + EQEmu::ItemInstance* parent_item = m_inv.GetItem(EQEmu::InventoryProfile::CalcSlotId(i)); if (parent_item && parent_item->GetItem()->ID == 17899) // trader satchel continue; } @@ -3418,7 +3418,7 @@ bool Client::DoItemEnterZone(uint32 slot_x, uint32 slot_y) { // TEST CODE: test for bazaar trader crashing with charm items if (Trader) if (i >= EQEmu::legacy::GENERAL_BAGS_BEGIN && i <= EQEmu::legacy::GENERAL_BAGS_END) { - EQEmu::ItemInstance* parent_item = m_inv.GetItem(Inventory::CalcSlotId(i)); + EQEmu::ItemInstance* parent_item = m_inv.GetItem(EQEmu::InventoryProfile::CalcSlotId(i)); if (parent_item && parent_item->GetItem()->ID == 17899) // trader satchel continue; } diff --git a/zone/bot.cpp b/zone/bot.cpp index 03ba04dfd..1629580bf 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -2875,7 +2875,7 @@ void Bot::Spawn(Client* botCharacterOwner) { for (int i = EQEmu::legacy::EQUIPMENT_BEGIN; i <= EQEmu::legacy::EQUIPMENT_END; ++i) { itemID = GetBotItemBySlot(i); if(itemID != 0) { - materialFromSlot = Inventory::CalcMaterialFromSlot(i); + materialFromSlot = EQEmu::InventoryProfile::CalcMaterialFromSlot(i); if(materialFromSlot != 0xFF) this->SendWearChange(materialFromSlot); } @@ -2897,7 +2897,7 @@ void Bot::RemoveBotItemBySlot(uint32 slotID, std::string *errorMessage) } // Retrieves all the inventory records from the database for this bot. -void Bot::GetBotItems(Inventory &inv, std::string* errorMessage) +void Bot::GetBotItems(EQEmu::InventoryProfile &inv, std::string* errorMessage) { if(!GetBotID()) return; @@ -3235,7 +3235,7 @@ EQEmu::ItemInstance* Bot::GetBotItem(uint32 slotID) { // Adds the specified item it bot to the NPC equipment array and to the bot inventory collection. void Bot::BotAddEquipItem(int slot, uint32 id) { if(slot > 0 && id > 0) { - uint8 materialFromSlot = Inventory::CalcMaterialFromSlot(slot); + uint8 materialFromSlot = EQEmu::InventoryProfile::CalcMaterialFromSlot(slot); if (materialFromSlot != EQEmu::textures::materialInvalid) { equipment[slot] = id; // npc has more than just material slots. Valid material should mean valid inventory index @@ -3251,7 +3251,7 @@ void Bot::BotAddEquipItem(int slot, uint32 id) { // Erases the specified item from bot the NPC equipment array and from the bot inventory collection. void Bot::BotRemoveEquipItem(int slot) { if(slot > 0) { - uint8 materialFromSlot = Inventory::CalcMaterialFromSlot(slot); + uint8 materialFromSlot = EQEmu::InventoryProfile::CalcMaterialFromSlot(slot); if (materialFromSlot != EQEmu::textures::materialInvalid) { equipment[slot] = 0; // npc has more than just material slots. Valid material should mean valid inventory index @@ -3382,7 +3382,7 @@ void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* cli bool UpdateClient = false; bool already_returned = false; - Inventory& clientInventory = client->GetInv(); + EQEmu::InventoryProfile& clientInventory = client->GetInv(); const EQEmu::ItemInstance* inst = clientInventory[i]; if(inst) { items[i] = inst->GetItem()->ID; @@ -8434,7 +8434,7 @@ bool Bot::DyeArmor(int16 slot_id, uint32 rgb, bool all_flag, bool save_flag) return false; for (uint8 i = EQEmu::textures::textureBegin; i < EQEmu::textures::weaponPrimary; ++i) { - uint8 inv_slot = Inventory::CalcSlotFromMaterial(i); + uint8 inv_slot = EQEmu::InventoryProfile::CalcSlotFromMaterial(i); EQEmu::ItemInstance* inst = m_inv.GetItem(inv_slot); if (!inst) continue; @@ -8444,7 +8444,7 @@ bool Bot::DyeArmor(int16 slot_id, uint32 rgb, bool all_flag, bool save_flag) } } else { - uint8 mat_slot = Inventory::CalcMaterialFromSlot(slot_id); + uint8 mat_slot = EQEmu::InventoryProfile::CalcMaterialFromSlot(slot_id); if (mat_slot == EQEmu::textures::materialInvalid || mat_slot >= EQEmu::textures::weaponPrimary) return false; diff --git a/zone/bot.h b/zone/bot.h index 96ca86eec..736a464ab 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -647,7 +647,7 @@ private: bool _petChooser; uint8 _petChooserID; bool berserk; - Inventory m_inv; + EQEmu::InventoryProfile m_inv; double _lastTotalPlayTime; time_t _startTotalPlayTime; Mob* _previousTarget; @@ -711,7 +711,7 @@ private: void SetBotID(uint32 botID); // Private "Inventory" Methods - void GetBotItems(Inventory &inv, std::string* errorMessage); + void GetBotItems(EQEmu::InventoryProfile &inv, std::string* errorMessage); void BotAddEquipItem(int slot, uint32 id); uint32 GetBotItemBySlot(uint32 slotID); diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index 57dd2d418..72ac6cae4 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -4375,7 +4375,7 @@ void bot_subcommand_bot_dye_armor(Client *c, const Seperator *sep) bool dye_all = (sep->arg[1][0] == '*'); if (!dye_all) { material_slot = atoi(sep->arg[1]); - slot_id = Inventory::CalcSlotFromMaterial(material_slot); + slot_id = EQEmu::InventoryProfile::CalcSlotFromMaterial(material_slot); if (!sep->IsNumber(1) || slot_id == INVALID_INDEX || material_slot > EQEmu::textures::LastTintableTexture) { c->Message(m_fail, "Valid [mat_slot]s for this command are:"); diff --git a/zone/bot_database.cpp b/zone/bot_database.cpp index 259df1d63..04ce5b281 100644 --- a/zone/bot_database.cpp +++ b/zone/bot_database.cpp @@ -1023,7 +1023,7 @@ bool BotDatabase::QueryInventoryCount(const uint32 bot_id, uint32& item_count) return true; } -bool BotDatabase::LoadItems(const uint32 bot_id, Inventory& inventory_inst) +bool BotDatabase::LoadItems(const uint32 bot_id, EQEmu::InventoryProfile& inventory_inst) { if (!bot_id) return false; @@ -1279,7 +1279,7 @@ bool BotDatabase::LoadEquipmentColor(const uint32 bot_id, const uint8 material_s if (!bot_id) return false; - int16 slot_id = Inventory::CalcSlotFromMaterial(material_slot_id); + int16 slot_id = EQEmu::InventoryProfile::CalcSlotFromMaterial(material_slot_id); if (slot_id == INVALID_INDEX) return false; diff --git a/zone/bot_database.h b/zone/bot_database.h index 3eaaf21d9..b7245306f 100644 --- a/zone/bot_database.h +++ b/zone/bot_database.h @@ -31,12 +31,12 @@ class Bot; -class Inventory; struct BotsAvailableList; namespace EQEmu { class ItemInstance; + class InventoryProfile; } @@ -89,7 +89,7 @@ public: /* Bot inventory functions */ bool QueryInventoryCount(const uint32 bot_id, uint32& item_count); - bool LoadItems(const uint32 bot_id, Inventory &inventory_inst); + bool LoadItems(const uint32 bot_id, EQEmu::InventoryProfile &inventory_inst); bool SaveItems(Bot* bot_inst); bool DeleteItems(const uint32 bot_id); diff --git a/zone/client.cpp b/zone/client.cpp index 09f843616..3f914d1ae 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -2799,7 +2799,7 @@ void Client::SetMaterial(int16 in_slot, uint32 item_id) { const EQEmu::ItemData* item = database.GetItem(item_id); if (item && item->IsClassCommon()) { - uint8 matslot = Inventory::CalcMaterialFromSlot(in_slot); + uint8 matslot = EQEmu::InventoryProfile::CalcMaterialFromSlot(in_slot); if (matslot != EQEmu::textures::materialInvalid) { m_pp.item_material.Slot[matslot].Material = GetEquipmentMaterial(matslot); @@ -3141,7 +3141,7 @@ void Client::SetTint(int16 in_slot, uint32 color) { // Still need to reconcile bracer01 versus bracer02 void Client::SetTint(int16 in_slot, EQEmu::textures::Tint_Struct& color) { - uint8 matslot = Inventory::CalcMaterialFromSlot(in_slot); + uint8 matslot = EQEmu::InventoryProfile::CalcMaterialFromSlot(in_slot); if (matslot != EQEmu::textures::materialInvalid) { m_pp.item_tint.Slot[matslot].Color = color.Color; diff --git a/zone/client.h b/zone/client.h index 82ee442d2..c7973de18 100644 --- a/zone/client.h +++ b/zone/client.h @@ -340,8 +340,8 @@ public: inline uint8 GetAnon() const { return m_pp.anon; } inline PlayerProfile_Struct& GetPP() { return m_pp; } inline ExtendedProfile_Struct& GetEPP() { return m_epp; } - inline Inventory& GetInv() { return m_inv; } - inline const Inventory& GetInv() const { return m_inv; } + inline EQEmu::InventoryProfile& GetInv() { return m_inv; } + inline const EQEmu::InventoryProfile& GetInv() const { return m_inv; } inline PetInfo* GetPetInfo(uint16 pet) { return (pet==1)?&m_suspendedminion:&m_petinfo; } inline InspectMessage_Struct& GetInspectMessage() { return m_inspect_message; } inline const InspectMessage_Struct& GetInspectMessage() const { return m_inspect_message; } @@ -1395,7 +1395,7 @@ private: PlayerProfile_Struct m_pp; ExtendedProfile_Struct m_epp; - Inventory m_inv; + EQEmu::InventoryProfile m_inv; Object* m_tradeskill_object; PetInfo m_petinfo; // current pet data, used while loading from and saving to DB PetInfo m_suspendedminion; // pet data for our suspended minion. diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index a537c1db2..0b6221c2a 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -2939,11 +2939,11 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app) // in_augment->container_slot, in_augment->augment_slot, in_augment->container_index, in_augment->augment_index, in_augment->augment_action, in_augment->dest_inst_id); EQEmu::ItemInstance *tobe_auged = nullptr, *old_aug = nullptr, *new_aug = nullptr, *aug = nullptr, *solvent = nullptr; - Inventory& user_inv = GetInv(); + EQEmu::InventoryProfile& user_inv = GetInv(); uint16 item_slot = in_augment->container_slot; uint16 solvent_slot = in_augment->augment_slot; - uint8 mat = Inventory::CalcMaterialFromSlot(item_slot); // for when player is augging a piece of equipment while they're wearing it + uint8 mat = EQEmu::InventoryProfile::CalcMaterialFromSlot(item_slot); // for when player is augging a piece of equipment while they're wearing it if (item_slot == INVALID_INDEX || solvent_slot == INVALID_INDEX) { diff --git a/zone/command.cpp b/zone/command.cpp index 487e25286..d75dec901 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -2596,7 +2596,7 @@ void command_peekinv(Client *c, const Seperator *sep) item_link = linker.GenerateLink(); c->Message((item_data == nullptr), " InvBagSlot: %i (Slot #%i, Bag #%i), Item: %i (%s), Charges: %i", - Inventory::CalcSlotId(indexMain, indexSub), indexMain, indexSub, ((item_data == nullptr) ? 0 : item_data->ID), item_link.c_str(), ((inst_sub == nullptr) ? 0 : inst_sub->GetCharges())); + EQEmu::InventoryProfile::CalcSlotId(indexMain, indexSub), indexMain, indexSub, ((item_data == nullptr) ? 0 : item_data->ID), item_link.c_str(), ((inst_sub == nullptr) ? 0 : inst_sub->GetCharges())); } } @@ -2630,7 +2630,7 @@ void command_peekinv(Client *c, const Seperator *sep) item_link = linker.GenerateLink(); c->Message((item_data == nullptr), " CursorBagSlot: %i (Slot #%i, Bag #%i), Item: %i (%s), Charges: %i", - Inventory::CalcSlotId(EQEmu::inventory::slotCursor, indexSub), EQEmu::inventory::slotCursor, indexSub, ((item_data == nullptr) ? 0 : item_data->ID), item_link.c_str(), ((inst_sub == nullptr) ? 0 : inst_sub->GetCharges())); + EQEmu::InventoryProfile::CalcSlotId(EQEmu::inventory::slotCursor, indexSub), EQEmu::inventory::slotCursor, indexSub, ((item_data == nullptr) ? 0 : item_data->ID), item_link.c_str(), ((inst_sub == nullptr) ? 0 : inst_sub->GetCharges())); } } } @@ -2667,7 +2667,7 @@ void command_peekinv(Client *c, const Seperator *sep) item_link = linker.GenerateLink(); c->Message((item_data == nullptr), " BankBagSlot: %i (Slot #%i, Bag #%i), Item: %i (%s), Charges: %i", - Inventory::CalcSlotId(indexMain, indexSub), indexMain, indexSub, ((item_data == nullptr) ? 0 : item_data->ID), item_link.c_str(), ((inst_sub == nullptr) ? 0 : inst_sub->GetCharges())); + EQEmu::InventoryProfile::CalcSlotId(indexMain, indexSub), indexMain, indexSub, ((item_data == nullptr) ? 0 : item_data->ID), item_link.c_str(), ((inst_sub == nullptr) ? 0 : inst_sub->GetCharges())); } } @@ -2689,7 +2689,7 @@ void command_peekinv(Client *c, const Seperator *sep) item_link = linker.GenerateLink(); c->Message((item_data == nullptr), " SharedBankBagSlot: %i (Slot #%i, Bag #%i), Item: %i (%s), Charges: %i", - Inventory::CalcSlotId(indexMain, indexSub), indexMain, indexSub, ((item_data == nullptr) ? 0 : item_data->ID), item_link.c_str(), ((inst_sub == nullptr) ? 0 : inst_sub->GetCharges())); + EQEmu::InventoryProfile::CalcSlotId(indexMain, indexSub), indexMain, indexSub, ((item_data == nullptr) ? 0 : item_data->ID), item_link.c_str(), ((inst_sub == nullptr) ? 0 : inst_sub->GetCharges())); } } @@ -2712,7 +2712,7 @@ void command_peekinv(Client *c, const Seperator *sep) item_link = linker.GenerateLink(); c->Message((item_data == nullptr), " TradeBagSlot: %i (Slot #%i, Bag #%i), Item: %i (%s), Charges: %i", - Inventory::CalcSlotId(indexMain, indexSub), indexMain, indexSub, ((item_data == nullptr) ? 0 : item_data->ID), item_link.c_str(), ((inst_sub == nullptr) ? 0 : inst_sub->GetCharges())); + EQEmu::InventoryProfile::CalcSlotId(indexMain, indexSub), indexMain, indexSub, ((item_data == nullptr) ? 0 : item_data->ID), item_link.c_str(), ((inst_sub == nullptr) ? 0 : inst_sub->GetCharges())); } } diff --git a/zone/corpse.cpp b/zone/corpse.cpp index 57a85aff9..3b9c15214 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -408,7 +408,7 @@ void Corpse::MoveItemToCorpse(Client *client, EQEmu::ItemInstance *inst, int16 e if (equipSlot < EQEmu::legacy::GENERAL_BEGIN || equipSlot > EQEmu::inventory::slotCursor) { break; } for (int16 sub_index = EQEmu::inventory::containerBegin; sub_index < EQEmu::inventory::ContainerCount; ++sub_index) { - int16 real_bag_slot = Inventory::CalcSlotId(equipSlot, sub_index); + int16 real_bag_slot = EQEmu::InventoryProfile::CalcSlotId(equipSlot, sub_index); auto bag_inst = client->GetInv().GetItem(real_bag_slot); if (bag_inst == nullptr) { continue; } @@ -684,8 +684,8 @@ ServerLootItem_Struct* Corpse::GetItem(uint16 lootslot, ServerLootItem_Struct** } } - if (sitem && bag_item_data && Inventory::SupportsContainers(sitem->equip_slot)) { - int16 bagstart = Inventory::CalcSlotId(sitem->equip_slot, EQEmu::inventory::containerBegin); + if (sitem && bag_item_data && EQEmu::InventoryProfile::SupportsContainers(sitem->equip_slot)) { + int16 bagstart = EQEmu::InventoryProfile::CalcSlotId(sitem->equip_slot, EQEmu::inventory::containerBegin); cur = itemlist.begin(); end = itemlist.end(); @@ -739,7 +739,7 @@ void Corpse::RemoveItem(ServerLootItem_Struct* item_data) is_corpse_changed = true; itemlist.erase(iter); - uint8 material = Inventory::CalcMaterialFromSlot(sitem->equip_slot); // autos to unsigned char + uint8 material = EQEmu::InventoryProfile::CalcMaterialFromSlot(sitem->equip_slot); // autos to unsigned char if (material != EQEmu::textures::materialInvalid) SendWearChange(material); @@ -1406,7 +1406,7 @@ uint32 Corpse::GetEquipment(uint8 material_slot) const { return 0; } - invslot = Inventory::CalcSlotFromMaterial(material_slot); + invslot = EQEmu::InventoryProfile::CalcSlotFromMaterial(material_slot); if(invslot == INVALID_INDEX) // GetWornItem() should be returning a 0 for any invalid index... return 0; diff --git a/zone/inventory.cpp b/zone/inventory.cpp index c89879610..c5d7de0fe 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -767,7 +767,7 @@ void Client::DeleteItemInInventory(int16 slot_id, int8 quantity, bool client_upd EQEmu::ItemInstance* bagitem = m_inv[slot_id]->GetItem(bag_idx); if(bagitem) { - int16 bagslot_id = Inventory::CalcSlotId(slot_id, bag_idx); + int16 bagslot_id = EQEmu::InventoryProfile::CalcSlotId(slot_id, bag_idx); qsaudit->items[++parent_offset].char_slot = bagslot_id; qsaudit->items[parent_offset].item_id = bagitem->GetID(); @@ -866,7 +866,7 @@ bool Client::PutItemInInventory(int16 slot_id, const EQEmu::ItemInstance& inst, if (client_update) { SendItemPacket(slot_id, &inst, ((slot_id == EQEmu::inventory::slotCursor) ? ItemPacketLimbo : ItemPacketTrade)); - //SendWearChange(Inventory::CalcMaterialFromSlot(slot_id)); + //SendWearChange(EQEmu::InventoryProfile::CalcMaterialFromSlot(slot_id)); } if (slot_id == EQEmu::inventory::slotCursor) { @@ -934,7 +934,7 @@ void Client::PutLootInInventory(int16 slot_id, const EQEmu::ItemInstance &inst, PutLootInInventory(EQEmu::inventory::slotCursor, *bagitem); } else { - auto bag_slot = Inventory::CalcSlotId(slot_id, index); + auto bag_slot = EQEmu::InventoryProfile::CalcSlotId(slot_id, index); Log.Out(Logs::Detail, Logs::Inventory, "Putting bag loot item %s (%d) into slot %d (bag slot %d)", @@ -966,7 +966,7 @@ bool Client::TryStacking(EQEmu::ItemInstance* item, uint8 type, bool try_worn, b } for (i = EQEmu::legacy::GENERAL_BEGIN; i <= EQEmu::legacy::GENERAL_END; i++) { for (uint8 j = EQEmu::inventory::containerBegin; j < EQEmu::inventory::ContainerCount; j++) { - uint16 slotid = Inventory::CalcSlotId(i, j); + uint16 slotid = EQEmu::InventoryProfile::CalcSlotId(i, j); EQEmu::ItemInstance* tmp_inst = m_inv.GetItem(slotid); if(tmp_inst && tmp_inst->GetItem()->ID == item_id && tmp_inst->GetCharges() < tmp_inst->GetItem()->StackSize) { @@ -1018,7 +1018,7 @@ bool Client::AutoPutLootInInventory(EQEmu::ItemInstance& inst, bool try_worn, bo if (inst.IsEquipable(i)) { // Equippable at this slot? //send worn to everyone... PutLootInInventory(i, inst); - uint8 worn_slot_material = Inventory::CalcMaterialFromSlot(i); + uint8 worn_slot_material = EQEmu::InventoryProfile::CalcMaterialFromSlot(i); if (worn_slot_material != EQEmu::textures::materialInvalid) { SendWearChange(worn_slot_material); } @@ -1518,8 +1518,8 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { if (src_slot_id >= EQEmu::legacy::SHARED_BANK_BEGIN && src_slot_id <= EQEmu::legacy::SHARED_BANK_END && src_inst->IsClassBag()){ for (uint8 idx = EQEmu::inventory::containerBegin; idx < EQEmu::inventory::ContainerCount; idx++) { const EQEmu::ItemInstance* baginst = src_inst->GetItem(idx); - if(baginst && !database.VerifyInventory(account_id, Inventory::CalcSlotId(src_slot_id, idx), baginst)){ - DeleteItemInInventory(Inventory::CalcSlotId(src_slot_id, idx),0,false); + if (baginst && !database.VerifyInventory(account_id, EQEmu::InventoryProfile::CalcSlotId(src_slot_id, idx), baginst)){ + DeleteItemInInventory(EQEmu::InventoryProfile::CalcSlotId(src_slot_id, idx), 0, false); } } } @@ -1533,8 +1533,8 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { if (dst_slot_id >= EQEmu::legacy::SHARED_BANK_BEGIN && dst_slot_id <= EQEmu::legacy::SHARED_BANK_END && dst_inst->IsClassBag()){ for (uint8 idx = EQEmu::inventory::containerBegin; idx < EQEmu::inventory::ContainerCount; idx++) { const EQEmu::ItemInstance* baginst = dst_inst->GetItem(idx); - if(baginst && !database.VerifyInventory(account_id, Inventory::CalcSlotId(dst_slot_id, idx), baginst)){ - DeleteItemInInventory(Inventory::CalcSlotId(dst_slot_id, idx),0,false); + if (baginst && !database.VerifyInventory(account_id, EQEmu::InventoryProfile::CalcSlotId(dst_slot_id, idx), baginst)){ + DeleteItemInInventory(EQEmu::InventoryProfile::CalcSlotId(dst_slot_id, idx), 0, false); } } } @@ -1576,7 +1576,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { if(m_tradeskill_object != nullptr) { if (src_slot_id >= EQEmu::legacy::WORLD_BEGIN && src_slot_id <= EQEmu::legacy::WORLD_END) { // Picking up item from world container - EQEmu::ItemInstance* inst = m_tradeskill_object->PopItem(Inventory::CalcBagIdx(src_slot_id)); + EQEmu::ItemInstance* inst = m_tradeskill_object->PopItem(EQEmu::InventoryProfile::CalcBagIdx(src_slot_id)); if (inst) { PutItemInInventory(dst_slot_id, *inst, false); safe_delete(inst); @@ -1588,7 +1588,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { } else if (dst_slot_id >= EQEmu::legacy::WORLD_BEGIN && dst_slot_id <= EQEmu::legacy::WORLD_END) { // Putting item into world container, which may swap (or pile onto) with existing item - uint8 world_idx = Inventory::CalcBagIdx(dst_slot_id); + uint8 world_idx = EQEmu::InventoryProfile::CalcBagIdx(dst_slot_id); EQEmu::ItemInstance* world_inst = m_tradeskill_object->PopItem(world_idx); // Case 1: No item in container, unidirectional "Put" @@ -1835,7 +1835,7 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) { Message(15, "Inventory Desyncronization detected: Resending slot data..."); if ((move_slots->from_slot >= EQEmu::legacy::EQUIPMENT_BEGIN && move_slots->from_slot <= EQEmu::legacy::CURSOR_BAG_END) || move_slots->from_slot == EQEmu::inventory::slotPowerSource) { - int16 resync_slot = (Inventory::CalcSlotId(move_slots->from_slot) == INVALID_INDEX) ? move_slots->from_slot : Inventory::CalcSlotId(move_slots->from_slot); + int16 resync_slot = (EQEmu::InventoryProfile::CalcSlotId(move_slots->from_slot) == INVALID_INDEX) ? move_slots->from_slot : EQEmu::InventoryProfile::CalcSlotId(move_slots->from_slot); if (IsValidSlot(resync_slot) && resync_slot != INVALID_INDEX) { // This prevents the client from crashing when closing any 'phantom' bags const EQEmu::ItemData* token_struct = database.GetItem(22292); // 'Copper Coin' @@ -1860,7 +1860,7 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) { else { Message(13, "Could not resyncronize source slot %i.", move_slots->from_slot); } } else { - int16 resync_slot = (Inventory::CalcSlotId(move_slots->from_slot) == INVALID_INDEX) ? move_slots->from_slot : Inventory::CalcSlotId(move_slots->from_slot); + int16 resync_slot = (EQEmu::InventoryProfile::CalcSlotId(move_slots->from_slot) == INVALID_INDEX) ? move_slots->from_slot : EQEmu::InventoryProfile::CalcSlotId(move_slots->from_slot); if (IsValidSlot(resync_slot) && resync_slot != INVALID_INDEX) { if(m_inv[resync_slot]) { const EQEmu::ItemData* token_struct = database.GetItem(22292); // 'Copper Coin' @@ -1878,7 +1878,7 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) { } if ((move_slots->to_slot >= EQEmu::legacy::EQUIPMENT_BEGIN && move_slots->to_slot <= EQEmu::legacy::CURSOR_BAG_END) || move_slots->to_slot == EQEmu::inventory::slotPowerSource) { - int16 resync_slot = (Inventory::CalcSlotId(move_slots->to_slot) == INVALID_INDEX) ? move_slots->to_slot : Inventory::CalcSlotId(move_slots->to_slot); + int16 resync_slot = (EQEmu::InventoryProfile::CalcSlotId(move_slots->to_slot) == INVALID_INDEX) ? move_slots->to_slot : EQEmu::InventoryProfile::CalcSlotId(move_slots->to_slot); if (IsValidSlot(resync_slot) && resync_slot != INVALID_INDEX) { const EQEmu::ItemData* token_struct = database.GetItem(22292); // 'Copper Coin' EQEmu::ItemInstance* token_inst = database.CreateItem(token_struct, 1); @@ -1902,7 +1902,7 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) { else { Message(13, "Could not resyncronize destination slot %i.", move_slots->to_slot); } } else { - int16 resync_slot = (Inventory::CalcSlotId(move_slots->to_slot) == INVALID_INDEX) ? move_slots->to_slot : Inventory::CalcSlotId(move_slots->to_slot); + int16 resync_slot = (EQEmu::InventoryProfile::CalcSlotId(move_slots->to_slot) == INVALID_INDEX) ? move_slots->to_slot : EQEmu::InventoryProfile::CalcSlotId(move_slots->to_slot); if (IsValidSlot(resync_slot) && resync_slot != INVALID_INDEX) { if(m_inv[resync_slot]) { const EQEmu::ItemData* token_struct = database.GetItem(22292); // 'Copper Coin' @@ -1963,8 +1963,8 @@ void Client::QSSwapItemAuditor(MoveItem_Struct* move_in, bool postaction_call) { const EQEmu::ItemInstance* from_baginst = from_inst->GetItem(bag_idx); if(from_baginst) { - qsaudit->items[move_count].from_slot = Inventory::CalcSlotId(from_slot_id, bag_idx); - qsaudit->items[move_count].to_slot = Inventory::CalcSlotId(to_slot_id, bag_idx); + qsaudit->items[move_count].from_slot = EQEmu::InventoryProfile::CalcSlotId(from_slot_id, bag_idx); + qsaudit->items[move_count].to_slot = EQEmu::InventoryProfile::CalcSlotId(to_slot_id, bag_idx); qsaudit->items[move_count].item_id = from_baginst->GetID(); qsaudit->items[move_count].charges = from_baginst->GetCharges(); qsaudit->items[move_count].aug_1 = from_baginst->GetAugmentItemID(1); @@ -1996,8 +1996,8 @@ void Client::QSSwapItemAuditor(MoveItem_Struct* move_in, bool postaction_call) { const EQEmu::ItemInstance* to_baginst = to_inst->GetItem(bag_idx); if(to_baginst) { - qsaudit->items[move_count].from_slot = Inventory::CalcSlotId(to_slot_id, bag_idx); - qsaudit->items[move_count].to_slot = Inventory::CalcSlotId(from_slot_id, bag_idx); + qsaudit->items[move_count].from_slot = EQEmu::InventoryProfile::CalcSlotId(to_slot_id, bag_idx); + qsaudit->items[move_count].to_slot = EQEmu::InventoryProfile::CalcSlotId(from_slot_id, bag_idx); qsaudit->items[move_count].item_id = to_baginst->GetID(); qsaudit->items[move_count].charges = to_baginst->GetCharges(); qsaudit->items[move_count].aug_1 = to_baginst->GetAugmentItemID(1); @@ -2598,7 +2598,7 @@ uint32 Client::GetEquipment(uint8 material_slot) const return 0; } - invslot = Inventory::CalcSlotFromMaterial(material_slot); + invslot = EQEmu::InventoryProfile::CalcSlotFromMaterial(material_slot); if (invslot == INVALID_INDEX) { return 0; @@ -2956,7 +2956,7 @@ bool Client::MoveItemToInventory(EQEmu::ItemInstance *ItemToReturn, bool UpdateC // if (InvItem && InvItem->IsClassBag()) { - int16 BaseSlotID = Inventory::CalcSlotId(i, EQEmu::inventory::containerBegin); + int16 BaseSlotID = EQEmu::InventoryProfile::CalcSlotId(i, EQEmu::inventory::containerBegin); uint8 BagSize=InvItem->GetItem()->BagSlots; @@ -3006,9 +3006,9 @@ bool Client::MoveItemToInventory(EQEmu::ItemInstance *ItemToReturn, bool UpdateC return true; } - if (InvItem->IsClassBag() && Inventory::CanItemFitInContainer(ItemToReturn->GetItem(), InvItem->GetItem())) { + if (InvItem->IsClassBag() && EQEmu::InventoryProfile::CanItemFitInContainer(ItemToReturn->GetItem(), InvItem->GetItem())) { - int16 BaseSlotID = Inventory::CalcSlotId(i, EQEmu::inventory::containerBegin); + int16 BaseSlotID = EQEmu::InventoryProfile::CalcSlotId(i, EQEmu::inventory::containerBegin); uint8 BagSize=InvItem->GetItem()->BagSlots; @@ -3272,7 +3272,7 @@ bool Client::InterrogateInventory_error(int16 head, int16 index, const EQEmu::It return false; } -void Inventory::SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, std::string value) { +void EQEmu::InventoryProfile::SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, std::string value) { EQEmu::ItemInstance *inst = GetItem(slot_id); if(inst) { inst->SetCustomData(identifier, value); @@ -3280,7 +3280,7 @@ void Inventory::SetCustomItemData(uint32 character_id, int16 slot_id, std::strin } } -void Inventory::SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, int value) { +void EQEmu::InventoryProfile::SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, int value) { EQEmu::ItemInstance *inst = GetItem(slot_id); if(inst) { inst->SetCustomData(identifier, value); @@ -3288,7 +3288,7 @@ void Inventory::SetCustomItemData(uint32 character_id, int16 slot_id, std::strin } } -void Inventory::SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, float value) { +void EQEmu::InventoryProfile::SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, float value) { EQEmu::ItemInstance *inst = GetItem(slot_id); if(inst) { inst->SetCustomData(identifier, value); @@ -3296,7 +3296,7 @@ void Inventory::SetCustomItemData(uint32 character_id, int16 slot_id, std::strin } } -void Inventory::SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, bool value) { +void EQEmu::InventoryProfile::SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, bool value) { EQEmu::ItemInstance *inst = GetItem(slot_id); if(inst) { inst->SetCustomData(identifier, value); @@ -3304,7 +3304,7 @@ void Inventory::SetCustomItemData(uint32 character_id, int16 slot_id, std::strin } } -std::string Inventory::GetCustomItemData(int16 slot_id, std::string identifier) { +std::string EQEmu::InventoryProfile::GetCustomItemData(int16 slot_id, std::string identifier) { EQEmu::ItemInstance *inst = GetItem(slot_id); if(inst) { return inst->GetCustomData(identifier); diff --git a/zone/lua_inventory.h b/zone/lua_inventory.h index ca49a55e6..baaa5d10f 100644 --- a/zone/lua_inventory.h +++ b/zone/lua_inventory.h @@ -4,26 +4,30 @@ #include "lua_ptr.h" -class Inventory; class Lua_ItemInst; class Lua_Item; +namespace EQEmu +{ + class InventoryProfile; +} + namespace luabind { struct scope; } luabind::scope lua_register_inventory(); -class Lua_Inventory : public Lua_Ptr +class Lua_Inventory : public Lua_Ptr { - typedef Inventory NativeType; + typedef EQEmu::InventoryProfile NativeType; public: Lua_Inventory() : Lua_Ptr(nullptr) { } - Lua_Inventory(Inventory *d) : Lua_Ptr(d) { } + Lua_Inventory(EQEmu::InventoryProfile *d) : Lua_Ptr(d) { } virtual ~Lua_Inventory() { } - operator Inventory*() { - return reinterpret_cast(GetLuaPtrData()); + operator EQEmu::InventoryProfile*() { + return reinterpret_cast(GetLuaPtrData()); } Lua_ItemInst GetItem(int slot_id); diff --git a/zone/merc.cpp b/zone/merc.cpp index c45d0c268..6dc00836b 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -5050,7 +5050,7 @@ void Merc::UpdateMercAppearance() { for (int i = EQEmu::legacy::EQUIPMENT_BEGIN; i <= EQEmu::legacy::EQUIPMENT_END; ++i) { itemID = equipment[i]; if(itemID != 0) { - materialFromSlot = Inventory::CalcMaterialFromSlot(i); + materialFromSlot = EQEmu::InventoryProfile::CalcMaterialFromSlot(i); if (materialFromSlot != EQEmu::textures::materialInvalid) this->SendWearChange(materialFromSlot); } diff --git a/zone/merc.h b/zone/merc.h index ad219a2ec..b563775b0 100644 --- a/zone/merc.h +++ b/zone/merc.h @@ -386,7 +386,7 @@ private: uint8 _OwnerClientVersion; uint32 _currentStance; - Inventory m_inv; + EQEmu::InventoryProfile m_inv; int32 max_end; int32 cur_end; bool _medding; diff --git a/zone/mob.cpp b/zone/mob.cpp index dcb9792f2..368d34e1f 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -2728,7 +2728,7 @@ uint32 NPC::GetEquipment(uint8 material_slot) const { if(material_slot > 8) return 0; - int16 invslot = Inventory::CalcSlotFromMaterial(material_slot); + int16 invslot = EQEmu::InventoryProfile::CalcSlotFromMaterial(material_slot); if (invslot == INVALID_INDEX) return 0; return equipment[invslot]; @@ -2862,7 +2862,7 @@ int32 Mob::GetEquipmentMaterial(uint8 material_slot) const { if (this->IsClient()) { - int16 invslot = Inventory::CalcSlotFromMaterial(material_slot); + int16 invslot = EQEmu::InventoryProfile::CalcSlotFromMaterial(material_slot); if (invslot == INVALID_INDEX) { return 0; @@ -2907,7 +2907,7 @@ int32 Mob::GetHerosForgeModel(uint8 material_slot) const uint32 ornamentationAugtype = RuleI(Character, OrnamentationAugmentType); const EQEmu::ItemData *item; item = database.GetItem(GetEquipment(material_slot)); - int16 invslot = Inventory::CalcSlotFromMaterial(material_slot); + int16 invslot = EQEmu::InventoryProfile::CalcSlotFromMaterial(material_slot); if (item != 0 && invslot != INVALID_INDEX) { diff --git a/zone/npc.cpp b/zone/npc.cpp index 166cd33fc..f6e080a26 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -489,7 +489,7 @@ void NPC::CheckMinMaxLevel(Mob *them) if(themlevel < (*cur)->min_level || themlevel > (*cur)->max_level) { - material = Inventory::CalcMaterialFromSlot((*cur)->equip_slot); + material = EQEmu::InventoryProfile::CalcMaterialFromSlot((*cur)->equip_slot); if (material != EQEmu::textures::materialInvalid) SendWearChange(material); @@ -1381,7 +1381,7 @@ int32 NPC::GetEquipmentMaterial(uint8 material_slot) const if (material_slot >= EQEmu::textures::materialCount) return 0; - int16 invslot = Inventory::CalcSlotFromMaterial(material_slot); + int16 invslot = EQEmu::InventoryProfile::CalcSlotFromMaterial(material_slot); if (invslot == INVALID_INDEX) return 0; diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index 8db24d81e..4c8dfdeaf 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -55,7 +55,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme else { // Check to see if they have an inventory container type 53 that is used for this. - Inventory& user_inv = user->GetInv(); + EQEmu::InventoryProfile& user_inv = user->GetInv(); EQEmu::ItemInstance* inst = nullptr; inst = user_inv.GetItem(in_augment->container_slot); @@ -227,7 +227,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme const EQEmu::ItemInstance* inst = container->GetItem(i); if (inst) { - user->DeleteItemInInventory(Inventory::CalcSlotId(in_augment->container_slot,i),0,true); + user->DeleteItemInInventory(EQEmu::InventoryProfile::CalcSlotId(in_augment->container_slot, i), 0, true); } } // Explicitly mark container as cleared. @@ -256,7 +256,7 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob return; } - Inventory& user_inv = user->GetInv(); + EQEmu::InventoryProfile& user_inv = user->GetInv(); PlayerProfile_Struct& user_pp = user->GetPP(); EQEmu::ItemInstance* container = nullptr; EQEmu::ItemInstance* inst = nullptr; @@ -295,7 +295,7 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob bool AllowAll = RuleB(Inventory, AllowAnyWeaponTransformation); if (inst && EQEmu::ItemInstance::CanTransform(inst->GetItem(), container->GetItem(), AllowAll)) { const EQEmu::ItemData* new_weapon = inst->GetItem(); - user->DeleteItemInInventory(Inventory::CalcSlotId(in_combine->container_slot, 0), 0, true); + user->DeleteItemInInventory(EQEmu::InventoryProfile::CalcSlotId(in_combine->container_slot, 0), 0, true); container->Clear(); user->SummonItem(new_weapon->ID, inst->GetCharges(), inst->GetAugmentItemID(0), inst->GetAugmentItemID(1), inst->GetAugmentItemID(2), inst->GetAugmentItemID(3), inst->GetAugmentItemID(4), inst->GetAugmentItemID(5), inst->IsAttuned(), EQEmu::inventory::slotCursor, container->GetItem()->Icon, atoi(container->GetItem()->IDFile + 2)); user->Message_StringID(4, TRANSFORM_COMPLETE, inst->GetItem()->Name); @@ -315,7 +315,7 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob const EQEmu::ItemInstance* inst = container->GetItem(0); if (inst && inst->GetOrnamentationIcon() && inst->GetOrnamentationIcon()) { const EQEmu::ItemData* new_weapon = inst->GetItem(); - user->DeleteItemInInventory(Inventory::CalcSlotId(in_combine->container_slot, 0), 0, true); + user->DeleteItemInInventory(EQEmu::InventoryProfile::CalcSlotId(in_combine->container_slot, 0), 0, true); container->Clear(); user->SummonItem(new_weapon->ID, inst->GetCharges(), inst->GetAugmentItemID(0), inst->GetAugmentItemID(1), inst->GetAugmentItemID(2), inst->GetAugmentItemID(3), inst->GetAugmentItemID(4), inst->GetAugmentItemID(5), inst->IsAttuned(), EQEmu::inventory::slotCursor, 0, 0); user->Message_StringID(4, TRANSFORM_COMPLETE, inst->GetItem()->Name); @@ -404,7 +404,7 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob for (uint8 i = EQEmu::inventory::slotBegin; i < EQEmu::legacy::TYPE_WORLD_SIZE; i++) { const EQEmu::ItemInstance* inst = container->GetItem(i); if (inst) { - user->DeleteItemInInventory(Inventory::CalcSlotId(in_combine->container_slot,i),0,true); + user->DeleteItemInInventory(EQEmu::InventoryProfile::CalcSlotId(in_combine->container_slot, i), 0, true); } } container->Clear(); @@ -501,7 +501,7 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac memset(counts, 0, sizeof(counts)); //search for all the items in their inventory - Inventory& user_inv = user->GetInv(); + EQEmu::InventoryProfile& user_inv = user->GetInv(); uint8 count = 0; uint8 needcount = 0; diff --git a/zone/trading.cpp b/zone/trading.cpp index 9d9738ffc..e150ceb12 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -174,7 +174,7 @@ void Trade::SendItemData(const EQEmu::ItemInstance* inst, int16 dest_slot_id) with->SendItemPacket(dest_slot_id - EQEmu::legacy::TRADE_BEGIN, inst, ItemPacketTradeView); if (inst->GetItem()->ItemClass == 1) { for (uint16 i = EQEmu::inventory::containerBegin; i < EQEmu::inventory::ContainerCount; i++) { - uint16 bagslot_id = Inventory::CalcSlotId(dest_slot_id, i); + uint16 bagslot_id = EQEmu::InventoryProfile::CalcSlotId(dest_slot_id, i); const EQEmu::ItemInstance* bagitem = trader->GetInv().GetItem(bagslot_id); if (bagitem) { with->SendItemPacket(bagslot_id - EQEmu::legacy::TRADE_BEGIN, bagitem, ItemPacketTradeView); @@ -317,7 +317,7 @@ void Trade::DumpTrade() if (inst) { Log.Out(Logs::Detail, Logs::Trading, "\tBagItem %i (Charges=%i, Slot=%i)", inst->GetItem()->ID, inst->GetCharges(), - Inventory::CalcSlotId(i, j)); + EQEmu::InventoryProfile::CalcSlotId(i, j)); } } } @@ -530,9 +530,9 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st detail = new QSTradeItems_Struct; detail->from_id = this->character_id; - detail->from_slot = Inventory::CalcSlotId(trade_slot, sub_slot); + detail->from_slot = EQEmu::InventoryProfile::CalcSlotId(trade_slot, sub_slot); detail->to_id = other->CharacterID(); - detail->to_slot = Inventory::CalcSlotId(free_slot, sub_slot); + detail->to_slot = EQEmu::InventoryProfile::CalcSlotId(free_slot, sub_slot); detail->item_id = bag_inst->GetID(); detail->charges = (!bag_inst->IsStackable() ? 1 : bag_inst->GetCharges()); detail->aug_1 = bag_inst->GetAugmentItemID(1); @@ -849,7 +849,7 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st strcpy(detail->action_type, "HANDIN"); - detail->char_slot = Inventory::CalcSlotId(trade_slot, sub_slot); + detail->char_slot = EQEmu::InventoryProfile::CalcSlotId(trade_slot, sub_slot); detail->item_id = trade_baginst->GetID(); detail->charges = (!trade_inst->IsStackable() ? 1 : trade_inst->GetCharges()); detail->aug_1 = trade_baginst->GetAugmentItemID(1); @@ -1237,7 +1237,7 @@ uint32 Client::FindTraderItemSerialNumber(int32 ItemID) { if (item && item->GetItem()->ID == 17899){ //Traders Satchel for (int x = EQEmu::inventory::containerBegin; x < EQEmu::inventory::ContainerCount; x++) { // we already have the parent bag and a contents iterator..why not just iterate the bag!?? - SlotID = Inventory::CalcSlotId(i, x); + SlotID = EQEmu::InventoryProfile::CalcSlotId(i, x); item = this->GetInv().GetItem(SlotID); if (item) { if (item->GetID() == ItemID) @@ -1260,7 +1260,7 @@ EQEmu::ItemInstance* Client::FindTraderItemBySerialNumber(int32 SerialNumber){ if(item && item->GetItem()->ID == 17899){ //Traders Satchel for (int x = EQEmu::inventory::containerBegin; x < EQEmu::inventory::ContainerCount; x++) { // we already have the parent bag and a contents iterator..why not just iterate the bag!?? - SlotID = Inventory::CalcSlotId(i, x); + SlotID = EQEmu::InventoryProfile::CalcSlotId(i, x); item = this->GetInv().GetItem(SlotID); if(item) { if(item->GetSerialNumber() == SerialNumber) @@ -1290,7 +1290,7 @@ GetItems_Struct* Client::GetTraderItems(){ item = this->GetInv().GetItem(i); if(item && item->GetItem()->ID == 17899){ //Traders Satchel for (int x = EQEmu::inventory::containerBegin; x < EQEmu::inventory::ContainerCount; x++) { - SlotID = Inventory::CalcSlotId(i, x); + SlotID = EQEmu::InventoryProfile::CalcSlotId(i, x); item = this->GetInv().GetItem(SlotID); @@ -1314,7 +1314,7 @@ uint16 Client::FindTraderItem(int32 SerialNumber, uint16 Quantity){ item = this->GetInv().GetItem(i); if(item && item->GetItem()->ID == 17899){ //Traders Satchel for (int x = EQEmu::inventory::containerBegin; x < EQEmu::inventory::ContainerCount; x++){ - SlotID = Inventory::CalcSlotId(i, x); + SlotID = EQEmu::InventoryProfile::CalcSlotId(i, x); item = this->GetInv().GetItem(SlotID); diff --git a/zone/zone.cpp b/zone/zone.cpp index 9391b47bb..ab0a9b6e4 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1167,7 +1167,7 @@ bool Zone::Process() { if(spawn2_timer.Check()) { LinkedListIterator iterator(spawn2_list); - Inventory::CleanDirty(); + EQEmu::InventoryProfile::CleanDirty(); iterator.Reset(); while (iterator.MoreElements()) {