summaryrefslogtreecommitdiff
path: root/src/proto2/types.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/proto2/types.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/proto2/types.hpp')
-rw-r--r--src/proto2/types.hpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/proto2/types.hpp b/src/proto2/types.hpp
index b047865..92413e3 100644
--- a/src/proto2/types.hpp
+++ b/src/proto2/types.hpp
@@ -32,6 +32,7 @@
# include "../mmo/strs.hpp"
# include "../mmo/utils.hpp"
# include "../mmo/version.hpp"
+# include "../login/types.hpp"
template<class T>
bool native_to_network(T *network, T native)
{
@@ -297,4 +298,22 @@ bool network_to_native(Version *native, NetVersion network)
return rv;
}
+inline __attribute__((warn_unused_result))
+bool native_to_network(Byte *network, VERSION_2 native)
+{
+ bool rv = true;
+ uint8_t tmp = static_cast<uint8_t>(native);
+ rv &= native_to_network(network, tmp);
+ return rv;
+}
+inline __attribute__((warn_unused_result))
+bool network_to_native(VERSION_2 *native, Byte network)
+{
+ bool rv = true;
+ uint8_t tmp;
+ rv &= network_to_native(&tmp, network);
+ *native = static_cast<VERSION_2>(tmp);
+ // TODO this is what really should be doing a checked cast
+ return rv;
+}
#endif // TMWA_PROTO2_TYPES_HPP