mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
Steal buffer from SerializeBuffer now
This commit is contained in:
parent
2d456ba8c9
commit
4c6de9b991
@ -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()
|
BasePacket::~BasePacket()
|
||||||
{
|
{
|
||||||
if (pBuffer)
|
if (pBuffer)
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
#define BASEPACKET_H_
|
#define BASEPACKET_H_
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "serialize_buffer.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -85,6 +86,7 @@ protected:
|
|||||||
virtual ~BasePacket();
|
virtual ~BasePacket();
|
||||||
BasePacket() { pBuffer=nullptr; size=0; _wpos = 0; _rpos = 0; }
|
BasePacket() { pBuffer=nullptr; size=0; _wpos = 0; _rpos = 0; }
|
||||||
BasePacket(const unsigned char *buf, const uint32 len);
|
BasePacket(const unsigned char *buf, const uint32 len);
|
||||||
|
BasePacket(SerializeBuffer &buf);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void DumpPacketHex(const BasePacket* app);
|
extern void DumpPacketHex(const BasePacket* app);
|
||||||
|
|||||||
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "base_packet.h"
|
#include "base_packet.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "serialize_buffer.h"
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#ifdef STATIC_OPCODE
|
#ifdef STATIC_OPCODE
|
||||||
@ -52,6 +51,7 @@ protected:
|
|||||||
EmuOpcode emu_opcode;
|
EmuOpcode emu_opcode;
|
||||||
|
|
||||||
EQPacket(EmuOpcode opcode, const unsigned char *buf, const uint32 len);
|
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(const EQPacket &p) { }
|
||||||
EQPacket() { emu_opcode=OP_Unknown; pBuffer=nullptr; size=0; }
|
EQPacket() { emu_opcode=OP_Unknown; pBuffer=nullptr; size=0; }
|
||||||
|
|
||||||
@ -105,6 +105,8 @@ public:
|
|||||||
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
|
{ 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)
|
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; }
|
{ 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);
|
bool combine(const EQApplicationPacket *rhs);
|
||||||
uint32 serialize (uint16 opcode, unsigned char *dest) const;
|
uint32 serialize (uint16 opcode, unsigned char *dest) const;
|
||||||
uint32 Size() const { return size+app_opcode_size; }
|
uint32 Size() const { return size+app_opcode_size; }
|
||||||
|
|||||||
@ -186,6 +186,8 @@ public:
|
|||||||
size_t capacity() const { return m_capacity; }
|
size_t capacity() const { return m_capacity; }
|
||||||
const unsigned char *buffer() const { return m_buffer; }
|
const unsigned char *buffer() const { return m_buffer; }
|
||||||
|
|
||||||
|
friend class BasePacket;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Grow(size_t new_size);
|
void Grow(size_t new_size);
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|||||||
@ -1146,7 +1146,7 @@ void TaskManager::SendTaskSelector(Client *c, Mob *mob, int TaskCount, int *Task
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto outapp = new EQApplicationPacket(OP_OpenNewTasksWindow, buf.buffer(), buf.length());
|
auto outapp = new EQApplicationPacket(OP_OpenNewTasksWindow, buf);
|
||||||
|
|
||||||
c->QueuePacket(outapp);
|
c->QueuePacket(outapp);
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
@ -1233,7 +1233,7 @@ void TaskManager::SendTaskSelectorNew(Client *c, Mob *mob, int TaskCount, int *T
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto outapp = new EQApplicationPacket(OP_OpenNewTasksWindow, buf.buffer(), buf.length());
|
auto outapp = new EQApplicationPacket(OP_OpenNewTasksWindow, buf);
|
||||||
|
|
||||||
c->QueuePacket(outapp);
|
c->QueuePacket(outapp);
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
@ -2770,7 +2770,7 @@ void TaskManager::SendTaskActivityLong(Client *c, int TaskID, int ActivityID, in
|
|||||||
|
|
||||||
buf.WriteUInt32(1); // unknown
|
buf.WriteUInt32(1); // unknown
|
||||||
|
|
||||||
auto outapp = new EQApplicationPacket(OP_TaskActivity, buf.buffer(), buf.length());
|
auto outapp = new EQApplicationPacket(OP_TaskActivity, buf);
|
||||||
|
|
||||||
c->QueuePacket(outapp);
|
c->QueuePacket(outapp);
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
@ -2830,7 +2830,7 @@ void TaskManager::SendTaskActivityNew(Client *c, int TaskID, int ActivityID, int
|
|||||||
|
|
||||||
buf.WriteString(Tasks[TaskID]->Activity[ActivityID].zones);
|
buf.WriteString(Tasks[TaskID]->Activity[ActivityID].zones);
|
||||||
|
|
||||||
auto outapp = new EQApplicationPacket(OP_TaskActivity, buf.buffer(), buf.length());
|
auto outapp = new EQApplicationPacket(OP_TaskActivity, buf);
|
||||||
|
|
||||||
c->QueuePacket(outapp);
|
c->QueuePacket(outapp);
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user