summaryrefslogtreecommitdiff
path: root/plugins/tweak.cpp
diff options
context:
space:
mode:
authorQuietust2012-08-27 14:06:10 -0500
committerQuietust2012-08-27 14:06:10 -0500
commitc587ea2c74056b392d004f8e5186c076fe0ed783 (patch)
tree1d887fe3a1ebdceacddae6217818e7b2ec128a54 /plugins/tweak.cpp
parentf73cebff68922801e4eaeffbd2b0487d868a3b56 (diff)
downloaddfhack-c587ea2c74056b392d004f8e5186c076fe0ed783.tar.gz
dfhack-c587ea2c74056b392d004f8e5186c076fe0ed783.tar.bz2
dfhack-c587ea2c74056b392d004f8e5186c076fe0ed783.tar.xz
Add new tweak command to make Train orders no longer count as patrol duty
Diffstat (limited to 'plugins/tweak.cpp')
-rw-r--r--plugins/tweak.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/plugins/tweak.cpp b/plugins/tweak.cpp
index 70acf760..591125c5 100644
--- a/plugins/tweak.cpp
+++ b/plugins/tweak.cpp
@@ -28,6 +28,7 @@
#include "df/criminal_case.h"
#include "df/unit_inventory_item.h"
#include "df/viewscreen_dwarfmodest.h"
+#include "df/squad_order_trainst.h"
#include <stdlib.h>
@@ -72,6 +73,10 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
" tweak stable-cursor [disable]\n"
" Keeps exact position of dwarfmode cursor during exits to main menu.\n"
" E.g. allows switching between t/q/k/d without losing position.\n"
+ " tweak patrol-duty [disable]\n"
+ " Causes 'Train' orders to no longer be considered 'patrol duty' so\n"
+ " soldiers will stop getting unhappy thoughts. Does NOT fix the problem\n"
+ " when soldiers go off-duty (i.e. civilian).\n"
));
return CR_OK;
}
@@ -184,7 +189,18 @@ struct stable_cursor_hook : df::viewscreen_dwarfmodest
}
};
+struct patrol_duty_hook : df::squad_order_trainst
+{
+ typedef df::squad_order_trainst interpose_base;
+
+ DEFINE_VMETHOD_INTERPOSE(bool, isPatrol, ())
+ {
+ return false;
+ }
+};
+
IMPLEMENT_VMETHOD_INTERPOSE(stable_cursor_hook, feed);
+IMPLEMENT_VMETHOD_INTERPOSE(patrol_duty_hook, isPatrol);
static command_result tweak(color_ostream &out, vector <string> &parameters)
{
@@ -292,6 +308,14 @@ static command_result tweak(color_ostream &out, vector <string> &parameters)
else
hook.apply();
}
+ else if (cmd == "patrol-duty")
+ {
+ auto &hook = INTERPOSE_HOOK(patrol_duty_hook, isPatrol);
+ if (vector_get(parameters, 1) == "disable")
+ hook.remove();
+ else
+ hook.apply();
+ }
else
return CR_WRONG_USAGE;