-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathweblegends.cpp
68 lines (58 loc) · 1.52 KB
/
weblegends.cpp
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
#include "weblegends.h"
DFHACK_PLUGIN("weblegends");
static WebLegends *weblegends = nullptr;
static command_result export_command(color_ostream & out, std::vector<std::string> & args)
{
if (args.size() != 1)
{
return CR_WRONG_USAGE;
}
return weblegends->export_all(out, args.at(0));
}
DFhackCExport command_result plugin_init(color_ostream & out, std::vector<PluginCommand> & commands)
{
commands.push_back(PluginCommand(
"weblegends-export",
"exports a full weblegends site to a folder",
export_command,
false,
"weblegends-export [folder-name]\n"
" exports a full weblegends site to a folder"
));
weblegends = new WebLegends();
return weblegends->init(out);
}
static command_result do_unload(color_ostream & out)
{
if (weblegends == nullptr)
{
return CR_OK;
}
command_result res = weblegends->shutdown(out);
if (res == CR_OK)
{
delete weblegends;
weblegends = nullptr;
#ifdef WEBLEGENDS_DEBUG
weblegends_debug_close_log();
#endif
}
return res;
}
void clear_region_map_cache(bool);
DFhackCExport command_result plugin_onstatechange(color_ostream & out, state_change_event sc)
{
if (sc == SC_WORLD_LOADED || sc == SC_WORLD_UNLOADED)
{
clear_region_map_cache(sc == SC_WORLD_LOADED);
}
if (sc == SC_BEGIN_UNLOAD)
{
return do_unload(out);
}
return CR_OK;
}
DFhackCExport command_result plugin_shutdown(color_ostream & out)
{
return do_unload(out);
}