summaryrefslogtreecommitdiff
path: root/src/net/packets.hpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-05-20 14:36:33 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-05-20 15:27:53 -0700
commitf6324ada91d412e041592598245770835991cbc6 (patch)
treec0c2e5abb284db8146f7d18bcb7280cda0fa9c07 /src/net/packets.hpp
parentb06dd5aaa0cf47b0b6f73ae858b2e2c267e60bbf (diff)
downloadtmwa-f6324ada91d412e041592598245770835991cbc6.tar.gz
tmwa-f6324ada91d412e041592598245770835991cbc6.tar.bz2
tmwa-f6324ada91d412e041592598245770835991cbc6.tar.xz
tmwa-f6324ada91d412e041592598245770835991cbc6.zip
Generate login/user protocol
Diffstat (limited to 'src/net/packets.hpp')
-rw-r--r--src/net/packets.hpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/net/packets.hpp b/src/net/packets.hpp
index c0f3ecb..6146b90 100644
--- a/src/net/packets.hpp
+++ b/src/net/packets.hpp
@@ -228,6 +228,7 @@ RecvResult recv_vpacket(Session *s, Packet_Head<id>& head, std::vector<Packet_Re
return rv;
}
+
// convenience for trailing strings
template<uint16_t id, uint16_t headsize, uint16_t repeatsize>
@@ -322,4 +323,36 @@ RecvResult recv_packet_repeatonly(Session *s, std::vector<Packet_Repeat<id>>& v)
return recv_vpacket<id, 4, repeatsize>(s, head, v);
}
+
+// and the combination of both of the above
+
+template<uint16_t id, uint16_t headsize, uint16_t repeatsize>
+void send_packet_repeatonly(Session *s, const XString& repeat)
+{
+ static_assert(id == Packet_Head<id>::PACKET_ID, "Packet_Head<id>::PACKET_ID");
+ static_assert(headsize == sizeof(NetPacket_Head<id>), "repeat headsize");
+ static_assert(headsize == 4, "repeat headsize");
+ static_assert(id == Packet_Repeat<id>::PACKET_ID, "Packet_Repeat<id>::PACKET_ID");
+ static_assert(repeatsize == sizeof(NetPacket_Repeat<id>), "sizeof(NetPacket_Repeat<id>)");
+ static_assert(repeatsize == 1, "repeatsize");
+
+ Packet_Head<id> head;
+ send_vpacket<id, 4, repeatsize>(s, head, repeat);
+}
+
+template<uint16_t id, uint16_t headsize, uint16_t repeatsize>
+__attribute__((warn_unused_result))
+RecvResult recv_packet_repeatonly(Session *s, AString& repeat)
+{
+ static_assert(id == Packet_Head<id>::PACKET_ID, "Packet_Head<id>::PACKET_ID");
+ static_assert(headsize == sizeof(NetPacket_Head<id>), "repeat headsize");
+ static_assert(headsize == 4, "repeat headsize");
+ static_assert(id == Packet_Repeat<id>::PACKET_ID, "Packet_Repeat<id>::PACKET_ID");
+ static_assert(repeatsize == sizeof(NetPacket_Repeat<id>), "sizeof(NetPacket_Repeat<id>)");
+ static_assert(repeatsize == 1, "repeatsize");
+
+ Packet_Head<id> head;
+ return recv_vpacket<id, 4, repeatsize>(s, head, repeat);
+}
+
#endif // TMWA_NET_PACKETS_HPP