From 01d2b4cfd83a22442b50d0b213e5c74d67d92d11 Mon Sep 17 00:00:00 2001 From: Eddoursul Date: Sun, 10 Aug 2025 20:58:55 +0200 Subject: [PATCH] Bitwise-based semver to int conversion --- Enderal SE v2.1.4 Changelog.txt | 2 +- source/Enderal DLL/src/PapyrusFunctions.h | 3 +-- source/Enderal DLL/src/Util.h | 12 +++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Enderal SE v2.1.4 Changelog.txt b/Enderal SE v2.1.4 Changelog.txt index 1af122df2..e5525475a 100644 --- a/Enderal SE v2.1.4 Changelog.txt +++ b/Enderal SE v2.1.4 Changelog.txt @@ -8,7 +8,7 @@ Beware, spoilers ahead! 2.1.4 (TBD) - Chinese Simplified localization revision by DaisyComment (no translation of lines added after 2.0.12.4 yet). -- Fixed a random crash, occurring in outskirts of Ark and on the Farmers Coast when guards are about to start a conversation scene and any of them is riding a horse. +- Fixed a random crash, occurring when guards on the outskirts of Ark or on the Farmers Coast are about to start a conversation scene and any of them is riding a horse. - Fixed help messages (in the middle of the screen) sometimes getting stuck in an infinite savebaked loop. - Dreamflower can be found without finishing The Secrets first. - Dimension Rift might get stuck in an infinite effect+sound loop if player left the cell while it's active. diff --git a/source/Enderal DLL/src/PapyrusFunctions.h b/source/Enderal DLL/src/PapyrusFunctions.h index 9a9f94418..9ff493713 100644 --- a/source/Enderal DLL/src/PapyrusFunctions.h +++ b/source/Enderal DLL/src/PapyrusFunctions.h @@ -58,9 +58,8 @@ namespace Papyrus::PapyrusFunctions inline std::uint32_t GetEnderalVersionInt(RE::StaticFunctionTag*) { const auto pluginVersion = SKSE::PluginDeclaration::GetSingleton()->GetVersion(); - std::string versionStr = std::format("{}{}{}{}", pluginVersion.major(), pluginVersion.minor(), pluginVersion.patch(), pluginVersion.build()); - return std::stoi(versionStr); + return SemVerToInt({ pluginVersion.major(), pluginVersion.minor(), pluginVersion.patch(), pluginVersion.build() }); } inline RE::TESObjectREFR* GetCurrentContainer(RE::StaticFunctionTag*) diff --git a/source/Enderal DLL/src/Util.h b/source/Enderal DLL/src/Util.h index ffca6b87f..5b9a231cb 100644 --- a/source/Enderal DLL/src/Util.h +++ b/source/Enderal DLL/src/Util.h @@ -23,6 +23,16 @@ inline uint8_t NewGameCount(bool increment = false) return g_NewGameStarted; } +inline std::uint32_t SemVerToInt(std::vector numbers) +{ + if (numbers.size() < 4) { + logger::error("Invalid SemVerToInt argument"); + return 0; + } + + return (numbers[0] << 24) | (numbers[1] << 16) | (numbers[2] << 8) | numbers[3]; +} + inline void CheckIncompatibleMods() { const auto pluginVersion = SKSE::PluginDeclaration::GetSingleton()->GetVersion(); @@ -320,4 +330,4 @@ inline RE::BSFixedString StringToHex(RE::BSFixedString a_string) } return sstream.str(); -} \ No newline at end of file +}