From dcce48c243d43df26a42ee45a83fbdecc2795727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 2 Nov 2011 00:26:45 +0100 Subject: [PATCH] Add simple creature probe, fix current civ address on windows, update df2mc. --- Memory.xml | 1 + plugins/devel/df2mc | 2 +- plugins/probe.cpp | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Memory.xml b/Memory.xml index 26495c4f7..366dc48ba 100644 --- a/Memory.xml +++ b/Memory.xml @@ -2269,6 +2269,7 @@
+
diff --git a/plugins/devel/df2mc b/plugins/devel/df2mc index 704705708..0f6389f41 160000 --- a/plugins/devel/df2mc +++ b/plugins/devel/df2mc @@ -1 +1 @@ -Subproject commit 704705708861ebf46d2d8bea64d08cf3d4986eed +Subproject commit 0f6389f4121d6cf3d447fb72a5b561d8d66b0de8 diff --git a/plugins/probe.cpp b/plugins/probe.cpp index 2e1997caf..6006e77ef 100644 --- a/plugins/probe.cpp +++ b/plugins/probe.cpp @@ -15,6 +15,7 @@ using namespace std; #include #include #include +#include #include #include #include @@ -27,6 +28,7 @@ using std::string; using namespace DFHack; DFhackCExport command_result df_probe (Core * c, vector & parameters); +DFhackCExport command_result df_cprobe (Core * c, vector & parameters); DFhackCExport const char * plugin_name ( void ) { @@ -39,6 +41,9 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector commands.push_back(PluginCommand("probe", "A tile probe", df_probe)); + commands.push_back(PluginCommand("cprobe", + "A creature probe", + df_cprobe)); return CR_OK; } @@ -47,6 +52,37 @@ DFhackCExport command_result plugin_shutdown ( Core * c ) return CR_OK; } +DFhackCExport command_result df_cprobe (Core * c, vector & parameters) +{ + Console & con = c->con; + BEGIN_PROBE: + c->Suspend(); + DFHack::Gui *Gui = c->getGui(); + DFHack::Creatures * cr = c->getCreatures(); + int32_t cursorX, cursorY, cursorZ; + Gui->getCursorCoords(cursorX,cursorY,cursorZ); + if(cursorX == -30000) + { + con.printerr("No cursor; place cursor over creature to probe.\n"); + } + else + { + uint32_t ncr; + cr->Start(ncr); + for(auto i = 0; i < ncr; i++) + { + df_creature * unit = cr->GetCreature( i ); + if(unit->x == cursorX && unit->y == cursorY && unit->z == cursorZ) + { + con.print("Creature %d, race %d (%x), civ %d (%x)\n", unit->id, unit->race, unit->race, unit->civ, unit->civ); + break; + } + } + } + c->Resume(); + return CR_OK; +} + DFhackCExport command_result df_probe (Core * c, vector & parameters) { //bool showBlock, showDesig, showOccup, showTile, showMisc;