diff --git a/common/Item.cpp b/common/Item.cpp index 0a05d8bff..b8e3c4298 100644 --- a/common/Item.cpp +++ b/common/Item.cpp @@ -15,20 +15,12 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifdef _WINDOWS - // VS6 doesn't like the length of STL generated names: disabling - #pragma warning(disable:4786) - // Quagmire: Dont know why the one in debug.h doesnt work, but it doesnt. -#endif #include "../common/debug.h" -/*#ifdef _CRTDBG_MAP_ALLOC - #undef new - #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) -#endif -*/ +#include "../common/StringUtil.h" + #include #include + #include #include "Item.h" #include "database.h" @@ -36,6 +28,7 @@ #include "races.h" #include "shareddb.h" #include "classes.h" + using namespace std; int32 NextItemInstSerialNumber = 1; @@ -1060,103 +1053,76 @@ int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, boo return SLOT_INVALID; } -void Inventory::dumpInventory() { +void Inventory::dumpBagContents(ItemInst *inst) { + iter_inst it; + iter_contents itb; + + if (!inst || !inst->IsType(ItemClassContainer)) + return; + + // Go through bag, if bag + for (itb=inst->_begin(); itb!=inst->_end(); itb++) { + ItemInst* baginst = itb->second; + if(!baginst || !baginst->GetItem()) + continue; + + std::string subSlot; + StringFormat(subSlot," Slot %d: %s (%d)", Inventory::CalcSlotId(it->first, itb->first), + baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges()); + std::cout << subSlot << std::endl; + } + +} + +void Inventory::dumpItemCollection(const map &collection) { iter_inst it; iter_contents itb; ItemInst* inst = nullptr; - - // Check item: After failed checks, check bag contents (if bag) - printf("Worn items:\n"); - for (it=m_worn.begin(); it!=m_worn.end(); it++) { + + for (it=collection.begin(); it!=collection.end(); it++) { inst = it->second; it->first; if(!inst || !inst->GetItem()) continue; + + std:string slot; + StringFormat(slot, "Slot %d: %s (%d)",it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); + std::cout << slot << std::endl; - printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); - - // Go through bag, if bag - if (inst && inst->IsType(ItemClassContainer)) { - for (itb=inst->_begin(); itb!=inst->_end(); itb++) { - ItemInst* baginst = itb->second; - if(!baginst || !baginst->GetItem()) - continue; - printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first), - baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges()); - } - } + dumpBagContents(inst); } +} - printf("Inventory items:\n"); - for (it=m_inv.begin(); it!=m_inv.end(); it++) { - inst = it->second; - it->first; - if(!inst || !inst->GetItem()) - continue; +void Inventory::dumpWornItems() { + std::cout << "Worn items:" << std::endl; + dumpItemCollection(m_worn); +} - printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); +void Inventory::dumpInventory() { + std::cout << "Inventory items:" << std::endl; + dumpItemCollection(m_inv); +} - // Go through bag, if bag - if (inst && inst->IsType(ItemClassContainer)) { - for (itb=inst->_begin(); itb!=inst->_end(); itb++) { - ItemInst* baginst = itb->second; - if(!baginst || !baginst->GetItem()) - continue; - printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first), - baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges()); +void Inventory::dumpBankItems() { + + std::cout << "Bank items:" << std::endl; + dumpItemCollection(m_bank); +} - } - } - } +void Inventory::dumpSharedBankItems() { + + std::cout << "Shared Bank items:" << std::endl; + dumpItemCollection(m_shbank); +} - printf("Bank items:\n"); - for (it=m_bank.begin(); it!=m_bank.end(); it++) { - inst = it->second; - it->first; - if(!inst || !inst->GetItem()) - continue; +void Inventory::dumpEntireInventory() { - printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); - - // Go through bag, if bag - if (inst && inst->IsType(ItemClassContainer)) { - - for (itb=inst->_begin(); itb!=inst->_end(); itb++) { - ItemInst* baginst = itb->second; - if(!baginst || !baginst->GetItem()) - continue; - printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first), - baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges()); - - } - } - } - - printf("Shared Bank items:\n"); - for (it=m_shbank.begin(); it!=m_shbank.end(); it++) { - inst = it->second; - it->first; - if(!inst || !inst->GetItem()) - continue; - - printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); - - // Go through bag, if bag - if (inst && inst->IsType(ItemClassContainer)) { - - for (itb=inst->_begin(); itb!=inst->_end(); itb++) { - ItemInst* baginst = itb->second; - if(!baginst || !baginst->GetItem()) - continue; - printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first), - baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges()); - - } - } - } - - printf("\n"); - fflush(stdout); + dumpWornItems(); + dumpInventory(); + dumpBankItems(); + dumpSharedBankItems(); + + std::cout << std::endl; } // Internal Method: Retrieves item within an inventory bucket diff --git a/common/Item.h b/common/Item.h index c5d43f25e..0c0ea81b9 100644 --- a/common/Item.h +++ b/common/Item.h @@ -196,7 +196,13 @@ public: // Test whether a given slot can support a container item static bool SupportsContainers(int16 slot_id); + void dumpItemCollection(const map &collection); + void dumpBagContents(ItemInst *inst); + 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); diff --git a/zone/client.cpp b/zone/client.cpp index 7b2460879..58219b697 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -597,7 +597,7 @@ bool Client::Save(uint8 iCommitNow) { p_timers.Store(&database); // printf("Dumping inventory on save:\n"); -// m_inv.dumpInventory(); +// m_inv.dumpEntireInventory(); SaveTaskState(); if (iCommitNow <= 1) { diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 11525537d..348ec7be2 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -9195,7 +9195,7 @@ bool Client::FinishConnState2(DBAsyncWork* dbaw) { #ifdef _EQDEBUG printf("Dumping inventory on load:\n"); - m_inv.dumpInventory(); + m_inv.dumpEntireInventory(); #endif //lost in current PP