Steal buffer from SerializeBuffer now

This commit is contained in:
Michael Cook (mackal)
2018-07-08 23:03:53 -04:00
parent 2d456ba8c9
commit 4c6de9b991
5 changed files with 23 additions and 5 deletions
+12
View File
@@ -39,6 +39,18 @@ BasePacket::BasePacket(const unsigned char *buf, uint32 len)
}
}
BasePacket::BasePacket(SerializeBuffer &buf)
{
pBuffer = buf.m_buffer;
buf.m_buffer = nullptr;
size = buf.m_pos;
buf.m_pos = 0;
buf.m_capacity = 0;
_wpos = 0;
_rpos = 0;
timestamp.tv_sec = 0;
}
BasePacket::~BasePacket()
{
if (pBuffer)
+2
View File
@@ -19,6 +19,7 @@
#define BASEPACKET_H_
#include "types.h"
#include "serialize_buffer.h"
#include <stdio.h>
#include <string.h>
@@ -85,6 +86,7 @@ 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);
+3 -1
View File
@@ -20,7 +20,6 @@
#include "base_packet.h"
#include "platform.h"
#include "serialize_buffer.h"
#include <iostream>
#ifdef STATIC_OPCODE
@@ -52,6 +51,7 @@ protected:
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; }
@@ -105,6 +105,8 @@ public:
{ 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; }
+2
View File
@@ -186,6 +186,8 @@ public:
size_t capacity() const { return m_capacity; }
const unsigned char *buffer() const { return m_buffer; }
friend class BasePacket;
private:
void Grow(size_t new_size);
void Reset();