2012-04-21 22:22:21 -06:00
|
|
|
// Produces a list of materials available on the map.
|
|
|
|
// Options:
|
|
|
|
// -a : show unrevealed tiles
|
|
|
|
// -p : don't show plants
|
|
|
|
// -s : don't show slade
|
|
|
|
// -t : don't show demon temple
|
|
|
|
|
|
|
|
//#include <cstdlib>
|
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <map>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
#include "Core.h"
|
|
|
|
#include "Console.h"
|
|
|
|
#include "Export.h"
|
|
|
|
#include "PluginManager.h"
|
|
|
|
#include "modules/MapCache.h"
|
|
|
|
|
|
|
|
#include "MiscUtils.h"
|
|
|
|
|
|
|
|
#include "DataDefs.h"
|
|
|
|
#include "df/world.h"
|
|
|
|
#include "df/world_data.h"
|
|
|
|
#include "df/world_region_details.h"
|
|
|
|
#include "df/world_geo_biome.h"
|
|
|
|
#include "df/world_geo_layer.h"
|
2012-08-27 13:03:02 -06:00
|
|
|
#include "df/region_map_entry.h"
|
2012-04-21 22:22:21 -06:00
|
|
|
#include "df/inclusion_type.h"
|
|
|
|
#include "df/viewscreen_choose_start_sitest.h"
|
|
|
|
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace df::enums;
|
|
|
|
using df::global::world;
|
|
|
|
using df::coord2d;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command_result rprobe (color_ostream &out, vector <string> & parameters);
|
|
|
|
|
|
|
|
DFHACK_PLUGIN("rprobe");
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
|
|
|
|
{
|
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
"rprobe", "Display assorted region information from embark screen",
|
|
|
|
rprobe, false,
|
|
|
|
"Display assorted region information from embark screen\n"
|
|
|
|
));
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_shutdown ( color_ostream &out )
|
|
|
|
{
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
command_result rprobe (color_ostream &out, vector <string> & parameters)
|
|
|
|
{
|
|
|
|
CoreSuspender suspend;
|
|
|
|
|
2012-04-22 09:17:14 -06:00
|
|
|
bool set = false;
|
2012-04-23 08:46:57 -06:00
|
|
|
int to_set, set_field, set_val;
|
2012-04-22 09:17:14 -06:00
|
|
|
|
2012-04-21 22:22:21 -06:00
|
|
|
// Embark screen active: estimate using world geology data
|
|
|
|
VIRTUAL_CAST_VAR(screen, df::viewscreen_choose_start_sitest, Core::getTopViewscreen());
|
|
|
|
|
|
|
|
if (!screen)
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
|
|
|
|
if (!world || !world->world_data)
|
|
|
|
{
|
|
|
|
out.printerr("World data is not available.\n");
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-04-23 08:46:57 -06:00
|
|
|
|
|
|
|
if (parameters.size() == 2)
|
2012-04-22 09:17:14 -06:00
|
|
|
{
|
2012-08-27 06:01:11 -06:00
|
|
|
if (parameters[0] == "rai")
|
2012-04-23 08:46:57 -06:00
|
|
|
set_field = 0;
|
|
|
|
else if (parameters[0] == "veg")
|
|
|
|
set_field = 1;
|
|
|
|
else if (parameters[0] == "tem")
|
|
|
|
set_field = 2;
|
|
|
|
else if (parameters[0] == "evi")
|
|
|
|
set_field = 3;
|
2012-08-27 06:01:11 -06:00
|
|
|
else if (parameters[0] == "dra")
|
2012-04-23 08:46:57 -06:00
|
|
|
set_field = 4;
|
|
|
|
else if (parameters[0] == "sav")
|
|
|
|
set_field = 5;
|
|
|
|
else if (parameters[0] == "sal")
|
|
|
|
set_field = 6;
|
|
|
|
else
|
2012-04-22 09:17:14 -06:00
|
|
|
return CR_WRONG_USAGE;
|
2012-04-23 08:46:57 -06:00
|
|
|
|
|
|
|
if (screen->biome_highlighted)
|
|
|
|
to_set = screen->biome_idx;
|
|
|
|
else
|
|
|
|
to_set = 0;
|
|
|
|
|
2012-04-22 09:17:14 -06:00
|
|
|
set = true;
|
2012-04-23 08:46:57 -06:00
|
|
|
set_val = atoi(parameters[1].c_str());
|
2012-04-22 09:17:14 -06:00
|
|
|
}
|
|
|
|
|
2012-04-21 22:22:21 -06:00
|
|
|
df::world_data *data = world->world_data;
|
|
|
|
coord2d cur_region = screen->region_pos;
|
|
|
|
|
|
|
|
// Compute biomes
|
|
|
|
for (int i = 0; i < screen->biome_rgn.size(); i++)
|
|
|
|
{
|
|
|
|
coord2d rg = screen->biome_rgn[i];
|
|
|
|
|
2012-08-27 13:03:02 -06:00
|
|
|
auto rd = &data->region_map[rg.x][rg.y];
|
2012-04-21 22:22:21 -06:00
|
|
|
|
2012-04-22 09:17:14 -06:00
|
|
|
if (set && i == to_set) {
|
2012-04-23 08:46:57 -06:00
|
|
|
if (set_field == 0)
|
2012-08-27 06:01:11 -06:00
|
|
|
rd->rainfall = set_val;
|
2012-04-23 08:46:57 -06:00
|
|
|
else if (set_field == 1)
|
|
|
|
rd->vegetation = set_val;
|
|
|
|
else if (set_field == 2)
|
|
|
|
rd->temperature = set_val;
|
|
|
|
else if (set_field == 3)
|
|
|
|
rd->evilness = set_val;
|
|
|
|
else if (set_field == 4)
|
2012-08-27 06:01:11 -06:00
|
|
|
rd->drainage = set_val;
|
2012-04-23 08:46:57 -06:00
|
|
|
else if (set_field == 5)
|
|
|
|
rd->savagery = set_val;
|
|
|
|
else if (set_field == 6)
|
2012-08-27 06:01:11 -06:00
|
|
|
rd->salinity = set_val;
|
2012-04-22 09:17:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
out << i << ": x = " << rg.x << ", y = " << rg.y;
|
|
|
|
|
2012-04-21 22:22:21 -06:00
|
|
|
out <<
|
|
|
|
" region_id: " << rd->region_id <<
|
|
|
|
" geo_index: " << rd->geo_index <<
|
|
|
|
" landmass_id: " << rd->landmass_id <<
|
2012-04-23 08:46:57 -06:00
|
|
|
" flags: " << hex << rd->flags.as_int() << dec << endl;
|
|
|
|
out <<
|
2012-08-27 06:01:11 -06:00
|
|
|
"rai: " << rd->rainfall << " " <<
|
2012-04-23 08:46:57 -06:00
|
|
|
"veg: " << rd->vegetation << " " <<
|
|
|
|
"tem: " << rd->temperature << " " <<
|
|
|
|
"evi: " << rd->evilness << " " <<
|
2012-08-27 06:01:11 -06:00
|
|
|
"dra: " << rd->drainage << " " <<
|
2012-04-23 08:46:57 -06:00
|
|
|
"sav: " << rd->savagery << " " <<
|
2012-08-27 06:01:11 -06:00
|
|
|
"sal: " << rd->salinity;
|
2012-04-23 08:46:57 -06:00
|
|
|
|
2012-04-21 22:22:21 -06:00
|
|
|
int32_t *p = (int32_t *)rd;
|
|
|
|
int c = sizeof(*rd) / sizeof(int32_t);
|
|
|
|
for (int j = 0; j < c; j++) {
|
|
|
|
if (j % 8 == 0)
|
|
|
|
out << endl << setfill('0') << setw(8) << hex << (int)(rd+j) << ": ";
|
|
|
|
out << " " << setfill('0') << setw(8) << hex << p[j];
|
|
|
|
}
|
2012-04-22 22:36:13 -06:00
|
|
|
out << setfill(' ') << setw(0) << dec << endl;
|
2012-04-21 22:22:21 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
}
|