diff --git a/scripts/_00E_EnderalVersion.pex b/scripts/_00E_EnderalVersion.pex index 3796b6961..67c21751d 100644 Binary files a/scripts/_00E_EnderalVersion.pex and b/scripts/_00E_EnderalVersion.pex differ diff --git a/scripts/enderalfunctions.pex b/scripts/enderalfunctions.pex index 227b52241..79eb6142a 100644 Binary files a/scripts/enderalfunctions.pex and b/scripts/enderalfunctions.pex differ diff --git a/source/Enderal DLL/CMakeLists.txt b/source/Enderal DLL/CMakeLists.txt index 819f3e74f..4bb498360 100644 --- a/source/Enderal DLL/CMakeLists.txt +++ b/source/Enderal DLL/CMakeLists.txt @@ -2,12 +2,17 @@ option(ENABLE_VCPKG OFF) cmake_minimum_required(VERSION 3.21) message("Using toolchain file ${CMAKE_TOOLCHAIN_FILE}.") +# Get current version +file(READ "${CMAKE_SOURCE_DIR}/../../SKSE/Plugins/EnderalVersion.ini" CONFIG_CONTENT) +string(REGEX MATCH "version[ \t]*=[ \t]*([0-9.]+)" _ ${CONFIG_CONTENT}) +set(VERSION_NUMBER "${CMAKE_MATCH_1}") + ######################################################################################################################## ## Define project ######################################################################################################################## project( EnderalSE - VERSION 2.1.4 + VERSION ${VERSION_NUMBER} DESCRIPTION "Enderal SE DLL" LANGUAGES CXX ) @@ -20,7 +25,7 @@ configure_file( ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY ) - + #include(GNUInstallDirs) file( @@ -78,7 +83,6 @@ FetchContent_MakeAvailable(simpleini) INCLUDE_DIRECTORIES(${simpleini_SOURCE_DIR}) # rapidcsv -set(RAPIDCSV_INCLUDE_DIRS ${rapidcsv_SOURCE_DIR}/src) FetchContent_Declare( rapidcsv URL "https://github.com/d99kris/rapidcsv/archive/refs/tags/v8.87.tar.gz" diff --git a/source/Enderal DLL/src/PapyrusFunctions.h b/source/Enderal DLL/src/PapyrusFunctions.h index 7c4ac5e5d..9a9f94418 100644 --- a/source/Enderal DLL/src/PapyrusFunctions.h +++ b/source/Enderal DLL/src/PapyrusFunctions.h @@ -41,6 +41,28 @@ namespace Papyrus::PapyrusFunctions return NewGameCount(); } + inline std::string GetEnderalVersion(RE::StaticFunctionTag*) + { + const auto pluginVersion = SKSE::PluginDeclaration::GetSingleton()->GetVersion(); + std::string versionStr; + + if (pluginVersion.build() > 0) { + versionStr = std::format("{}.{}.{}.{}", pluginVersion.major(), pluginVersion.minor(), pluginVersion.patch(), pluginVersion.build()); + } else { + versionStr = std::format("{}.{}.{}", pluginVersion.major(), pluginVersion.minor(), pluginVersion.patch()); + } + + return versionStr; + } + + 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); + } + inline RE::TESObjectREFR* GetCurrentContainer(RE::StaticFunctionTag*) { const auto handle = RE::ContainerMenu::GetTargetRefHandle(); @@ -155,6 +177,10 @@ namespace Papyrus::PapyrusFunctions logger::info("{}", "Registered CreatePotion"sv); BIND(GetNewGameCount); logger::info("{}", "Registered GetNewGameCount"sv); + BIND(GetEnderalVersion); + logger::info("{}", "Registered GetEnderalVersion"sv); + BIND(GetEnderalVersionInt); + logger::info("{}", "Registered GetEnderalVersionInt"sv); BIND(GetCurrentContainer); logger::info("{}", "Registered GetCurrentContainer"sv); BIND(GetPlayerFollowers); diff --git a/source/Enderal DLL/src/Util.h b/source/Enderal DLL/src/Util.h index 30884d097..5cfd64908 100644 --- a/source/Enderal DLL/src/Util.h +++ b/source/Enderal DLL/src/Util.h @@ -26,23 +26,16 @@ inline uint8_t NewGameCount(bool increment = false) inline void CheckIncompatibleMods() { - bool bPrinted = false; - if (std::filesystem::exists("Data\\SKSE\\Plugins\\EnderalVersion.ini")) { - CSimpleIniA ini; - ini.SetUnicode(false); - ini.SetMultiKey(false); - ini.LoadFile("Data/SKSE/Plugins/EnderalVersion.ini"); - const char* version = ini.GetValue("", "version", "2.0.x"); - std::regex version_expr("^[\\d\\.]+$"); - if (std::regex_match(version, version_expr)) { - RE::ConsoleLog::GetSingleton()->Print(std::format("Loaded SureAI's Enderal: Forgotten Stories | Special Edition v{} by Eddoursul and contributors", version).c_str()); - bPrinted = true; - } + const auto pluginVersion = SKSE::PluginDeclaration::GetSingleton()->GetVersion(); + std::string versionStr; + + if (pluginVersion.build() > 0) { + versionStr = std::format("{}.{}.{}.{}", pluginVersion.major(), pluginVersion.minor(), pluginVersion.patch(), pluginVersion.build()); + } else { + versionStr = std::format("{}.{}.{}", pluginVersion.major(), pluginVersion.minor(), pluginVersion.patch()); } - if (!bPrinted) { - RE::ConsoleLog::GetSingleton()->Print("Loaded SureAI's Enderal: Forgotten Stories | Special Edition v2.0.x by Eddoursul and contributors"); - } + RE::ConsoleLog::GetSingleton()->Print(std::format("Loaded SureAI's Enderal: Forgotten Stories | Special Edition v{} by Eddoursul and contributors", versionStr).c_str()); if (RE::BSResourceNiBinaryStream("scripts/_00e_questfunctions.pex").good() || RE::BSResourceNiBinaryStream("scripts/_00e_game_skillmenusc.pex").good() || RE::TESDataHandler::GetSingleton()->LookupForm(0x10AA2, "Skyrim.esm")) { @@ -107,7 +100,8 @@ inline void CheckScriptVersions() std::map scripts; scripts["_00e_a2_eyeofthestormsc"] = 1; - scripts["EnderalFunctions"] = 1; + scripts["_00E_EnderalVersion"] = 1; + scripts["EnderalFunctions"] = 2; scripts["_00E_PlayerFunctions"] = 2; scripts["_00E_PlayerSetUpScript"] = 1; scripts["_00E_EngineBugfixAlias"] = 2; diff --git a/source/scripts/_00E_EnderalVersion.psc b/source/scripts/_00E_EnderalVersion.psc index 06cacdde3..7b62fd79c 100644 --- a/source/scripts/_00E_EnderalVersion.psc +++ b/source/scripts/_00E_EnderalVersion.psc @@ -3,19 +3,12 @@ Scriptname _00E_EnderalVersion extends ReferenceAlias Hidden int iPatchVersion -; Do not make comparisons with GetVersionFull(), versions are not float numbers, use GetVersion(). -float function _GetVersionFull() global - ; ABCD.E - ; A - engine version (1 - LE, 2 - SE) - ; B - backward-incompatible update - ; C - backward-compatible update - ; D - hotfix - ; E - build - return 2130.0 -endfunction +int function _GetScriptVersion() Global + return 1 +endFunction int function GetVersion() global - return Math.Floor(_GetVersionFull()) + return EnderalFunctions.GetEnderalVersionInt() endfunction Event OnInit() @@ -27,8 +20,6 @@ EndEvent Event OnPlayerLoadGame() if iPatchVersion < GetVersion() - ;Utility.Wait(0.1) ; wait for menu mode to end - ; iPatchVersion = GetVersion() endif diff --git a/source/scripts/enderalfunctions.psc b/source/scripts/enderalfunctions.psc index 52425ea78..3b2a0d229 100644 --- a/source/scripts/enderalfunctions.psc +++ b/source/scripts/enderalfunctions.psc @@ -1,7 +1,7 @@ Scriptname EnderalFunctions Hidden int function _GetScriptVersion() Global - return 1 + return 2 endFunction float function CalculateContentStrength(ObjectReference container) native global @@ -12,6 +12,10 @@ ObjectReference function GetCurrentContainer() native global int function GetNewGameCount() native global +string function GetEnderalVersion() native global + +int function GetEnderalVersionInt() native global + Actor[] function GetPlayerFollowers() native global String Function GetAutosaveName(int index) native global