summaryrefslogtreecommitdiffstats
path: root/src/network/packet.cpp
diff options
context:
space:
mode:
authorB3n30 <bene_thomas@web.de>2017-08-19 19:14:33 +0200
committerJames Rowe <jroweboy@gmail.com>2017-08-19 19:14:33 +0200
commit5d0a1e7efddf234234d54fe97395f6975f8d1a28 (patch)
treecef0c9114f39af64c2971509fb2d0197c73cc155 /src/network/packet.cpp
parentMerge pull request #2881 from MerryMage/dsp-firm-check (diff)
downloadyuzu-5d0a1e7efddf234234d54fe97395f6975f8d1a28.tar
yuzu-5d0a1e7efddf234234d54fe97395f6975f8d1a28.tar.gz
yuzu-5d0a1e7efddf234234d54fe97395f6975f8d1a28.tar.bz2
yuzu-5d0a1e7efddf234234d54fe97395f6975f8d1a28.tar.lz
yuzu-5d0a1e7efddf234234d54fe97395f6975f8d1a28.tar.xz
yuzu-5d0a1e7efddf234234d54fe97395f6975f8d1a28.tar.zst
yuzu-5d0a1e7efddf234234d54fe97395f6975f8d1a28.zip
Diffstat (limited to '')
-rw-r--r--src/network/packet.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/network/packet.cpp b/src/network/packet.cpp
index 660e92c0d..cc60f2fbc 100644
--- a/src/network/packet.cpp
+++ b/src/network/packet.cpp
@@ -13,6 +13,18 @@
namespace Network {
+#ifndef htonll
+u64 htonll(u64 x) {
+ return ((1 == htonl(1)) ? (x) : ((uint64_t)htonl((x)&0xFFFFFFFF) << 32) | htonl((x) >> 32));
+}
+#endif
+
+#ifndef ntohll
+u64 ntohll(u64 x) {
+ return ((1 == ntohl(1)) ? (x) : ((uint64_t)ntohl((x)&0xFFFFFFFF) << 32) | ntohl((x) >> 32));
+}
+#endif
+
void Packet::Append(const void* in_data, std::size_t size_in_bytes) {
if (in_data && (size_in_bytes > 0)) {
std::size_t start = data.size();
@@ -100,6 +112,20 @@ Packet& Packet::operator>>(u32& out_data) {
return *this;
}
+Packet& Packet::operator>>(s64& out_data) {
+ s64 value;
+ Read(&value, sizeof(value));
+ out_data = ntohll(value);
+ return *this;
+}
+
+Packet& Packet::operator>>(u64& out_data) {
+ u64 value;
+ Read(&value, sizeof(value));
+ out_data = ntohll(value);
+ return *this;
+}
+
Packet& Packet::operator>>(float& out_data) {
Read(&out_data, sizeof(out_data));
return *this;
@@ -183,6 +209,18 @@ Packet& Packet::operator<<(u32 in_data) {
return *this;
}
+Packet& Packet::operator<<(s64 in_data) {
+ s64 toWrite = htonll(in_data);
+ Append(&toWrite, sizeof(toWrite));
+ return *this;
+}
+
+Packet& Packet::operator<<(u64 in_data) {
+ u64 toWrite = htonll(in_data);
+ Append(&toWrite, sizeof(toWrite));
+ return *this;
+}
+
Packet& Packet::operator<<(float in_data) {
Append(&in_data, sizeof(in_data));
return *this;