From 915f22d564ea5de138f564d93ac3ebf58b1734b0 Mon Sep 17 00:00:00 2001 From: Uleat Date: Wed, 11 May 2016 00:30:04 -0400 Subject: [PATCH] Added 'ItemInst::Serialize()' overload to make use of std::stringstream implementation --- changelog.txt | 1 + common/item.h | 4 +++- zone/client_process.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/changelog.txt b/changelog.txt index f37bad44d..971a49cb9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,7 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) == 05/10/2016 == Uleat: Converted client translators' 'SerializeItem()' to recursive, single buffer methodology. Titanium SerializeItem() now adds a null term between parent items instead of the invoking function Uleat: Converted server 'BulkSendInventoryItems()' to use single buffer methodology +Uleat: Added 'ItemInst::Serialize()' overload to make use of the above single buffer methodology == 05/08/2016 == Uleat: Re-coded Titanium client translator 'SerializeItem()' to use coded property assignments over file enumerated ones diff --git a/common/item.h b/common/item.h index 54bd519fc..22da54183 100644 --- a/common/item.h +++ b/common/item.h @@ -411,7 +411,9 @@ public: int8 GetMaxEvolveLvl() const; uint32 GetKillsNeeded(uint8 currentlevel); - std::string Serialize(int16 slot_id) const { InternalSerializedItem_Struct s; s.slot_id=slot_id; s.inst=(const void *)this; std::string ser; ser.assign((char *)&s,sizeof(InternalSerializedItem_Struct)); return ser; } + std::string Serialize(int16 slot_id) const { InternalSerializedItem_Struct s; s.slot_id = slot_id; s.inst = (const void*)this; std::string ser; ser.assign((char*)&s, sizeof(InternalSerializedItem_Struct)); return ser; } + void Serialize(std::stringstream& ss, int16 slot_id) const { InternalSerializedItem_Struct isi; isi.slot_id = slot_id; isi.inst = (const void*)this; ss.write((const char*)&isi, sizeof(isi)); } + inline int32 GetSerialNumber() const { return m_SerialNumber; } inline void SetSerialNumber(int32 id) { m_SerialNumber = id; } diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 0751ac0a9..8c58049ab 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -768,7 +768,7 @@ void Client::BulkSendInventoryItems() if (!inst) continue; - ss << inst->Serialize(slot_id); + inst->Serialize(ss, slot_id); if (ss.tellp() == last_pos) Log.Out(Logs::General, Logs::Inventory, "Serialization failed on item slot %d during BulkSendInventoryItems. Item skipped.", slot_id); @@ -780,7 +780,7 @@ void Client::BulkSendInventoryItems() if (ClientVersion() >= EQEmu::versions::ClientVersion::SoF) { const ItemInst* inst = m_inv[EQEmu::legacy::SlotPowerSource]; if (inst) { - ss << inst->Serialize(EQEmu::legacy::SlotPowerSource); + inst->Serialize(ss, EQEmu::legacy::SlotPowerSource); if (ss.tellp() == last_pos) Log.Out(Logs::General, Logs::Inventory, "Serialization failed on item slot %d during BulkSendInventoryItems. Item skipped.", EQEmu::legacy::SlotPowerSource); @@ -795,7 +795,7 @@ void Client::BulkSendInventoryItems() if (!inst) continue; - ss << inst->Serialize(slot_id); + inst->Serialize(ss, slot_id); if (ss.tellp() == last_pos) Log.Out(Logs::General, Logs::Inventory, "Serialization failed on item slot %d during BulkSendInventoryItems. Item skipped.", slot_id); @@ -809,7 +809,7 @@ void Client::BulkSendInventoryItems() if (!inst) continue; - ss << inst->Serialize(slot_id); + inst->Serialize(ss, slot_id); if (ss.tellp() == last_pos) Log.Out(Logs::General, Logs::Inventory, "Serialization failed on item slot %d during BulkSendInventoryItems. Item skipped.", slot_id);