2011-07-25 02:14:58 -06:00
|
|
|
// Just show some position data
|
|
|
|
|
|
|
|
#include <climits>
|
|
|
|
#include <cstdio>
|
2016-08-13 19:44:01 -06:00
|
|
|
#include <ctime>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2011-07-25 02:14:58 -06:00
|
|
|
using namespace std;
|
|
|
|
|
2012-01-15 13:54:14 -07:00
|
|
|
#include "Console.h"
|
2016-08-13 19:44:01 -06:00
|
|
|
#include "Core.h"
|
2012-01-15 13:54:14 -07:00
|
|
|
#include "Export.h"
|
2016-08-13 19:44:01 -06:00
|
|
|
#include "MiscUtils.h"
|
2012-01-15 13:54:14 -07:00
|
|
|
#include "PluginManager.h"
|
2016-08-13 19:44:01 -06:00
|
|
|
|
|
|
|
#include "modules/Buildings.h"
|
2012-01-15 13:54:14 -07:00
|
|
|
#include "modules/Gui.h"
|
|
|
|
#include "modules/MapCache.h"
|
2016-08-13 19:44:01 -06:00
|
|
|
#include "modules/Maps.h"
|
|
|
|
#include "modules/Materials.h"
|
|
|
|
#include "modules/Units.h"
|
2011-07-25 02:14:58 -06:00
|
|
|
|
2016-08-13 19:44:01 -06:00
|
|
|
#include "df/block_square_event_grassst.h"
|
|
|
|
#include "df/block_square_event_world_constructionst.h"
|
2012-03-02 08:35:49 -07:00
|
|
|
#include "df/building_def.h"
|
2016-08-13 19:44:01 -06:00
|
|
|
#include "df/building_nest_boxst.h"
|
2012-08-27 13:03:02 -06:00
|
|
|
#include "df/region_map_entry.h"
|
2016-08-13 19:44:01 -06:00
|
|
|
#include "df/unit_inventory_item.h"
|
|
|
|
#include "df/world.h"
|
|
|
|
#include "df/world_data.h"
|
|
|
|
#include "df/world_raws.h"
|
2012-01-24 10:32:34 -07:00
|
|
|
|
2011-07-25 02:14:58 -06:00
|
|
|
using std::vector;
|
|
|
|
using std::string;
|
|
|
|
using namespace DFHack;
|
2012-01-21 17:31:15 -07:00
|
|
|
using namespace df::enums;
|
2014-12-06 16:47:35 -07:00
|
|
|
|
|
|
|
DFHACK_PLUGIN("probe");
|
|
|
|
REQUIRE_GLOBAL(world);
|
|
|
|
REQUIRE_GLOBAL(cursor);
|
2011-07-25 02:14:58 -06:00
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
command_result df_probe (color_ostream &out, vector <string> & parameters);
|
|
|
|
command_result df_cprobe (color_ostream &out, vector <string> & parameters);
|
|
|
|
command_result df_bprobe (color_ostream &out, vector <string> & parameters);
|
2011-07-25 02:14:58 -06:00
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
|
2011-07-25 02:14:58 -06:00
|
|
|
{
|
|
|
|
commands.push_back(PluginCommand("probe",
|
|
|
|
"A tile probe",
|
2013-10-30 14:58:14 -06:00
|
|
|
df_probe,
|
|
|
|
false,
|
|
|
|
"Hover the cursor over a tile to view its properties.\n"));
|
2011-11-01 17:26:45 -06:00
|
|
|
commands.push_back(PluginCommand("cprobe",
|
|
|
|
"A creature probe",
|
2013-10-30 14:58:14 -06:00
|
|
|
df_cprobe,
|
|
|
|
false,
|
|
|
|
"Select a creature to view its properties.\n"));
|
2012-03-02 08:35:49 -07:00
|
|
|
commands.push_back(PluginCommand("bprobe",
|
|
|
|
"A simple building probe",
|
2013-10-30 14:58:14 -06:00
|
|
|
df_bprobe,
|
|
|
|
false,
|
|
|
|
"Select a building to view its properties.\n"));
|
2011-07-25 02:14:58 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
DFhackCExport command_result plugin_shutdown ( color_ostream &out )
|
2011-07-25 02:14:58 -06:00
|
|
|
{
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
command_result df_cprobe (color_ostream &out, vector <string> & parameters)
|
2011-11-01 17:26:45 -06:00
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
CoreSuspender suspend;
|
2011-11-01 17:26:45 -06:00
|
|
|
int32_t cursorX, cursorY, cursorZ;
|
2012-03-03 06:38:24 -07:00
|
|
|
Gui::getCursorCoords(cursorX,cursorY,cursorZ);
|
2011-11-01 17:26:45 -06:00
|
|
|
if(cursorX == -30000)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("No cursor; place cursor over creature to probe.\n");
|
2011-11-01 17:26:45 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-31 09:55:38 -07:00
|
|
|
for(size_t i = 0; i < world->units.all.size(); i++)
|
2011-11-01 17:26:45 -06:00
|
|
|
{
|
2012-01-24 10:32:34 -07:00
|
|
|
df::unit * unit = world->units.all[i];
|
2012-01-21 12:03:39 -07:00
|
|
|
if(unit->pos.x == cursorX && unit->pos.y == cursorY && unit->pos.z == cursorZ)
|
2011-11-01 17:26:45 -06:00
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("Creature %d, race %d (%x), civ %d (%x)\n", unit->id, unit->race, unit->race, unit->civ_id, unit->civ_id);
|
2015-02-14 20:53:06 -07:00
|
|
|
|
2012-04-11 10:22:39 -06:00
|
|
|
for(size_t j=0; j<unit->inventory.size(); j++)
|
|
|
|
{
|
|
|
|
df::unit_inventory_item* inv_item = unit->inventory[j];
|
|
|
|
df::item* item = inv_item->item;
|
|
|
|
if(inv_item->mode == df::unit_inventory_item::T_mode::Worn)
|
|
|
|
{
|
|
|
|
out << " wears item: #" << item->id;
|
|
|
|
if(item->flags.bits.owned)
|
|
|
|
out << " (owned)";
|
|
|
|
else
|
|
|
|
out << " (not owned)";
|
|
|
|
if(item->getEffectiveArmorLevel() != 0)
|
|
|
|
out << ", armor";
|
|
|
|
out << endl;
|
|
|
|
}
|
|
|
|
}
|
2015-02-14 20:53:06 -07:00
|
|
|
|
2012-04-11 10:22:39 -06:00
|
|
|
// don't leave loop, there may be more than 1 creature at the cursor position
|
|
|
|
//break;
|
2011-11-01 17:26:45 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2012-04-19 09:17:07 -06:00
|
|
|
void describeTile(color_ostream &out, df::tiletype tiletype)
|
|
|
|
{
|
|
|
|
out.print("%d", tiletype);
|
|
|
|
if(tileName(tiletype))
|
|
|
|
out.print(" = %s",tileName(tiletype));
|
2017-05-10 10:40:57 -06:00
|
|
|
out.print(" (%s)", ENUM_KEY_STR(tiletype, tiletype).c_str());
|
2012-04-19 09:17:07 -06:00
|
|
|
out.print("\n");
|
|
|
|
|
|
|
|
df::tiletype_shape shape = tileShape(tiletype);
|
|
|
|
df::tiletype_material material = tileMaterial(tiletype);
|
|
|
|
df::tiletype_special special = tileSpecial(tiletype);
|
|
|
|
df::tiletype_variant variant = tileVariant(tiletype);
|
|
|
|
out.print("%-10s: %4d %s\n","Class" ,shape,
|
|
|
|
ENUM_KEY_STR(tiletype_shape, shape).c_str());
|
|
|
|
out.print("%-10s: %4d %s\n","Material" ,
|
|
|
|
material, ENUM_KEY_STR(tiletype_material, material).c_str());
|
|
|
|
out.print("%-10s: %4d %s\n","Special" ,
|
|
|
|
special, ENUM_KEY_STR(tiletype_special, special).c_str());
|
|
|
|
out.print("%-10s: %4d %s\n" ,"Variant" ,
|
|
|
|
variant, ENUM_KEY_STR(tiletype_variant, variant).c_str());
|
|
|
|
out.print("%-10s: %s\n" ,"Direction",
|
|
|
|
tileDirection(tiletype).getStr());
|
|
|
|
out.print("\n");
|
|
|
|
}
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
command_result df_probe (color_ostream &out, vector <string> & parameters)
|
2011-07-25 02:14:58 -06:00
|
|
|
{
|
|
|
|
//bool showBlock, showDesig, showOccup, showTile, showMisc;
|
2012-03-10 04:55:42 -07:00
|
|
|
|
2011-07-25 02:14:58 -06:00
|
|
|
/*
|
|
|
|
if (!parseOptions(parameters, showBlock, showDesig, showOccup,
|
|
|
|
showTile, showMisc))
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("Unknown parameters!\n");
|
2011-07-25 02:14:58 -06:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
CoreSuspender suspend;
|
|
|
|
|
|
|
|
DFHack::Materials *Materials = Core::getInstance().getMaterials();
|
2011-07-25 02:14:58 -06:00
|
|
|
|
2011-11-02 21:30:59 -06:00
|
|
|
std::vector<t_matglossInorganic> inorganic;
|
|
|
|
bool hasmats = Materials->CopyInorganicMaterials(inorganic);
|
2011-07-25 02:14:58 -06:00
|
|
|
|
2012-01-19 20:44:17 -07:00
|
|
|
if (!Maps::IsValid())
|
2011-07-25 02:14:58 -06:00
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("Map is not available!\n");
|
2012-01-19 20:44:17 -07:00
|
|
|
return CR_FAILURE;
|
2011-07-25 02:14:58 -06:00
|
|
|
}
|
2012-01-19 20:44:17 -07:00
|
|
|
MapExtras::MapCache mc;
|
2011-07-25 02:14:58 -06:00
|
|
|
|
2012-01-19 20:44:17 -07:00
|
|
|
int32_t regionX, regionY, regionZ;
|
|
|
|
Maps::getPosition(regionX,regionY,regionZ);
|
2011-07-25 02:14:58 -06:00
|
|
|
|
2012-01-19 20:44:17 -07:00
|
|
|
int32_t cursorX, cursorY, cursorZ;
|
2012-03-03 06:38:24 -07:00
|
|
|
Gui::getCursorCoords(cursorX,cursorY,cursorZ);
|
2012-01-19 20:44:17 -07:00
|
|
|
if(cursorX == -30000)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("No cursor; place cursor over tile to probe.\n");
|
2012-01-19 20:44:17 -07:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
DFCoord cursor (cursorX,cursorY,cursorZ);
|
2011-07-25 02:14:58 -06:00
|
|
|
|
2012-01-19 20:44:17 -07:00
|
|
|
uint32_t blockX = cursorX / 16;
|
|
|
|
uint32_t tileX = cursorX % 16;
|
|
|
|
uint32_t blockY = cursorY / 16;
|
|
|
|
uint32_t tileY = cursorY % 16;
|
2011-07-25 02:14:58 -06:00
|
|
|
|
2012-01-19 20:44:17 -07:00
|
|
|
MapExtras::Block * b = mc.BlockAt(cursor/16);
|
2012-04-10 08:21:19 -06:00
|
|
|
if(!b || !b->is_valid())
|
2012-01-19 20:44:17 -07:00
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("No data.\n");
|
2012-01-19 20:44:17 -07:00
|
|
|
return CR_OK;
|
|
|
|
}
|
2012-04-10 08:21:19 -06:00
|
|
|
|
|
|
|
auto &block = *b->getRaw();
|
|
|
|
out.print("block addr: 0x%x\n\n", &block);
|
2011-07-25 02:14:58 -06:00
|
|
|
/*
|
2012-01-19 20:44:17 -07:00
|
|
|
if (showBlock)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("block flags:\n");
|
|
|
|
print_bits<uint32_t>(block.blockflags.whole,out);
|
|
|
|
out.print("\n\n");
|
2012-01-19 20:44:17 -07:00
|
|
|
}
|
2011-07-25 02:14:58 -06:00
|
|
|
*/
|
2012-02-13 15:56:33 -07:00
|
|
|
df::tiletype tiletype = mc.tiletypeAt(cursor);
|
2012-01-19 20:44:17 -07:00
|
|
|
df::tile_designation &des = block.designation[tileX][tileY];
|
2012-03-11 15:25:30 -06:00
|
|
|
df::tile_occupancy &occ = block.occupancy[tileX][tileY];
|
2016-06-02 13:02:11 -06:00
|
|
|
uint8_t fog_of_war = block.fog_of_war[tileX][tileY];
|
2011-07-25 02:14:58 -06:00
|
|
|
/*
|
2012-01-19 20:44:17 -07:00
|
|
|
if(showDesig)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("designation\n");
|
2012-01-19 20:44:17 -07:00
|
|
|
print_bits<uint32_t>(block.designation[tileX][tileY].whole,
|
2012-03-10 04:55:42 -07:00
|
|
|
out);
|
|
|
|
out.print("\n\n");
|
2012-01-19 20:44:17 -07:00
|
|
|
}
|
2011-07-25 02:14:58 -06:00
|
|
|
|
2012-01-19 20:44:17 -07:00
|
|
|
if(showOccup)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("occupancy\n");
|
2012-01-19 20:44:17 -07:00
|
|
|
print_bits<uint32_t>(block.occupancy[tileX][tileY].whole,
|
2012-03-10 04:55:42 -07:00
|
|
|
out);
|
|
|
|
out.print("\n\n");
|
2012-01-19 20:44:17 -07:00
|
|
|
}
|
2011-07-25 02:14:58 -06:00
|
|
|
*/
|
|
|
|
|
2012-01-19 20:44:17 -07:00
|
|
|
// tiletype
|
2012-04-19 09:17:07 -06:00
|
|
|
out.print("tiletype: ");
|
|
|
|
describeTile(out, tiletype);
|
|
|
|
out.print("static: ");
|
|
|
|
describeTile(out, mc.staticTiletypeAt(cursor));
|
|
|
|
out.print("base: ");
|
|
|
|
describeTile(out, mc.baseTiletypeAt(cursor));
|
2011-07-25 02:14:58 -06:00
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("temperature1: %d U\n",mc.temperature1At(cursor));
|
|
|
|
out.print("temperature2: %d U\n",mc.temperature2At(cursor));
|
2011-07-25 02:14:58 -06:00
|
|
|
|
2012-04-21 22:22:21 -06:00
|
|
|
int offset = block.region_offset[des.bits.biome];
|
2012-06-27 15:38:39 -06:00
|
|
|
int bx = clip_range(block.region_pos.x + (offset % 3) - 1, 0, world->world_data->world_width-1);
|
|
|
|
int by = clip_range(block.region_pos.y + (offset / 3) - 1, 0, world->world_data->world_height-1);
|
2012-04-21 22:22:21 -06:00
|
|
|
|
2012-08-27 13:03:02 -06:00
|
|
|
auto biome = &world->world_data->region_map[bx][by];
|
2012-04-21 22:22:21 -06:00
|
|
|
|
2012-04-22 09:17:14 -06:00
|
|
|
int sav = biome->savagery;
|
|
|
|
int evi = biome->evilness;
|
|
|
|
int sindex = sav > 65 ? 2 : sav < 33 ? 0 : 1;
|
|
|
|
int eindex = evi > 65 ? 2 : evi < 33 ? 0 : 1;
|
|
|
|
int surr = sindex + eindex * 3;
|
|
|
|
|
2012-05-10 14:57:11 -06:00
|
|
|
const char* surroundings[] = { "Serene", "Mirthful", "Joyous Wilds", "Calm", "Wilderness", "Untamed Wilds", "Sinister", "Haunted", "Terrifying" };
|
2012-04-22 09:17:14 -06:00
|
|
|
|
2012-01-19 20:44:17 -07:00
|
|
|
// biome, geolayer
|
2015-02-14 20:53:06 -07:00
|
|
|
out << "biome: " << des.bits.biome << " (" <<
|
2012-04-21 22:22:21 -06:00
|
|
|
"region id=" << biome->region_id << ", " <<
|
2012-04-22 09:17:14 -06:00
|
|
|
surroundings[surr] << ", " <<
|
2012-04-21 22:22:21 -06:00
|
|
|
"savagery " << biome->savagery << ", " <<
|
|
|
|
"evilness " << biome->evilness << ")" << std::endl;
|
2012-03-10 04:55:42 -07:00
|
|
|
out << "geolayer: " << des.bits.geolayer_index
|
2012-01-19 20:44:17 -07:00
|
|
|
<< std::endl;
|
2012-04-19 09:17:07 -06:00
|
|
|
int16_t base_rock = mc.layerMaterialAt(cursor);
|
2012-01-19 20:44:17 -07:00
|
|
|
if(base_rock != -1)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out << "Layer material: " << dec << base_rock;
|
2012-01-19 20:44:17 -07:00
|
|
|
if(hasmats)
|
2012-03-10 04:55:42 -07:00
|
|
|
out << " / " << inorganic[base_rock].id
|
2012-01-19 20:44:17 -07:00
|
|
|
<< " / "
|
|
|
|
<< inorganic[base_rock].name
|
|
|
|
<< endl;
|
|
|
|
else
|
2012-03-10 04:55:42 -07:00
|
|
|
out << endl;
|
2012-01-19 20:44:17 -07:00
|
|
|
}
|
|
|
|
int16_t vein_rock = mc.veinMaterialAt(cursor);
|
|
|
|
if(vein_rock != -1)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out << "Vein material (final): " << dec << vein_rock;
|
2012-01-19 20:44:17 -07:00
|
|
|
if(hasmats)
|
2012-03-10 04:55:42 -07:00
|
|
|
out << " / " << inorganic[vein_rock].id
|
2012-01-19 20:44:17 -07:00
|
|
|
<< " / "
|
|
|
|
<< inorganic[vein_rock].name
|
2013-10-05 10:53:43 -06:00
|
|
|
<< " ("
|
|
|
|
<< ENUM_KEY_STR(inclusion_type,b->veinTypeAt(cursor))
|
|
|
|
<< ")"
|
2012-01-19 20:44:17 -07:00
|
|
|
<< endl;
|
|
|
|
else
|
2012-03-10 04:55:42 -07:00
|
|
|
out << endl;
|
2012-01-19 20:44:17 -07:00
|
|
|
}
|
2012-04-19 09:17:07 -06:00
|
|
|
MaterialInfo minfo(mc.baseMaterialAt(cursor));
|
|
|
|
if (minfo.isValid())
|
|
|
|
out << "Base material: " << minfo.getToken() << " / " << minfo.toString() << endl;
|
|
|
|
minfo.decode(mc.staticMaterialAt(cursor));
|
|
|
|
if (minfo.isValid())
|
|
|
|
out << "Static material: " << minfo.getToken() << " / " << minfo.toString() << endl;
|
2012-01-19 20:44:17 -07:00
|
|
|
// liquids
|
|
|
|
if(des.bits.flow_size)
|
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
if(des.bits.liquid_type == tile_liquid::Magma)
|
2012-03-10 04:55:42 -07:00
|
|
|
out <<"magma: ";
|
|
|
|
else out <<"water: ";
|
|
|
|
out << des.bits.flow_size << std::endl;
|
2012-01-19 20:44:17 -07:00
|
|
|
}
|
|
|
|
if(des.bits.flow_forbid)
|
2012-03-10 04:55:42 -07:00
|
|
|
out << "flow forbid" << std::endl;
|
2012-01-19 20:44:17 -07:00
|
|
|
if(des.bits.pile)
|
2012-03-10 04:55:42 -07:00
|
|
|
out << "stockpile?" << std::endl;
|
2012-01-19 20:44:17 -07:00
|
|
|
if(des.bits.rained)
|
2012-03-10 04:55:42 -07:00
|
|
|
out << "rained?" << std::endl;
|
2012-01-19 20:44:17 -07:00
|
|
|
if(des.bits.smooth)
|
2012-03-10 04:55:42 -07:00
|
|
|
out << "smooth?" << std::endl;
|
2012-01-19 20:44:17 -07:00
|
|
|
if(des.bits.water_salt)
|
2012-03-10 04:55:42 -07:00
|
|
|
out << "salty" << endl;
|
2012-01-19 20:44:17 -07:00
|
|
|
if(des.bits.water_stagnant)
|
2012-03-10 04:55:42 -07:00
|
|
|
out << "stagnant" << endl;
|
2016-08-13 19:44:01 -06:00
|
|
|
|
2016-06-02 13:02:11 -06:00
|
|
|
out.print("%-16s= %s\n", "dig", ENUM_KEY_STR(tile_dig_designation, des.bits.dig).c_str());
|
|
|
|
out.print("%-16s= %s\n", "traffic", ENUM_KEY_STR(tile_traffic, des.bits.traffic).c_str());
|
2011-07-25 02:14:58 -06:00
|
|
|
|
2012-03-11 15:25:30 -06:00
|
|
|
#define PRINT_FLAG( FIELD, BIT ) out.print("%-16s= %c\n", #BIT , ( FIELD.bits.BIT ? 'Y' : ' ' ) )
|
|
|
|
PRINT_FLAG( des, hidden );
|
|
|
|
PRINT_FLAG( des, light );
|
|
|
|
PRINT_FLAG( des, outside );
|
|
|
|
PRINT_FLAG( des, subterranean );
|
|
|
|
PRINT_FLAG( des, water_table );
|
|
|
|
PRINT_FLAG( des, rained );
|
|
|
|
PRINT_FLAG( occ, monster_lair);
|
2016-06-02 13:02:11 -06:00
|
|
|
out.print("%-16s= %d\n", "fog_of_war", fog_of_war);
|
2011-07-25 02:14:58 -06:00
|
|
|
|
2012-01-20 03:28:00 -07:00
|
|
|
df::coord2d pc(blockX, blockY);
|
2011-07-25 02:14:58 -06:00
|
|
|
|
2012-01-19 20:44:17 -07:00
|
|
|
t_feature local;
|
|
|
|
t_feature global;
|
2012-04-10 08:21:19 -06:00
|
|
|
Maps::ReadFeatures(&block,&local,&global);
|
2012-03-11 15:25:30 -06:00
|
|
|
PRINT_FLAG( des, feature_local );
|
2012-01-19 20:44:17 -07:00
|
|
|
if(local.type != -1)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%-16s", "");
|
|
|
|
out.print(" %4d", block.local_feature);
|
|
|
|
out.print(" (%2d)", local.type);
|
|
|
|
out.print(" addr 0x%X ", local.origin);
|
|
|
|
out.print(" %s\n", sa_feature(local.type));
|
2012-01-19 20:44:17 -07:00
|
|
|
}
|
2012-03-11 15:25:30 -06:00
|
|
|
PRINT_FLAG( des, feature_global );
|
2012-01-19 20:44:17 -07:00
|
|
|
if(global.type != -1)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%-16s", "");
|
|
|
|
out.print(" %4d", block.global_feature);
|
|
|
|
out.print(" (%2d)", global.type);
|
|
|
|
out.print(" %s\n", sa_feature(global.type));
|
2011-07-25 02:14:58 -06:00
|
|
|
}
|
2012-01-19 20:44:17 -07:00
|
|
|
#undef PRINT_FLAG
|
2012-03-10 04:55:42 -07:00
|
|
|
out << "local feature idx: " << block.local_feature
|
2012-01-19 20:44:17 -07:00
|
|
|
<< endl;
|
2012-03-10 04:55:42 -07:00
|
|
|
out << "global feature idx: " << block.global_feature
|
2012-01-19 20:44:17 -07:00
|
|
|
<< endl;
|
2012-03-10 04:55:42 -07:00
|
|
|
out << std::endl;
|
2012-04-22 16:34:19 -06:00
|
|
|
|
|
|
|
if(block.occupancy[tileX][tileY].bits.no_grow)
|
|
|
|
out << "no grow" << endl;
|
|
|
|
|
|
|
|
for(size_t e=0; e<block.block_events.size(); e++)
|
2015-02-14 20:53:06 -07:00
|
|
|
{
|
2012-04-22 16:34:19 -06:00
|
|
|
df::block_square_event * blev = block.block_events[e];
|
|
|
|
df::block_square_event_type blevtype = blev->getType();
|
|
|
|
switch(blevtype)
|
|
|
|
{
|
|
|
|
case df::block_square_event_type::grass:
|
|
|
|
{
|
|
|
|
df::block_square_event_grassst * gr_ev = (df::block_square_event_grassst *)blev;
|
|
|
|
if(gr_ev->amount[tileX][tileY] > 0)
|
|
|
|
{
|
|
|
|
out << "amount of grass: " << (int)gr_ev->amount[tileX][tileY] << endl;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case df::block_square_event_type::world_construction:
|
|
|
|
{
|
|
|
|
df::block_square_event_world_constructionst * co_ev = (df::block_square_event_world_constructionst*)blev;
|
|
|
|
uint16_t bits = co_ev->tile_bitmask[tileY];
|
|
|
|
out << "construction bits: " << bits << endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
//out << "unhandled block event type!" << endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-25 02:14:58 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
2012-03-02 08:35:49 -07:00
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
command_result df_bprobe (color_ostream &out, vector <string> & parameters)
|
2012-03-02 08:35:49 -07:00
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
CoreSuspender suspend;
|
2012-03-02 08:35:49 -07:00
|
|
|
|
|
|
|
if(cursor->x == -30000)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("No cursor; place cursor over tile to probe.\n");
|
2012-03-02 08:35:49 -07:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 0; i < world->buildings.all.size(); i++)
|
|
|
|
{
|
|
|
|
Buildings::t_building building;
|
|
|
|
if (!Buildings::Read(i, building))
|
|
|
|
continue;
|
2018-04-06 00:18:15 -06:00
|
|
|
if (int32_t(building.x1) > cursor->x || cursor->x > int32_t(building.x2) ||
|
|
|
|
int32_t(building.y1) > cursor->y || cursor->y > int32_t(building.y2) ||
|
|
|
|
int32_t(building.z) != cursor->z)
|
2012-03-02 08:35:49 -07:00
|
|
|
continue;
|
|
|
|
string name;
|
|
|
|
building.origin->getName(&name);
|
2012-03-18 13:42:13 -06:00
|
|
|
out.print("Building %i - \"%s\" - type %s (%i)",
|
|
|
|
building.origin->id,
|
|
|
|
name.c_str(),
|
|
|
|
ENUM_KEY_STR(building_type, building.type).c_str(),
|
|
|
|
building.type);
|
2012-03-02 08:35:49 -07:00
|
|
|
|
|
|
|
switch (building.type)
|
|
|
|
{
|
2012-03-15 19:09:56 -06:00
|
|
|
case building_type::Civzone:
|
2012-03-18 13:42:13 -06:00
|
|
|
out.print(", subtype %s (%i)",
|
|
|
|
ENUM_KEY_STR(civzone_type, building.civzone_type).c_str(),
|
|
|
|
building.civzone_type);
|
2012-03-15 19:09:56 -06:00
|
|
|
break;
|
2012-03-02 08:35:49 -07:00
|
|
|
case building_type::Furnace:
|
2012-03-18 13:42:13 -06:00
|
|
|
out.print(", subtype %s (%i)",
|
|
|
|
ENUM_KEY_STR(furnace_type, building.furnace_type).c_str(),
|
|
|
|
building.furnace_type);
|
2012-03-02 08:35:49 -07:00
|
|
|
if (building.furnace_type == furnace_type::Custom)
|
2012-03-18 13:42:13 -06:00
|
|
|
out.print(", custom type %s (%i)",
|
|
|
|
world->raws.buildings.all[building.custom_type]->code.c_str(),
|
|
|
|
building.custom_type);
|
2012-03-02 08:35:49 -07:00
|
|
|
break;
|
|
|
|
case building_type::Workshop:
|
2012-03-18 13:42:13 -06:00
|
|
|
out.print(", subtype %s (%i)",
|
|
|
|
ENUM_KEY_STR(workshop_type, building.workshop_type).c_str(),
|
|
|
|
building.workshop_type);
|
2012-03-02 08:35:49 -07:00
|
|
|
if (building.workshop_type == workshop_type::Custom)
|
2012-03-18 13:42:13 -06:00
|
|
|
out.print(", custom type %s (%i)",
|
|
|
|
world->raws.buildings.all[building.custom_type]->code.c_str(),
|
|
|
|
building.custom_type);
|
2012-03-02 08:35:49 -07:00
|
|
|
break;
|
|
|
|
case building_type::Construction:
|
2012-03-18 13:42:13 -06:00
|
|
|
out.print(", subtype %s (%i)",
|
|
|
|
ENUM_KEY_STR(construction_type, building.construction_type).c_str(),
|
|
|
|
building.construction_type);
|
2012-03-02 08:35:49 -07:00
|
|
|
break;
|
|
|
|
case building_type::Shop:
|
2012-03-18 13:42:13 -06:00
|
|
|
out.print(", subtype %s (%i)",
|
|
|
|
ENUM_KEY_STR(shop_type, building.shop_type).c_str(),
|
|
|
|
building.shop_type);
|
2012-03-02 08:35:49 -07:00
|
|
|
break;
|
|
|
|
case building_type::SiegeEngine:
|
2012-03-18 13:42:13 -06:00
|
|
|
out.print(", subtype %s (%i)",
|
|
|
|
ENUM_KEY_STR(siegeengine_type, building.siegeengine_type).c_str(),
|
|
|
|
building.siegeengine_type);
|
2012-03-02 08:35:49 -07:00
|
|
|
break;
|
|
|
|
case building_type::Trap:
|
2012-03-18 13:42:13 -06:00
|
|
|
out.print(", subtype %s (%i)",
|
|
|
|
ENUM_KEY_STR(trap_type, building.trap_type).c_str(),
|
|
|
|
building.trap_type);
|
2012-03-02 08:35:49 -07:00
|
|
|
break;
|
2012-04-15 13:45:15 -06:00
|
|
|
case building_type::NestBox:
|
|
|
|
{
|
|
|
|
df::building_nest_boxst* nestbox = (df::building_nest_boxst*) building.origin;
|
|
|
|
out.print(", claimed:(%i), items:%i", nestbox->claimed_by, nestbox->contained_items.size());
|
|
|
|
break;
|
|
|
|
}
|
2012-03-02 08:35:49 -07:00
|
|
|
default:
|
|
|
|
if (building.subtype != -1)
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print(", subtype %i", building.subtype);
|
2012-03-02 08:35:49 -07:00
|
|
|
break;
|
|
|
|
}
|
2012-04-17 08:57:41 -06:00
|
|
|
if(building.origin->is_room) //isRoom())
|
2012-04-21 03:52:03 -06:00
|
|
|
out << ", room";
|
2012-04-17 10:11:14 -06:00
|
|
|
if(building.origin->getBuildStage()!=building.origin->getMaxBuildStage())
|
|
|
|
out << ", in construction";
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("\n");
|
2012-03-02 08:35:49 -07:00
|
|
|
}
|
|
|
|
return CR_OK;
|
|
|
|
}
|