From 347e096200fff771039e58dcd6029e5c8dbcac6e Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Sat, 30 Sep 2023 21:41:20 -0500 Subject: [PATCH] feat!: return plugin version instead of uint32 - simplify SetOrClearBit --- CommonLibSF/include/SFSE/Interfaces.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/CommonLibSF/include/SFSE/Interfaces.h b/CommonLibSF/include/SFSE/Interfaces.h index d55bd9e6..899c056f 100644 --- a/CommonLibSF/include/SFSE/Interfaces.h +++ b/CommonLibSF/include/SFSE/Interfaces.h @@ -133,7 +133,7 @@ namespace SFSE constexpr void PluginVersion(REL::Version a_version) noexcept { pluginVersion = a_version.pack(); } - [[nodiscard]] constexpr std::uint32_t GetPluginVersion() const noexcept { return pluginVersion; } + [[nodiscard]] constexpr REL::Version GetPluginVersion() const noexcept { return REL::Version::unpack(pluginVersion); } constexpr void PluginName(std::string_view a_plugin) noexcept { SetCharBuffer(a_plugin, std::span{ pluginName }); } @@ -143,19 +143,22 @@ namespace SFSE [[nodiscard]] constexpr std::string_view GetAuthorName() const noexcept { return std::string_view{ author }; } - constexpr void UsesSigScanning(bool a_value) noexcept { addressIndependence = SetOrClearBit(addressIndependence, 1 << 0, a_value); } + constexpr void UsesSigScanning(bool a_value) noexcept { SetOrClearBit(addressIndependence, 1 << 0, a_value); } - constexpr void UsesAddressLibrary(bool a_value) noexcept { addressIndependence = SetOrClearBit(addressIndependence, 1 << 1, a_value); } + constexpr void UsesAddressLibrary(bool a_value) noexcept { SetOrClearBit(addressIndependence, 1 << 1, a_value); } - constexpr void HasNoStructUse(bool a_value) noexcept { structureCompatibility = SetOrClearBit(structureCompatibility, 1 << 0, a_value); } + constexpr void HasNoStructUse(bool a_value) noexcept { SetOrClearBit(structureCompatibility, 1 << 0, a_value); } - constexpr void IsLayoutDependent(bool a_value) noexcept { structureCompatibility = SetOrClearBit(structureCompatibility, 1 << 1, a_value); } + constexpr void IsLayoutDependent(bool a_value) noexcept { SetOrClearBit(structureCompatibility, 1 << 1, a_value); } constexpr void CompatibleVersions(std::initializer_list a_versions) noexcept { // must be zero-terminated assert(a_versions.size() < std::size(compatibleVersions) - 1); - std::ranges::transform(a_versions, std::begin(compatibleVersions), [](const REL::Version& a_version) noexcept { return a_version.pack(); }); + std::ranges::transform(a_versions, std::begin(compatibleVersions), [](const REL::Version& a_version) noexcept + { + return a_version.pack(); + }); } constexpr void MinimumRequiredXSEVersion(REL::Version a_version) noexcept { xseMinimum = a_version.pack(); } @@ -181,14 +184,12 @@ namespace SFSE std::ranges::copy(a_src, a_dst.begin()); } - [[nodiscard]] static constexpr std::uint32_t SetOrClearBit(std::uint32_t a_data, std::uint32_t a_bit, bool a_set) noexcept + static constexpr void SetOrClearBit(std::uint32_t& a_data, std::uint32_t a_bit, bool a_set) noexcept { if (a_set) a_data |= a_bit; else a_data &= ~a_bit; - - return a_data; } };