diff --git a/include/SKSE/Interfaces.h b/include/SKSE/Interfaces.h index 92cdaa45aa..24b1cec041 100644 --- a/include/SKSE/Interfaces.h +++ b/include/SKSE/Interfaces.h @@ -533,7 +533,7 @@ namespace SKSE struct PluginVersionData { public: - enum + enum Version : std::uint32_t { kVersion = 1, }; @@ -567,24 +567,25 @@ namespace SKSE [[nodiscard]] constexpr std::string_view GetAuthorEmail() const noexcept { return std::string_view{ supportEmail }; } - constexpr void UsesAddressLibrary() noexcept { versionIndependence |= kVersionIndependent_AddressLibraryPostAE; } - constexpr void UsesSigScanning() noexcept { versionIndependence |= kVersionIndependent_Signatures; } - constexpr void UsesUpdatedStructs() noexcept { versionIndependence |= kVersionIndependent_StructsPost629; } + constexpr void UsesSigScanning(const bool a_value) noexcept { SetOrClearBit(versionIndependence, kVersionIndependent_Signatures, a_value); } - constexpr void UsesNoStructs() noexcept { versionIndependenceEx |= kVersionIndependentEx_NoStructUse; } + constexpr void UsesAddressLibrary(const bool a_value) noexcept { SetOrClearBit(versionIndependence, kVersionIndependent_AddressLibraryPostAE, a_value); } - constexpr void MinimumRequiredXSEVersion(REL::Version a_version) noexcept { xseMinimum = a_version.pack(); } + constexpr void HasNoStructUse(const bool a_value) noexcept { SetOrClearBit(versionIndependenceEx, kVersionIndependentEx_NoStructUse, a_value); } + + constexpr void IsLayoutDependent(const bool a_value) noexcept { SetOrClearBit(versionIndependence, kVersionIndependent_StructsPost629, a_value); } constexpr void CompatibleVersions(std::initializer_list a_versions) noexcept { + // must be zero-terminated assert(a_versions.size() < std::size(compatibleVersions) - 1); - std::transform( - a_versions.begin(), - a_versions.end(), - 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(); } + [[nodiscard]] static const PluginVersionData* GetSingleton() noexcept; const std::uint32_t dataVersion{ kVersion }; @@ -598,13 +599,19 @@ namespace SKSE std::uint32_t xseMinimum = 0; private: - static constexpr void SetCharBuffer( - std::string_view a_src, - std::span a_dst) noexcept + static constexpr void SetCharBuffer(std::string_view a_src, std::span a_dst) noexcept { assert(a_src.size() < a_dst.size()); - std::fill(a_dst.begin(), a_dst.end(), '\0'); - std::copy(a_src.begin(), a_src.end(), a_dst.begin()); + std::ranges::fill(a_dst, '\0'); + std::ranges::copy(a_src, a_dst.begin()); + } + + static constexpr void SetOrClearBit(std::uint32_t& a_data, const std::uint32_t a_bit, const bool a_set) noexcept + { + if (a_set) + a_data |= a_bit; + else + a_data &= ~a_bit; } }; static_assert(offsetof(PluginVersionData, dataVersion) == 0x000); diff --git a/lib/commonlib-shared b/lib/commonlib-shared index 2e36a6eafb..9fbb74d628 160000 --- a/lib/commonlib-shared +++ b/lib/commonlib-shared @@ -1 +1 @@ -Subproject commit 2e36a6eafb5efb094d0560b641447109a473528a +Subproject commit 9fbb74d628134ab4ea3a3cf5c0ed3f7eeabbd01d diff --git a/res/commonlibsse-plugin.cpp.in b/res/commonlibsse-plugin.cpp.in index 1a49fc4e70..db1f47255f 100644 --- a/res/commonlibsse-plugin.cpp.in +++ b/res/commonlibsse-plugin.cpp.in @@ -6,8 +6,10 @@ SKSE_EXPORT constinit auto SKSEPlugin_Version = []() { v.PluginName("${COMMONLIB_PLUGIN_NAME}"); v.AuthorName("${COMMONLIB_PLUGIN_AUTHOR}"); v.AuthorEmail("${COMMONLIB_PLUGIN_CONTACT}"); - v.UsesAddressLibrary(); - v.UsesUpdatedStructs(); + v.UsesSigScanning(${COMMONLIBSSE_OPTION_SIG_SCANNING}); + v.UsesAddressLibrary(${COMMONLIBSSE_OPTION_ADDRESS_LIBRARY}); + v.HasNoStructUse(${COMMONLIBSSE_OPTION_NO_STRUCT_USE}); + v.IsLayoutDependent(${COMMONLIBSSE_OPTION_LAYOUT_DEPENDENT}); v.CompatibleVersions({ SKSE::RUNTIME_LATEST }); v.MinimumRequiredXSEVersion({ ${COMMONLIB_PLUGIN_XSE_VERSION_MAJOR}, ${COMMONLIB_PLUGIN_XSE_VERSION_MINOR}, ${COMMONLIB_PLUGIN_XSE_VERSION_PATCH}, 0 }); return v; diff --git a/xmake.lua b/xmake.lua index 4f7c8e1786..57bf858d70 100644 --- a/xmake.lua +++ b/xmake.lua @@ -57,6 +57,38 @@ rule("commonlibsse.plugin", function() target:add("configfiles", path.join(os.scriptdir(), "res/commonlibsse-plugin.cpp.in")) target:add("files", path.join(target:configdir(), "commonlibsse-plugin.cpp")) + local conf = target:extraconf("rules", "commonlibsse.plugin") + if conf.options then + if conf.options.sig_scanning then + conf.options.address_library = false + else + conf.options.sig_scanning = false + if conf.options.address_library == nil then + conf.options.address_library = true + end + end + if conf.options.no_struct_use then + conf.options.layout_dependent = false + else + conf.options.no_struct_use = false + if conf.options.layout_dependent == nil then + conf.options.layout_dependent = true + end + end + else + conf.options = { + sig_scanning = false, + address_library = true, + no_struct_use = false, + layout_dependent = true + } + end + + target:set("configvar", "COMMONLIBSSE_OPTION_SIG_SCANNING", tostring(conf.options.sig_scanning)) + target:set("configvar", "COMMONLIBSSE_OPTION_ADDRESS_LIBRARY", tostring(conf.options.address_library)) + target:set("configvar", "COMMONLIBSSE_OPTION_NO_STRUCT_USE", tostring(conf.options.no_struct_use)) + target:set("configvar", "COMMONLIBSSE_OPTION_LAYOUT_DEPENDENT", tostring(conf.options.layout_dependent)) + if os.getenv("XSE_TES5_MODS_PATH") then target:set("installdir", path.join(os.getenv("XSE_TES5_MODS_PATH"), target:name())) elseif os.getenv("XSE_TES5_GAME_PATH") then @@ -67,3 +99,25 @@ rule("commonlibsse.plugin", function() target:add("installfiles", target:symbolfile(), { prefixdir = "SKSE/Plugins" }) end) end) + +rule("commonlibsse.archive", function() + add_deps("commonlib.archive") + + on_load(function(target) + target:data_set("commonlib.archive.config", target:extraconf("rules", "commonlibsse.archive")) + target:data_set("commonlib.archive.format", "-sse" ) + target:data_set("commonlib.archive.extension", ".bsa") + end) +end) + +rule("commonlibsse.papyrus", function() + add_deps("commonlib.papyrus") + + on_load(function(target) + target:data_set("commonlib.papyrus.config", target:extraconf("rules", "commonlibsse.papyrus")) + target:data_set("commonlib.papyrus.game", "skyrim" ) + target:data_set("commonlib.papyrus.gamevar", "XSE_TES5_GAME_PATH") + target:data_set("commonlib.papyrus.defaults", { "Data/Source/Scripts" } ) + target:data_set("commonlib.papyrus.flags", "TESV_Papyrus_Flags.flg") + end) +end)