120 lines
3.5 KiB
C++
120 lines
3.5 KiB
C++
#include <string>
|
|
#include <vector>
|
|
|
|
#include "df/world.h"
|
|
|
|
#include "Core.h"
|
|
#include "Debug.h"
|
|
#include "PluginManager.h"
|
|
|
|
#include "modules/Persistence.h"
|
|
#include "modules/World.h"
|
|
|
|
using std::string;
|
|
using std::vector;
|
|
|
|
using namespace DFHack;
|
|
|
|
DFHACK_PLUGIN("multidwarf");
|
|
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
|
|
|
|
REQUIRE_GLOBAL(world);
|
|
|
|
namespace DFHack {
|
|
DBG_DECLARE(multidwarf, status, DebugCategory::LDEBUG);
|
|
DBG_DECLARE(multidwarf, onupdate, DebugCategory::LDEBUG);
|
|
DBG_DECLARE(multidwarf, command, DebugCategory::LDEBUG);
|
|
}
|
|
|
|
static command_result command_callback1(color_ostream &out, vector<string> ¶meters);
|
|
|
|
DFhackCExport command_result plugin_init(color_ostream &out, std::vector<PluginCommand> &commands) {
|
|
DEBUG(status,out).print("initializing %s\n", plugin_name);
|
|
|
|
commands.push_back(PluginCommand(
|
|
"multidwarf",
|
|
"Short (~54 character) description of command.",
|
|
command_callback1));
|
|
return CR_OK;
|
|
}
|
|
|
|
DFhackCExport command_result plugin_shutdown(color_ostream &out) {
|
|
DEBUG(status,out).print("shutting down %s\n", plugin_name);
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) {
|
|
DEBUG(status,out).print("%s from the API\n", enable ? "enabled" : "disabled");
|
|
|
|
is_enabled = enable;
|
|
return CR_OK;
|
|
}
|
|
|
|
DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) {
|
|
switch (event) {
|
|
case SC_UNKNOWN:
|
|
DEBUG(status,out).print("game state changed: SC_UNKNOWN\n");
|
|
break;
|
|
case SC_WORLD_LOADED:
|
|
DEBUG(status,out).print("game state changed: SC_WORLD_LOADED\n");
|
|
break;
|
|
case SC_WORLD_UNLOADED:
|
|
DEBUG(status,out).print("game state changed: SC_WORLD_UNLOADED\n");
|
|
break;
|
|
case SC_MAP_LOADED:
|
|
DEBUG(status,out).print("game state changed: SC_MAP_LOADED\n");
|
|
break;
|
|
case SC_MAP_UNLOADED:
|
|
DEBUG(status,out).print("game state changed: SC_MAP_UNLOADED\n");
|
|
break;
|
|
case SC_VIEWSCREEN_CHANGED:
|
|
DEBUG(status,out).print("game state changed: SC_VIEWSCREEN_CHANGED\n");
|
|
break;
|
|
case SC_CORE_INITIALIZED:
|
|
DEBUG(status,out).print("game state changed: SC_CORE_INITIALIZED\n");
|
|
break;
|
|
case SC_BEGIN_UNLOAD:
|
|
DEBUG(status,out).print("game state changed: SC_BEGIN_UNLOAD\n");
|
|
break;
|
|
case SC_PAUSED:
|
|
DEBUG(status,out).print("game state changed: SC_PAUSED\n");
|
|
break;
|
|
case SC_UNPAUSED:
|
|
DEBUG(status,out).print("game state changed: SC_UNPAUSED\n");
|
|
break;
|
|
}
|
|
|
|
return CR_OK;
|
|
}
|
|
|
|
DFhackCExport command_result plugin_onupdate (color_ostream &out) {
|
|
DEBUG(onupdate,out).print(
|
|
"onupdate called (run 'debugfilter set info multidwarf onupdate' to stop"
|
|
" seeing these messages)\n");
|
|
|
|
return CR_OK;
|
|
}
|
|
|
|
DFhackCExport command_result plugin_save_data (color_ostream &out) {
|
|
DEBUG(status,out).print("save or unload is imminent; time to persist state\n");
|
|
|
|
return CR_OK;
|
|
}
|
|
|
|
DFhackCExport command_result plugin_load_data (color_ostream &out) {
|
|
DEBUG(status,out).print("world is loading; time to load persisted state\n");
|
|
|
|
return CR_OK;
|
|
}
|
|
|
|
static command_result command_callback1(color_ostream &out, vector<string> ¶meters) {
|
|
DEBUG(command,out).print("%s command called with %zu parameters\n",
|
|
plugin_name, parameters.size());
|
|
|
|
CoreSuspender suspend;
|
|
|
|
return CR_OK;
|
|
}
|