| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <SFML/Network/Packet.hpp> |
| 7 |
|
| 8 |
#include <utility> |
| 9 |
|
| 10 |
#include "Common/CommonTypes.h" |
| 11 |
#include "Common/Swap.h" |
| 12 |
#include "Common/TypeUtils.h" |
| 13 |
|
| 14 |
sf::Packet& operator>>(sf::Packet& packet, Common::BigEndianValue<u16>& data); |
| 15 |
sf::Packet& operator>>(sf::Packet& packet, Common::BigEndianValue<u32>& data); |
| 16 |
sf::Packet& operator>>(sf::Packet& packet, Common::BigEndianValue<u64>& data); |
| 17 |
|
| 18 |
template <Common::Enum Enum> |
| 19 |
sf::Packet& operator<<(sf::Packet& packet, Enum e) |
| 20 |
{ |
| 21 |
packet << std::to_underlying(e); |
| 22 |
return packet; |
| 23 |
} |
| 24 |
|
| 25 |
template <Common::Enum Enum> |
| 26 |
sf::Packet& operator>>(sf::Packet& packet, Enum& e) |
| 27 |
{ |
| 28 |
using Underlying = std::underlying_type_t<Enum>; |
| 29 |
|
| 30 |
Underlying value{}; |
| 31 |
packet >> value; |
| 32 |
|
| 33 |
e = static_cast<Enum>(value); |
| 34 |
return packet; |
| 35 |
} |
| 36 |
|
| 37 |
namespace Common |
| 38 |
{ |
| 39 |
u64 PacketReadU64(sf::Packet& packet); |
| 40 |
} |