mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2026-02-10 06:20:04 +00:00
[refactor] Validate all inbound packets before handling them
This commit is contained in:
63
src/core/Packets.hpp
Normal file
63
src/core/Packets.hpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNStructs.hpp"
|
||||
|
||||
#include <map>
|
||||
|
||||
// Packet Descriptor
|
||||
struct PacketDesc {
|
||||
uint32_t val;
|
||||
std::string name;
|
||||
size_t size;
|
||||
bool variadic;
|
||||
size_t cntMembOfs;
|
||||
size_t trailerSize;
|
||||
|
||||
PacketDesc() {}
|
||||
|
||||
PacketDesc(const PacketDesc& other) {
|
||||
val = other.val;
|
||||
name = other.name;
|
||||
size = other.size;
|
||||
variadic = other.variadic;
|
||||
cntMembOfs = other.cntMembOfs;
|
||||
trailerSize = other.trailerSize;
|
||||
}
|
||||
|
||||
PacketDesc(PacketDesc&& other) {
|
||||
val = other.val;
|
||||
name = std::move(other.name);
|
||||
size = other.size;
|
||||
variadic = other.variadic;
|
||||
cntMembOfs = other.cntMembOfs;
|
||||
trailerSize = other.trailerSize;
|
||||
}
|
||||
|
||||
// non-variadic constructor
|
||||
PacketDesc(uint32_t v, size_t s, std::string n) :
|
||||
val(v), name(n), size(s), variadic(false) {}
|
||||
|
||||
// variadic constructor
|
||||
PacketDesc(uint32_t v, size_t s, std::string n, size_t ofs, size_t ts) :
|
||||
val(v), name(n), size(s), variadic(true), cntMembOfs(ofs), trailerSize(ts) {}
|
||||
};
|
||||
|
||||
/*
|
||||
* Extra trailer structs for places where the client doesn't have any, but
|
||||
* really should.
|
||||
*/
|
||||
struct sGM_PVPTarget {
|
||||
uint32_t eCT;
|
||||
uint32_t iID;
|
||||
};
|
||||
|
||||
struct sSkillResult_Leech {
|
||||
sSkillResult_Heal_HP Heal;
|
||||
sSkillResult_Damage Damage;
|
||||
};
|
||||
|
||||
namespace Packets {
|
||||
extern std::map<uint32_t, PacketDesc> packets;
|
||||
|
||||
std::string p2str(int val);
|
||||
}
|
||||
Reference in New Issue
Block a user