From c2e1fd1c72883cde3cc86b0ef936638283ba755c Mon Sep 17 00:00:00 2001 From: Eddoursul Date: Tue, 5 Aug 2025 23:13:56 +0200 Subject: [PATCH] Read Enderal version from INI at build time --- scripts/_00E_EnderalVersion.pex | Bin 962 -> 951 bytes scripts/enderalfunctions.pex | Bin 2581 -> 2674 bytes source/Enderal DLL/CMakeLists.txt | 10 ++++++--- source/Enderal DLL/src/PapyrusFunctions.h | 26 ++++++++++++++++++++++ source/Enderal DLL/src/Util.h | 26 +++++++++------------- source/scripts/_00E_EnderalVersion.psc | 17 ++++---------- source/scripts/enderalfunctions.psc | 6 ++++- 7 files changed, 52 insertions(+), 33 deletions(-) diff --git a/scripts/_00E_EnderalVersion.pex b/scripts/_00E_EnderalVersion.pex index 3796b696149191a6e5dd098243e91bf4fcc5fb17..67c21751dd1b4498fc548abc050b0f3393c246ed 100644 GIT binary patch delta 553 zcmYjMKTpDN5PjETs{yoN`6IL?adDABjSftP#1I!35_K~K3N*oA3Dn7f#l;c(VH`Dn z0l$GC#L2t18hgp*_uk#R_xfSJn%4Kt`;rj zi)9e1_0xf!ABJiaM2rSA7}H=h^40ond}#S<X}AAS_Enmf0EZSJDq+shjCd>lhhzf?PKYXTPEAaZ~fo zP5uMI2B0C&CBP71aS7nLfof7UNNLz4Y{^LGr}3lat#T-4SV&Mqm(ExJ(S&V=+8$wt zU@?*%G=$bsLRpZAc42d`Fs0WBRRZ@)vRfq7dCr)R{IMKwRZ88{1C7i^0uYiYU}=Hh y9NtDVF-jV-eVu>tpI(E*dKVrHc1dqIi9Kg_lQRy7a)rue8x=yjlG-@74Cx1&kV@hJ delta 564 zcmZ8cJx{_=6g{_}8UZUH2ui_86N8Cj92iN2!Ni3`N7G1wCZ#o4SJ~K`{sVu4i>vxG z97y~dPTtp2LVPzbx#!&T&OPs4|I&@$yN`t|fxu_@_VN=Nmvk8Rn#T5h&kk67Do z-DlSg=SM|t>udZpTF#`ik*$ngZZ(znuw7f?FB@1{AwqhrbJNvql(_`Z!MGMz1EM5s0Gq@kF~5%Hk~ve6U1H`Ws}C5PCz%zr9iZ%LrS z3PP1BxlGt6956~vn5post+D*^we=EAUSH?$YpV!m{MsPYPvRJ6iCe)b|0GFDGmcDu DQ!YmL diff --git a/scripts/enderalfunctions.pex b/scripts/enderalfunctions.pex index 227b5224183131703582196e6c55a89085018da0..79eb6142a9e63a9e02fb92013f5c3e1288e991cd 100644 GIT binary patch literal 2674 zcmb7E=~~-H6g~2SF_G$*31A#)h=$ z8`nDdEPGZMs_<)`JhD6#*2DTP2KUA5Xx(QvNgxN6y6XtJ7q?n6h)|LKl4!bq!gG)G z$wDIc+R}Gi#UY(_9lMSrd~}gzm3CoCN)M%l1!mZKguJ4rJJF`6I?^->;j2)fhe>9% z7MhBo%CnGe6#p&DL2=cSR)jJmW*hYM=qF)EyP_eub2ghHWE`+fQ=Fyp%w$@&4((yX9&7jbb!Aa(07R8@q5i+ra$2k-& z&$Yr#pU24I)RZ{18V%QXqccTTaJ~um(N|4pcC;JSV%Ni-VVnh<@PR@1d>S|imxCsvbr#g1UgdP4~o zEuO^?MfL}^vJ(fEz8p}tg1|c4bAJ&iy1WHmXJvNCoyMTz}HBY%iBnn&77oAR< z=}5C3i3B?0C~oTW$uk=%w)OceJ`IlC5RbCE%8ZV!$PC+VWFL!=nj4x@H=r3ws=^Fg z!gd=jcQe#?Q@1bL$uTJ}ET~NCR={Q#UPIN9%-ng?eITMZ@RfIA+DTWY&gN>Tyq(NI z*up(!i1slzMkk?znan25%`vUEb!IlWrMUY)Rz)(qsBdGGm#l%Dy112)&xC@~_{aZZ zhIM5^DHFOgp_~alnb4aFl}zZ%g#Jtz$b`X67y?r;^{YZ(0ZRB#zqgUR3LaKgpXyhs zBR~cB{^L~!SAjBS-+I-Qs-KU6G4;vent|&|<&*!NUnM2~$#;~V#?yIa#AgKWB!IHb z;|6Zx7NH4_%5?*#fp-nu(9HH5xJ7xCAEg&K{hopMQx!dW`c`6)~NG{+3bEQfl!FRvcHNL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al 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