diff --git a/Source/Core/Common/SFMLHelper.h b/Source/Core/Common/SFMLHelper.h index efc8f91f84..cd8bb2303b 100644 --- a/Source/Core/Common/SFMLHelper.h +++ b/Source/Core/Common/SFMLHelper.h @@ -3,18 +3,37 @@ #pragma once +#include + +#include + #include "Common/CommonTypes.h" #include "Common/Swap.h" -namespace sf -{ -class Packet; -} - sf::Packet& operator>>(sf::Packet& packet, Common::BigEndianValue& data); sf::Packet& operator>>(sf::Packet& packet, Common::BigEndianValue& data); sf::Packet& operator>>(sf::Packet& packet, Common::BigEndianValue& data); +template >* = nullptr> +sf::Packet& operator<<(sf::Packet& packet, Enum e) +{ + using Underlying = std::underlying_type_t; + packet << static_cast(e); + return packet; +} + +template >* = nullptr> +sf::Packet& operator>>(sf::Packet& packet, Enum& e) +{ + using Underlying = std::underlying_type_t; + + Underlying value{}; + packet >> value; + + e = static_cast(value); + return packet; +} + namespace Common { u64 PacketReadU64(sf::Packet& packet); diff --git a/Source/Core/Core/NetPlayProto.h b/Source/Core/Core/NetPlayProto.h index 4b7da05d80..657d33b19b 100644 --- a/Source/Core/Core/NetPlayProto.h +++ b/Source/Core/Core/NetPlayProto.h @@ -121,7 +121,7 @@ struct NetTraversalConfig }; // messages -enum +enum MessageID : u8 { NP_MSG_PLAYER_JOIN = 0x10, NP_MSG_PLAYER_LEAVE = 0x11,