From 509c54e62af0a5e88c982e192adca968eb359e12 Mon Sep 17 00:00:00 2001 From: Eddoursul Date: Thu, 1 Sep 2022 11:20:08 +0200 Subject: [PATCH] Check size of incompatible mods to allow placeholders --- SKSE/Plugins/EnderalSE.dll | 4 ++-- source/Enderal DLL/src/CheckInvalidForms.h | 8 +++++++- source/Enderal DLL/src/Main.cpp | 4 ++-- source/Enderal DLL/src/Papyrus.cpp | 2 +- source/Enderal DLL/src/PapyrusFunctions.h | 8 ++++---- source/Enderal DLL/src/PhasmalistFunctions.h | 2 +- source/Enderal DLL/src/Util.h | 4 ++-- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/SKSE/Plugins/EnderalSE.dll b/SKSE/Plugins/EnderalSE.dll index f16eb2ea..979427cd 100644 --- a/SKSE/Plugins/EnderalSE.dll +++ b/SKSE/Plugins/EnderalSE.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c36e877366484af2b3631a38ffe19174963e8fa459ccdfb4a09613ef40ee689d -size 647168 +oid sha256:9996320987e1db1911f09c8724eedfb0655d3a34916eb6a4d59dd8b485f9563d +size 658944 diff --git a/source/Enderal DLL/src/CheckInvalidForms.h b/source/Enderal DLL/src/CheckInvalidForms.h index 810a879c..6d528619 100644 --- a/source/Enderal DLL/src/CheckInvalidForms.h +++ b/source/Enderal DLL/src/CheckInvalidForms.h @@ -4,6 +4,12 @@ static bool bMessageShown = false; static std::unordered_set aModNames; +inline bool DataFileExists(std::string filename, int maxSize = 1000000) +{ + const auto path = std::format("Data\\{}", filename); + return std::filesystem::exists(path) && std::filesystem::file_size(path) > maxSize; +} + inline void NotifyInvalidForm(const RE::TESForm* form) { if (!form) { @@ -1177,7 +1183,7 @@ inline void CheckCCMods() }; for (short i = 0; i < 74; i++) { - if (std::filesystem::exists(std::format("Data\\{}", filenames[i]))) { + if (DataFileExists(filenames[i], 800)) { MessageBoxW(NULL, L"Creation Club mods are incompatible with Enderal.", L"Error", MB_OK | MB_ICONERROR); exit(EXIT_FAILURE); } diff --git a/source/Enderal DLL/src/Main.cpp b/source/Enderal DLL/src/Main.cpp index 33327821..843f9f03 100644 --- a/source/Enderal DLL/src/Main.cpp +++ b/source/Enderal DLL/src/Main.cpp @@ -35,11 +35,11 @@ namespace { { GetMessagingInterface()->RegisterListener([](MessagingInterface::Message* message) { if (message->type == MessagingInterface::kPostLoad) { - if ((std::filesystem::exists("Data\\Dawnguard.esm") && std::filesystem::file_size("Data\\Dawnguard.esm") > 1000000) || (std::filesystem::exists("Data\\Dragonborn.esm") && std::filesystem::file_size("Data\\Dragonborn.esm") > 1000000) || (std::filesystem::exists("Data\\HearthFires.esm") && std::filesystem::file_size("Data\\HearthFires.esm") > 1000000) || (std::filesystem::exists("Data\\Update.esm") && std::filesystem::file_size("Data\\Update.esm") > 1000000)) { + if (DataFileExists("Dawnguard.esm") || DataFileExists("Dragonborn.esm") || DataFileExists("HearthFires.esm") || DataFileExists("Update.esm")) { MessageBoxW(NULL, L"Skyrim DLCs are incompatible with Enderal.", L"Error", MB_OK | MB_ICONERROR); exit(EXIT_FAILURE); } - if (std::filesystem::exists("Data\\Unofficial Skyrim Special Edition Patch.esp")) { + if (DataFileExists("Unofficial Skyrim Special Edition Patch.esp")) { MessageBoxW(NULL, L"Unofficial Skyrim Special Edition Patch is incompatible with Enderal.", L"Error", MB_OK | MB_ICONERROR); exit(EXIT_FAILURE); } diff --git a/source/Enderal DLL/src/Papyrus.cpp b/source/Enderal DLL/src/Papyrus.cpp index 2b7ecaa8..e5e5bfc5 100644 --- a/source/Enderal DLL/src/Papyrus.cpp +++ b/source/Enderal DLL/src/Papyrus.cpp @@ -7,7 +7,7 @@ namespace Papyrus bool Bind(VM* a_vm) { if (!a_vm) { - logger::critical("couldn't get VM State"sv); + logger::critical("{}", "couldn't get VM State"sv); return false; } diff --git a/source/Enderal DLL/src/PapyrusFunctions.h b/source/Enderal DLL/src/PapyrusFunctions.h index e35ea7b4..5ad18c67 100644 --- a/source/Enderal DLL/src/PapyrusFunctions.h +++ b/source/Enderal DLL/src/PapyrusFunctions.h @@ -65,12 +65,12 @@ namespace Papyrus::PapyrusFunctions inline void Bind(VM& a_vm) { BIND(CreatePotion); - logger::info("Registered CreatePotion"sv); + logger::info("{}", "Registered CreatePotion"sv); BIND(GetNewGameCount); - logger::info("Registered GetNewGameCount"sv); + logger::info("{}", "Registered GetNewGameCount"sv); BIND(GetCurrentContainer); - logger::info("Registered GetCurrentContainer"sv); + logger::info("{}", "Registered GetCurrentContainer"sv); BIND(GetPlayerFollowers); - logger::info("Registered GetPlayerFollowers"sv); + logger::info("{}", "Registered GetPlayerFollowers"sv); } } diff --git a/source/Enderal DLL/src/PhasmalistFunctions.h b/source/Enderal DLL/src/PhasmalistFunctions.h index 1dae75d2..83802ab1 100644 --- a/source/Enderal DLL/src/PhasmalistFunctions.h +++ b/source/Enderal DLL/src/PhasmalistFunctions.h @@ -154,6 +154,6 @@ namespace Papyrus::PhasmalistFunctions inline void Bind(VM& a_vm) { BIND(calculateContentStrength); - logger::info("Registered calculateContentStrength"sv); + logger::info("{}", "Registered calculateContentStrength"sv); } } \ No newline at end of file diff --git a/source/Enderal DLL/src/Util.h b/source/Enderal DLL/src/Util.h index f093b829..44e02c89 100644 --- a/source/Enderal DLL/src/Util.h +++ b/source/Enderal DLL/src/Util.h @@ -51,7 +51,7 @@ inline void SetINISettings() inline void CheckIncompatibleMods() { - RE::ConsoleLog::GetSingleton()->Print("Loaded SureAI's Enderal: Forgotten Stories | Special Edition port v2.0.12 by Eddoursul et al"); + RE::ConsoleLog::GetSingleton()->Print("Loaded SureAI's Enderal: Forgotten Stories | Special Edition v2.0.12 by Eddoursul and contributors"); CheckWorldspaces(); CheckUnconvertedMap(); @@ -102,6 +102,6 @@ inline void LoadINI(std::map* settings, const char* iniPath) } } catch (const std::exception& e) { - logger::error(e.what()); + logger::error("{}", e.what()); } } \ No newline at end of file