Fix Z level computation in prospect, and add levels for flows & aquifer.

develop
Alexander Gavrilov 2012-01-17 19:44:48 +04:00
parent 89cb12add1
commit 43476b2ea7
1 changed files with 61 additions and 14 deletions

@ -19,6 +19,9 @@ using namespace std;
#include "PluginManager.h" #include "PluginManager.h"
#include "modules/MapCache.h" #include "modules/MapCache.h"
#include "DataDefs.h"
#include "df/world.h"
using namespace DFHack; using namespace DFHack;
struct matdata 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 // printMats() accepts a vector of pointers to t_matgloss so that it can
// deal t_matgloss and all subclasses. // deal t_matgloss and all subclasses.
template <typename T> template <typename T>
@ -108,12 +121,8 @@ void printMats(DFHack::Console & con, MatMap &mat, std::vector<T*> &materials)
continue; continue;
} }
T* mat = materials[it->first]; T* mat = materials[it->first];
con << std::setw(25) << mat->ID << " : " con << std::setw(25) << mat->ID << " : ";
<< std::setw(9) << it->second.count; printMatdata(con, it->second);
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; total += it->second.count;
} }
@ -231,6 +240,10 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
MatMap plantMats; MatMap plantMats;
MatMap treeMats; MatMap treeMats;
matdata liquidWater;
matdata liquidMagma;
matdata aquiferTiles;
if (!(showSlade && maps->ReadGlobalFeatures(globalFeatures))) if (!(showSlade && maps->ReadGlobalFeatures(globalFeatures)))
{ {
con.printerr("Unable to read global features; slade won't be listed!\n"); 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 // Iterate over all the tiles in the block
for(uint32_t y = 0; y < 16; y++) 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) if (des.bits.water_table)
{ {
hasAquifer = true; hasAquifer = true;
aquiferTiles.add(global_z);
} }
// Check for lairs // Check for lairs
@ -309,6 +325,15 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
hasLair = true; 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); uint16_t type = b->TileTypeAt(coord);
const DFHack::TileRow *info = DFHack::getTileRow(type); 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 // Count the material type
baseMats[info->material].add(z); baseMats[info->material].add(global_z);
// Find the type of the tile // Find the type of the tile
switch (info->material) switch (info->material)
{ {
case DFHack::SOIL: case DFHack::SOIL:
case DFHack::STONE: case DFHack::STONE:
layerMats[b->baseMaterialAt(coord)].add(z); layerMats[b->baseMaterialAt(coord)].add(global_z);
break; break;
case DFHack::VEIN: case DFHack::VEIN:
veinMats[b->veinMaterialAt(coord)].add(z); veinMats[b->veinMaterialAt(coord)].add(global_z);
break; break;
case DFHack::FEATSTONE: case DFHack::FEATSTONE:
if (blockFeatureLocal && des.bits.feature_local) 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 if (blockFeatureLocal->type == DFHack::feature_Adamantine_Tube
&& blockFeatureLocal->main_material == 0) // stone && blockFeatureLocal->main_material == 0) // stone
{ {
veinMats[blockFeatureLocal->sub_material].add(z); veinMats[blockFeatureLocal->sub_material].add(global_z);
} }
else if (showTemple else if (showTemple
&& blockFeatureLocal->type == DFHack::feature_Hell_Temple) && 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->type == DFHack::feature_Underworld
&& blockFeatureGlobal->main_material == 0) // stone && blockFeatureGlobal->main_material == 0) // stone
{ {
layerMats[blockFeatureGlobal->sub_material].add(z); layerMats[blockFeatureGlobal->sub_material].add(global_z);
} }
break; break;
case DFHack::OBSIDIAN: 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 (showHidden || !b->DesignationAt(loc).bits.hidden)
{ {
if(plant.is_shrub) if(plant.is_shrub)
plantMats[plant.material].add(z); plantMats[plant.material].add(global_z);
else 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; 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; con << std::endl << "Layer materials:" << std::endl;
printMats(con, layerMats, *mats->df_inorganic); printMats(con, layerMats, *mats->df_inorganic);
@ -424,7 +464,14 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
if (hasAquifer) if (hasAquifer)
{ {
con << "Has aquifer" << std::endl; con << "Has aquifer";
if (aquiferTiles.count)
{
con << " : ";
printMatdata(con, aquiferTiles);
}
else
con << std::endl;
} }
if (hasDemonTemple) if (hasDemonTemple)