diff --git a/dCommon/GeneralUtils.h b/dCommon/GeneralUtils.h index f57be9a2..c3422b05 100644 --- a/dCommon/GeneralUtils.h +++ b/dCommon/GeneralUtils.h @@ -264,8 +264,8 @@ namespace GeneralUtils { * @returns The enum entry's value in its underlying type */ template - constexpr typename std::underlying_type_t CastUnderlyingType(const eType entry) noexcept { - return static_cast>(entry); + constexpr std::underlying_type_t ToUnderlying(const eType entry) noexcept { + return static_cast>(entry); } // on Windows we need to undef these or else they conflict with our numeric limits calls diff --git a/dNet/AuthPackets.cpp b/dNet/AuthPackets.cpp index dce7e8e9..a2bf731c 100644 --- a/dNet/AuthPackets.cpp +++ b/dNet/AuthPackets.cpp @@ -229,7 +229,7 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd RakNet::BitStream loginResponse; BitStreamUtils::WriteHeader(loginResponse, eConnectionType::CLIENT, eClientMessageType::LOGIN_RESPONSE); - loginResponse.Write(GeneralUtils::CastUnderlyingType(responseCode)); + loginResponse.Write(responseCode); // Event Gating loginResponse.Write(LUString(Game::config->GetValue("event_1"))); diff --git a/tests/dCommonTests/CMakeLists.txt b/tests/dCommonTests/CMakeLists.txt index cf0a03ed..ef7c4cba 100644 --- a/tests/dCommonTests/CMakeLists.txt +++ b/tests/dCommonTests/CMakeLists.txt @@ -1,7 +1,7 @@ set(DCOMMONTEST_SOURCES "AMFDeserializeTests.cpp" "Amf3Tests.cpp" - "CastUnderlyingTypeTests.cpp" + "ToUnderlyingTests.cpp" "HeaderSkipTest.cpp" "TestCDFeatureGatingTable.cpp" "TestLDFFormat.cpp" diff --git a/tests/dCommonTests/CastUnderlyingTypeTests.cpp b/tests/dCommonTests/ToUnderlyingTests.cpp similarity index 68% rename from tests/dCommonTests/CastUnderlyingTypeTests.cpp rename to tests/dCommonTests/ToUnderlyingTests.cpp index 9cdfcdd3..4cbf4635 100644 --- a/tests/dCommonTests/CastUnderlyingTypeTests.cpp +++ b/tests/dCommonTests/ToUnderlyingTests.cpp @@ -7,13 +7,13 @@ #include "eWorldMessageType.h" #define ASSERT_TYPE_EQ(TYPE, ENUM)\ - ASSERT_TRUE(typeid(TYPE) == typeid(GeneralUtils::CastUnderlyingType(static_cast(0)))); + ASSERT_TRUE(typeid(TYPE) == typeid(GeneralUtils::ToUnderlying(static_cast(0)))); #define ASSERT_TYPE_NE(TYPE, ENUM)\ - ASSERT_FALSE(typeid(TYPE) == typeid(GeneralUtils::CastUnderlyingType(static_cast(0)))); + ASSERT_FALSE(typeid(TYPE) == typeid(GeneralUtils::ToUnderlying(static_cast(0)))); // Verify that the underlying enum types are being cast correctly -TEST(CastUnderlyingTypeTests, VerifyCastUnderlyingType) { +TEST(ToUnderlyingTests, VerifyToUnderlying) { ASSERT_TYPE_EQ(uint8_t, eGameMasterLevel); ASSERT_TYPE_EQ(uint16_t, eGameMessageType); ASSERT_TYPE_EQ(uint32_t, eWorldMessageType)