diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index ff7daf24f..82c0ee986 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -34,3 +34,10 @@ DFHACK_PLUGIN(cleanmap cleanmap.cpp) DFHACK_PLUGIN(weather weather.cpp) DFHACK_PLUGIN(vdig vdig.cpp) DFHACK_PLUGIN(colonies colonies.cpp) + +IF(UNIX) + OPTION(BUILD_KILL_GAME "Build the kill gmae plugin." OFF) + if(BUILD_KILL_GAME) + DFHACK_PLUGIN(die die.cpp) + endif() +endif() diff --git a/plugins/die.cpp b/plugins/die.cpp new file mode 100644 index 000000000..74e1186cd --- /dev/null +++ b/plugins/die.cpp @@ -0,0 +1,47 @@ +// Since you can't do "Ctrl-Z kill -9 %1" from the console, instead just +// give the "die" command to terminate the game without saving. +// Linux only, since _exit() probably doesn't work on Windows. +// +// Need to set cmake option BUILD_KILL_GAME to ON to compile this +// plugin. + +#ifndef LINUX_BUILD + #error "This plugin only compiles on Linux" +#endif + +#include +#include +#include +#include +#include + +using std::vector; +using std::string; +using namespace DFHack; + +DFhackCExport command_result df_die (Core * c, vector & parameters); + +DFhackCExport const char * plugin_name ( void ) +{ + return "die"; +} + +DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) +{ + commands.clear(); + commands.push_back(PluginCommand("die", + "Kill game without saving", df_die)); + return CR_OK; +} + +DFhackCExport command_result plugin_shutdown ( Core * c ) +{ + return CR_OK; +} + +DFhackCExport command_result df_die (Core * c, vector & parameters) +{ + _exit(0); + + return CR_OK; +}