2011-04-30 15:58:29 -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
|
2009-09-13 18:02:46 -06:00
|
|
|
|
2011-05-02 15:32:32 -06:00
|
|
|
//#include <cstdlib>
|
2009-09-13 18:02:46 -06:00
|
|
|
#include <iostream>
|
2011-05-01 21:03:48 -06:00
|
|
|
#include <iomanip>
|
2009-09-13 18:02:46 -06:00
|
|
|
#include <map>
|
2011-05-01 21:03:48 -06:00
|
|
|
#include <algorithm>
|
2011-04-30 15:58:29 -06:00
|
|
|
#include <vector>
|
2009-09-13 18:02:46 -06:00
|
|
|
|
2011-04-30 15:58:29 -06:00
|
|
|
using namespace std;
|
2010-05-25 22:48:23 -06:00
|
|
|
#include <DFHack.h>
|
2011-04-30 15:58:29 -06:00
|
|
|
#include <dfhack/extra/MapExtras.h>
|
2011-05-17 00:36:38 -06:00
|
|
|
#include <dfhack/extra/termutil.h>
|
2011-06-19 21:08:21 -06:00
|
|
|
#include <dfhack/Core.h>
|
2011-06-23 18:48:56 -06:00
|
|
|
#include <dfhack/Console.h>
|
2011-06-26 20:49:56 -06:00
|
|
|
#include <dfhack/PluginManager.h>
|
|
|
|
|
|
|
|
using namespace DFHack;
|
2011-04-30 15:58:29 -06:00
|
|
|
|
2011-10-24 18:39:15 -06:00
|
|
|
struct matdata
|
|
|
|
{
|
|
|
|
const static int invalid_z = -30000;
|
|
|
|
matdata()
|
|
|
|
{
|
|
|
|
count = 0;
|
|
|
|
lower_z = invalid_z;
|
|
|
|
upper_z = invalid_z;
|
|
|
|
}
|
|
|
|
matdata (const matdata & copyme)
|
|
|
|
{
|
|
|
|
count = copyme.count;
|
|
|
|
lower_z = copyme.lower_z;
|
|
|
|
upper_z = copyme.upper_z;
|
|
|
|
}
|
|
|
|
unsigned int add( int z_level = invalid_z )
|
|
|
|
{
|
|
|
|
count ++;
|
|
|
|
if(z_level != invalid_z)
|
|
|
|
{
|
|
|
|
if(lower_z == invalid_z || z_level < lower_z)
|
|
|
|
{
|
|
|
|
lower_z = z_level;
|
|
|
|
}
|
|
|
|
if(upper_z == invalid_z || z_level > upper_z)
|
|
|
|
{
|
|
|
|
upper_z = z_level;
|
|
|
|
}
|
|
|
|
}
|
2011-10-24 21:34:11 -06:00
|
|
|
return count;
|
2011-10-24 18:39:15 -06:00
|
|
|
}
|
|
|
|
unsigned int count;
|
|
|
|
int lower_z;
|
|
|
|
int upper_z;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool operator>(const matdata & q1, const matdata & q2)
|
|
|
|
{
|
|
|
|
return q1.count > q2.count;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef std::map<int16_t, matdata> MatMap;
|
|
|
|
typedef std::vector< pair<int16_t, matdata> > MatSorter;
|
2011-04-30 15:58:29 -06:00
|
|
|
|
|
|
|
typedef std::vector<DFHack::t_feature> FeatureList;
|
|
|
|
typedef std::vector<DFHack::t_feature*> FeatureListPointer;
|
|
|
|
typedef std::map<DFHack::DFCoord, FeatureListPointer> FeatureMap;
|
2011-06-19 21:08:21 -06:00
|
|
|
typedef std::vector<DFHack::df_plant *> PlantList;
|
2011-06-26 20:49:56 -06:00
|
|
|
|
2011-07-20 07:18:50 -06:00
|
|
|
#define TO_PTR_VEC(obj_vec, ptr_vec) \
|
|
|
|
ptr_vec.clear(); \
|
|
|
|
for (size_t i = 0; i < obj_vec.size(); i++) \
|
|
|
|
ptr_vec.push_back(&obj_vec[i])
|
|
|
|
|
2011-05-01 21:03:48 -06:00
|
|
|
template<template <typename> class P = std::greater >
|
|
|
|
struct compare_pair_second
|
|
|
|
{
|
|
|
|
template<class T1, class T2>
|
|
|
|
bool operator()(const std::pair<T1, T2>& left, const std::pair<T1, T2>& right)
|
|
|
|
{
|
|
|
|
return P<T2>()(left.second, right.second);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-07-20 07:18:50 -06:00
|
|
|
// printMats() accepts a vector of pointers to t_matgloss so that it can
|
|
|
|
// deal t_matgloss and all subclasses.
|
2011-11-02 21:30:59 -06:00
|
|
|
template <typename T>
|
|
|
|
void printMats(DFHack::Console & con, MatMap &mat, std::vector<T*> &materials)
|
2010-06-20 16:31:43 -06:00
|
|
|
{
|
2011-04-30 15:58:29 -06:00
|
|
|
unsigned int total = 0;
|
2011-05-01 21:03:48 -06:00
|
|
|
MatSorter sorting_vector;
|
2011-04-30 15:58:29 -06:00
|
|
|
for (MatMap::const_iterator it = mat.begin(); it != mat.end(); ++it)
|
2011-05-01 21:03:48 -06:00
|
|
|
{
|
|
|
|
sorting_vector.push_back(*it);
|
|
|
|
}
|
2011-07-20 07:18:50 -06:00
|
|
|
std::sort(sorting_vector.begin(), sorting_vector.end(),
|
|
|
|
compare_pair_second<>());
|
|
|
|
for (MatSorter::const_iterator it = sorting_vector.begin();
|
|
|
|
it != sorting_vector.end(); ++it)
|
2010-06-20 16:31:43 -06:00
|
|
|
{
|
2011-05-24 21:13:24 -06:00
|
|
|
if(it->first >= materials.size())
|
|
|
|
{
|
2011-07-20 07:18:50 -06:00
|
|
|
con << "Bad index: " << it->first << " out of "
|
|
|
|
<< materials.size() << endl;
|
2011-05-24 21:13:24 -06:00
|
|
|
continue;
|
|
|
|
}
|
2011-11-02 21:30:59 -06:00
|
|
|
T* mat = materials[it->first];
|
|
|
|
con << std::setw(25) << mat->ID << " : "
|
2011-10-24 18:39:15 -06:00
|
|
|
<< std::setw(9) << it->second.count;
|
|
|
|
if(it->second.lower_z != it->second.upper_z)
|
|
|
|
con <<" Z:" << std::setw(4) << it->second.lower_z << ".." << it->second.upper_z << std::endl;
|
|
|
|
else
|
|
|
|
con <<" Z:" << std::setw(4) << it->second.lower_z << std::endl;
|
|
|
|
total += it->second.count;
|
2010-06-20 16:31:43 -06:00
|
|
|
}
|
2011-05-01 21:03:48 -06:00
|
|
|
|
2011-07-13 03:45:30 -06:00
|
|
|
con << ">>> TOTAL = " << total << std::endl << std::endl;
|
2011-04-30 15:58:29 -06:00
|
|
|
}
|
2011-07-20 07:18:50 -06:00
|
|
|
|
|
|
|
void printVeins(DFHack::Console & con, MatMap &mat_map,
|
|
|
|
DFHack::Materials* mats)
|
|
|
|
{
|
|
|
|
MatMap ores;
|
|
|
|
MatMap gems;
|
|
|
|
MatMap rest;
|
|
|
|
|
|
|
|
for (MatMap::const_iterator it = mat_map.begin(); it != mat_map.end(); ++it)
|
|
|
|
{
|
2011-11-02 21:30:59 -06:00
|
|
|
DFHack::df_inorganic_type *gloss = mats->df_inorganic->at(it->first);
|
2011-07-20 07:18:50 -06:00
|
|
|
|
2011-11-02 21:30:59 -06:00
|
|
|
if (gloss->mat.isGem())
|
2011-07-20 07:18:50 -06:00
|
|
|
gems[it->first] = it->second;
|
2011-11-02 21:30:59 -06:00
|
|
|
else if (gloss->isOre())
|
2011-07-21 19:00:56 -06:00
|
|
|
ores[it->first] = it->second;
|
2011-07-20 07:18:50 -06:00
|
|
|
else
|
|
|
|
rest[it->first] = it->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
con << "Ores:" << std::endl;
|
2011-11-02 21:30:59 -06:00
|
|
|
printMats(con, ores, *mats->df_inorganic);
|
2011-07-20 07:18:50 -06:00
|
|
|
|
|
|
|
con << "Gems:" << std::endl;
|
2011-11-02 21:30:59 -06:00
|
|
|
printMats(con, gems, *mats->df_inorganic);
|
2011-07-20 07:18:50 -06:00
|
|
|
|
|
|
|
con << "Other vein stone:" << std::endl;
|
2011-11-02 21:30:59 -06:00
|
|
|
printMats(con, rest, *mats->df_inorganic);
|
2011-07-20 07:18:50 -06:00
|
|
|
}
|
|
|
|
|
2011-06-26 20:49:56 -06:00
|
|
|
DFhackCExport command_result prospector (Core * c, vector <string> & parameters);
|
2010-06-20 16:31:43 -06:00
|
|
|
|
2011-06-19 21:08:21 -06:00
|
|
|
DFhackCExport const char * plugin_name ( void )
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2011-06-19 21:08:21 -06:00
|
|
|
return "prospector";
|
|
|
|
}
|
|
|
|
|
2011-06-26 20:49:56 -06:00
|
|
|
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
|
|
|
|
{
|
|
|
|
commands.clear();
|
2011-08-08 17:50:22 -06:00
|
|
|
commands.push_back(PluginCommand("prospect","Show stats of available raw resources. Use option 'all' to show hidden resources.",prospector));
|
2011-06-26 20:49:56 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_shutdown ( Core * c )
|
|
|
|
{
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & parameters)
|
2011-06-19 21:08:21 -06:00
|
|
|
{
|
2011-06-26 20:49:56 -06:00
|
|
|
bool showHidden = false;
|
2011-04-30 15:58:29 -06:00
|
|
|
bool showPlants = true;
|
|
|
|
bool showSlade = true;
|
|
|
|
bool showTemple = true;
|
2011-07-13 20:05:27 -06:00
|
|
|
Console & con = c->con;
|
2011-08-08 17:50:22 -06:00
|
|
|
for(int i = 0; i < parameters.size();i++)
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2011-08-08 17:50:22 -06:00
|
|
|
if (parameters[0] == "all")
|
|
|
|
{
|
|
|
|
showHidden = true;
|
|
|
|
}
|
|
|
|
else if(parameters[i] == "help" || parameters[i] == "?")
|
|
|
|
{
|
|
|
|
c->con.print("Prints a big list of all the present minerals.\n"
|
|
|
|
"By default, only the visible part of the map is scanned.\n"
|
|
|
|
"\n"
|
|
|
|
"Options:\n"
|
|
|
|
"all - Scan the whole map, as if it was revealed.\n"
|
|
|
|
);
|
|
|
|
return CR_OK;
|
|
|
|
}
|
2009-09-13 18:02:46 -06:00
|
|
|
}
|
2011-04-30 15:58:29 -06:00
|
|
|
uint32_t x_max = 0, y_max = 0, z_max = 0;
|
2011-06-19 21:08:21 -06:00
|
|
|
c->Suspend();
|
|
|
|
DFHack::Maps *maps = c->getMaps();
|
2011-04-30 15:58:29 -06:00
|
|
|
if (!maps->Start())
|
2010-03-26 06:01:46 -06:00
|
|
|
{
|
2011-11-04 02:08:29 -06:00
|
|
|
con.printerr("Cannot get map info!\n");
|
2011-06-19 21:08:21 -06:00
|
|
|
c->Resume();
|
2011-06-26 20:49:56 -06:00
|
|
|
return CR_FAILURE;
|
2010-03-26 06:01:46 -06:00
|
|
|
}
|
2011-04-30 15:58:29 -06:00
|
|
|
maps->getSize(x_max, y_max, z_max);
|
|
|
|
MapExtras::MapCache map(maps);
|
2010-11-10 18:32:33 -07:00
|
|
|
|
2011-06-19 21:08:21 -06:00
|
|
|
DFHack::Materials *mats = c->getMaterials();
|
2011-11-02 21:30:59 -06:00
|
|
|
if (!mats->df_inorganic)
|
2010-04-23 17:15:15 -06:00
|
|
|
{
|
2011-11-04 02:08:29 -06:00
|
|
|
con.printerr("Unable to read inorganic material definitons!\n");
|
2011-06-19 21:08:21 -06:00
|
|
|
c->Resume();
|
2011-06-26 20:49:56 -06:00
|
|
|
return CR_FAILURE;
|
2010-04-23 17:15:15 -06:00
|
|
|
}
|
2011-11-02 21:30:59 -06:00
|
|
|
if (showPlants && !mats->df_organic)
|
2011-04-30 15:58:29 -06:00
|
|
|
{
|
2011-11-04 02:08:29 -06:00
|
|
|
con.printerr("Unable to read organic material definitons; plants won't be listed!\n");
|
2011-05-01 03:11:42 -06:00
|
|
|
showPlants = false;
|
2011-04-30 15:58:29 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
FeatureList globalFeatures;
|
|
|
|
FeatureMap localFeatures;
|
|
|
|
DFHack::t_feature *blockFeatureGlobal = 0;
|
|
|
|
DFHack::t_feature *blockFeatureLocal = 0;
|
2010-04-23 17:15:15 -06:00
|
|
|
|
2011-04-30 15:58:29 -06:00
|
|
|
bool hasAquifer = false;
|
|
|
|
bool hasDemonTemple = false;
|
|
|
|
bool hasLair = false;
|
|
|
|
MatMap baseMats;
|
|
|
|
MatMap layerMats;
|
|
|
|
MatMap veinMats;
|
|
|
|
MatMap plantMats;
|
2011-05-01 21:03:48 -06:00
|
|
|
MatMap treeMats;
|
2011-04-30 15:58:29 -06:00
|
|
|
|
|
|
|
if (!(showSlade && maps->ReadGlobalFeatures(globalFeatures)))
|
2010-04-23 17:15:15 -06:00
|
|
|
{
|
2011-11-04 02:08:29 -06:00
|
|
|
con.printerr("Unable to read global features; slade won't be listed!\n");
|
2010-05-22 05:20:58 -06:00
|
|
|
}
|
2011-04-30 15:58:29 -06:00
|
|
|
|
|
|
|
if (!maps->ReadLocalFeatures(localFeatures))
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2011-11-04 02:08:29 -06:00
|
|
|
con.printerr("Unable to read local features; adamantine and demon temples won't be listed.\n" );
|
2009-09-13 18:02:46 -06:00
|
|
|
}
|
2010-11-10 18:32:33 -07:00
|
|
|
|
2011-04-30 15:58:29 -06:00
|
|
|
uint32_t vegCount = 0;
|
2011-06-19 21:08:21 -06:00
|
|
|
DFHack::Vegetation *veg = c->getVegetation();
|
|
|
|
if (showPlants && !veg->Start())
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2011-11-04 02:08:29 -06:00
|
|
|
con.printerr("Unable to read vegetation; plants won't be listed!\n" );
|
2009-09-13 18:02:46 -06:00
|
|
|
}
|
2010-11-10 18:32:33 -07:00
|
|
|
|
2011-04-30 15:58:29 -06:00
|
|
|
for(uint32_t z = 0; z < z_max; z++)
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2011-04-30 15:58:29 -06:00
|
|
|
for(uint32_t b_y = 0; b_y < y_max; b_y++)
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2011-04-30 15:58:29 -06:00
|
|
|
for(uint32_t b_x = 0; b_x < x_max; b_x++)
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2011-04-30 15:58:29 -06:00
|
|
|
// Get the map block
|
|
|
|
DFHack::DFCoord blockCoord(b_x, b_y);
|
|
|
|
MapExtras::Block *b = map.BlockAt(DFHack::DFCoord(b_x, b_y, z));
|
|
|
|
if (!b || !b->valid)
|
|
|
|
{
|
2009-09-13 18:02:46 -06:00
|
|
|
continue;
|
2011-04-30 15:58:29 -06:00
|
|
|
}
|
2010-11-10 18:32:33 -07:00
|
|
|
|
2011-04-30 15:58:29 -06:00
|
|
|
{ // Find features
|
|
|
|
uint16_t index = b->raw.global_feature;
|
|
|
|
if (index != -1 && index < globalFeatures.size())
|
|
|
|
{
|
|
|
|
blockFeatureGlobal = &globalFeatures[index];
|
|
|
|
}
|
2010-11-10 18:32:33 -07:00
|
|
|
|
2011-04-30 15:58:29 -06:00
|
|
|
index = b->raw.local_feature;
|
|
|
|
FeatureMap::const_iterator it = localFeatures.find(blockCoord);
|
|
|
|
if (it != localFeatures.end())
|
2011-04-17 07:51:52 -06:00
|
|
|
{
|
2011-04-30 15:58:29 -06:00
|
|
|
FeatureListPointer features = it->second;
|
|
|
|
|
|
|
|
if (index != -1 && index < features.size())
|
2011-04-17 07:51:52 -06:00
|
|
|
{
|
2011-04-30 15:58:29 -06:00
|
|
|
blockFeatureLocal = features[index];
|
2011-04-17 07:51:52 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-17 03:37:36 -06:00
|
|
|
|
2011-04-30 15:58:29 -06:00
|
|
|
// Iterate over all the tiles in the block
|
|
|
|
for(uint32_t y = 0; y < 16; y++)
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2011-04-30 15:58:29 -06:00
|
|
|
for(uint32_t x = 0; x < 16; x++)
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2011-04-30 15:58:29 -06:00
|
|
|
DFHack::DFCoord coord(x, y);
|
|
|
|
DFHack::t_designation des = b->DesignationAt(coord);
|
|
|
|
DFHack::t_occupancy occ = b->OccupancyAt(coord);
|
|
|
|
|
|
|
|
// Skip hidden tiles
|
|
|
|
if (!showHidden && des.bits.hidden)
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2011-04-19 17:28:47 -06:00
|
|
|
continue;
|
|
|
|
}
|
2011-04-30 15:58:29 -06:00
|
|
|
|
|
|
|
// Check for aquifer
|
|
|
|
if (des.bits.water_table)
|
2011-04-19 17:28:47 -06:00
|
|
|
{
|
2011-04-30 15:58:29 -06:00
|
|
|
hasAquifer = true;
|
2011-04-19 17:28:47 -06:00
|
|
|
}
|
2011-04-30 15:58:29 -06:00
|
|
|
|
|
|
|
// Check for lairs
|
|
|
|
if (occ.bits.monster_lair)
|
2011-04-19 17:28:47 -06:00
|
|
|
{
|
2011-04-30 15:58:29 -06:00
|
|
|
hasLair = true;
|
2011-04-17 07:51:52 -06:00
|
|
|
}
|
2011-04-30 15:58:29 -06:00
|
|
|
|
|
|
|
uint16_t type = b->TileTypeAt(coord);
|
|
|
|
const DFHack::TileRow *info = DFHack::getTileRow(type);
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
{
|
2011-07-13 20:05:27 -06:00
|
|
|
con << "Bad type: " << type << std::endl;
|
2011-04-17 07:51:52 -06:00
|
|
|
continue;
|
2011-04-30 15:58:29 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// We only care about these types
|
|
|
|
switch (info->shape)
|
|
|
|
{
|
|
|
|
case DFHack::WALL:
|
|
|
|
case DFHack::PILLAR:
|
|
|
|
case DFHack::FORTIFICATION:
|
|
|
|
break;
|
|
|
|
default:
|
2011-04-19 17:28:47 -06:00
|
|
|
continue;
|
2011-04-30 15:58:29 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Count the material type
|
2011-10-24 18:39:15 -06:00
|
|
|
baseMats[info->material].add(z);
|
2011-04-30 15:58:29 -06:00
|
|
|
|
|
|
|
// Find the type of the tile
|
|
|
|
switch (info->material)
|
2011-04-17 07:51:52 -06:00
|
|
|
{
|
2011-04-30 15:58:29 -06:00
|
|
|
case DFHack::SOIL:
|
|
|
|
case DFHack::STONE:
|
2011-10-24 18:39:15 -06:00
|
|
|
layerMats[b->baseMaterialAt(coord)].add(z);
|
2011-04-30 15:58:29 -06:00
|
|
|
break;
|
|
|
|
case DFHack::VEIN:
|
2011-10-24 18:39:15 -06:00
|
|
|
veinMats[b->veinMaterialAt(coord)].add(z);
|
2011-04-30 15:58:29 -06:00
|
|
|
break;
|
|
|
|
case DFHack::FEATSTONE:
|
2011-05-04 17:24:20 -06:00
|
|
|
if (blockFeatureLocal && des.bits.feature_local)
|
2011-04-17 07:51:52 -06:00
|
|
|
{
|
2011-04-30 15:58:29 -06:00
|
|
|
if (blockFeatureLocal->type == DFHack::feature_Adamantine_Tube
|
|
|
|
&& blockFeatureLocal->main_material == 0) // stone
|
2011-04-17 07:51:52 -06:00
|
|
|
{
|
2011-10-24 18:39:15 -06:00
|
|
|
veinMats[blockFeatureLocal->sub_material].add(z);
|
2011-04-17 07:51:52 -06:00
|
|
|
}
|
2011-04-30 15:58:29 -06:00
|
|
|
else if (showTemple
|
|
|
|
&& blockFeatureLocal->type == DFHack::feature_Hell_Temple)
|
2011-04-17 07:51:52 -06:00
|
|
|
{
|
2011-04-30 15:58:29 -06:00
|
|
|
hasDemonTemple = true;
|
2011-04-17 07:51:52 -06:00
|
|
|
}
|
|
|
|
}
|
2010-11-10 18:32:33 -07:00
|
|
|
|
2011-05-04 17:24:20 -06:00
|
|
|
if (showSlade && blockFeatureGlobal && des.bits.feature_global
|
2011-04-30 15:58:29 -06:00
|
|
|
&& blockFeatureGlobal->type == DFHack::feature_Underworld
|
|
|
|
&& blockFeatureGlobal->main_material == 0) // stone
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2011-10-24 18:39:15 -06:00
|
|
|
layerMats[blockFeatureGlobal->sub_material].add(z);
|
2009-09-13 18:02:46 -06:00
|
|
|
}
|
2011-04-30 15:58:29 -06:00
|
|
|
break;
|
|
|
|
case DFHack::OBSIDIAN:
|
|
|
|
// TODO ?
|
|
|
|
break;
|
2009-09-13 18:02:46 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-11-10 18:32:33 -07:00
|
|
|
|
2011-04-30 15:58:29 -06:00
|
|
|
// Check plants this way, as the other way wasn't getting them all
|
|
|
|
// and we can check visibility more easily here
|
|
|
|
if (showPlants)
|
2010-04-23 17:15:15 -06:00
|
|
|
{
|
2011-06-19 21:08:21 -06:00
|
|
|
PlantList * plants;
|
|
|
|
if (maps->ReadVegetation(b_x, b_y, z, plants))
|
2010-04-23 17:15:15 -06:00
|
|
|
{
|
2011-06-19 21:08:21 -06:00
|
|
|
for (PlantList::const_iterator it = plants->begin(); it != plants->end(); it++)
|
2011-03-10 19:09:45 -07:00
|
|
|
{
|
2011-06-19 21:08:21 -06:00
|
|
|
const DFHack::df_plant & plant = *(*it);
|
2011-04-30 15:58:29 -06:00
|
|
|
DFHack::DFCoord loc(plant.x, plant.y);
|
|
|
|
loc = loc % 16;
|
|
|
|
if (showHidden || !b->DesignationAt(loc).bits.hidden)
|
2010-04-23 17:15:15 -06:00
|
|
|
{
|
2011-05-01 21:03:48 -06:00
|
|
|
if(plant.is_shrub)
|
2011-10-24 18:39:15 -06:00
|
|
|
plantMats[plant.material].add(z);
|
2011-05-01 21:03:48 -06:00
|
|
|
else
|
2011-10-24 18:39:15 -06:00
|
|
|
treeMats[plant.material].add(z);
|
2010-04-23 17:15:15 -06:00
|
|
|
}
|
2011-03-10 19:09:45 -07:00
|
|
|
}
|
2010-04-23 17:15:15 -06:00
|
|
|
}
|
|
|
|
}
|
2011-04-30 15:58:29 -06:00
|
|
|
// Block end
|
|
|
|
} // block x
|
2010-11-10 18:32:33 -07:00
|
|
|
|
2011-04-30 15:58:29 -06:00
|
|
|
// Clean uneeded memory
|
|
|
|
map.trash();
|
|
|
|
} // block y
|
|
|
|
} // z
|
2010-11-10 18:32:33 -07:00
|
|
|
|
2011-04-30 15:58:29 -06:00
|
|
|
MatMap::const_iterator it;
|
2011-04-17 07:51:52 -06:00
|
|
|
|
2011-07-13 20:05:27 -06:00
|
|
|
con << "Base materials:" << std::endl;
|
2011-04-30 15:58:29 -06:00
|
|
|
for (it = baseMats.begin(); it != baseMats.end(); ++it)
|
2010-03-31 09:31:49 -06:00
|
|
|
{
|
2011-10-24 18:39:15 -06:00
|
|
|
con << std::setw(25) << DFHack::TileMaterialString[it->first] << " : " << it->second.count << std::endl;
|
2010-03-31 09:31:49 -06:00
|
|
|
}
|
2011-04-30 15:58:29 -06:00
|
|
|
|
2011-07-13 20:05:27 -06:00
|
|
|
con << std::endl << "Layer materials:" << std::endl;
|
2011-11-02 21:30:59 -06:00
|
|
|
printMats(con, layerMats, *mats->df_inorganic);
|
2011-04-30 15:58:29 -06:00
|
|
|
|
2011-07-20 07:18:50 -06:00
|
|
|
printVeins(con, veinMats, mats);
|
2011-04-30 15:58:29 -06:00
|
|
|
|
|
|
|
if (showPlants)
|
2011-04-17 07:51:52 -06:00
|
|
|
{
|
2011-07-13 20:05:27 -06:00
|
|
|
con << "Shrubs:" << std::endl;
|
2011-11-02 21:30:59 -06:00
|
|
|
printMats(con, plantMats, *mats->df_organic);
|
2011-07-13 20:05:27 -06:00
|
|
|
con << "Wood in trees:" << std::endl;
|
2011-11-02 21:30:59 -06:00
|
|
|
printMats(con, treeMats, *mats->df_organic);
|
2011-04-17 07:51:52 -06:00
|
|
|
}
|
2011-04-30 15:58:29 -06:00
|
|
|
|
|
|
|
if (hasAquifer)
|
2011-04-17 07:51:52 -06:00
|
|
|
{
|
2011-07-13 20:05:27 -06:00
|
|
|
con << "Has aquifer" << std::endl;
|
2011-04-17 07:51:52 -06:00
|
|
|
}
|
2011-04-30 15:58:29 -06:00
|
|
|
|
|
|
|
if (hasDemonTemple)
|
2011-04-17 07:51:52 -06:00
|
|
|
{
|
2011-07-13 20:05:27 -06:00
|
|
|
con << "Has demon temple" << std::endl;
|
2011-04-17 07:51:52 -06:00
|
|
|
}
|
2011-04-30 15:58:29 -06:00
|
|
|
|
|
|
|
if (hasLair)
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2011-07-13 20:05:27 -06:00
|
|
|
con << "Has lair" << std::endl;
|
2009-09-13 18:02:46 -06:00
|
|
|
}
|
2011-04-30 15:58:29 -06:00
|
|
|
|
|
|
|
// Cleanup
|
|
|
|
if (showPlants)
|
2010-06-20 16:31:43 -06:00
|
|
|
{
|
2011-04-30 15:58:29 -06:00
|
|
|
veg->Finish();
|
2010-06-20 16:31:43 -06:00
|
|
|
}
|
2011-04-30 15:58:29 -06:00
|
|
|
mats->Finish();
|
|
|
|
maps->Finish();
|
2011-06-19 21:08:21 -06:00
|
|
|
c->Resume();
|
2011-07-13 20:05:27 -06:00
|
|
|
con << std::endl;
|
2011-06-26 20:49:56 -06:00
|
|
|
return CR_OK;
|
2009-12-13 14:03:19 -07:00
|
|
|
}
|