Inventory Swap implemented and passes tests, though still want to verify it a bit more also does not yet save but that's next. Fixed a crash in memory buffer too.

This commit is contained in:
KimLS
2015-03-02 00:44:28 -08:00
parent 14b5a8d817
commit abc5ddc5f8
13 changed files with 177 additions and 160 deletions
+5 -1
View File
@@ -1271,7 +1271,6 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
m_pp.platinum_shared = database.GetSharedPlatinum(this->AccountID());
database.ClearOldRecastTimestamps(cid); /* Clear out our old recast timestamps to keep the DB clean */
loaditems = database.GetInventory(cid, &m_inventory); /* Load Character Inventory */
database.LoadCharacterBandolier(cid, &m_pp); /* Load Character Bandolier */
database.LoadCharacterBindPoint(cid, &m_pp); /* Load Character Bind */
database.LoadCharacterMaterialColor(cid, &m_pp); /* Load Character Material */
@@ -1287,6 +1286,11 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
database.LoadCharacterLeadershipAA(cid, &m_pp); /* Load Character Leadership AA's */
database.LoadCharacterTribute(cid, &m_pp); /* Load CharacterTribute */
m_inventory.SetRace(GetBaseRace());
m_inventory.SetClass(GetBaseClass());
m_inventory.SetDeity(GetDeity());
loaditems = database.GetInventory(cid, &m_inventory); /* Load Character Inventory */
/* Load AdventureStats */
AdventureStats_Struct as;
if(database.GetAdventureStats(cid, &as))
-100
View File
@@ -824,106 +824,6 @@ void Client::BulkSendInventoryItems() {
EQApplicationPacket outapp(OP_CharInventory, items.Size());
memcpy(outapp.pBuffer, items, items.Size());
QueuePacket(&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) {
+4 -2
View File
@@ -3133,12 +3133,14 @@ bool Client::SwapItem(const EQEmu::InventorySlot &src, const EQEmu::InventorySlo
}
}
Message(0, "%s -> %s (%i)\n", src.IsCursor() ? "Cursor" : src.ToString().c_str(), dest.IsCursor() ? "Cursor" : dest.ToString().c_str(), number_in_stack);
bool res = m_inventory.Swap(src, dest, number_in_stack);
if(res) {
printf("Swap success\n");
Message(0, "Swap success\n");
} else {
printf("Swap failure!\n");
Message(0, "Swap failure!\n");
}
if(auto_attack && res && recalc_weapon_speed) {