#pragma once #include "../opcodemgr.h" #include "../net/packet.h" #include "../net/daybreak_connection.h" #include #include #include namespace EQ { namespace Patches { enum IdentityMatchStatus { IdentityMatchFailure, IdentityMatchSuccess }; struct Signature { int match_message_opcode; size_t match_message_size; }; class BasePatch { public: typedef std::function DecodeStructFunction; typedef std::function, EmuOpcode, const EQ::Net::Packet*)> EncodeStructFunction; BasePatch() { } virtual ~BasePatch() { } virtual std::string GetName() const = 0; IdentityMatchStatus TryIdentityMatch(const EQ::Net::Packet &p) const; void Decode(const EQ::Net::Packet *in, EmuOpcode& opcode, EQ::Net::WritablePacket& out); void Encode(std::shared_ptr connection, EmuOpcode opcode, const EQ::Net::Packet *in); void RegisterDecode(int protocol_number, DecodeStructFunction f); void RegisterEncode(EmuOpcode opcode, EncodeStructFunction f); protected: void SendPacket(std::shared_ptr connection, EmuOpcode opcode, const EQ::Net::Packet *p); std::unique_ptr m_opcode_manager; std::map m_decode; std::map m_encode; Signature m_signature; int m_message_size; }; } }