summaryrefslogtreecommitdiff
path: root/src/network/packet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/packet.cpp')
-rw-r--r--src/network/packet.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/network/packet.cpp b/src/network/packet.cpp
index 8fc5feabd..a3c1e1644 100644
--- a/src/network/packet.cpp
+++ b/src/network/packet.cpp
@@ -14,13 +14,13 @@
14namespace Network { 14namespace Network {
15 15
16#ifndef htonll 16#ifndef htonll
17u64 htonll(u64 x) { 17static u64 htonll(u64 x) {
18 return ((1 == htonl(1)) ? (x) : ((uint64_t)htonl((x)&0xFFFFFFFF) << 32) | htonl((x) >> 32)); 18 return ((1 == htonl(1)) ? (x) : ((uint64_t)htonl((x)&0xFFFFFFFF) << 32) | htonl((x) >> 32));
19} 19}
20#endif 20#endif
21 21
22#ifndef ntohll 22#ifndef ntohll
23u64 ntohll(u64 x) { 23static u64 ntohll(u64 x) {
24 return ((1 == ntohl(1)) ? (x) : ((uint64_t)ntohl((x)&0xFFFFFFFF) << 32) | ntohl((x) >> 32)); 24 return ((1 == ntohl(1)) ? (x) : ((uint64_t)ntohl((x)&0xFFFFFFFF) << 32) | ntohl((x) >> 32));
25} 25}
26#endif 26#endif
@@ -67,7 +67,7 @@ Packet::operator bool() const {
67} 67}
68 68
69Packet& Packet::operator>>(bool& out_data) { 69Packet& Packet::operator>>(bool& out_data) {
70 u8 value; 70 u8 value{};
71 if (*this >> value) { 71 if (*this >> value) {
72 out_data = (value != 0); 72 out_data = (value != 0);
73 } 73 }
@@ -85,42 +85,42 @@ Packet& Packet::operator>>(u8& out_data) {
85} 85}
86 86
87Packet& Packet::operator>>(s16& out_data) { 87Packet& Packet::operator>>(s16& out_data) {
88 s16 value; 88 s16 value{};
89 Read(&value, sizeof(value)); 89 Read(&value, sizeof(value));
90 out_data = ntohs(value); 90 out_data = ntohs(value);
91 return *this; 91 return *this;
92} 92}
93 93
94Packet& Packet::operator>>(u16& out_data) { 94Packet& Packet::operator>>(u16& out_data) {
95 u16 value; 95 u16 value{};
96 Read(&value, sizeof(value)); 96 Read(&value, sizeof(value));
97 out_data = ntohs(value); 97 out_data = ntohs(value);
98 return *this; 98 return *this;
99} 99}
100 100
101Packet& Packet::operator>>(s32& out_data) { 101Packet& Packet::operator>>(s32& out_data) {
102 s32 value; 102 s32 value{};
103 Read(&value, sizeof(value)); 103 Read(&value, sizeof(value));
104 out_data = ntohl(value); 104 out_data = ntohl(value);
105 return *this; 105 return *this;
106} 106}
107 107
108Packet& Packet::operator>>(u32& out_data) { 108Packet& Packet::operator>>(u32& out_data) {
109 u32 value; 109 u32 value{};
110 Read(&value, sizeof(value)); 110 Read(&value, sizeof(value));
111 out_data = ntohl(value); 111 out_data = ntohl(value);
112 return *this; 112 return *this;
113} 113}
114 114
115Packet& Packet::operator>>(s64& out_data) { 115Packet& Packet::operator>>(s64& out_data) {
116 s64 value; 116 s64 value{};
117 Read(&value, sizeof(value)); 117 Read(&value, sizeof(value));
118 out_data = ntohll(value); 118 out_data = ntohll(value);
119 return *this; 119 return *this;
120} 120}
121 121
122Packet& Packet::operator>>(u64& out_data) { 122Packet& Packet::operator>>(u64& out_data) {
123 u64 value; 123 u64 value{};
124 Read(&value, sizeof(value)); 124 Read(&value, sizeof(value));
125 out_data = ntohll(value); 125 out_data = ntohll(value);
126 return *this; 126 return *this;