-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.cpp
More file actions
73 lines (58 loc) · 1.61 KB
/
plugin.cpp
File metadata and controls
73 lines (58 loc) · 1.61 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "plugin.h"
#include "cargo_runtime.h"
#include "plugin_config.h"
#include "plugin_helpers.h"
static IPluginLogger* g_logger = nullptr;
static IPluginConfig* g_config = nullptr;
static IPluginScanner* g_scanner = nullptr;
static IPluginHooks* g_hooks = nullptr;
IPluginLogger* GetLogger() { return g_logger; }
IPluginConfig* GetConfig() { return g_config; }
IPluginScanner* GetScanner() { return g_scanner; }
IPluginHooks* GetHooks() { return g_hooks; }
#ifndef MODLOADER_BUILD_TAG
#define MODLOADER_BUILD_TAG "dev"
#endif
static PluginInfo s_pluginInfo = {
"MapExtension_Plugin",
MODLOADER_BUILD_TAG,
"OpenAI",
"Publishes cargo sender and receiver positions over local HTTP",
PLUGIN_INTERFACE_VERSION
};
extern "C" {
__declspec(dllexport) PluginInfo* GetPluginInfo()
{
return &s_pluginInfo;
}
__declspec(dllexport) bool PluginInit(IPluginLogger* logger, IPluginConfig* config, IPluginScanner* scanner, IPluginHooks* hooks)
{
g_logger = logger;
g_config = config;
g_scanner = scanner;
g_hooks = hooks;
LOG_INFO("Plugin initializing...");
MapExtensionPluginConfig::Config::Initialize(config);
if (!MapExtensionPluginConfig::Config::IsEnabled())
{
LOG_WARN("Plugin is disabled in config");
return true;
}
if (!CargoRuntime::RegisterCallbacks())
{
LOG_ERROR("Failed to register runtime callbacks / HTTP endpoint");
return false;
}
LOG_INFO("Plugin initialized");
return true;
}
__declspec(dllexport) void PluginShutdown()
{
CargoRuntime::UnregisterCallbacks();
LOG_INFO("Plugin shutting down");
g_hooks = nullptr;
g_scanner = nullptr;
g_config = nullptr;
g_logger = nullptr;
}
} // extern "C"