summaryrefslogtreecommitdiff
path: root/plugins/prospector.cpp
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-01-17 19:44:48 +0400
committerAlexander Gavrilov2012-01-17 20:04:49 +0400
commit43476b2ea750daff2badd8cc7dd3abf5ffd601c3 (patch)
tree7cd617326192fd868ff2ac810e3c2dee9644c622 /plugins/prospector.cpp
parent89cb12add1f9406ffeee1e9858f6bdea3c24dfe5 (diff)
downloaddfhack-43476b2ea750daff2badd8cc7dd3abf5ffd601c3.tar.gz
dfhack-43476b2ea750daff2badd8cc7dd3abf5ffd601c3.tar.bz2
dfhack-43476b2ea750daff2badd8cc7dd3abf5ffd601c3.tar.xz
Fix Z level computation in prospect, and add levels for flows & aquifer.
Diffstat (limited to 'plugins/prospector.cpp')
-rw-r--r--plugins/prospector.cpp75
1 files changed, 61 insertions, 14 deletions
diff --git a/plugins/prospector.cpp b/plugins/prospector.cpp
index 6d907a4a..c2a936f1 100644
--- a/plugins/prospector.cpp
+++ b/plugins/prospector.cpp
@@ -19,6 +19,9 @@ using namespace std;
#include "PluginManager.h"
#include "modules/MapCache.h"
+#include "DataDefs.h"
+#include "df/world.h"
+
using namespace DFHack;
struct matdata
@@ -85,6 +88,16 @@ struct compare_pair_second
}
};
+void printMatdata(DFHack::Console & con, const matdata &data)
+{
+ con << std::setw(9) << data.count;
+
+ if(data.lower_z != data.upper_z)
+ con <<" Z:" << std::setw(4) << data.lower_z << ".." << data.upper_z << std::endl;
+ else
+ con <<" Z:" << std::setw(4) << data.lower_z << std::endl;
+}
+
// printMats() accepts a vector of pointers to t_matgloss so that it can
// deal t_matgloss and all subclasses.
template <typename T>
@@ -108,12 +121,8 @@ void printMats(DFHack::Console & con, MatMap &mat, std::vector<T*> &materials)
continue;
}
T* mat = materials[it->first];
- con << std::setw(25) << mat->ID << " : "
- << 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;
+ con << std::setw(25) << mat->ID << " : ";
+ printMatdata(con, it->second);
total += it->second.count;
}
@@ -231,6 +240,10 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
MatMap plantMats;
MatMap treeMats;
+ matdata liquidWater;
+ matdata liquidMagma;
+ matdata aquiferTiles;
+
if (!(showSlade && maps->ReadGlobalFeatures(globalFeatures)))
{
con.printerr("Unable to read global features; slade won't be listed!\n");
@@ -282,6 +295,8 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
}
}
+ int global_z = df::global::world->map.region_z + z;
+
// Iterate over all the tiles in the block
for(uint32_t y = 0; y < 16; y++)
{
@@ -301,6 +316,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
if (des.bits.water_table)
{
hasAquifer = true;
+ aquiferTiles.add(global_z);
}
// Check for lairs
@@ -309,6 +325,15 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
hasLair = true;
}
+ // Check for liquid
+ if (des.bits.flow_size)
+ {
+ if (des.bits.liquid_type == liquid_magma)
+ liquidMagma.add(global_z);
+ else
+ liquidWater.add(global_z);
+ }
+
uint16_t type = b->TileTypeAt(coord);
const DFHack::TileRow *info = DFHack::getTileRow(type);
@@ -330,17 +355,17 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
}
// Count the material type
- baseMats[info->material].add(z);
+ baseMats[info->material].add(global_z);
// Find the type of the tile
switch (info->material)
{
case DFHack::SOIL:
case DFHack::STONE:
- layerMats[b->baseMaterialAt(coord)].add(z);
+ layerMats[b->baseMaterialAt(coord)].add(global_z);
break;
case DFHack::VEIN:
- veinMats[b->veinMaterialAt(coord)].add(z);
+ veinMats[b->veinMaterialAt(coord)].add(global_z);
break;
case DFHack::FEATSTONE:
if (blockFeatureLocal && des.bits.feature_local)
@@ -348,7 +373,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
if (blockFeatureLocal->type == DFHack::feature_Adamantine_Tube
&& blockFeatureLocal->main_material == 0) // stone
{
- veinMats[blockFeatureLocal->sub_material].add(z);
+ veinMats[blockFeatureLocal->sub_material].add(global_z);
}
else if (showTemple
&& blockFeatureLocal->type == DFHack::feature_Hell_Temple)
@@ -361,7 +386,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
&& blockFeatureGlobal->type == DFHack::feature_Underworld
&& blockFeatureGlobal->main_material == 0) // stone
{
- layerMats[blockFeatureGlobal->sub_material].add(z);
+ layerMats[blockFeatureGlobal->sub_material].add(global_z);
}
break;
case DFHack::OBSIDIAN:
@@ -386,9 +411,9 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
if (showHidden || !b->DesignationAt(loc).bits.hidden)
{
if(plant.is_shrub)
- plantMats[plant.material].add(z);
+ plantMats[plant.material].add(global_z);
else
- treeMats[plant.material].add(z);
+ treeMats[plant.material].add(global_z);
}
}
}
@@ -409,6 +434,21 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
con << std::setw(25) << DFHack::TileMaterialString[it->first] << " : " << it->second.count << std::endl;
}
+ if (liquidWater.count || liquidMagma.count)
+ {
+ con << std::endl << "Liquids:" << std::endl;
+ if (liquidWater.count)
+ {
+ con << std::setw(25) << "WATER" << " : ";
+ printMatdata(con, liquidWater);
+ }
+ if (liquidWater.count)
+ {
+ con << std::setw(25) << "MAGMA" << " : ";
+ printMatdata(con, liquidMagma);
+ }
+ }
+
con << std::endl << "Layer materials:" << std::endl;
printMats(con, layerMats, *mats->df_inorganic);
@@ -424,7 +464,14 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
if (hasAquifer)
{
- con << "Has aquifer" << std::endl;
+ con << "Has aquifer";
+ if (aquiferTiles.count)
+ {
+ con << " : ";
+ printMatdata(con, aquiferTiles);
+ }
+ else
+ con << std::endl;
}
if (hasDemonTemple)