diff --git a/include/SKSE/API.h b/include/SKSE/API.h index d099a7944..95657cba9 100644 --- a/include/SKSE/API.h +++ b/include/SKSE/API.h @@ -15,6 +15,12 @@ namespace SKSE void Init(const LoadInterface* a_intfc, const bool a_log = true) noexcept; void RegisterForAPIInitEvent(std::function a_fn); +#ifdef SKYRIM_SUPPORT_AE + std::string_view GetPluginName() noexcept; + std::string_view GetPluginAuthor() noexcept; + REL::Version GetPluginVersion() noexcept; +#endif + PluginHandle GetPluginHandle() noexcept; std::uint32_t GetReleaseIndex() noexcept; diff --git a/src/SKSE/API.cpp b/src/SKSE/API.cpp index 3ad841b85..ff5506187 100644 --- a/src/SKSE/API.cpp +++ b/src/SKSE/API.cpp @@ -16,6 +16,10 @@ namespace SKSE return singleton; } + std::string_view pluginName{}; + std::string_view pluginAuthor{}; + REL::Version pluginVersion{}; + PluginHandle pluginHandle{ static_cast(-1) }; std::uint32_t releaseIndex{ 0 }; @@ -87,6 +91,14 @@ namespace SKSE const auto& intfc = *a_intfc; const std::scoped_lock l(storage.apiLock); +#ifdef SKYRIM_SUPPORT_AE + if (const auto pluginVersionData = PluginVersionData::GetSingleton()) { + storage.pluginName = pluginVersionData->GetPluginName(); + storage.pluginAuthor = pluginVersionData->GetAuthorName(); + storage.pluginVersion = pluginVersionData->GetPluginVersion(); + } +#endif + if (!storage.apiInit) { storage.pluginHandle = intfc.GetPluginHandle(); storage.releaseIndex = intfc.GetReleaseIndex(); @@ -138,6 +150,23 @@ namespace SKSE a_fn(); } +#ifdef SKYRIM_SUPPORT_AE + std::string_view GetPluginName() noexcept + { + return detail::APIStorage::get().pluginName; + } + + std::string_view GetPluginAuthor() noexcept + { + return detail::APIStorage::get().pluginAuthor; + } + + REL::Version GetPluginVersion() noexcept + { + return detail::APIStorage::get().pluginVersion; + } +#endif + PluginHandle GetPluginHandle() noexcept { return detail::APIStorage::get().pluginHandle; diff --git a/src/SKSE/Logger.cpp b/src/SKSE/Logger.cpp index 21784b4a6..3209b4a17 100644 --- a/src/SKSE/Logger.cpp +++ b/src/SKSE/Logger.cpp @@ -126,8 +126,7 @@ namespace SKSE return; } - const auto data = PluginVersionData::GetSingleton(); - *path /= std::format("{}.log", data->GetPluginName()); + *path /= std::format("{}.log", SKSE::GetPluginName()); std::vector sinks{ std::make_shared(path->string(), true),