mirror of
https://github.com/EQEmu/Server.git
synced 2026-01-07 22:53:51 +00:00
Working working working on getting the basics setup
This commit is contained in:
parent
a90e9cf4c6
commit
f511862004
@ -92,3 +92,7 @@ bool EQEmu::Inventory::Put(const InventorySlot &slot, std::shared_ptr<ItemInstan
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EQEmu::Inventory::Swap(const InventorySlot &src, const InventorySlot &dest) {
|
||||
return false;
|
||||
}
|
||||
@ -59,7 +59,9 @@ namespace EQEmu
|
||||
|
||||
std::shared_ptr<ItemInstance> Get(const InventorySlot &slot);
|
||||
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:
|
||||
struct impl;
|
||||
impl *impl_;
|
||||
|
||||
@ -23,7 +23,7 @@ EQEmu::ItemContainer::ItemContainer(ItemContainer &&other) {
|
||||
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);
|
||||
if(iter != impl_->items.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
return false;
|
||||
|
||||
@ -46,7 +46,7 @@ bool EQEmu::ItemContainer::Put(int slot_id, std::shared_ptr<ItemInstance> inst)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EQEmu::ItemContainer::Delete(int slot_id) {
|
||||
bool EQEmu::ItemContainer::Delete(const int slot_id) {
|
||||
auto iter = impl_->items.find(slot_id);
|
||||
if(iter == impl_->items.end()) {
|
||||
return false;
|
||||
|
||||
@ -31,9 +31,9 @@ namespace EQEmu
|
||||
~ItemContainer();
|
||||
ItemContainer(ItemContainer &&other);
|
||||
|
||||
std::shared_ptr<ItemInstance> Get(int slot_id);
|
||||
bool Put(int slot_id, std::shared_ptr<ItemInstance> inst);
|
||||
bool Delete(int slot_id);
|
||||
std::shared_ptr<ItemInstance> Get(const int slot_id);
|
||||
bool Put(const int slot_id, std::shared_ptr<ItemInstance> inst);
|
||||
bool Delete(const int slot_id);
|
||||
private:
|
||||
ItemContainer(const ItemContainer &other);
|
||||
ItemContainer& operator=(const ItemContainer &other);
|
||||
|
||||
@ -31,6 +31,7 @@ struct EQEmu::ItemInstance::impl {
|
||||
uint32 ornament_icon_;
|
||||
uint32 ornament_hero_model_;
|
||||
uint64 tracking_id_;
|
||||
uint32 recast_timestamp_;
|
||||
ItemContainer contents_;
|
||||
};
|
||||
|
||||
@ -44,6 +45,7 @@ EQEmu::ItemInstance::ItemInstance() {
|
||||
impl_->ornament_idfile_ = 0;
|
||||
impl_->ornament_icon_ = 0;
|
||||
impl_->ornament_hero_model_ = 0;
|
||||
impl_->recast_timestamp_ = 0;
|
||||
impl_->tracking_id_ = 0;
|
||||
}
|
||||
|
||||
@ -57,6 +59,7 @@ EQEmu::ItemInstance::ItemInstance(const ItemData* idata) {
|
||||
impl_->ornament_idfile_ = 0;
|
||||
impl_->ornament_icon_ = 0;
|
||||
impl_->ornament_hero_model_ = 0;
|
||||
impl_->recast_timestamp_ = 0;
|
||||
impl_->tracking_id_ = 0;
|
||||
}
|
||||
|
||||
@ -70,6 +73,7 @@ EQEmu::ItemInstance::ItemInstance(const ItemData* idata, int16 charges) {
|
||||
impl_->ornament_idfile_ = 0;
|
||||
impl_->ornament_icon_ = 0;
|
||||
impl_->ornament_hero_model_ = 0;
|
||||
impl_->recast_timestamp_ = 0;
|
||||
impl_->tracking_id_ = 0;
|
||||
}
|
||||
|
||||
@ -81,7 +85,7 @@ const ItemData *EQEmu::ItemInstance::GetItem() {
|
||||
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)) {
|
||||
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);
|
||||
}
|
||||
|
||||
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()) {
|
||||
return false;
|
||||
}
|
||||
@ -126,3 +130,40 @@ bool EQEmu::ItemInstance::Put(int index, std::shared_ptr<ItemInstance> inst) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -29,12 +29,22 @@ namespace EQEmu
|
||||
public:
|
||||
ItemInstance();
|
||||
ItemInstance(const ItemData* idata);
|
||||
ItemInstance(const ItemData* idata, int16 charges);
|
||||
ItemInstance(const ItemData* idata, const int16 charges);
|
||||
~ItemInstance();
|
||||
|
||||
const ItemData *GetItem();
|
||||
std::shared_ptr<ItemInstance> Get(int index);
|
||||
bool Put(int index, std::shared_ptr<ItemInstance> inst);
|
||||
std::shared_ptr<ItemInstance> Get(const int index);
|
||||
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:
|
||||
struct impl;
|
||||
impl *impl_;
|
||||
|
||||
@ -487,145 +487,63 @@ bool SharedDatabase::GetSharedBank(uint32 id, InventoryOld *inv, bool is_charid)
|
||||
// Overloaded: Retrieve character inventory based on character id
|
||||
bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::Inventory *inv)
|
||||
{
|
||||
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 = CreateBaseItemOld(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);
|
||||
std::string query = StringFormat("SELECT type, slot, bag_index, aug_index, item_id, charges, color, attuned, "
|
||||
"custom_data, ornament_icon, ornament_idfile, ornament_hero_model, tracking_id "
|
||||
"FROM character_inventory WHERE id=%u ORDER BY type, slot, bag_index, aug_index",
|
||||
char_id);
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
Log.Out(Logs::General, Logs::Error, "Error with query in SharedDatabase::GetInventory, could not get inventory"
|
||||
" for character %u", char_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto timestamps = GetItemRecastTimestamps(char_id);
|
||||
for(auto row : results) {
|
||||
int type = atoi(row[0]);
|
||||
int slot = atoi(row[1]);
|
||||
int bag_index = atoi(row[2]);
|
||||
int aug_index = atoi(row[3]);
|
||||
int item_id = atoi(row[4]);
|
||||
int charges = atoi(row[5]);
|
||||
|
||||
auto inst = CreateItem(item_id, charges);
|
||||
if(inst) {
|
||||
uint32 color = (uint32)std::stoul(row[6]);
|
||||
int attuned = atoi(row[7]);
|
||||
uint32 ornament_icon = (uint32)std::stoul(row[9]);
|
||||
uint32 ornament_idfile = (uint32)std::stoul(row[10]);
|
||||
uint32 ornament_hero_model = (uint32)std::stoul(row[11]);
|
||||
uint64 tracking_id = (uint64)std::stoull(row[12]);
|
||||
|
||||
inst->SetColor(color);
|
||||
inst->SetAttuned(attuned ? true : false);
|
||||
inst->SetCustomData(row[8]);
|
||||
inst->SetOrnamentIcon(ornament_icon);
|
||||
inst->SetOrnamentIDFile(ornament_idfile);
|
||||
inst->SetOrnamentHeroModel(ornament_hero_model);
|
||||
inst->SetTrackingID(tracking_id);
|
||||
|
||||
auto *item = inst->GetItem();
|
||||
if(item->RecastDelay) {
|
||||
if(timestamps.count(item->RecastType)) {
|
||||
inst->SetRecastTimestamp(timestamps.at(item->RecastType));
|
||||
}
|
||||
}
|
||||
|
||||
if(!inv->Put(EQEmu::InventorySlot(type, slot, bag_index, aug_index), inst)) {
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
Log.Out(Logs::General, Logs::Error, "Error putting item %u into (%d, %d, %d, %d) for char %u. Item does not exist.",
|
||||
item_id, type, slot, bag_index, aug_index, char_id);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Overloaded: Retrieve character inventory based on account_id and character name
|
||||
|
||||
@ -38,6 +38,7 @@ public:
|
||||
~InventoryTest() {
|
||||
}
|
||||
|
||||
private:
|
||||
void InitContainer() {
|
||||
memset(&container, 0, sizeof(container));
|
||||
strcpy(container.Name, "Backpack");
|
||||
@ -174,14 +175,35 @@ public:
|
||||
|
||||
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;
|
||||
ItemData container;
|
||||
ItemData armor;
|
||||
ItemData augment;
|
||||
ItemData stackable;
|
||||
EQEmu::Inventory inv;
|
||||
ItemData container;
|
||||
ItemData armor;
|
||||
ItemData augment;
|
||||
ItemData stackable;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -1716,14 +1716,14 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
|
||||
*/
|
||||
if (loaditems) { /* Dont load if a length error occurs */
|
||||
BulkSendInventoryItems();
|
||||
/* Send stuff on the cursor which isnt sent in bulk */
|
||||
for (auto iter = m_inv.cursor_cbegin(); iter != m_inv.cursor_cend(); ++iter) {
|
||||
/* First item cursor is sent in bulk inventory packet */
|
||||
if (iter == m_inv.cursor_cbegin())
|
||||
continue;
|
||||
const ItemInst *inst = *iter;
|
||||
SendItemPacket(MainCursor, inst, ItemPacketSummonItem);
|
||||
}
|
||||
// /* Send stuff on the cursor which isnt sent in bulk */
|
||||
// for (auto iter = m_inv.cursor_cbegin(); iter != m_inv.cursor_cend(); ++iter) {
|
||||
// /* First item cursor is sent in bulk inventory packet */
|
||||
// if (iter == m_inv.cursor_cbegin())
|
||||
// continue;
|
||||
// const ItemInst *inst = *iter;
|
||||
// SendItemPacket(MainCursor, inst, ItemPacketSummonItem);
|
||||
// }
|
||||
}
|
||||
|
||||
/* Task Packets */
|
||||
|
||||
@ -815,104 +815,104 @@ void Client::OnDisconnect(bool hard_disconnect) {
|
||||
}
|
||||
|
||||
void Client::BulkSendInventoryItems() {
|
||||
int16 slot_id = 0;
|
||||
|
||||
// LINKDEAD TRADE ITEMS
|
||||
// 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++) {
|
||||
ItemInst* inst = m_inv.PopItem(slot_id);
|
||||
if(inst) {
|
||||
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);
|
||||
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);
|
||||
database.SaveInventory(character_id, nullptr, slot_id);
|
||||
safe_delete(inst);
|
||||
}
|
||||
}
|
||||
|
||||
bool deletenorent = database.NoRentExpired(GetName());
|
||||
if(deletenorent){ RemoveNoRent(false); } //client was offline for more than 30 minutes, delete no rent items
|
||||
|
||||
RemoveDuplicateLore(false);
|
||||
MoveSlotNotAllowed(false);
|
||||
|
||||
// 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
|
||||
//new item. It should be changed to loop through once, gather the
|
||||
//lengths, and item packet pointers into an array (fixed length), and
|
||||
//then loop again to build the packet.
|
||||
//EQApplicationPacket *packets[50];
|
||||
//unsigned long buflen = 0;
|
||||
//unsigned long pos = 0;
|
||||
//memset(packets, 0, sizeof(packets));
|
||||
//foreach item in the invendor sections
|
||||
// packets[pos++] = ReturnItemPacket(...)
|
||||
// buflen += temp->size
|
||||
//...
|
||||
//allocat the buffer
|
||||
//for r from 0 to pos
|
||||
// put pos[r]->pBuffer into the buffer
|
||||
//for r from 0 to pos
|
||||
// safe_delete(pos[r]);
|
||||
|
||||
uint32 size = 0;
|
||||
uint16 i = 0;
|
||||
std::map<uint16, std::string> ser_items;
|
||||
std::map<uint16, std::string>::iterator itr;
|
||||
|
||||
//Inventory items
|
||||
for(slot_id = MAIN_BEGIN; slot_id < EmuConstants::MAP_POSSESSIONS_SIZE; slot_id++) {
|
||||
const ItemInst* inst = m_inv[slot_id];
|
||||
if(inst) {
|
||||
std::string packet = inst->Serialize(slot_id);
|
||||
ser_items[i++] = packet;
|
||||
size += packet.length();
|
||||
}
|
||||
}
|
||||
|
||||
// Power Source
|
||||
if(GetClientVersion() >= ClientVersion::SoF) {
|
||||
const ItemInst* inst = m_inv[MainPowerSource];
|
||||
if(inst) {
|
||||
std::string packet = inst->Serialize(MainPowerSource);
|
||||
ser_items[i++] = packet;
|
||||
size += packet.length();
|
||||
}
|
||||
}
|
||||
|
||||
// Bank items
|
||||
for(slot_id = EmuConstants::BANK_BEGIN; slot_id <= EmuConstants::BANK_END; slot_id++) {
|
||||
const ItemInst* inst = m_inv[slot_id];
|
||||
if(inst) {
|
||||
std::string packet = inst->Serialize(slot_id);
|
||||
ser_items[i++] = packet;
|
||||
size += packet.length();
|
||||
}
|
||||
}
|
||||
|
||||
// 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) {
|
||||
std::string packet = inst->Serialize(slot_id);
|
||||
ser_items[i++] = packet;
|
||||
size += packet.length();
|
||||
}
|
||||
}
|
||||
|
||||
EQApplicationPacket* outapp = new EQApplicationPacket(OP_CharInventory, size);
|
||||
uchar* ptr = outapp->pBuffer;
|
||||
for(itr = ser_items.begin(); itr != ser_items.end(); ++itr){
|
||||
int length = itr->second.length();
|
||||
if(length > 5) {
|
||||
memcpy(ptr, itr->second.c_str(), length);
|
||||
ptr += length;
|
||||
}
|
||||
}
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
//int16 slot_id = 0;
|
||||
//
|
||||
//// LINKDEAD TRADE ITEMS
|
||||
//// 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++) {
|
||||
// ItemInst* inst = m_inv.PopItem(slot_id);
|
||||
// if(inst) {
|
||||
// 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);
|
||||
// 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);
|
||||
// database.SaveInventory(character_id, nullptr, slot_id);
|
||||
// safe_delete(inst);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//bool deletenorent = database.NoRentExpired(GetName());
|
||||
//if(deletenorent){ RemoveNoRent(false); } //client was offline for more than 30 minutes, delete no rent items
|
||||
//
|
||||
//RemoveDuplicateLore(false);
|
||||
//MoveSlotNotAllowed(false);
|
||||
//
|
||||
//// 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
|
||||
////new item. It should be changed to loop through once, gather the
|
||||
////lengths, and item packet pointers into an array (fixed length), and
|
||||
////then loop again to build the packet.
|
||||
////EQApplicationPacket *packets[50];
|
||||
////unsigned long buflen = 0;
|
||||
////unsigned long pos = 0;
|
||||
////memset(packets, 0, sizeof(packets));
|
||||
////foreach item in the invendor sections
|
||||
//// packets[pos++] = ReturnItemPacket(...)
|
||||
//// buflen += temp->size
|
||||
////...
|
||||
////allocat the buffer
|
||||
////for r from 0 to pos
|
||||
//// put pos[r]->pBuffer into the buffer
|
||||
////for r from 0 to pos
|
||||
//// safe_delete(pos[r]);
|
||||
//
|
||||
//uint32 size = 0;
|
||||
//uint16 i = 0;
|
||||
//std::map<uint16, std::string> ser_items;
|
||||
//std::map<uint16, std::string>::iterator itr;
|
||||
//
|
||||
////Inventory items
|
||||
//for(slot_id = MAIN_BEGIN; slot_id < EmuConstants::MAP_POSSESSIONS_SIZE; slot_id++) {
|
||||
// const ItemInst* inst = m_inv[slot_id];
|
||||
// if(inst) {
|
||||
// std::string packet = inst->Serialize(slot_id);
|
||||
// ser_items[i++] = packet;
|
||||
// size += packet.length();
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//// Power Source
|
||||
//if(GetClientVersion() >= ClientVersion::SoF) {
|
||||
// const ItemInst* inst = m_inv[MainPowerSource];
|
||||
// if(inst) {
|
||||
// std::string packet = inst->Serialize(MainPowerSource);
|
||||
// ser_items[i++] = packet;
|
||||
// size += packet.length();
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//// Bank items
|
||||
//for(slot_id = EmuConstants::BANK_BEGIN; slot_id <= EmuConstants::BANK_END; slot_id++) {
|
||||
// const ItemInst* inst = m_inv[slot_id];
|
||||
// if(inst) {
|
||||
// std::string packet = inst->Serialize(slot_id);
|
||||
// ser_items[i++] = packet;
|
||||
// size += packet.length();
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//// 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) {
|
||||
// std::string packet = inst->Serialize(slot_id);
|
||||
// ser_items[i++] = packet;
|
||||
// size += packet.length();
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//EQApplicationPacket* outapp = new EQApplicationPacket(OP_CharInventory, size);
|
||||
//uchar* ptr = outapp->pBuffer;
|
||||
//for(itr = ser_items.begin(); itr != ser_items.end(); ++itr){
|
||||
// int length = itr->second.length();
|
||||
// if(length > 5) {
|
||||
// memcpy(ptr, itr->second.c_str(), length);
|
||||
// ptr += length;
|
||||
// }
|
||||
//}
|
||||
//QueuePacket(outapp);
|
||||
//safe_delete(outapp);
|
||||
}
|
||||
|
||||
void Client::BulkSendMerchantInventory(int merchant_id, int npcid) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user