summaryrefslogtreecommitdiff
path: root/plugins/probe.cpp
diff options
context:
space:
mode:
authorQuietust2012-03-02 09:35:49 -0600
committerQuietust2012-03-02 09:35:49 -0600
commit5d4114f5b797f302b903116d1439e6d94fa6d7f5 (patch)
tree6fe7c161ad3b4f55a1630b26991b79e785af38b6 /plugins/probe.cpp
parent3dd27c8d1d60f44987c26fa0a5aef6df7df1bad3 (diff)
downloaddfhack-5d4114f5b797f302b903116d1439e6d94fa6d7f5.tar.gz
dfhack-5d4114f5b797f302b903116d1439e6d94fa6d7f5.tar.bz2
dfhack-5d4114f5b797f302b903116d1439e6d94fa6d7f5.tar.xz
Add "bprobe" command, describes the buildings located under the cursor
Diffstat (limited to 'plugins/probe.cpp')
-rw-r--r--plugins/probe.cpp67
1 files changed, 66 insertions, 1 deletions
diff --git a/plugins/probe.cpp b/plugins/probe.cpp
index 970a0735..7849c33b 100644
--- a/plugins/probe.cpp
+++ b/plugins/probe.cpp
@@ -19,10 +19,12 @@ using namespace std;
#include "modules/Gui.h"
#include "modules/Materials.h"
#include "modules/MapCache.h"
+#include "modules/Buildings.h"
#include "MiscUtils.h"
#include "df/world.h"
-
+#include "df/world_raws.h"
+#include "df/building_def.h"
using std::vector;
using std::string;
@@ -30,9 +32,11 @@ using namespace DFHack;
using namespace DFHack::Simple;
using namespace df::enums;
using df::global::world;
+using df::global::cursor;
command_result df_probe (Core * c, vector <string> & parameters);
command_result df_cprobe (Core * c, vector <string> & parameters);
+command_result df_bprobe (Core * c, vector <string> & parameters);
DFHACK_PLUGIN("probe");
@@ -45,6 +49,9 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
commands.push_back(PluginCommand("cprobe",
"A creature probe",
df_cprobe));
+ commands.push_back(PluginCommand("bprobe",
+ "A simple building probe",
+ df_bprobe));
return CR_OK;
}
@@ -273,3 +280,61 @@ command_result df_probe (Core * c, vector <string> & parameters)
con << std::endl;
return CR_OK;
}
+
+command_result df_bprobe (Core * c, vector <string> & parameters)
+{
+ CoreSuspender suspend(c);
+
+ if(cursor->x == -30000)
+ {
+ c->con.printerr("No cursor; place cursor over tile to probe.\n");
+ return CR_FAILURE;
+ }
+
+ for (size_t i = 0; i < world->buildings.all.size(); i++)
+ {
+ Buildings::t_building building;
+ if (!Buildings::Read(i, building))
+ continue;
+ if (!(building.x1 <= cursor->x && cursor->x <= building.x2 &&
+ building.y1 <= cursor->y && cursor->y <= building.y2 &&
+ building.z == cursor->z))
+ continue;
+ string name;
+ building.origin->getName(&name);
+ c->con.print("Building %i - \"%s\" - type %s", building.origin->id, name.c_str(), ENUM_KEY_STR(building_type, building.type));
+
+ switch (building.type)
+ {
+ case building_type::Furnace:
+ c->con.print(", subtype %s", ENUM_KEY_STR(furnace_type, building.furnace_type));
+ if (building.furnace_type == furnace_type::Custom)
+ c->con.print(", custom type %i (%s)", building.custom_type, world->raws.buildings.all[building.custom_type]->code.c_str());
+ break;
+ case building_type::Workshop:
+ c->con.print(", subtype %s", ENUM_KEY_STR(workshop_type, building.workshop_type));
+ if (building.workshop_type == workshop_type::Custom)
+ c->con.print(", custom type %i (%s)", building.custom_type, world->raws.buildings.all[building.custom_type]->code.c_str());
+ break;
+ case building_type::Construction:
+ c->con.print(", subtype %s", ENUM_KEY_STR(construction_type, building.construction_type));
+ break;
+ case building_type::Shop:
+ c->con.print(", subtype %s", ENUM_KEY_STR(shop_type, building.shop_type));
+ break;
+ case building_type::SiegeEngine:
+ c->con.print(", subtype %s", ENUM_KEY_STR(siegeengine_type, building.siegeengine_type));
+ break;
+ case building_type::Trap:
+ c->con.print(", subtype %s", ENUM_KEY_STR(trap_type, building.trap_type));
+ break;
+ default:
+ if (building.subtype != -1)
+ c->con.print(", subtype %i", building.subtype);
+ break;
+ }
+ c->con.print("\n");
+
+ }
+ return CR_OK;
+}