mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
Data verification utils, not in use yet. Also added ability for lua packet to bypass the translation layer (dangerous) if a writer so desires (useful for quickly trying packet stuff)
This commit is contained in:
@@ -701,14 +701,10 @@ void Client::QueuePacket(const EQApplicationPacket* app, bool ack_req, CLIENT_CO
|
||||
}
|
||||
|
||||
void Client::FastQueuePacket(EQApplicationPacket** app, bool ack_req, CLIENT_CONN_STATUS required_state) {
|
||||
|
||||
//std::cout << "Sending: 0x" << std::hex << std::setw(4) << std::setfill('0') << (*app)->GetOpcode() << std::dec << ", size=" << (*app)->size << std::endl;
|
||||
|
||||
// if the program doesnt care about the status or if the status isnt what we requested
|
||||
if (required_state != CLIENT_CONNECTINGALL && client_state != required_state) {
|
||||
// todo: save packets for later use
|
||||
AddPacket(app, ack_req);
|
||||
// LogFile->write(EQEMuLog::Normal, "Adding Packet to list (%d) (%d)", (*app)->GetOpcode(), (int)required_state);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
||||
+42
-5
@@ -14,14 +14,31 @@ Lua_Packet::Lua_Packet(int opcode, int size) {
|
||||
owned_ = true;
|
||||
}
|
||||
|
||||
Lua_Packet::Lua_Packet(int opcode, int size, bool raw) {
|
||||
if(raw) {
|
||||
SetLuaPtrData(new EQApplicationPacket(OP_Unknown, size));
|
||||
owned_ = true;
|
||||
|
||||
EQApplicationPacket *self = reinterpret_cast<EQApplicationPacket*>(d_);
|
||||
self->SetOpcodeBypass(opcode);
|
||||
} else {
|
||||
SetLuaPtrData(new EQApplicationPacket(static_cast<EmuOpcode>(opcode), size));
|
||||
owned_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
Lua_Packet& Lua_Packet::operator=(const Lua_Packet& o) {
|
||||
if(o.owned_) {
|
||||
owned_ = true;
|
||||
EQApplicationPacket *app = reinterpret_cast<EQApplicationPacket*>(o.d_);
|
||||
if(app)
|
||||
if(app) {
|
||||
d_ = new EQApplicationPacket(app->GetOpcode(), app->pBuffer, app->size);
|
||||
else
|
||||
|
||||
EQApplicationPacket *self = reinterpret_cast<EQApplicationPacket*>(d_);
|
||||
self->SetOpcodeBypass(app->GetOpcodeBypass());
|
||||
} else {
|
||||
d_ = nullptr;
|
||||
}
|
||||
} else {
|
||||
owned_ = false;
|
||||
d_ = o.d_;
|
||||
@@ -33,10 +50,14 @@ Lua_Packet::Lua_Packet(const Lua_Packet& o) {
|
||||
if(o.owned_) {
|
||||
owned_ = true;
|
||||
EQApplicationPacket *app = reinterpret_cast<EQApplicationPacket*>(o.d_);
|
||||
if(app)
|
||||
if(app) {
|
||||
d_ = new EQApplicationPacket(app->GetOpcode(), app->pBuffer, app->size);
|
||||
else
|
||||
|
||||
EQApplicationPacket *self = reinterpret_cast<EQApplicationPacket*>(d_);
|
||||
self->SetOpcodeBypass(app->GetOpcodeBypass());
|
||||
} else {
|
||||
d_ = nullptr;
|
||||
}
|
||||
} else {
|
||||
owned_ = false;
|
||||
d_ = o.d_;
|
||||
@@ -54,6 +75,16 @@ int Lua_Packet::GetOpcode() {
|
||||
}
|
||||
|
||||
void Lua_Packet::SetOpcode(int op) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->SetOpcodeBypass(static_cast<uint16>(op));
|
||||
}
|
||||
|
||||
int Lua_Packet::GetRawOpcode() {
|
||||
Lua_Safe_Call_Int();
|
||||
return static_cast<int>(self->GetOpcodeBypass());
|
||||
}
|
||||
|
||||
void Lua_Packet::SetRawOpcode(int op) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->SetOpcode(static_cast<EmuOpcode>(op));
|
||||
}
|
||||
@@ -244,11 +275,14 @@ luabind::scope lua_register_packet() {
|
||||
return luabind::class_<Lua_Packet>("Packet")
|
||||
.def(luabind::constructor<>())
|
||||
.def(luabind::constructor<int,int>())
|
||||
.def(luabind::constructor<int,int,bool>())
|
||||
.property("null", &Lua_Packet::Null)
|
||||
.property("valid", &Lua_Packet::Valid)
|
||||
.def("GetSize", &Lua_Packet::GetSize)
|
||||
.def("GetOpcode", &Lua_Packet::GetOpcode)
|
||||
.def("SetOpcode", &Lua_Packet::SetOpcode)
|
||||
.def("GetRawOpcode", &Lua_Packet::GetRawOpcode)
|
||||
.def("SetRawOpcode", &Lua_Packet::SetRawOpcode)
|
||||
.def("WriteInt8", &Lua_Packet::WriteInt8)
|
||||
.def("WriteInt16", &Lua_Packet::WriteInt16)
|
||||
.def("WriteInt32", &Lua_Packet::WriteInt32)
|
||||
@@ -809,7 +843,10 @@ luabind::scope lua_register_packet_opcodes() {
|
||||
luabind::value("MercenaryDismiss", static_cast<int>(OP_MercenaryDismiss)),
|
||||
luabind::value("MercenaryTimerRequest", static_cast<int>(OP_MercenaryTimerRequest)),
|
||||
luabind::value("OpenInventory", static_cast<int>(OP_OpenInventory)),
|
||||
luabind::value("OpenContainer", static_cast<int>(OP_OpenContainer))
|
||||
luabind::value("OpenContainer", static_cast<int>(OP_OpenContainer)),
|
||||
luabind::value("Marquee", static_cast<int>(OP_Marquee)),
|
||||
luabind::value("ClientTimeStamp", static_cast<int>(OP_ClientTimeStamp)),
|
||||
luabind::value("GuildPromote", static_cast<int>(OP_GuildPromote))
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
Lua_Packet() : Lua_Ptr(nullptr), owned_(false) { }
|
||||
Lua_Packet(EQApplicationPacket *d) : Lua_Ptr(d), owned_(false) { }
|
||||
Lua_Packet(int opcode, int size);
|
||||
Lua_Packet(int opcode, int size, bool raw);
|
||||
Lua_Packet& operator=(const Lua_Packet& o);
|
||||
Lua_Packet(const Lua_Packet& o);
|
||||
virtual ~Lua_Packet() { if(owned_) { EQApplicationPacket *ptr = GetLuaPtrData(); if(ptr) { delete ptr; } } }
|
||||
@@ -28,6 +29,8 @@ public:
|
||||
int GetSize();
|
||||
int GetOpcode();
|
||||
void SetOpcode(int op);
|
||||
int GetRawOpcode();
|
||||
void SetRawOpcode(int op);
|
||||
void WriteInt8(int offset, int value);
|
||||
void WriteInt16(int offset, int value);
|
||||
void WriteInt32(int offset, int value);
|
||||
|
||||
Reference in New Issue
Block a user