Quietust 2012-01-20 10:40:25 -06:00
commit 1b419313f4
8 changed files with 60 additions and 99 deletions

@ -1,4 +1,4 @@
inline bool getassignment( DFCoord & xy )
inline bool getassignment( const df::coord2d &xy )
{
return getassignment(xy.x,xy.y);
}
@ -6,7 +6,7 @@ inline bool getassignment( int x, int y )
{
return (tile_bitmask[y] & (1 << x));
}
inline void setassignment( DFCoord & xy, bool bit )
inline void setassignment( const df::coord2d &xy, bool bit )
{
return setassignment(xy.x,xy.y, bit);
}

@ -105,24 +105,24 @@ class Block
valid = true;
}
}
int16_t veinMaterialAt(DFHack::DFCoord p)
int16_t veinMaterialAt(df::coord2d p)
{
return veinmats[p.x][p.y];
}
int16_t baseMaterialAt(DFHack::DFCoord p)
int16_t baseMaterialAt(df::coord2d p)
{
return basemats[p.x][p.y];
}
void ClearMaterialAt(DFHack::DFCoord p)
void ClearMaterialAt(df::coord2d p)
{
veinmats[p.x][p.y] = -1;
}
uint16_t TileTypeAt(DFHack::DFCoord p)
uint16_t TileTypeAt(df::coord2d p)
{
return raw.tiletypes[p.x][p.y];
}
bool setTiletypeAt(DFHack::DFCoord p, uint16_t tiletype)
bool setTiletypeAt(df::coord2d p, uint16_t tiletype)
{
if(!valid) return false;
dirty_tiletypes = true;
@ -131,11 +131,11 @@ class Block
return true;
}
uint16_t temperature1At(DFHack::DFCoord p)
uint16_t temperature1At(df::coord2d p)
{
return temp1[p.x][p.y];
}
bool setTemp1At(DFHack::DFCoord p, uint16_t temp)
bool setTemp1At(df::coord2d p, uint16_t temp)
{
if(!valid) return false;
dirty_temperatures = true;
@ -143,11 +143,11 @@ class Block
return true;
}
uint16_t temperature2At(DFHack::DFCoord p)
uint16_t temperature2At(df::coord2d p)
{
return temp2[p.x][p.y];
}
bool setTemp2At(DFHack::DFCoord p, uint16_t temp)
bool setTemp2At(df::coord2d p, uint16_t temp)
{
if(!valid) return false;
dirty_temperatures = true;
@ -155,11 +155,11 @@ class Block
return true;
}
df::tile_designation DesignationAt(DFHack::DFCoord p)
df::tile_designation DesignationAt(df::coord2d p)
{
return raw.designation[p.x][p.y];
}
bool setDesignationAt(DFHack::DFCoord p, df::tile_designation des)
bool setDesignationAt(df::coord2d p, df::tile_designation des)
{
if(!valid) return false;
dirty_designations = true;
@ -173,11 +173,11 @@ class Block
return true;
}
df::tile_occupancy OccupancyAt(DFHack::DFCoord p)
df::tile_occupancy OccupancyAt(df::coord2d p)
{
return raw.occupancy[p.x][p.y];
}
bool setOccupancyAt(DFHack::DFCoord p, df::tile_occupancy des)
bool setOccupancyAt(df::coord2d p, df::tile_occupancy des)
{
if(!valid) return false;
dirty_occupancies = true;
@ -295,7 +295,7 @@ class MapCache
}
return 0;
}
bool setTiletypeAt(DFHack::DFCoord& tilecoord, uint16_t tiletype)
bool setTiletypeAt(DFHack::DFCoord tilecoord, uint16_t tiletype)
{
Block * b= BlockAt(tilecoord / 16);
if(b && b->valid)
@ -315,7 +315,7 @@ class MapCache
}
return 0;
}
bool setTemp1At(DFHack::DFCoord& tilecoord, uint16_t temperature)
bool setTemp1At(DFHack::DFCoord tilecoord, uint16_t temperature)
{
Block * b= BlockAt(tilecoord / 16);
if(b && b->valid)
@ -335,7 +335,7 @@ class MapCache
}
return 0;
}
bool setTemp2At(DFHack::DFCoord& tilecoord, uint16_t temperature)
bool setTemp2At(DFHack::DFCoord tilecoord, uint16_t temperature)
{
Block * b= BlockAt(tilecoord / 16);
if(b && b->valid)

@ -67,75 +67,7 @@ namespace DFHack
*/
extern DFHACK_EXPORT const char * sa_feature(df::feature_type index);
/**
* Class for holding a world coordinate. Can do math with coordinates and can be used as an index for std::map
* \ingroup grp_maps
*/
class DFCoord
{
public:
DFCoord(uint16_t _x, uint16_t _y, uint16_t _z = 0): x(_x), y(_y), z(_z) {}
DFCoord()
{
comparate = 0;
}
bool operator==(const DFCoord &other) const
{
return (other.comparate == comparate);
}
bool operator!=(const DFCoord &other) const
{
return (other.comparate != comparate);
}
// FIXME: <tomprince> peterix_: you could probably get away with not defining operator< if you defined a std::less specialization for Vertex.
bool operator<(const DFCoord &other) const
{
return comparate < other.comparate;
}
DFCoord operator/(int number) const
{
return DFCoord(x/number, y/number, z);
}
DFCoord operator*(int number) const
{
return DFCoord(x*number, y*number, z);
}
DFCoord operator%(int number) const
{
return DFCoord(x%number, y%number, z);
}
DFCoord operator-(int number) const
{
return DFCoord(x,y,z-number);
}
DFCoord operator+(int number) const
{
return DFCoord(x,y,z+number);
}
// this is a hack. beware.
// x,y,z share the same space with comparate. comparate can be used for fast comparisons
union
{
// new shiny DFCoord struct. notice the ludicrous space for Z-levels
struct
{
uint16_t x;
uint16_t y;
uint32_t z;
};
// old planeccord struct for compatibility
struct
{
uint16_t x;
uint16_t y;
} dim;
// comparing thing
uint64_t comparate;
};
};
/**
* \ingroup grp_maps
*/
typedef df::coord DFCoord;
typedef DFCoord planecoord;
/**
@ -323,7 +255,7 @@ extern DFHACK_EXPORT bool ReadFeatures(mapblock40d * block, t_feature * local, t
* Read a specific global or local feature directly
*/
extern DFHACK_EXPORT bool GetGlobalFeature(t_feature &feature, int32_t index);
extern DFHACK_EXPORT bool GetLocalFeature(t_feature &feature, DFCoord coord, int32_t index);
extern DFHACK_EXPORT bool GetLocalFeature(t_feature &feature, df::coord2d coord, int32_t index);
/*
* BLOCK DATA

@ -43,6 +43,8 @@ using namespace std;
#include "DataDefs.h"
#include "df/world_data.h"
#include "df/world_underground_region.h"
#include "df/world_geo_biome.h"
#include "df/world_geo_layer.h"
#include "df/feature_init.h"
using namespace DFHack;
@ -337,7 +339,7 @@ bool Maps::GetGlobalFeature(t_feature &feature, int32_t index)
return true;
}
bool Maps::GetLocalFeature(t_feature &feature, DFCoord coord, int32_t index)
bool Maps::GetLocalFeature(t_feature &feature, df::coord2d coord, int32_t index)
{
feature.type = (df::feature_type)-1;
if (!world->world_data)
@ -416,7 +418,7 @@ bool Maps::ReadFeatures(uint32_t x, uint32_t y, uint32_t z, t_feature *local, t_
{
if (loc != -1)
{
DFCoord coord(x,y,0);
df::coord2d coord(x,y);
result &= GetLocalFeature(*local, coord, loc);
}
else
@ -569,14 +571,18 @@ bool Maps::ReadGeology (vector < vector <uint16_t> >& assign)
/// geology blocks have a vector of layer descriptors
// get the vector with pointer to layers
vector <df::world_data::T_unk_190::T_unk_4 *> &geolayers = world->world_data->unk_190[geoindex]->unk_4;
df::world_geo_biome *geo_biome = df::world_geo_biome::find(geoindex);
if (!geo_biome)
continue;
vector <df::world_geo_layer*> &geolayers = geo_biome->layers;
/// layer descriptor has a field that determines the type of stone/soil
v_geology[i].reserve(geolayers.size());
// finally, read the layer matgloss
for (uint32_t j = 0; j < geolayers.size(); j++)
v_geology[i].push_back(geolayers[j]->unk_4);
v_geology[i].push_back(geolayers[j]->mat_index);
}
assign.clear();

@ -1 +1 @@
Subproject commit d5abec61f72f113e023219fed19c4022363de953
Subproject commit 8f9f7cf3bc4cff3dc721dc9e0ba51bc54b069587

@ -300,7 +300,7 @@ DFhackCExport command_result setAllMatching(DFHack::Core * c, checkTile checkPro
//Ensure maximum coordinate is within map. Truncate to map edge.
maxCoord.x = std::min((uint32_t) maxCoord.x, tx_max);
maxCoord.y = std::min((uint32_t) maxCoord.y, ty_max);
maxCoord.z = std::min(maxCoord.z, z_max);
maxCoord.z = std::min((uint32_t) maxCoord.z, z_max);
//Check minimum co-ordinates against maximum map size
if (minCoord.x > maxCoord.x)

@ -246,7 +246,7 @@ DFhackCExport command_result df_probe (Core * c, vector <string> & parameters)
PRINT_FLAG( bits.water_table );
PRINT_FLAG( bits.rained );
DFCoord pc(blockX, blockY);
df::coord2d pc(blockX, blockY);
t_feature local;
t_feature global;

@ -193,6 +193,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
bool showSlade = true;
bool showTemple = true;
bool showValue = false;
bool showTube = false;
Console & con = c->con;
for(int i = 0; i < parameters.size();i++)
{
@ -200,10 +201,14 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
{
showHidden = true;
}
if (parameters[i] == "value")
else if (parameters[i] == "value")
{
showValue = true;
}
else if (parameters[i] == "hell")
{
showHidden = showTube = true;
}
else if(parameters[i] == "help" || parameters[i] == "?")
{
c->con.print("Prints a big list of all the present minerals.\n"
@ -212,6 +217,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
"Options:\n"
"all - Scan the whole map, as if it was revealed.\n"
"value - Show material value in the output.\n"
"hell - Show the Z range of HFS tubes.\n"
);
return CR_OK;
}
@ -255,6 +261,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
matdata liquidWater;
matdata liquidMagma;
matdata aquiferTiles;
matdata tubeTiles;
uint32_t vegCount = 0;
DFHack::Vegetation *veg = c->getVegetation();
@ -270,7 +277,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
for(uint32_t b_x = 0; b_x < x_max; b_x++)
{
// Get the map block
DFHack::DFCoord blockCoord(b_x, b_y);
df::coord2d blockCoord(b_x, b_y);
MapExtras::Block *b = map.BlockAt(DFHack::DFCoord(b_x, b_y, z));
if (!b || !b->valid)
{
@ -294,7 +301,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
{
for(uint32_t x = 0; x < 16; x++)
{
DFHack::DFCoord coord(x, y);
df::coord2d coord(x, y);
df::tile_designation des = b->DesignationAt(coord);
df::tile_occupancy occ = b->OccupancyAt(coord);
@ -342,6 +349,16 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
case DFHack::PILLAR:
case DFHack::FORTIFICATION:
break;
case DFHack::EMPTY:
/* A heuristic: tubes inside adamantine have EMPTY:AIR tiles which
still have feature_local set. Also check the unrevealed status,
so as to exclude any holes mined by the player. */
if (info->material == DFHack::AIR &&
des.bits.feature_local && des.bits.hidden &&
blockFeatureLocal.type == df::feature_type::deep_special_tube)
{
tubeTiles.add(global_z);
}
default:
continue;
}
@ -398,7 +415,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
for (PlantList::const_iterator it = plants->begin(); it != plants->end(); it++)
{
const DFHack::df_plant & plant = *(*it);
DFHack::DFCoord loc(plant.x, plant.y);
df::coord2d loc(plant.x, plant.y);
loc = loc % 16;
if (showHidden || !b->DesignationAt(loc).bits.hidden)
{
@ -466,6 +483,12 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
con << std::endl;
}
if (showTube && tubeTiles.count)
{
con << "Has HFS tubes : ";
printMatdata(con, tubeTiles);
}
if (hasDemonTemple)
{
con << "Has demon temple" << std::endl;