-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplugin.cpp
More file actions
45 lines (36 loc) · 1.42 KB
/
Copy pathplugin.cpp
File metadata and controls
45 lines (36 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <SKSE/SKSE.h>
#include <LocationalDamage.h>
using namespace RE::BSScript;
using namespace SKSE;
using namespace SKSE::log;
using namespace SKSE::stl;
void SetupLog() {
// Credit to mrowrpurr
// https://github.com/SkyrimScripting/SKSE_Template_Logging
auto logsFolder = SKSE::log::log_directory();
if (!logsFolder) SKSE::stl::report_and_fail("SKSE log_directory not provided, logs disabled.");
auto pluginName = SKSE::PluginDeclaration::GetSingleton()->GetName();
auto logFilePath = *logsFolder / std::format("{}.log", pluginName);
auto fileLoggerPtr = std::make_shared<spdlog::sinks::basic_file_sink_mt>(logFilePath.string(), true);
auto loggerPtr = std::make_shared<spdlog::logger>("log", std::move(fileLoggerPtr));
spdlog::set_default_logger(std::move(loggerPtr));
spdlog::set_level(spdlog::level::trace);
spdlog::flush_on(spdlog::level::trace);
}
namespace {
void InitializePapyrus() {
log::trace("Initializing Papyrus binding...");
if (GetPapyrusInterface()->Register(LocDamageNamespace::RegisterFuncs)) {
log::debug("Papyrus functions bound.");
} else {
stl::report_and_fail("Failure to register Papyrus bindings.");
}
}
}
SKSEPluginLoad(const SKSE::LoadInterface *skse) {
SKSE::Init(skse);
SetupLog();
InitializePapyrus();
SKSE::log::info<>("Locational Damage SKSE DLL loaded successfully");
return true;
}