diff --git a/common/base_packet.cpp b/common/base_packet.cpp index b9f60f6a7..048bceb9c 100644 --- a/common/base_packet.cpp +++ b/common/base_packet.cpp @@ -19,44 +19,34 @@ #include "common/misc.h" #include "common/packet_dump.h" -BasePacket::BasePacket(const unsigned char *buf, uint32 len) +BasePacket::BasePacket(const unsigned char* buf, size_t len) { - pBuffer=nullptr; - size=0; - _wpos = 0; - _rpos = 0; - timestamp.tv_sec = 0; - if (len>0) { - size=len; - pBuffer= new unsigned char[len]; + if (len > 0) { + size = static_cast(len); + pBuffer = new unsigned char[len]; if (buf) { - memcpy(pBuffer,buf,len); - } else { - memset(pBuffer,0,len); + memcpy(pBuffer, buf, len); + } + else { + memset(pBuffer, 0, len); } } } -BasePacket::BasePacket(SerializeBuffer &buf) +BasePacket::BasePacket(SerializeBuffer&& buf) + : pBuffer(std::exchange(buf.m_buffer, nullptr)) { - pBuffer = buf.m_buffer; - buf.m_buffer = nullptr; - size = buf.m_pos; - buf.m_pos = 0; + // We are essentially taking ownership of this serialize buffer. + size = static_cast(std::exchange(buf.m_pos, 0)); buf.m_capacity = 0; - _wpos = 0; - _rpos = 0; - timestamp.tv_sec = 0; } BasePacket::~BasePacket() { - if (pBuffer) - delete[] pBuffer; - pBuffer=nullptr; + delete[] pBuffer; + pBuffer = nullptr; } - void BasePacket::build_raw_header_dump(char *buffer, uint16 seq) const { if (timestamp.tv_sec) { diff --git a/common/base_packet.h b/common/base_packet.h index 607e04576..b3ea8430e 100644 --- a/common/base_packet.h +++ b/common/base_packet.h @@ -23,14 +23,26 @@ #include -class BasePacket { +class BasePacket +{ +protected: + BasePacket() = default; + BasePacket(const unsigned char* buf, size_t len); + BasePacket(SerializeBuffer&& buf); + + virtual ~BasePacket(); + public: - unsigned char *pBuffer; - uint32 size, _wpos, _rpos; - uint32 src_ip,dst_ip; - uint16 src_port,dst_port; - uint32 priority; - timeval timestamp; + unsigned char* pBuffer = nullptr; + uint32 size = 0; + uint32 _wpos = 0; + uint32 _rpos = 0; + uint32 src_ip = 0; + uint32 dst_ip = 0; + uint16 src_port = 0; + uint16 dst_port = 0; + uint32 priority = 0; + timeval timestamp{}; virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const; virtual void build_header_dump(char *buffer) const; @@ -40,11 +52,11 @@ public: void setSrcInfo(uint32 sip, uint16 sport) { src_ip=sip; src_port=sport; } void setDstInfo(uint32 dip, uint16 dport) { dst_ip=dip; dst_port=dport; } - void setTimeInfo(uint32 ts_sec, uint32 ts_usec) { timestamp.tv_sec=ts_sec; timestamp.tv_usec=ts_usec; } + void setTimeInfo(uint32 ts_sec, uint32 ts_usec) { timestamp.tv_sec = ts_sec; timestamp.tv_usec = ts_usec; } void copyInfo(const BasePacket *p) { src_ip=p->src_ip; src_port=p->src_port; dst_ip=p->dst_ip; dst_port=p->dst_port; timestamp.tv_sec=p->timestamp.tv_sec; timestamp.tv_usec=p->timestamp.tv_usec; } inline bool operator<(const BasePacket &rhs) { - return (timestamp.tv_sec < rhs.timestamp.tv_sec || (timestamp.tv_sec==rhs.timestamp.tv_sec && timestamp.tv_usec < rhs.timestamp.tv_usec)); + return (timestamp.tv_sec < rhs.timestamp.tv_sec || (timestamp.tv_sec == rhs.timestamp.tv_sec && timestamp.tv_usec < rhs.timestamp.tv_usec)); } void WriteUInt8(uint8 value) { *(uint8 *)(pBuffer + _wpos) = value; _wpos += sizeof(uint8); } @@ -73,12 +85,6 @@ public: uint32 GetReadPosition() { return _rpos; } void SetWritePosition(uint32 Newwpos) { _wpos = Newwpos; } void SetReadPosition(uint32 Newrpos) { _rpos = Newrpos; } - -protected: - virtual ~BasePacket(); - BasePacket() { pBuffer=nullptr; size=0; _wpos = 0; _rpos = 0; } - BasePacket(const unsigned char *buf, const uint32 len); - BasePacket(SerializeBuffer &buf); }; extern void DumpPacketHex(const BasePacket* app); diff --git a/common/eq_packet.cpp b/common/eq_packet.cpp index 93b4f1052..62136ca8b 100644 --- a/common/eq_packet.cpp +++ b/common/eq_packet.cpp @@ -31,9 +31,19 @@ #include #include -EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len) -: BasePacket(buf, len), - emu_opcode(op) +EQPacket::EQPacket() +{ +} + +EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, size_t len) + : BasePacket(buf, len) + , emu_opcode(op) +{ +} + +EQPacket::EQPacket(EmuOpcode opcode, SerializeBuffer&& buf) + : BasePacket(std::move(buf)) + , emu_opcode(opcode) { } @@ -360,17 +370,16 @@ EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const u } } -void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) { +void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) +{ if (iShowInfo) { - std::cout << "Dumping Applayer: 0x" << std::hex << std::setfill('0') << std::setw(4) << app->GetOpcode() << std::dec; - std::cout << " size:" << app->size << std::endl; + printf("Dumping Applayer: 0x%04x size: %u", app->GetOpcode(), app->size); } + DumpPacketHex(app->pBuffer, app->size); -// DumpPacketAscii(app->pBuffer, app->size); } -std::string DumpPacketToString(const EQApplicationPacket* app){ - std::ostringstream out; - out << DumpPacketHexToString(app->pBuffer, app->size); - return out.str(); +std::string DumpPacketToString(const EQApplicationPacket* app) +{ + return DumpPacketHexToString(app->pBuffer, app->size); } diff --git a/common/eq_packet.h b/common/eq_packet.h index e2d0d2710..e8ad80d12 100644 --- a/common/eq_packet.h +++ b/common/eq_packet.h @@ -28,8 +28,15 @@ #include "common/emu_opcodes.h" #endif -class EQPacket : public BasePacket { +class EQPacket : public BasePacket +{ friend class EQStream; + +protected: + EQPacket(); + EQPacket(EmuOpcode opcode, const unsigned char* buf, size_t len); + EQPacket(EmuOpcode opcode, SerializeBuffer&& buf); + public: virtual ~EQPacket() {} @@ -41,19 +48,12 @@ public: virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const; void SetOpcode(EmuOpcode op) { emu_opcode = op; } - const EmuOpcode GetOpcode() const { return(emu_opcode); } -// const char *GetOpcodeName() const; + EmuOpcode GetOpcode() const { return(emu_opcode); } protected: //this is just a cache so we dont look it up several times on Get() //and it is mutable so we can store the cached copy even on a const object - EmuOpcode emu_opcode; - - EQPacket(EmuOpcode opcode, const unsigned char *buf, const uint32 len); - EQPacket(EmuOpcode opcode, SerializeBuffer &buf) : BasePacket(buf), emu_opcode(opcode) { }; -// EQPacket(const EQPacket &p) { } - EQPacket() { emu_opcode=OP_Unknown; pBuffer=nullptr; size=0; } - + EmuOpcode emu_opcode = OP_Unknown; }; class EQRawApplicationPacket; @@ -90,19 +90,43 @@ protected: uint16 opcode; }; -class EQApplicationPacket : public EQPacket { +class EQApplicationPacket : public EQPacket +{ friend class EQStream; + +public: + EQApplicationPacket() + { + } + + EQApplicationPacket(EmuOpcode op) + : EQPacket(op, nullptr, 0) + { + } + + EQApplicationPacket(EmuOpcode op, size_t len) + : EQPacket(op, nullptr, len) + { + } + EQApplicationPacket(EmuOpcode op, const unsigned char* buf, size_t len) + : EQPacket(op, buf, len) + { + } + + EQApplicationPacket(EmuOpcode op, SerializeBuffer&& buf) + : EQPacket(op, std::move(buf)) + { + } + +private: + EQApplicationPacket(const EQApplicationPacket& p) + : EQPacket(p.emu_opcode, p.pBuffer, p.size) + , app_opcode_size(p.app_opcode_size) + , opcode_bypass(p.opcode_bypass) + { + } + public: - EQApplicationPacket() : EQPacket(OP_Unknown, nullptr, 0), opcode_bypass(0) - { app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; } - EQApplicationPacket(const EmuOpcode op) : EQPacket(op, nullptr, 0), opcode_bypass(0) - { app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; } - EQApplicationPacket(const EmuOpcode op, const uint32 len) : EQPacket(op, nullptr, len), opcode_bypass(0) - { app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; } - EQApplicationPacket(const EmuOpcode op, const unsigned char *buf, const uint32 len) : EQPacket(op, buf, len), opcode_bypass(0) - { app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; } - EQApplicationPacket(const EmuOpcode op, SerializeBuffer &buf) : EQPacket(op, buf), opcode_bypass(0) - { app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; } bool combine(const EQApplicationPacket *rhs); uint32 serialize (uint16 opcode, unsigned char *dest) const; uint32 Size() const { return size+app_opcode_size; } @@ -119,15 +143,11 @@ public: uint16 GetProtocolOpcode() const { return protocol_opcode; } void SetProtocolOpcode(uint16 v) { protocol_opcode = v; } + protected: - - uint16 protocol_opcode; - uint8 app_opcode_size; - uint16 opcode_bypass; -private: - - EQApplicationPacket(const EQApplicationPacket &p) : EQPacket(p.emu_opcode, p.pBuffer, p.size), opcode_bypass(p.opcode_bypass) { app_opcode_size = p.app_opcode_size; } - + uint16 protocol_opcode = 0; + uint8 app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; + uint16 opcode_bypass = 0; }; class EQRawApplicationPacket : public EQApplicationPacket { diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp index 90fc99312..3ce262080 100644 --- a/common/patches/rof.cpp +++ b/common/patches/rof.cpp @@ -3221,7 +3221,7 @@ namespace RoF buf.WriteString(new_message); - auto outapp = new EQApplicationPacket(OP_SpecialMesg, buf); + auto outapp = new EQApplicationPacket(OP_SpecialMesg, std::move(buf)); dest->FastQueuePacket(&outapp, ack_req); delete in; diff --git a/common/patches/rof2.cpp b/common/patches/rof2.cpp index b240fd4b3..32eff3fd2 100644 --- a/common/patches/rof2.cpp +++ b/common/patches/rof2.cpp @@ -689,7 +689,7 @@ namespace RoF2 EQApplicationPacket *outapp = nullptr; if (eq->bufffade == 1) { - outapp = new EQApplicationPacket(OP_BuffCreate, 29); + outapp = new EQApplicationPacket(OP_BuffCreate, 29u); outapp->WriteUInt32(emu->entityid); outapp->WriteUInt32(0); // tic timer outapp->WriteUInt8(0); // Type of OP_BuffCreate packet ? @@ -753,7 +753,7 @@ namespace RoF2 ar(bl); //packet size - auto packet_size = bl.item_name.length() + 1 + 34; + size_t packet_size = bl.item_name.length() + 1 + 34; for (auto const &b: bl.trade_items) { packet_size += b.item_name.length() + 1; packet_size += 12; @@ -1622,7 +1622,7 @@ namespace RoF2 //Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Yourname is %s", gu2->yourname); int MemberCount = 1; - int PacketLength = 8 + strlen(gu2->leadersname) + 1 + 22 + strlen(gu2->yourname) + 1; + uint32 PacketLength = 8 + strlen(gu2->leadersname) + 1 + 22 + strlen(gu2->yourname) + 1; for (int i = 0; i < 5; ++i) { @@ -2207,7 +2207,7 @@ namespace RoF2 char *Buffer = (char *)in->pBuffer; - int PacketSize = sizeof(structs::MercenaryMerchantList_Struct) - 4 + emu->MercTypeCount * 4; + uint32 PacketSize = sizeof(structs::MercenaryMerchantList_Struct) - 4 + emu->MercTypeCount * 4; PacketSize += (sizeof(structs::MercenaryListEntry_Struct) - sizeof(structs::MercenaryStance_Struct)) * emu->MercCount; uint32 r; @@ -3820,7 +3820,7 @@ namespace RoF2 buf.WriteString(new_message); - auto outapp = new EQApplicationPacket(OP_SpecialMesg, buf); + auto outapp = new EQApplicationPacket(OP_SpecialMesg, std::move(buf)); dest->FastQueuePacket(&outapp, ack_req); delete in; @@ -4599,7 +4599,7 @@ namespace RoF2 int k; for (r = 0; r < entrycount; r++, emu++) { - int PacketSize = 206; + uint32 PacketSize = 206; PacketSize += strlen(emu->name); PacketSize += strlen(emu->lastName); diff --git a/common/patches/sod.cpp b/common/patches/sod.cpp index 27224e380..ca8602565 100644 --- a/common/patches/sod.cpp +++ b/common/patches/sod.cpp @@ -2128,7 +2128,7 @@ namespace SoD buf.WriteString(new_message); - auto outapp = new EQApplicationPacket(OP_SpecialMesg, buf); + auto outapp = new EQApplicationPacket(OP_SpecialMesg, std::move(buf)); dest->FastQueuePacket(&outapp, ack_req); delete in; diff --git a/common/patches/sof.cpp b/common/patches/sof.cpp index 818bc3b8f..ed72691f6 100644 --- a/common/patches/sof.cpp +++ b/common/patches/sof.cpp @@ -1785,7 +1785,7 @@ namespace SoF buf.WriteString(new_message); - auto outapp = new EQApplicationPacket(OP_SpecialMesg, buf); + auto outapp = new EQApplicationPacket(OP_SpecialMesg, std::move(buf)); dest->FastQueuePacket(&outapp, ack_req); delete in; diff --git a/common/patches/titanium.cpp b/common/patches/titanium.cpp index c3fdf479e..395094306 100644 --- a/common/patches/titanium.cpp +++ b/common/patches/titanium.cpp @@ -1991,7 +1991,7 @@ namespace Titanium buf.WriteString(new_message); - auto outapp = new EQApplicationPacket(OP_SpecialMesg, buf); + auto outapp = new EQApplicationPacket(OP_SpecialMesg, std::move(buf)); dest->FastQueuePacket(&outapp, ack_req); delete in; diff --git a/common/patches/uf.cpp b/common/patches/uf.cpp index 05c058217..32f958b35 100644 --- a/common/patches/uf.cpp +++ b/common/patches/uf.cpp @@ -2711,7 +2711,7 @@ namespace UF buf.WriteString(new_message); - auto outapp = new EQApplicationPacket(OP_SpecialMesg, buf); + auto outapp = new EQApplicationPacket(OP_SpecialMesg, std::move(buf)); dest->FastQueuePacket(&outapp, ack_req); delete in; diff --git a/common/serialize_buffer.h b/common/serialize_buffer.h index fb3e2904e..9e5ba8a9b 100644 --- a/common/serialize_buffer.h +++ b/common/serialize_buffer.h @@ -27,7 +27,7 @@ class SerializeBuffer { public: - SerializeBuffer() : m_buffer(nullptr), m_capacity(0), m_pos(0) {} + SerializeBuffer() = default; explicit SerializeBuffer(size_t size) : m_capacity(size), m_pos(0) { @@ -35,8 +35,10 @@ public: memset(m_buffer, 0, size); } - SerializeBuffer(const SerializeBuffer &rhs) - : m_buffer(new unsigned char[rhs.m_capacity]), m_capacity(rhs.m_capacity), m_pos(rhs.m_pos) + SerializeBuffer(const SerializeBuffer& rhs) + : m_buffer(new unsigned char[rhs.m_capacity]) + , m_capacity(rhs.m_capacity) + , m_pos(rhs.m_pos) { memcpy(m_buffer, rhs.m_buffer, rhs.m_capacity); } @@ -53,30 +55,31 @@ public: return *this; } - SerializeBuffer(SerializeBuffer &&rhs) : m_buffer(rhs.m_buffer), m_capacity(rhs.m_capacity), m_pos(rhs.m_pos) + SerializeBuffer(SerializeBuffer&& rhs) + : m_buffer(std::exchange(rhs.m_buffer, nullptr)) + , m_capacity(std::exchange(rhs.m_capacity, 0)) + , m_pos(std::exchange(rhs.m_pos, 0)) { - rhs.m_buffer = nullptr; - rhs.m_capacity = 0; - rhs.m_pos = 0; } - SerializeBuffer &operator=(SerializeBuffer &&rhs) + SerializeBuffer& operator=(SerializeBuffer&& rhs) { - if (this != &rhs) { + if (this != &rhs) + { delete[] m_buffer; - m_buffer = rhs.m_buffer; - m_capacity = rhs.m_capacity; - m_pos = rhs.m_pos; - - rhs.m_buffer = nullptr; - rhs.m_capacity = 0; - rhs.m_pos = 0; + m_buffer = std::exchange(rhs.m_buffer, nullptr); + m_capacity = std::exchange(rhs.m_capacity, 0); + m_pos = std::exchange(rhs.m_pos, 0); } + return *this; } - ~SerializeBuffer() { delete[] m_buffer; } + ~SerializeBuffer() + { + delete[] m_buffer; + } void WriteUInt8(uint8_t v) { @@ -209,7 +212,8 @@ public: private: void Grow(size_t new_size); void Reset(); - unsigned char *m_buffer; - size_t m_capacity; - size_t m_pos; + + unsigned char* m_buffer = nullptr; + size_t m_capacity = 0; + size_t m_pos = 0; }; diff --git a/common/servertalk.h b/common/servertalk.h index e550dc5d1..da30dc4b1 100644 --- a/common/servertalk.h +++ b/common/servertalk.h @@ -389,35 +389,31 @@ enum { class ServerPacket { public: - ~ServerPacket() { safe_delete_array(pBuffer); } - ServerPacket(uint16 in_opcode = 0, uint32 in_size = 0) { - this->compressed = false; - size = in_size; - opcode = in_opcode; - if (size == 0) { - pBuffer = 0; - } - else { + ~ServerPacket() + { + safe_delete_array(pBuffer); + } + + ServerPacket(uint16 in_opcode = 0, size_t in_size = 0) + : size(static_cast(in_size)) + , opcode(in_opcode) + { + if (size != 0) + { pBuffer = new uchar[size]; memset(pBuffer, 0, size); } - _wpos = 0; - _rpos = 0; } - ServerPacket(uint16 in_opcode, const EQ::Net::Packet &p) { - this->compressed = false; - size = (uint32)p.Length(); - opcode = in_opcode; - if (size == 0) { - pBuffer = 0; - } - else { + ServerPacket(uint16 in_opcode, const EQ::Net::Packet& p) + : size(static_cast(p.Length())) + , opcode(in_opcode) + { + if (size != 0) + { pBuffer = new uchar[size]; memcpy(pBuffer, p.Data(), size); } - _wpos = 0; - _rpos = 0; } ServerPacket* Copy() { @@ -447,14 +443,14 @@ public: void ReadSkipBytes(uint32 count) { _rpos += count; } void SetReadPosition(uint32 Newrpos) { _rpos = Newrpos; } - uint32 size; - uint16 opcode; - uchar* pBuffer; - uint32 _wpos; - uint32 _rpos; - bool compressed; - uint32 InflatedSize; - uint32 destination; + uint32 size = 0; + uint16 opcode = 0; + uchar* pBuffer = nullptr; + uint32 _wpos = 0; + uint32 _rpos = 0; + bool compressed = false; + uint32 InflatedSize = 0; + uint32 destination = 0; }; #pragma pack(push) @@ -989,11 +985,12 @@ struct LauncherConnectInfo { char name[64]; }; -typedef enum { +enum ZoneRequestCommands { ZR_Start, ZR_Restart, ZR_Stop -} ZoneRequestCommands; +}; + struct LauncherZoneRequest { uint8 command; char short_name[33]; diff --git a/loginserver/client.cpp b/loginserver/client.cpp index d9baf088f..165ac7bdc 100644 --- a/loginserver/client.cpp +++ b/loginserver/client.cpp @@ -547,7 +547,7 @@ void Client::SendExpansionPacketData(PlayerLoginReply &plrs) buf.WriteInt32(0xFFFFFFFF); } - auto out = std::make_unique(OP_LoginExpansionPacketData, buf); + auto out = std::make_unique(OP_LoginExpansionPacketData, std::move(buf)); m_connection->QueuePacket(out.get()); } diff --git a/loginserver/world_server_manager.cpp b/loginserver/world_server_manager.cpp index 118a58f5c..d519710ba 100644 --- a/loginserver/world_server_manager.cpp +++ b/loginserver/world_server_manager.cpp @@ -153,7 +153,7 @@ std::unique_ptr WorldServerManager::CreateServerListPacket( s->SerializeForClientServerList(buf, use_local_ip, client->GetClientVersion()); } - return std::make_unique(OP_ServerListResponse, buf); + return std::make_unique(OP_ServerListResponse, std::move(buf)); } void WorldServerManager::SendUserLoginToWorldRequest( diff --git a/zone/client.cpp b/zone/client.cpp index 67462169f..56d59c4b3 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -1784,7 +1784,7 @@ void Client::Message(uint32 type, const char* message, ...) { buf.WriteInt32(0); buf.WriteString(buffer); - auto app = new EQApplicationPacket(OP_SpecialMesg, buf); + auto app = new EQApplicationPacket(OP_SpecialMesg, std::move(buf)); FastQueuePacket(&app); @@ -1813,7 +1813,7 @@ void Client::FilteredMessage(Mob *sender, uint32 type, eqFilterType filter, cons buf.WriteInt32(0); buf.WriteString(buffer); - auto app = new EQApplicationPacket(OP_SpecialMesg, buf); + auto app = new EQApplicationPacket(OP_SpecialMesg, std::move(buf)); FastQueuePacket(&app); @@ -3869,7 +3869,7 @@ void Client::MessageString(uint32 type, uint32 string_id, const char* message1, buf.WriteInt8(0); // prevent oob in packet translation, maybe clean that up sometime - auto outapp = std::make_unique(OP_FormattedMessage, buf); + auto outapp = std::make_unique(OP_FormattedMessage, std::move(buf)); if (distance > 0) entity_list.QueueCloseClients(this, outapp.get(), false, distance); @@ -3987,7 +3987,7 @@ void Client::FilteredMessageString(Mob *sender, uint32 type, eqFilterType filter buf.WriteInt8(0); // prevent oob in packet translation, maybe clean that up sometime - auto outapp = std::make_unique(OP_FormattedMessage, buf); + auto outapp = std::make_unique(OP_FormattedMessage, std::move(buf)); QueuePacket(outapp.get()); } diff --git a/zone/entity.cpp b/zone/entity.cpp index e1b25370f..ddbf34b6d 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -4437,7 +4437,7 @@ void EntityList::QuestJournalledSayClose( buf.WriteString(message); } - auto outapp = new EQApplicationPacket(OP_SpecialMesg, buf); + auto outapp = new EQApplicationPacket(OP_SpecialMesg, std::move(buf)); // client only bothers logging if target spawn ID matches, safe to send to everyone QueueCloseClients(sender, outapp, false, dist); diff --git a/zone/shared_task_zone_messaging.cpp b/zone/shared_task_zone_messaging.cpp index a579f53c3..0d8455e5d 100644 --- a/zone/shared_task_zone_messaging.cpp +++ b/zone/shared_task_zone_messaging.cpp @@ -117,7 +117,7 @@ void SharedTaskZoneMessaging::HandleWorldMessage(ServerPacket *pack) buf.WriteInt8(m.is_leader ? 1 : 0); } - auto outapp = std::make_unique(OP_SharedTaskMemberList, buf); + auto outapp = std::make_unique(OP_SharedTaskMemberList, std::move(buf)); c->QueuePacket(outapp.get()); } @@ -141,7 +141,7 @@ void SharedTaskZoneMessaging::HandleWorldMessage(ServerPacket *pack) // live sends more after the name but it might just be garbage from // a re-used buffer (possibly a former name[64] buffer?) - auto outapp = std::make_unique(OP_SharedTaskMemberChange, buf); + auto outapp = std::make_unique(OP_SharedTaskMemberChange, std::move(buf)); c->QueuePacket(outapp.get()); } diff --git a/zone/task_manager.cpp b/zone/task_manager.cpp index 23b308201..a3af9f013 100644 --- a/zone/task_manager.cpp +++ b/zone/task_manager.cpp @@ -858,7 +858,7 @@ void TaskManager::SendTaskSelector(Client* client, Mob* mob, const std::vectorGetTaskState()->AddOffer(task_list[i], mob->GetID()); } - auto outapp = std::make_unique(OP_TaskSelectWindow, buf); + auto outapp = std::make_unique(OP_TaskSelectWindow, std::move(buf)); client->QueuePacket(outapp.get()); } @@ -883,7 +883,7 @@ void TaskManager::SendSharedTaskSelector(Client* client, Mob* mob, const std::ve client->GetTaskState()->AddOffer(task_id, mob->GetID()); } - auto outapp = std::make_unique(OP_SharedTaskSelectWindow, buf); + auto outapp = std::make_unique(OP_SharedTaskSelectWindow, std::move(buf)); client->QueuePacket(outapp.get()); } @@ -1009,7 +1009,7 @@ void TaskManager::SendTaskActivityLong( activity.SerializeObjective(buf, client->ClientVersion(), done_count); - auto outapp = std::make_unique(OP_TaskActivity, buf); + auto outapp = std::make_unique(OP_TaskActivity, std::move(buf)); client->QueuePacket(outapp.get()); } diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index a273af186..a314936ca 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -550,7 +550,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) SerializeBuffer buf(100); buf.WriteString(smotd->motd); - auto outapp = std::make_unique(OP_MOTD, buf); + auto outapp = std::make_unique(OP_MOTD, std::move(buf)); entity_list.QueueClients(0, outapp.get()); break;