summaryrefslogtreecommitdiff
path: root/plugins/tweak.cpp
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-03-05 19:47:06 +0400
committerAlexander Gavrilov2012-03-05 19:47:06 +0400
commitcbd254991f509b7cd0641f81696a1b45a2d80a8c (patch)
tree439d85242a29e7ed2daa221c42291671e07fbfd7 /plugins/tweak.cpp
parentf83db862582fdd4e6929879e7659499edaa2501e (diff)
downloaddfhack-cbd254991f509b7cd0641f81696a1b45a2d80a8c.tar.gz
dfhack-cbd254991f509b7cd0641f81696a1b45a2d80a8c.tar.bz2
dfhack-cbd254991f509b7cd0641f81696a1b45a2d80a8c.tar.xz
Add a tweak for forcibly clearing the Missing status of units.
Mainly useful for fixing inexplicably missing ghosts.
Diffstat (limited to 'plugins/tweak.cpp')
-rw-r--r--plugins/tweak.cpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/plugins/tweak.cpp b/plugins/tweak.cpp
new file mode 100644
index 00000000..c244553a
--- /dev/null
+++ b/plugins/tweak.cpp
@@ -0,0 +1,88 @@
+// A container for random minor tweaks that don't fit anywhere else,
+// in order to avoid creating lots of plugins and polluting the namespace.
+
+#include "Core.h"
+#include "Console.h"
+#include "Export.h"
+#include "PluginManager.h"
+
+#include "modules/Gui.h"
+
+#include "DataDefs.h"
+#include "df/ui.h"
+#include "df/world.h"
+#include "df/squad.h"
+#include "df/unit.h"
+#include "df/unit_soul.h"
+#include "df/historical_entity.h"
+#include "df/historical_figure.h"
+#include "df/historical_figure_info.h"
+#include "df/assumed_identity.h"
+#include "df/language_name.h"
+#include "df/death_info.h"
+#include "df/criminal_case.h"
+
+#include <stdlib.h>
+
+using std::vector;
+using std::string;
+using std::endl;
+using namespace DFHack;
+using namespace df::enums;
+
+using df::global::ui;
+using df::global::world;
+
+using namespace DFHack::Gui;
+
+static command_result tweak(Core * c, vector <string> & parameters);
+
+DFHACK_PLUGIN("tweak");
+
+DFhackCExport command_result plugin_init (Core *c, std::vector <PluginCommand> &commands)
+{
+ commands.clear();
+ commands.push_back(PluginCommand(
+ "tweak", "Various tweaks for minor bugs.", tweak, false,
+ " tweak clear-missing\n"
+ " Remove the missing status from the selected unit.\n"
+ ));
+ return CR_OK;
+}
+
+DFhackCExport command_result plugin_shutdown ( Core * c )
+{
+ return CR_OK;
+}
+
+static command_result tweak(Core * c, vector <string> &parameters)
+{
+ CoreSuspender suspend(c);
+
+ if (parameters.empty())
+ return CR_WRONG_USAGE;
+
+ string cmd = parameters[0];
+
+ if (cmd == "clear-missing")
+ {
+ df::unit *unit = getSelectedUnit(c);
+ if (!unit)
+ return CR_FAILURE;
+
+ auto death = df::death_info::find(unit->counters.death_id);
+
+ if (death)
+ {
+ death->flags.bits.discovered = true;
+
+ auto crime = df::criminal_case::find(death->crime_id);
+ if (crime)
+ crime->flags.bits.discovered = true;
+ }
+ }
+ else
+ return CR_WRONG_USAGE;
+
+ return CR_OK;
+}