summaryrefslogtreecommitdiff
path: root/src/proto2/any-user.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/proto2/any-user.hpp')
-rw-r--r--src/proto2/any-user.hpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/proto2/any-user.hpp b/src/proto2/any-user.hpp
index d704233..da9b1bc 100644
--- a/src/proto2/any-user.hpp
+++ b/src/proto2/any-user.hpp
@@ -27,6 +27,19 @@
// This is a public protocol, and changes require client cooperation
+// this is only needed for the payload packet right now, and that needs to die
+#pragma pack(push, 1)
+
+template<>
+struct Packet_Fixed<0x0081>
+{
+ static const uint16_t PACKET_ID = 0x0081;
+
+ // TODO remove this
+ uint16_t magic_packet_id = PACKET_ID;
+ uint8_t error_code = {};
+};
+
template<>
struct Packet_Fixed<0x7530>
{
@@ -57,6 +70,16 @@ struct Packet_Fixed<0x7532>
template<>
+struct NetPacket_Fixed<0x0081>
+{
+ Little16 magic_packet_id;
+ Byte error_code;
+};
+static_assert(offsetof(NetPacket_Fixed<0x0081>, magic_packet_id) == 0, "offsetof(NetPacket_Fixed<0x0081>, magic_packet_id) == 0");
+static_assert(offsetof(NetPacket_Fixed<0x0081>, error_code) == 2, "offsetof(NetPacket_Fixed<0x0081>, error_code) == 2");
+static_assert(sizeof(NetPacket_Fixed<0x0081>) == 3, "sizeof(NetPacket_Fixed<0x0081>) == 3");
+
+template<>
struct NetPacket_Fixed<0x7530>
{
Little16 magic_packet_id;
@@ -84,6 +107,23 @@ static_assert(sizeof(NetPacket_Fixed<0x7532>) == 2, "sizeof(NetPacket_Fixed<0x75
inline __attribute__((warn_unused_result))
+bool native_to_network(NetPacket_Fixed<0x0081> *network, Packet_Fixed<0x0081> native)
+{
+ bool rv = true;
+ rv &= native_to_network(&network->magic_packet_id, native.magic_packet_id);
+ rv &= native_to_network(&network->error_code, native.error_code);
+ return rv;
+}
+inline __attribute__((warn_unused_result))
+bool network_to_native(Packet_Fixed<0x0081> *native, NetPacket_Fixed<0x0081> network)
+{
+ bool rv = true;
+ rv &= network_to_native(&native->magic_packet_id, network.magic_packet_id);
+ rv &= network_to_native(&native->error_code, network.error_code);
+ return rv;
+}
+
+inline __attribute__((warn_unused_result))
bool native_to_network(NetPacket_Fixed<0x7530> *network, Packet_Fixed<0x7530> native)
{
bool rv = true;
@@ -131,4 +171,6 @@ bool network_to_native(Packet_Fixed<0x7532> *native, NetPacket_Fixed<0x7532> net
}
+#pragma pack(pop)
+
#endif // TMWA_PROTO2_ANY_USER_HPP