-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMergeMapperPluginAPI.cpp
More file actions
26 lines (22 loc) · 1.15 KB
/
Copy pathMergeMapperPluginAPI.cpp
File metadata and controls
26 lines (22 loc) · 1.15 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
#include "MergeMapperPluginAPI.h"
// Interface code based on https://github.com/adamhynek/higgs
// Stores the API after it has already been fetched
MergeMapperPluginAPI::IMergeMapperInterface001* g_mergeMapperInterface = nullptr;
// Fetches the interface to use from MergeMapper
MergeMapperPluginAPI::IMergeMapperInterface001* MergeMapperPluginAPI::GetMergeMapperInterface001() {
// If the interface has already been fetched, rturn the same object
if (g_mergeMapperInterface) {
return g_mergeMapperInterface;
}
// Dispatch a message to get the plugin interface from MergeMapper
MergeMapperMessage mergeMapperMessage;
const auto skseMessaging = SKSE::GetMessagingInterface();
skseMessaging->Dispatch(MergeMapperMessage::kMessage_GetInterface, (void*)&mergeMapperMessage,
sizeof(MergeMapperMessage*), MergeMapperPluginName);
if (!mergeMapperMessage.GetApiFunction) {
return nullptr;
}
// Fetch the API for this version of the MergeMapper interface
g_mergeMapperInterface = static_cast<IMergeMapperInterface001*>(mergeMapperMessage.GetApiFunction(1));
return g_mergeMapperInterface;
}