diff options
| author | Techjar <tecknojar@gmail.com> | 2018-10-02 04:45:36 -0400 |
|---|---|---|
| committer | Techjar <tecknojar@gmail.com> | 2018-10-02 05:44:50 -0400 |
| commit | c5b4e1a5f67991d82ece34dc3e443146395525e1 (patch) | |
| tree | b0e37149b55c5b0dc1d75a35e967453af3d07399 /Source/Core/Common/SFMLHelper.cpp | |
| parent | 58b0a284a85637a2a0f1f6e896fdc3a596487c36 (diff) | |
Improve SFMLHelper
Switch to using additional overloads of sf::Packet, so we can eliminate
some of the messy code and just use the normal syntax for
BigEndianValue.
We can't avoid helper functions with u64 due to SFML's non-standard way
of defining 64-bit integer types.
Diffstat (limited to 'Source/Core/Common/SFMLHelper.cpp')
| -rw-r--r-- | Source/Core/Common/SFMLHelper.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/Source/Core/Common/SFMLHelper.cpp b/Source/Core/Common/SFMLHelper.cpp index 46b8ce836b..481db625e1 100644 --- a/Source/Core/Common/SFMLHelper.cpp +++ b/Source/Core/Common/SFMLHelper.cpp @@ -6,24 +6,34 @@ #include <SFML/Network/Packet.hpp> -namespace Common -{ -// This only exists as a helper for BigEndianValue -u16 PacketReadU16(sf::Packet& packet) +sf::Packet& operator>>(sf::Packet& packet, Common::BigEndianValue<u16>& data) { u16 tmp; packet >> tmp; - return tmp; + data = tmp; + return packet; } -// This only exists as a helper for BigEndianValue -u32 PacketReadU32(sf::Packet& packet) +sf::Packet& operator>>(sf::Packet& packet, Common::BigEndianValue<u32>& data) { u32 tmp; packet >> tmp; - return tmp; + data = tmp; + return packet; +} + +sf::Packet& operator>>(sf::Packet& packet, Common::BigEndianValue<u64>& data) +{ + sf::Uint64 tmp; + packet >> tmp; + data = tmp; + return packet; } +namespace Common +{ +// SFML's Uint64 type is different depending on platform, +// so we have this for cleaner code. u64 PacketReadU64(sf::Packet& packet) { sf::Uint64 value; |
