diff --git a/common/database.h b/common/database.h index b28fd4d8f..c71d767df 100644 --- a/common/database.h +++ b/common/database.h @@ -27,6 +27,7 @@ #include "dbcore.h" #include "linked_list.h" #include "eq_packet_structs.h" +#include "inventory.h" #include #include diff --git a/common/inventory.cpp b/common/inventory.cpp index b63ba4eaf..5ca07becf 100644 --- a/common/inventory.cpp +++ b/common/inventory.cpp @@ -18,3 +18,21 @@ #include "inventory.h" +EQEmu::Inventory::Inventory() { +} + +EQEmu::Inventory::~Inventory() { +} + +std::shared_ptr EQEmu::Inventory::GetItem(InventoryType type, int16 slot) { + auto area = items_.find(type); + + if(area != items_.end()) { + auto item = area->second.find(slot); + if(item != area->second.end()) { + return item->second; + } + } + + return std::shared_ptr(nullptr); +} \ No newline at end of file diff --git a/common/inventory.h b/common/inventory.h index 9816bd8dd..163a5be57 100644 --- a/common/inventory.h +++ b/common/inventory.h @@ -19,12 +19,36 @@ #ifndef COMMON_INVENTORY_H #define COMMON_INVENTORY_H +#include "item_instance.h" +#include +#include +#include + namespace EQEmu { + enum InventoryType : int16 + { + InvTypePersonal, + InvTypeBank, + InvTypeSharedBank, + InvTypeTrade, + InvTypeWorld, + InvTypeCursorBuffer, + InvTypeTribute, + InvTypeTrophyTribute, + InvTypeGuildTribute + }; + class Inventory { public: + Inventory(); + ~Inventory(); + + std::shared_ptr GetItem(InventoryType type, int16 slot); + private: + std::map>> items_; }; } // EQEmu diff --git a/common/item_instance.cpp b/common/item_instance.cpp index 0a8fb4940..9427ec890 100644 --- a/common/item_instance.cpp +++ b/common/item_instance.cpp @@ -17,3 +17,54 @@ */ #include "item_instance.h" +#include "data_verification.h" + +EQEmu::ItemInstance::ItemInstance() { + base_item_ = nullptr; + modified_item_ = nullptr; + charges_ = -1; + color_ = 0; + attuned_ = false; + ornament_idfile_ = 0; + ornament_icon_ = 0; + ornament_hero_model_ = 0; + tracking_id_ = 0; +} + +EQEmu::ItemInstance::ItemInstance(const ItemData* idata) { + base_item_ = idata; + modified_item_ = nullptr; + charges_ = -1; + color_ = 0; + attuned_ = false; + ornament_idfile_ = 0; + ornament_icon_ = 0; + ornament_hero_model_ = 0; + tracking_id_ = 0; +} + +EQEmu::ItemInstance::ItemInstance(const ItemData* idata, int16 charges) { + base_item_ = idata; + modified_item_ = nullptr; + charges_ = charges; + color_ = 0; + attuned_ = false; + ornament_idfile_ = 0; + ornament_icon_ = 0; + ornament_hero_model_ = 0; + tracking_id_ = 0; +} + +EQEmu::ItemInstance::~ItemInstance() { +} + +std::shared_ptr EQEmu::ItemInstance::GetItem(int index) { + if(EQEmu::ValueWithin(index, 0, 200)) { + auto iter = contents_.find(index); + if(iter != contents_.end()) { + return iter->second; + } + } + + return std::shared_ptr(nullptr); +} diff --git a/common/item_instance.h b/common/item_instance.h index 8ba559681..582e80164 100644 --- a/common/item_instance.h +++ b/common/item_instance.h @@ -19,12 +19,34 @@ #ifndef COMMON_ITEM_INSTANCE_H #define COMMON_ITEM_INSTANCE_H +#include "item_data.h" +#include +#include +#include + namespace EQEmu { class ItemInstance { public: + ItemInstance(); + ItemInstance(const ItemData* idata); + ItemInstance(const ItemData* idata, int16 charges); + ~ItemInstance(); + + std::shared_ptr GetItem(int index); private: + const ItemData *base_item_; + ItemData *modified_item_; + int16 charges_; + uint32 color_; + bool attuned_; + std::string custom_data_; + uint32 ornament_idfile_; + uint32 ornament_icon_; + uint32 ornament_hero_model_; + uint64 tracking_id_; + std::map> contents_; }; } // EQEmu diff --git a/common/shareddb.cpp b/common/shareddb.cpp index c1766b5c0..7b0863bca 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -151,74 +151,77 @@ bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const Ite bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 slot_id) { - // If we never save tribute slots..how are we to ever benefit from them!!? The client - // object is destroyed upon zoning - including its inventory object..and if tributes - // don't exist in the database, then they will never be loaded when the new client - // object is created in the new zone object... Something to consider... -U + return true; + //// If we never save tribute slots..how are we to ever benefit from them!!? The client + //// object is destroyed upon zoning - including its inventory object..and if tributes + //// don't exist in the database, then they will never be loaded when the new client + //// object is created in the new zone object... Something to consider... -U + //// + //// (we could add them to the 'NoRent' checks and dispose of after 30 minutes offline) // - // (we could add them to the 'NoRent' checks and dispose of after 30 minutes offline) - - //never save tribute slots: - if(slot_id >= EmuConstants::TRIBUTE_BEGIN && slot_id <= EmuConstants::TRIBUTE_END) - return true; - - if (slot_id >= EmuConstants::SHARED_BANK_BEGIN && slot_id <= EmuConstants::SHARED_BANK_BAGS_END) { - // Shared bank inventory - if (!inst) - return DeleteSharedBankSlot(char_id, slot_id); - else - return UpdateSharedBankSlot(char_id, inst, slot_id); - } - else if (!inst) { // All other inventory - return DeleteInventorySlot(char_id, slot_id); - } - - return UpdateInventorySlot(char_id, inst, slot_id); + ////never save tribute slots: + //if(slot_id >= EmuConstants::TRIBUTE_BEGIN && slot_id <= EmuConstants::TRIBUTE_END) + // return true; + // + //if (slot_id >= EmuConstants::SHARED_BANK_BEGIN && slot_id <= EmuConstants::SHARED_BANK_BAGS_END) { + // // Shared bank inventory + // if (!inst) + // return DeleteSharedBankSlot(char_id, slot_id); + // else + // return UpdateSharedBankSlot(char_id, inst, slot_id); + //} + //else if (!inst) { // All other inventory + // return DeleteInventorySlot(char_id, slot_id); + //} + // + //return UpdateInventorySlot(char_id, inst, slot_id); } bool SharedDatabase::UpdateInventorySlot(uint32 char_id, const ItemInst* inst, int16 slot_id) { - // need to check 'inst' argument for valid pointer - - uint32 augslot[EmuConstants::ITEM_COMMON_SIZE] = { NO_ITEM, NO_ITEM, NO_ITEM, NO_ITEM, NO_ITEM, NO_ITEM }; - if (inst->IsType(ItemClassCommon)) { - for (int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++) { - ItemInst *auginst = inst->GetItem(i); - augslot[i] = (auginst && auginst->GetItem()) ? auginst->GetItem()->ID : NO_ITEM; - } - } - - uint16 charges = 0; - if(inst->GetCharges() >= 0) - charges = inst->GetCharges(); - else - charges = 0x7FFF; - - // Update/Insert item - std::string query = StringFormat("REPLACE INTO inventory " - "(charid, slotid, itemid, charges, instnodrop, custom_data, color, " - "augslot1, augslot2, augslot3, augslot4, augslot5, augslot6, ornamenticon, ornamentidfile, ornament_hero_model) " - "VALUES( %lu, %lu, %lu, %lu, %lu, '%s', %lu, " - "%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu)", - (unsigned long)char_id, (unsigned long)slot_id, (unsigned long)inst->GetItem()->ID, - (unsigned long)charges, (unsigned long)(inst->IsAttuned()? 1: 0), - inst->GetCustomDataString().c_str(), (unsigned long)inst->GetColor(), - (unsigned long)augslot[0], (unsigned long)augslot[1], (unsigned long)augslot[2], - (unsigned long)augslot[3], (unsigned long)augslot[4], (unsigned long)augslot[5], (unsigned long)inst->GetOrnamentationIcon(), - (unsigned long)inst->GetOrnamentationIDFile(), (unsigned long)inst->GetOrnamentHeroModel()); - auto results = QueryDatabase(query); - - // Save bag contents, if slot supports bag contents - if (inst->IsType(ItemClassContainer) && InventoryOld::SupportsContainers(slot_id)) - for (uint8 idx = SUB_BEGIN; idx < EmuConstants::ITEM_CONTAINER_SIZE; idx++) { - const ItemInst* baginst = inst->GetItem(idx); - SaveInventory(char_id, baginst, InventoryOld::CalcSlotId(slot_id, idx)); - } - - if (!results.Success()) { - return false; - } - return true; + + // need to check 'inst' argument for valid pointer + // + //uint32 augslot[EmuConstants::ITEM_COMMON_SIZE] = { NO_ITEM, NO_ITEM, NO_ITEM, NO_ITEM, NO_ITEM, NO_ITEM }; + //if (inst->IsType(ItemClassCommon)) { + // for (int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++) { + // ItemInst *auginst = inst->GetItem(i); + // augslot[i] = (auginst && auginst->GetItem()) ? auginst->GetItem()->ID : NO_ITEM; + // } + //} + // + //uint16 charges = 0; + //if(inst->GetCharges() >= 0) + // charges = inst->GetCharges(); + //else + // charges = 0x7FFF; + // + //// Update/Insert item + //std::string query = StringFormat("REPLACE INTO inventory " + // "(charid, slotid, itemid, charges, instnodrop, custom_data, color, " + // "augslot1, augslot2, augslot3, augslot4, augslot5, augslot6, ornamenticon, ornamentidfile, ornament_hero_model) " + // "VALUES( %lu, %lu, %lu, %lu, %lu, '%s', %lu, " + // "%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu)", + // (unsigned long)char_id, (unsigned long)slot_id, (unsigned long)inst->GetItem()->ID, + // (unsigned long)charges, (unsigned long)(inst->IsAttuned()? 1: 0), + // inst->GetCustomDataString().c_str(), (unsigned long)inst->GetColor(), + // (unsigned long)augslot[0], (unsigned long)augslot[1], (unsigned long)augslot[2], + // (unsigned long)augslot[3], (unsigned long)augslot[4], (unsigned long)augslot[5], (unsigned long)inst->GetOrnamentationIcon(), + // (unsigned long)inst->GetOrnamentationIDFile(), (unsigned long)inst->GetOrnamentHeroModel()); + //auto results = QueryDatabase(query); + // + //// Save bag contents, if slot supports bag contents + //if (inst->IsType(ItemClassContainer) && InventoryOld::SupportsContainers(slot_id)) + // for (uint8 idx = SUB_BEGIN; idx < EmuConstants::ITEM_CONTAINER_SIZE; idx++) { + // const ItemInst* baginst = inst->GetItem(idx); + // SaveInventory(char_id, baginst, InventoryOld::CalcSlotId(slot_id, idx)); + // } + // + //if (!results.Success()) { + // return false; + //} + // + //return true; } bool SharedDatabase::UpdateSharedBankSlot(uint32 char_id, const ItemInst* inst, int16 slot_id) { @@ -482,146 +485,147 @@ bool SharedDatabase::GetSharedBank(uint32 id, InventoryOld *inv, bool is_charid) } // Overloaded: Retrieve character inventory based on character id -bool SharedDatabase::GetInventory(uint32 char_id, InventoryOld *inv) +bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::Inventory *inv) { - // Retrieve character inventory - std::string query = - StringFormat("SELECT slotid, itemid, charges, color, augslot1, augslot2, augslot3, augslot4, augslot5, " - "augslot6, instnodrop, custom_data, ornamenticon, ornamentidfile, ornament_hero_model FROM " - "inventory WHERE charid = %i ORDER BY slotid", - char_id); - auto results = QueryDatabase(query); - if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "If you got an error related to the 'instnodrop' field, run the " - "following SQL Queries:\nalter table inventory add instnodrop " - "tinyint(1) unsigned default 0 not null;\n"); - return false; - } - - auto timestamps = GetItemRecastTimestamps(char_id); - - for (auto row = results.begin(); row != results.end(); ++row) { - int16 slot_id = atoi(row[0]); - uint32 item_id = atoi(row[1]); - uint16 charges = atoi(row[2]); - uint32 color = atoul(row[3]); - - uint32 aug[EmuConstants::ITEM_COMMON_SIZE]; - - aug[0] = (uint32)atoul(row[4]); - aug[1] = (uint32)atoul(row[5]); - aug[2] = (uint32)atoul(row[6]); - aug[3] = (uint32)atoul(row[7]); - aug[4] = (uint32)atoul(row[8]); - aug[5] = (uint32)atoul(row[9]); - - bool instnodrop = (row[10] && (uint16)atoi(row[10])) ? true : false; - - uint32 ornament_icon = (uint32)atoul(row[12]); - uint32 ornament_idfile = (uint32)atoul(row[13]); - uint32 ornament_hero_model = (uint32)atoul(row[14]); - - const ItemData *item = GetItem(item_id); - - if (!item) { - Log.Out(Logs::General, Logs::Error, - "Warning: charid %i has an invalid item_id %i in inventory slot %i", char_id, item_id, - slot_id); - continue; - } - - int16 put_slot_id = INVALID_INDEX; - - ItemInst *inst = CreateBaseItem(item, charges); - - if (inst == nullptr) - continue; - - if (row[11]) { - std::string data_str(row[11]); - std::string idAsString; - std::string value; - bool use_id = true; - - for (int i = 0; i < data_str.length(); ++i) { - if (data_str[i] == '^') { - if (!use_id) { - inst->SetCustomData(idAsString, value); - idAsString.clear(); - value.clear(); - } - - use_id = !use_id; - continue; - } - - char v = data_str[i]; - if (use_id) - idAsString.push_back(v); - else - value.push_back(v); - } - } - - inst->SetOrnamentIcon(ornament_icon); - inst->SetOrnamentationIDFile(ornament_idfile); - inst->SetOrnamentHeroModel(ornament_hero_model); - - if (instnodrop || - (((slot_id >= EmuConstants::EQUIPMENT_BEGIN && slot_id <= EmuConstants::EQUIPMENT_END) || - slot_id == MainPowerSource) && - inst->GetItem()->Attuneable)) - inst->SetAttuned(true); - - if (color > 0) - inst->SetColor(color); - - if (charges == 0x7FFF) - inst->SetCharges(-1); - else if (charges == 0 && - inst->IsStackable()) // Stackable items need a minimum charge of 1 remain moveable. - inst->SetCharges(1); - else - inst->SetCharges(charges); - - if (item->RecastDelay) { - if (timestamps.count(item->RecastType)) - inst->SetRecastTimestamp(timestamps.at(item->RecastType)); - else - inst->SetRecastTimestamp(0); - } - - if (item->ItemClass == ItemClassCommon) { - for (int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++) { - if (aug[i]) - inst->PutAugment(this, i, aug[i]); - } - } - - if (slot_id >= 8000 && slot_id <= 8999) { - put_slot_id = inv->PushCursor(*inst); - } else if (slot_id >= 3111 && slot_id <= 3179) { - // Admins: please report any occurrences of this error - Log.Out(Logs::General, Logs::Error, "Warning: Defunct location for item in inventory: " - "charid=%i, item_id=%i, slot_id=%i .. pushing to cursor...", - char_id, item_id, slot_id); - put_slot_id = inv->PushCursor(*inst); - } else { - put_slot_id = inv->PutItem(slot_id, *inst); - } - - safe_delete(inst); - - // Save ptr to item in inventory - if (put_slot_id == INVALID_INDEX) { - Log.Out(Logs::General, Logs::Error, - "Warning: Invalid slot_id for item in inventory: charid=%i, item_id=%i, slot_id=%i", - char_id, item_id, slot_id); - } - } - - // Retrieve shared inventory - return GetSharedBank(char_id, inv, true); + return false; + //// Retrieve character inventory + //std::string query = + // StringFormat("SELECT slotid, itemid, charges, color, augslot1, augslot2, augslot3, augslot4, augslot5, " + // "augslot6, instnodrop, custom_data, ornamenticon, ornamentidfile, ornament_hero_model FROM " + // "inventory WHERE charid = %i ORDER BY slotid", + // char_id); + //auto results = QueryDatabase(query); + //if (!results.Success()) { + // Log.Out(Logs::General, Logs::Error, "If you got an error related to the 'instnodrop' field, run the " + // "following SQL Queries:\nalter table inventory add instnodrop " + // "tinyint(1) unsigned default 0 not null;\n"); + // return false; + //} + // + //auto timestamps = GetItemRecastTimestamps(char_id); + // + //for (auto row = results.begin(); row != results.end(); ++row) { + // int16 slot_id = atoi(row[0]); + // uint32 item_id = atoi(row[1]); + // uint16 charges = atoi(row[2]); + // uint32 color = atoul(row[3]); + // + // uint32 aug[EmuConstants::ITEM_COMMON_SIZE]; + // + // aug[0] = (uint32)atoul(row[4]); + // aug[1] = (uint32)atoul(row[5]); + // aug[2] = (uint32)atoul(row[6]); + // aug[3] = (uint32)atoul(row[7]); + // aug[4] = (uint32)atoul(row[8]); + // aug[5] = (uint32)atoul(row[9]); + // + // bool instnodrop = (row[10] && (uint16)atoi(row[10])) ? true : false; + // + // uint32 ornament_icon = (uint32)atoul(row[12]); + // uint32 ornament_idfile = (uint32)atoul(row[13]); + // uint32 ornament_hero_model = (uint32)atoul(row[14]); + // + // const ItemData *item = GetItem(item_id); + // + // if (!item) { + // Log.Out(Logs::General, Logs::Error, + // "Warning: charid %i has an invalid item_id %i in inventory slot %i", char_id, item_id, + // slot_id); + // continue; + // } + // + // int16 put_slot_id = INVALID_INDEX; + // + // ItemInst *inst = CreateBaseItem(item, charges); + // + // if (inst == nullptr) + // continue; + // + // if (row[11]) { + // std::string data_str(row[11]); + // std::string idAsString; + // std::string value; + // bool use_id = true; + // + // for (int i = 0; i < data_str.length(); ++i) { + // if (data_str[i] == '^') { + // if (!use_id) { + // inst->SetCustomData(idAsString, value); + // idAsString.clear(); + // value.clear(); + // } + // + // use_id = !use_id; + // continue; + // } + // + // char v = data_str[i]; + // if (use_id) + // idAsString.push_back(v); + // else + // value.push_back(v); + // } + // } + // + // inst->SetOrnamentIcon(ornament_icon); + // inst->SetOrnamentationIDFile(ornament_idfile); + // inst->SetOrnamentHeroModel(ornament_hero_model); + // + // if (instnodrop || + // (((slot_id >= EmuConstants::EQUIPMENT_BEGIN && slot_id <= EmuConstants::EQUIPMENT_END) || + // slot_id == MainPowerSource) && + // inst->GetItem()->Attuneable)) + // inst->SetAttuned(true); + // + // if (color > 0) + // inst->SetColor(color); + // + // if (charges == 0x7FFF) + // inst->SetCharges(-1); + // else if (charges == 0 && + // inst->IsStackable()) // Stackable items need a minimum charge of 1 remain moveable. + // inst->SetCharges(1); + // else + // inst->SetCharges(charges); + // + // if (item->RecastDelay) { + // if (timestamps.count(item->RecastType)) + // inst->SetRecastTimestamp(timestamps.at(item->RecastType)); + // else + // inst->SetRecastTimestamp(0); + // } + // + // if (item->ItemClass == ItemClassCommon) { + // for (int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++) { + // if (aug[i]) + // inst->PutAugment(this, i, aug[i]); + // } + // } + // + // if (slot_id >= 8000 && slot_id <= 8999) { + // put_slot_id = inv->PushCursor(*inst); + // } else if (slot_id >= 3111 && slot_id <= 3179) { + // // Admins: please report any occurrences of this error + // Log.Out(Logs::General, Logs::Error, "Warning: Defunct location for item in inventory: " + // "charid=%i, item_id=%i, slot_id=%i .. pushing to cursor...", + // char_id, item_id, slot_id); + // put_slot_id = inv->PushCursor(*inst); + // } else { + // put_slot_id = inv->PutItem(slot_id, *inst); + // } + // + // safe_delete(inst); + // + // // Save ptr to item in inventory + // if (put_slot_id == INVALID_INDEX) { + // Log.Out(Logs::General, Logs::Error, + // "Warning: Invalid slot_id for item in inventory: charid=%i, item_id=%i, slot_id=%i", + // char_id, item_id, slot_id); + // } + //} + // + //// Retrieve shared inventory + //return GetSharedBank(char_id, inv, true); } // Overloaded: Retrieve character inventory based on account_id and character name diff --git a/common/shareddb.h b/common/shareddb.h index 9f7708919..1eb64fdd9 100644 --- a/common/shareddb.h +++ b/common/shareddb.h @@ -9,6 +9,7 @@ #include "base_data.h" #include "fixed_memory_hash_set.h" #include "fixed_memory_variable_hash_set.h" +#include "inventory.h" #include #include @@ -68,7 +69,7 @@ class SharedDatabase : public Database bool GetSharedBank(uint32 id, InventoryOld* inv, bool is_charid); int32 GetSharedPlatinum(uint32 account_id); bool SetSharedPlatinum(uint32 account_id, int32 amount_to_add); - bool GetInventory(uint32 char_id, InventoryOld* inv); + bool GetInventory(uint32 char_id, EQEmu::Inventory* inv); bool GetInventory(uint32 account_id, char* name, InventoryOld* inv); std::map GetItemRecastTimestamps(uint32 char_id); uint32 GetItemRecastTimestamp(uint32 char_id, uint32 recast_type); diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 92c025734..e8ec515b5 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -1271,7 +1271,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) m_pp.platinum_shared = database.GetSharedPlatinum(this->AccountID()); database.ClearOldRecastTimestamps(cid); /* Clear out our old recast timestamps to keep the DB clean */ - loaditems = database.GetInventory(cid, &m_inv); /* Load Character Inventory */ + loaditems = database.GetInventory(cid, &m_inventory); /* Load Character Inventory */ database.LoadCharacterBandolier(cid, &m_pp); /* Load Character Bandolier */ database.LoadCharacterBindPoint(cid, &m_pp); /* Load Character Bind */ database.LoadCharacterMaterialColor(cid, &m_pp); /* Load Character Material */ diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 3f8e818e3..ac3d27e94 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -814,11 +814,6 @@ void Client::OnDisconnect(bool hard_disconnect) { Disconnect(); } -// Sends the client complete inventory used in character login - -// DO WE STILL NEED THE 'ITEMCOMBINED' CONDITIONAL CODE? -U - -//#ifdef ITEMCOMBINED void Client::BulkSendInventoryItems() { int16 slot_id = 0; @@ -919,51 +914,6 @@ void Client::BulkSendInventoryItems() { QueuePacket(outapp); safe_delete(outapp); } -/*#else -void Client::BulkSendInventoryItems() -{ - // Search all inventory buckets for items - bool deletenorent=database.NoRentExpired(GetName()); - // Worn items and Inventory items - int16 slot_id = 0; - if(deletenorent){//client was offline for more than 30 minutes, delete no rent items - RemoveNoRent(); - } - for (slot_id=EmuConstants::POSSESSIONS_BEGIN; slot_id<=EmuConstants::POSSESSIONS_END; slot_id++) { - const ItemInst* inst = m_inv[slot_id]; - if (inst){ - SendItemPacket(slot_id, inst, ItemPacketCharInventory); - } - } - // Bank items - for (slot_id=EmuConstants::BANK_BEGIN; slot_id<=EmuConstants::BANK_END; slot_id++) { // 2015... - const ItemInst* inst = m_inv[slot_id]; - if (inst){ - SendItemPacket(slot_id, inst, ItemPacketCharInventory); - } - } - - // Shared Bank items - for (slot_id=EmuConstants::SHARED_BANK_BEGIN; slot_id<=EmuConstants::SHARED_BANK_END; slot_id++) { - const ItemInst* inst = m_inv[slot_id]; - if (inst){ - SendItemPacket(slot_id, inst, ItemPacketCharInventory); - } - } - - // LINKDEAD TRADE ITEMS - // If player went LD during a trade, they have items in the trade inventory - // slots. These items are now being put into their inventory (then queue up on cursor) - for (int16 trade_slot_id=EmuConstants::TRADE_BEGIN; trade_slot_id<=EmuConstants::TRADE_END; trade_slot_id++) { - const ItemInst* inst = m_inv[slot_id]; - if (inst) { - int16 free_slot_id = m_inv.FindFreeSlot(inst->IsType(ItemClassContainer), true, inst->GetItem()->Size); - DeleteItemInInventory(trade_slot_id, 0, false); - PutItemInInventory(free_slot_id, *inst, true); - } - } -} -#endif*/ void Client::BulkSendMerchantInventory(int merchant_id, int npcid) { const ItemData* handyitem = nullptr; diff --git a/zone/mob.h b/zone/mob.h index 09b8d9d4a..862963794 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -18,6 +18,7 @@ #ifndef MOB_H #define MOB_H +#include "../common/inventory.h" #include "common.h" #include "entity.h" #include "hate_list.h" @@ -940,6 +941,9 @@ public: void Tune_FindAccuaryByHitChance(Mob* defender, Mob *attacker, float hit_chance, int interval, int max_loop, int avoid_override, int Msg = 0); void Tune_FindAvoidanceByHitChance(Mob* defender, Mob *attacker, float hit_chance, int interval, int max_loop, int acc_override, int Msg = 0); + inline EQEmu::Inventory& GetInventory() { return m_inventory; } + inline const EQEmu::Inventory& GetInventory() const { return m_inventory; } + protected: void CommonDamage(Mob* other, int32 &damage, const uint16 spell_id, const SkillUseTypes attack_skill, bool &avoidable, const int8 buffslot, const bool iBuffTic); static uint16 GetProcID(uint16 spell_id, uint8 effect_index); @@ -1273,6 +1277,8 @@ protected: bool bEnraged; bool destructibleobject; + EQEmu::Inventory m_inventory; + private: void _StopSong(); //this is not what you think it is Mob* target;