Working working working on getting the basics setup

This commit is contained in:
KimLS 2015-02-21 15:21:45 -08:00
parent a90e9cf4c6
commit f511862004
10 changed files with 260 additions and 263 deletions

View File

@ -92,3 +92,7 @@ bool EQEmu::Inventory::Put(const InventorySlot &slot, std::shared_ptr<ItemInstan
return false; return false;
} }
bool EQEmu::Inventory::Swap(const InventorySlot &src, const InventorySlot &dest) {
return false;
}

View File

@ -59,7 +59,9 @@ namespace EQEmu
std::shared_ptr<ItemInstance> Get(const InventorySlot &slot); std::shared_ptr<ItemInstance> Get(const InventorySlot &slot);
bool Put(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst); bool Put(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst);
bool Swap(const InventorySlot &src, const InventorySlot &dest); bool Swap(const InventorySlot &src, const InventorySlot &dest);
void Serialize();
private: private:
struct impl; struct impl;
impl *impl_; impl *impl_;

View File

@ -23,7 +23,7 @@ EQEmu::ItemContainer::ItemContainer(ItemContainer &&other) {
other.impl_ = nullptr; other.impl_ = nullptr;
} }
std::shared_ptr<EQEmu::ItemInstance> EQEmu::ItemContainer::Get(int slot_id) { std::shared_ptr<EQEmu::ItemInstance> EQEmu::ItemContainer::Get(const int slot_id) {
auto iter = impl_->items.find(slot_id); auto iter = impl_->items.find(slot_id);
if(iter != impl_->items.end()) { if(iter != impl_->items.end()) {
return iter->second; return iter->second;
@ -32,7 +32,7 @@ std::shared_ptr<EQEmu::ItemInstance> EQEmu::ItemContainer::Get(int slot_id) {
return std::shared_ptr<EQEmu::ItemInstance>(nullptr); return std::shared_ptr<EQEmu::ItemInstance>(nullptr);
} }
bool EQEmu::ItemContainer::Put(int slot_id, std::shared_ptr<ItemInstance> inst) { bool EQEmu::ItemContainer::Put(const int slot_id, std::shared_ptr<ItemInstance> inst) {
if(!inst) if(!inst)
return false; return false;
@ -46,7 +46,7 @@ bool EQEmu::ItemContainer::Put(int slot_id, std::shared_ptr<ItemInstance> inst)
return false; return false;
} }
bool EQEmu::ItemContainer::Delete(int slot_id) { bool EQEmu::ItemContainer::Delete(const int slot_id) {
auto iter = impl_->items.find(slot_id); auto iter = impl_->items.find(slot_id);
if(iter == impl_->items.end()) { if(iter == impl_->items.end()) {
return false; return false;

View File

@ -31,9 +31,9 @@ namespace EQEmu
~ItemContainer(); ~ItemContainer();
ItemContainer(ItemContainer &&other); ItemContainer(ItemContainer &&other);
std::shared_ptr<ItemInstance> Get(int slot_id); std::shared_ptr<ItemInstance> Get(const int slot_id);
bool Put(int slot_id, std::shared_ptr<ItemInstance> inst); bool Put(const int slot_id, std::shared_ptr<ItemInstance> inst);
bool Delete(int slot_id); bool Delete(const int slot_id);
private: private:
ItemContainer(const ItemContainer &other); ItemContainer(const ItemContainer &other);
ItemContainer& operator=(const ItemContainer &other); ItemContainer& operator=(const ItemContainer &other);

View File

@ -31,6 +31,7 @@ struct EQEmu::ItemInstance::impl {
uint32 ornament_icon_; uint32 ornament_icon_;
uint32 ornament_hero_model_; uint32 ornament_hero_model_;
uint64 tracking_id_; uint64 tracking_id_;
uint32 recast_timestamp_;
ItemContainer contents_; ItemContainer contents_;
}; };
@ -44,6 +45,7 @@ EQEmu::ItemInstance::ItemInstance() {
impl_->ornament_idfile_ = 0; impl_->ornament_idfile_ = 0;
impl_->ornament_icon_ = 0; impl_->ornament_icon_ = 0;
impl_->ornament_hero_model_ = 0; impl_->ornament_hero_model_ = 0;
impl_->recast_timestamp_ = 0;
impl_->tracking_id_ = 0; impl_->tracking_id_ = 0;
} }
@ -57,6 +59,7 @@ EQEmu::ItemInstance::ItemInstance(const ItemData* idata) {
impl_->ornament_idfile_ = 0; impl_->ornament_idfile_ = 0;
impl_->ornament_icon_ = 0; impl_->ornament_icon_ = 0;
impl_->ornament_hero_model_ = 0; impl_->ornament_hero_model_ = 0;
impl_->recast_timestamp_ = 0;
impl_->tracking_id_ = 0; impl_->tracking_id_ = 0;
} }
@ -70,6 +73,7 @@ EQEmu::ItemInstance::ItemInstance(const ItemData* idata, int16 charges) {
impl_->ornament_idfile_ = 0; impl_->ornament_idfile_ = 0;
impl_->ornament_icon_ = 0; impl_->ornament_icon_ = 0;
impl_->ornament_hero_model_ = 0; impl_->ornament_hero_model_ = 0;
impl_->recast_timestamp_ = 0;
impl_->tracking_id_ = 0; impl_->tracking_id_ = 0;
} }
@ -81,7 +85,7 @@ const ItemData *EQEmu::ItemInstance::GetItem() {
return impl_->modified_item_ ? impl_->modified_item_ : impl_->base_item_; return impl_->modified_item_ ? impl_->modified_item_ : impl_->base_item_;
} }
std::shared_ptr<EQEmu::ItemInstance> EQEmu::ItemInstance::Get(int index) { std::shared_ptr<EQEmu::ItemInstance> EQEmu::ItemInstance::Get(const int index) {
if(EQEmu::ValueWithin(index, 0, 255)) { if(EQEmu::ValueWithin(index, 0, 255)) {
return impl_->contents_.Get(index); return impl_->contents_.Get(index);
} }
@ -89,7 +93,7 @@ std::shared_ptr<EQEmu::ItemInstance> EQEmu::ItemInstance::Get(int index) {
return std::shared_ptr<EQEmu::ItemInstance>(nullptr); return std::shared_ptr<EQEmu::ItemInstance>(nullptr);
} }
bool EQEmu::ItemInstance::Put(int index, std::shared_ptr<ItemInstance> inst) { bool EQEmu::ItemInstance::Put(const int index, std::shared_ptr<ItemInstance> inst) {
if(!inst || !inst->GetItem()) { if(!inst || !inst->GetItem()) {
return false; return false;
} }
@ -126,3 +130,40 @@ bool EQEmu::ItemInstance::Put(int index, std::shared_ptr<ItemInstance> inst) {
return false; return false;
} }
void EQEmu::ItemInstance::SetCharges(const int16 charges) {
impl_->charges_ = charges;
}
void EQEmu::ItemInstance::SetColor(const uint32 color) {
impl_->color_ = color;
}
void EQEmu::ItemInstance::SetAttuned(const bool attuned) {
impl_->attuned_ = attuned;
}
void EQEmu::ItemInstance::SetCustomData(const std::string &custom_data) {
//We need to actually set the custom data stuff based on this string
impl_->custom_data_ = custom_data;
}
void EQEmu::ItemInstance::SetOrnamentIDFile(const uint32 ornament_idfile) {
impl_->ornament_idfile_ = ornament_idfile;
}
void EQEmu::ItemInstance::SetOrnamentIcon(const uint32 ornament_icon) {
impl_->ornament_icon_ = ornament_icon;
}
void EQEmu::ItemInstance::SetOrnamentHeroModel(const uint32 ornament_hero_model) {
impl_->ornament_hero_model_ = ornament_hero_model;
}
void EQEmu::ItemInstance::SetTrackingID(const uint64 tracking_id) {
impl_->tracking_id_ = tracking_id;
}
void EQEmu::ItemInstance::SetRecastTimestamp(const uint32 recast_timestamp) {
impl_->recast_timestamp_ = recast_timestamp;
}

View File

@ -29,12 +29,22 @@ namespace EQEmu
public: public:
ItemInstance(); ItemInstance();
ItemInstance(const ItemData* idata); ItemInstance(const ItemData* idata);
ItemInstance(const ItemData* idata, int16 charges); ItemInstance(const ItemData* idata, const int16 charges);
~ItemInstance(); ~ItemInstance();
const ItemData *GetItem(); const ItemData *GetItem();
std::shared_ptr<ItemInstance> Get(int index); std::shared_ptr<ItemInstance> Get(const int index);
bool Put(int index, std::shared_ptr<ItemInstance> inst); bool Put(const int index, std::shared_ptr<ItemInstance> inst);
void SetCharges(const int16 charges);
void SetColor(const uint32 color);
void SetAttuned(const bool attuned);
void SetCustomData(const std::string &custom_data);
void SetOrnamentIDFile(const uint32 ornament_idfile);
void SetOrnamentIcon(const uint32 ornament_icon);
void SetOrnamentHeroModel(const uint32 ornament_hero_model);
void SetTrackingID(const uint64 tracking_id);
void SetRecastTimestamp(const uint32 recast_timestamp);
private: private:
struct impl; struct impl;
impl *impl_; impl *impl_;

View File

@ -487,145 +487,63 @@ bool SharedDatabase::GetSharedBank(uint32 id, InventoryOld *inv, bool is_charid)
// Overloaded: Retrieve character inventory based on character id // Overloaded: Retrieve character inventory based on character id
bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::Inventory *inv) bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::Inventory *inv)
{ {
return false; std::string query = StringFormat("SELECT type, slot, bag_index, aug_index, item_id, charges, color, attuned, "
//// Retrieve character inventory "custom_data, ornament_icon, ornament_idfile, ornament_hero_model, tracking_id "
//std::string query = "FROM character_inventory WHERE id=%u ORDER BY type, slot, bag_index, aug_index",
// StringFormat("SELECT slotid, itemid, charges, color, augslot1, augslot2, augslot3, augslot4, augslot5, " char_id);
// "augslot6, instnodrop, custom_data, ornamenticon, ornamentidfile, ornament_hero_model FROM "
// "inventory WHERE charid = %i ORDER BY slotid", auto results = QueryDatabase(query);
// char_id);
//auto results = QueryDatabase(query); if (!results.Success()) {
//if (!results.Success()) { Log.Out(Logs::General, Logs::Error, "Error with query in SharedDatabase::GetInventory, could not get inventory"
// Log.Out(Logs::General, Logs::Error, "If you got an error related to the 'instnodrop' field, run the " " for character %u", char_id);
// "following SQL Queries:\nalter table inventory add instnodrop " return false;
// "tinyint(1) unsigned default 0 not null;\n"); }
// return false;
//} auto timestamps = GetItemRecastTimestamps(char_id);
// for(auto row : results) {
//auto timestamps = GetItemRecastTimestamps(char_id); int type = atoi(row[0]);
// int slot = atoi(row[1]);
//for (auto row = results.begin(); row != results.end(); ++row) { int bag_index = atoi(row[2]);
// int16 slot_id = atoi(row[0]); int aug_index = atoi(row[3]);
// uint32 item_id = atoi(row[1]); int item_id = atoi(row[4]);
// uint16 charges = atoi(row[2]); int charges = atoi(row[5]);
// uint32 color = atoul(row[3]);
// auto inst = CreateItem(item_id, charges);
// uint32 aug[EmuConstants::ITEM_COMMON_SIZE]; if(inst) {
// uint32 color = (uint32)std::stoul(row[6]);
// aug[0] = (uint32)atoul(row[4]); int attuned = atoi(row[7]);
// aug[1] = (uint32)atoul(row[5]); uint32 ornament_icon = (uint32)std::stoul(row[9]);
// aug[2] = (uint32)atoul(row[6]); uint32 ornament_idfile = (uint32)std::stoul(row[10]);
// aug[3] = (uint32)atoul(row[7]); uint32 ornament_hero_model = (uint32)std::stoul(row[11]);
// aug[4] = (uint32)atoul(row[8]); uint64 tracking_id = (uint64)std::stoull(row[12]);
// aug[5] = (uint32)atoul(row[9]);
// inst->SetColor(color);
// bool instnodrop = (row[10] && (uint16)atoi(row[10])) ? true : false; inst->SetAttuned(attuned ? true : false);
// inst->SetCustomData(row[8]);
// uint32 ornament_icon = (uint32)atoul(row[12]); inst->SetOrnamentIcon(ornament_icon);
// uint32 ornament_idfile = (uint32)atoul(row[13]); inst->SetOrnamentIDFile(ornament_idfile);
// uint32 ornament_hero_model = (uint32)atoul(row[14]); inst->SetOrnamentHeroModel(ornament_hero_model);
// inst->SetTrackingID(tracking_id);
// const ItemData *item = GetItem(item_id);
// auto *item = inst->GetItem();
// if (!item) { if(item->RecastDelay) {
// Log.Out(Logs::General, Logs::Error, if(timestamps.count(item->RecastType)) {
// "Warning: charid %i has an invalid item_id %i in inventory slot %i", char_id, item_id, inst->SetRecastTimestamp(timestamps.at(item->RecastType));
// slot_id); }
// continue; }
// }
// if(!inv->Put(EQEmu::InventorySlot(type, slot, bag_index, aug_index), inst)) {
// int16 put_slot_id = INVALID_INDEX; Log.Out(Logs::General, Logs::Error, "Error putting item %u into (%d, %d, %d, %d) for char %u.",
// item_id, type, slot, bag_index, aug_index, char_id);
// ItemInst *inst = CreateBaseItemOld(item, charges); }
// } else {
// if (inst == nullptr) Log.Out(Logs::General, Logs::Error, "Error putting item %u into (%d, %d, %d, %d) for char %u. Item does not exist.",
// continue; item_id, type, slot, bag_index, aug_index, char_id);
// }
// if (row[11]) { }
// std::string data_str(row[11]);
// std::string idAsString; return true;
// 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 // Overloaded: Retrieve character inventory based on account_id and character name

View File

@ -38,6 +38,7 @@ public:
~InventoryTest() { ~InventoryTest() {
} }
private:
void InitContainer() { void InitContainer() {
memset(&container, 0, sizeof(container)); memset(&container, 0, sizeof(container));
strcpy(container.Name, "Backpack"); strcpy(container.Name, "Backpack");
@ -174,14 +175,35 @@ public:
void InventorySwapItemsTest() void InventorySwapItemsTest()
{ {
auto swap_result = inv.Swap(EQEmu::InventorySlot(0, 23), EQEmu::InventorySlot(0, 24));
TEST_ASSERT(swap_result == true);
auto m_bag = inv.Get(EQEmu::InventorySlot(0, 24));
TEST_ASSERT(m_bag);
TEST_ASSERT(m_bag->GetItem());
TEST_ASSERT(m_bag->GetItem()->ID == 1000);
auto m_armor = m_bag->Get(0);
TEST_ASSERT(m_armor);
TEST_ASSERT(m_armor->GetItem());
TEST_ASSERT(m_armor->GetItem()->ID == 1001);
auto m_augment = m_bag->Get(1);
TEST_ASSERT(m_augment);
TEST_ASSERT(m_augment->GetItem());
TEST_ASSERT(m_augment->GetItem()->ID == 1002);
auto m_stackable = m_bag->Get(7);
TEST_ASSERT(m_stackable);
TEST_ASSERT(m_stackable->GetItem());
TEST_ASSERT(m_stackable->GetItem()->ID == 1003);
} }
private: EQEmu::Inventory inv;
EQEmu::Inventory inv; ItemData container;
ItemData container; ItemData armor;
ItemData armor; ItemData augment;
ItemData augment; ItemData stackable;
ItemData stackable;
}; };
#endif #endif

View File

@ -1716,14 +1716,14 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
*/ */
if (loaditems) { /* Dont load if a length error occurs */ if (loaditems) { /* Dont load if a length error occurs */
BulkSendInventoryItems(); BulkSendInventoryItems();
/* Send stuff on the cursor which isnt sent in bulk */ // /* Send stuff on the cursor which isnt sent in bulk */
for (auto iter = m_inv.cursor_cbegin(); iter != m_inv.cursor_cend(); ++iter) { // for (auto iter = m_inv.cursor_cbegin(); iter != m_inv.cursor_cend(); ++iter) {
/* First item cursor is sent in bulk inventory packet */ // /* First item cursor is sent in bulk inventory packet */
if (iter == m_inv.cursor_cbegin()) // if (iter == m_inv.cursor_cbegin())
continue; // continue;
const ItemInst *inst = *iter; // const ItemInst *inst = *iter;
SendItemPacket(MainCursor, inst, ItemPacketSummonItem); // SendItemPacket(MainCursor, inst, ItemPacketSummonItem);
} // }
} }
/* Task Packets */ /* Task Packets */

View File

@ -815,104 +815,104 @@ void Client::OnDisconnect(bool hard_disconnect) {
} }
void Client::BulkSendInventoryItems() { void Client::BulkSendInventoryItems() {
int16 slot_id = 0; //int16 slot_id = 0;
//
// LINKDEAD TRADE ITEMS //// LINKDEAD TRADE ITEMS
// Move trade slot items back into normal inventory..need them there now for the proceeding validity checks -U //// Move trade slot items back into normal inventory..need them there now for the proceeding validity checks -U
for(slot_id = EmuConstants::TRADE_BEGIN; slot_id <= EmuConstants::TRADE_END; slot_id++) { //for(slot_id = EmuConstants::TRADE_BEGIN; slot_id <= EmuConstants::TRADE_END; slot_id++) {
ItemInst* inst = m_inv.PopItem(slot_id); // ItemInst* inst = m_inv.PopItem(slot_id);
if(inst) { // if(inst) {
bool is_arrow = (inst->GetItem()->ItemType == ItemTypeArrow) ? true : false; // bool is_arrow = (inst->GetItem()->ItemType == ItemTypeArrow) ? true : false;
int16 free_slot_id = m_inv.FindFreeSlot(inst->IsType(ItemClassContainer), true, inst->GetItem()->Size, is_arrow); // int16 free_slot_id = m_inv.FindFreeSlot(inst->IsType(ItemClassContainer), true, inst->GetItem()->Size, is_arrow);
Log.Out(Logs::Detail, Logs::Inventory, "Incomplete Trade Transaction: Moving %s from slot %i to %i", inst->GetItem()->Name, slot_id, free_slot_id); // Log.Out(Logs::Detail, Logs::Inventory, "Incomplete Trade Transaction: Moving %s from slot %i to %i", inst->GetItem()->Name, slot_id, free_slot_id);
PutItemInInventory(free_slot_id, *inst, false); // PutItemInInventory(free_slot_id, *inst, false);
database.SaveInventory(character_id, nullptr, slot_id); // database.SaveInventory(character_id, nullptr, slot_id);
safe_delete(inst); // safe_delete(inst);
} // }
} //}
//
bool deletenorent = database.NoRentExpired(GetName()); //bool deletenorent = database.NoRentExpired(GetName());
if(deletenorent){ RemoveNoRent(false); } //client was offline for more than 30 minutes, delete no rent items //if(deletenorent){ RemoveNoRent(false); } //client was offline for more than 30 minutes, delete no rent items
//
RemoveDuplicateLore(false); //RemoveDuplicateLore(false);
MoveSlotNotAllowed(false); //MoveSlotNotAllowed(false);
//
// The previous three method calls took care of moving/removing expired/illegal item placements -U //// The previous three method calls took care of moving/removing expired/illegal item placements -U
//
//TODO: this function is just retarded... it re-allocates the buffer for every ////TODO: this function is just retarded... it re-allocates the buffer for every
//new item. It should be changed to loop through once, gather the ////new item. It should be changed to loop through once, gather the
//lengths, and item packet pointers into an array (fixed length), and ////lengths, and item packet pointers into an array (fixed length), and
//then loop again to build the packet. ////then loop again to build the packet.
//EQApplicationPacket *packets[50]; ////EQApplicationPacket *packets[50];
//unsigned long buflen = 0; ////unsigned long buflen = 0;
//unsigned long pos = 0; ////unsigned long pos = 0;
//memset(packets, 0, sizeof(packets)); ////memset(packets, 0, sizeof(packets));
//foreach item in the invendor sections ////foreach item in the invendor sections
// packets[pos++] = ReturnItemPacket(...) //// packets[pos++] = ReturnItemPacket(...)
// buflen += temp->size //// buflen += temp->size
//... ////...
//allocat the buffer ////allocat the buffer
//for r from 0 to pos ////for r from 0 to pos
// put pos[r]->pBuffer into the buffer //// put pos[r]->pBuffer into the buffer
//for r from 0 to pos ////for r from 0 to pos
// safe_delete(pos[r]); //// safe_delete(pos[r]);
//
uint32 size = 0; //uint32 size = 0;
uint16 i = 0; //uint16 i = 0;
std::map<uint16, std::string> ser_items; //std::map<uint16, std::string> ser_items;
std::map<uint16, std::string>::iterator itr; //std::map<uint16, std::string>::iterator itr;
//
//Inventory items ////Inventory items
for(slot_id = MAIN_BEGIN; slot_id < EmuConstants::MAP_POSSESSIONS_SIZE; slot_id++) { //for(slot_id = MAIN_BEGIN; slot_id < EmuConstants::MAP_POSSESSIONS_SIZE; slot_id++) {
const ItemInst* inst = m_inv[slot_id]; // const ItemInst* inst = m_inv[slot_id];
if(inst) { // if(inst) {
std::string packet = inst->Serialize(slot_id); // std::string packet = inst->Serialize(slot_id);
ser_items[i++] = packet; // ser_items[i++] = packet;
size += packet.length(); // size += packet.length();
} // }
} //}
//
// Power Source //// Power Source
if(GetClientVersion() >= ClientVersion::SoF) { //if(GetClientVersion() >= ClientVersion::SoF) {
const ItemInst* inst = m_inv[MainPowerSource]; // const ItemInst* inst = m_inv[MainPowerSource];
if(inst) { // if(inst) {
std::string packet = inst->Serialize(MainPowerSource); // std::string packet = inst->Serialize(MainPowerSource);
ser_items[i++] = packet; // ser_items[i++] = packet;
size += packet.length(); // size += packet.length();
} // }
} //}
//
// Bank items //// Bank items
for(slot_id = EmuConstants::BANK_BEGIN; slot_id <= EmuConstants::BANK_END; slot_id++) { //for(slot_id = EmuConstants::BANK_BEGIN; slot_id <= EmuConstants::BANK_END; slot_id++) {
const ItemInst* inst = m_inv[slot_id]; // const ItemInst* inst = m_inv[slot_id];
if(inst) { // if(inst) {
std::string packet = inst->Serialize(slot_id); // std::string packet = inst->Serialize(slot_id);
ser_items[i++] = packet; // ser_items[i++] = packet;
size += packet.length(); // size += packet.length();
} // }
} //}
//
// Shared Bank items //// Shared Bank items
for(slot_id = EmuConstants::SHARED_BANK_BEGIN; slot_id <= EmuConstants::SHARED_BANK_END; slot_id++) { //for(slot_id = EmuConstants::SHARED_BANK_BEGIN; slot_id <= EmuConstants::SHARED_BANK_END; slot_id++) {
const ItemInst* inst = m_inv[slot_id]; // const ItemInst* inst = m_inv[slot_id];
if(inst) { // if(inst) {
std::string packet = inst->Serialize(slot_id); // std::string packet = inst->Serialize(slot_id);
ser_items[i++] = packet; // ser_items[i++] = packet;
size += packet.length(); // size += packet.length();
} // }
} //}
//
EQApplicationPacket* outapp = new EQApplicationPacket(OP_CharInventory, size); //EQApplicationPacket* outapp = new EQApplicationPacket(OP_CharInventory, size);
uchar* ptr = outapp->pBuffer; //uchar* ptr = outapp->pBuffer;
for(itr = ser_items.begin(); itr != ser_items.end(); ++itr){ //for(itr = ser_items.begin(); itr != ser_items.end(); ++itr){
int length = itr->second.length(); // int length = itr->second.length();
if(length > 5) { // if(length > 5) {
memcpy(ptr, itr->second.c_str(), length); // memcpy(ptr, itr->second.c_str(), length);
ptr += length; // ptr += length;
} // }
} //}
QueuePacket(outapp); //QueuePacket(outapp);
safe_delete(outapp); //safe_delete(outapp);
} }
void Client::BulkSendMerchantInventory(int merchant_id, int npcid) { void Client::BulkSendMerchantInventory(int merchant_id, int npcid) {