broke up dumpInventory into methods, changed it to dumpEntireInventory (dumpInventory now only dumps a small peice)

This commit is contained in:
Arthur Ice 2013-05-21 22:51:35 -07:00
parent e9577db9c2
commit d7546e09ee
4 changed files with 67 additions and 95 deletions

View File

@ -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 <sstream>
#include <iostream>
#include <limits.h>
#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<int16, ItemInst*> &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

View File

@ -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<int16, ItemInst*> &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);

View File

@ -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) {

View File

@ -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