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
+8 -8
View File
@@ -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 */
+98 -98
View File
@@ -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) {