Merge remote-tracking branch 'quietust/master'

develop
Mike Stewart 2012-01-20 09:47:32 -08:00
commit 9b0b0d53f9
21 changed files with 1037 additions and 2002 deletions

@ -1090,7 +1090,6 @@ TYPE * Core::get##TYPE() \
MODULE_GETTER(Units);
MODULE_GETTER(Engravings);
MODULE_GETTER(Maps);
MODULE_GETTER(Gui);
MODULE_GETTER(World);
MODULE_GETTER(Materials);

@ -54,7 +54,6 @@ namespace DFHack
class Module;
class Units;
class Engravings;
class Maps;
class Gui;
class World;
class Materials;
@ -102,8 +101,6 @@ namespace DFHack
Units * getUnits();
/// get the engravings module
Engravings * getEngravings();
/// get the maps module
Maps * getMaps();
/// get the gui module
Gui * getGui();
/// get the world module
@ -166,7 +163,6 @@ namespace DFHack
{
Units * pUnits;
Engravings * pEngravings;
Maps * pMaps;
Gui * pGui;
World * pWorld;
Materials * pMaterials;

@ -39,7 +39,6 @@ namespace DFHack
Module* createVegetation();
Module* createBuildings();
Module* createConstructions();
Module* createMaps();
Module* createNotes();
Module* createGraphic();
}

@ -0,0 +1,19 @@
inline bool getassignment( const df::coord2d &xy )
{
return getassignment(xy.x,xy.y);
}
inline bool getassignment( int x, int y )
{
return (tile_bitmask[y] & (1 << x));
}
inline void setassignment( const df::coord2d &xy, bool bit )
{
return setassignment(xy.x,xy.y, bit);
}
inline void setassignment( int x, int y, bool bit )
{
if(bit)
tile_bitmask[y] |= (1 << x);
else
tile_bitmask[y] &= 0xFFFF ^ (1 << x);
}

@ -30,13 +30,17 @@ distribution.
#include "TileTypes.h"
#include <stdint.h>
#include <cstring>
#include "df/map_block.h"
#include "df/block_square_event_mineralst.h"
using namespace DFHack;
using namespace DFHack::Simple;
namespace MapExtras
{
void SquashVeins (DFHack::Maps *m, DFHack::DFCoord bcoord, DFHack::mapblock40d & mb, DFHack::t_blockmaterials & materials)
void SquashVeins (DFCoord bcoord, mapblock40d & mb, t_blockmaterials & materials)
{
memset(materials,-1,sizeof(materials));
std::vector <DFHack::t_vein *> veins;
m->SortBlockEvents(bcoord.x,bcoord.y,bcoord.z,&veins);
std::vector <df::block_square_event_mineralst *> veins;
Maps::SortBlockEvents(bcoord.x,bcoord.y,bcoord.z,&veins);
//iterate through block rows
for(uint32_t j = 0;j<16;j++)
{
@ -48,9 +52,9 @@ void SquashVeins (DFHack::Maps *m, DFHack::DFCoord bcoord, DFHack::mapblock40d &
{
for(int i = (int) veins.size() - 1; i >= 0;i--)
{
if(!!(((1 << k) & veins[i]->assignment[j]) >> k))
if(!!(((1 << k) & veins[i]->tile_bitmask[j]) >> k))
{
materials[k][j] = veins[i]->type;
materials[k][j] = veins[i]->inorganic_mat;
i = -1;
}
}
@ -81,9 +85,8 @@ void SquashRocks ( std::vector< std::vector <uint16_t> > * layerassign, DFHack::
class Block
{
public:
Block(DFHack::Maps *_m, DFHack::DFCoord _bcoord, std::vector< std::vector <uint16_t> > * layerassign = 0)
Block(DFHack::DFCoord _bcoord, std::vector< std::vector <uint16_t> > * layerassign = 0)
{
m = _m;
dirty_designations = false;
dirty_tiletypes = false;
dirty_temperatures = false;
@ -91,10 +94,10 @@ class Block
dirty_occupancies = false;
valid = false;
bcoord = _bcoord;
if(m->ReadBlock40d(bcoord.x,bcoord.y,bcoord.z,&raw))
if(Maps::ReadBlock40d(bcoord.x,bcoord.y,bcoord.z,&raw))
{
m->ReadTemperatures(bcoord.x,bcoord.y, bcoord.z,&temp1,&temp2);
SquashVeins(m,bcoord,raw,veinmats);
Maps::ReadTemperatures(bcoord.x,bcoord.y, bcoord.z,&temp1,&temp2);
SquashVeins(bcoord,raw,veinmats);
if(layerassign)
SquashRocks(layerassign,raw,basemats);
else
@ -102,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;
@ -128,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;
@ -140,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;
@ -152,11 +155,11 @@ class Block
return true;
}
DFHack::t_designation DesignationAt(DFHack::DFCoord p)
df::tile_designation DesignationAt(df::coord2d p)
{
return raw.designation[p.x][p.y];
}
bool setDesignationAt(DFHack::DFCoord p, DFHack::t_designation des)
bool setDesignationAt(df::coord2d p, df::tile_designation des)
{
if(!valid) return false;
dirty_designations = true;
@ -170,11 +173,11 @@ class Block
return true;
}
DFHack::t_occupancy OccupancyAt(DFHack::DFCoord p)
df::tile_occupancy OccupancyAt(df::coord2d p)
{
return raw.occupancy[p.x][p.y];
}
bool setOccupancyAt(DFHack::DFCoord p, DFHack::t_occupancy des)
bool setOccupancyAt(df::coord2d p, df::tile_occupancy des)
{
if(!valid) return false;
dirty_occupancies = true;
@ -200,28 +203,28 @@ class Block
if(!valid) return false;
if(dirty_designations)
{
m->WriteDesignations(bcoord.x,bcoord.y,bcoord.z, &raw.designation);
m->WriteDirtyBit(bcoord.x,bcoord.y,bcoord.z,true);
Maps::WriteDesignations(bcoord.x,bcoord.y,bcoord.z, &raw.designation);
Maps::WriteDirtyBit(bcoord.x,bcoord.y,bcoord.z,true);
dirty_designations = false;
}
if(dirty_tiletypes)
{
m->WriteTileTypes(bcoord.x,bcoord.y,bcoord.z, &raw.tiletypes);
Maps::WriteTileTypes(bcoord.x,bcoord.y,bcoord.z, &raw.tiletypes);
dirty_tiletypes = false;
}
if(dirty_temperatures)
{
m->WriteTemperatures(bcoord.x,bcoord.y,bcoord.z, &temp1, &temp2);
Maps::WriteTemperatures(bcoord.x,bcoord.y,bcoord.z, &temp1, &temp2);
dirty_temperatures = false;
}
if(dirty_blockflags)
{
m->WriteBlockFlags(bcoord.x,bcoord.y,bcoord.z,raw.blockflags);
Maps::WriteBlockFlags(bcoord.x,bcoord.y,bcoord.z,raw.blockflags);
dirty_blockflags = false;
}
if(dirty_occupancies)
{
m->WriteOccupancy(bcoord.x,bcoord.y,bcoord.z,&raw.occupancy);
Maps::WriteOccupancy(bcoord.x,bcoord.y,bcoord.z,&raw.occupancy);
dirty_occupancies = false;
}
return true;
@ -232,7 +235,6 @@ class Block
bool dirty_temperatures:1;
bool dirty_blockflags:1;
bool dirty_occupancies:1;
DFHack::Maps * m;
DFHack::mapblock40d raw;
DFHack::DFCoord bcoord;
DFHack::t_blockmaterials veinmats;
@ -244,12 +246,11 @@ class Block
class MapCache
{
public:
MapCache(DFHack::Maps * Maps)
MapCache()
{
valid = 0;
this->Maps = Maps;
Maps->getSize(x_bmax, y_bmax, z_max);
validgeo = Maps->ReadGeology( layerassign );
Maps::getSize(x_bmax, y_bmax, z_max);
validgeo = Maps::ReadGeology( layerassign );
valid = true;
};
~MapCache()
@ -276,9 +277,9 @@ class MapCache
{
Block * nblo;
if(validgeo)
nblo = new Block(Maps,blockcoord, &layerassign);
nblo = new Block(blockcoord, &layerassign);
else
nblo = new Block(Maps,blockcoord);
nblo = new Block(blockcoord);
blocks[blockcoord] = nblo;
return nblo;
}
@ -294,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)
@ -314,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)
@ -334,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)
@ -373,18 +374,18 @@ class MapCache
return 0;
}
DFHack::t_designation designationAt (DFHack::DFCoord tilecoord)
df::tile_designation designationAt (DFHack::DFCoord tilecoord)
{
Block * b= BlockAt(tilecoord / 16);
if(b && b->valid)
{
return b->DesignationAt(tilecoord % 16);
}
DFHack:: t_designation temp;
df::tile_designation temp;
temp.whole = 0;
return temp;
}
bool setDesignationAt (DFHack::DFCoord tilecoord, DFHack::t_designation des)
bool setDesignationAt (DFHack::DFCoord tilecoord, df::tile_designation des)
{
Block * b= BlockAt(tilecoord / 16);
if(b && b->valid)
@ -395,18 +396,18 @@ class MapCache
return false;
}
DFHack::t_occupancy occupancyAt (DFHack::DFCoord tilecoord)
df::tile_occupancy occupancyAt (DFHack::DFCoord tilecoord)
{
Block * b= BlockAt(tilecoord / 16);
if(b && b->valid)
{
return b->OccupancyAt(tilecoord % 16);
}
DFHack:: t_occupancy temp;
df::tile_occupancy temp;
temp.whole = 0;
return temp;
}
bool setOccupancyAt (DFHack::DFCoord tilecoord, DFHack::t_occupancy occ)
bool setOccupancyAt (DFHack::DFCoord tilecoord, df::tile_occupancy occ)
{
Block * b= BlockAt(tilecoord / 16);
if(b && b->valid)
@ -453,7 +454,6 @@ class MapCache
uint32_t y_tmax;
uint32_t z_max;
std::vector< std::vector <uint16_t> > layerassign;
DFHack::Maps * Maps;
std::map<DFHack::DFCoord, Block *> blocks;
};
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

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

@ -96,17 +96,14 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
DFHack::VersionInfo *mem = c->vinfo;
DFHack::Gui * Gui = c->getGui();
DFHack::Maps *Maps = c->getMaps();
std::size_t numItems = world->items.all.size();
// init the map
if(!Maps->Start())
if (!Maps::IsValid())
{
c->con.printerr("Can't initialize map.\n");
c->con.printerr("Map is not available!\n");
return CR_FAILURE;
}
MapCache MC (Maps);
std::size_t numItems = world->items.all.size();
MapCache MC;
int i = 0;
int dumped_total = 0;
@ -185,8 +182,8 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
{
// yes...
cerr << "Moving from block to block!" << endl;
df_block * bl_src = Maps->getBlock(itm->pos.x /16, itm->pos.y/16, itm->pos.z);
df_block * bl_tgt = Maps->getBlock(cx /16, cy/16, cz);
df::map_block * bl_src = Maps::getBlockAbs(itm->pos.x, itm->pos.y, itm->pos.z);
df::map_block * bl_tgt = Maps::getBlockAbs(cx, cy, cz);
if(bl_src)
{
std::remove(bl_src->items.begin(), bl_src->items.end(),itm->id);
@ -234,7 +231,7 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
{
if(it->second == 0)
{
t_occupancy occ = MC.occupancyAt(it->first);
df::tile_occupancy occ = MC.occupancyAt(it->first);
occ.bits.item = false;
MC.setOccupancyAt(it->first, occ);
}
@ -247,7 +244,7 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
Block * b = MC.BlockAt(pos_cursor / 16);
if(b)
{
t_occupancy occ = MC.occupancyAt(pos_cursor);
df::tile_occupancy occ = MC.occupancyAt(pos_cursor);
occ.bits.item = 1;
MC.setOccupancyAt(pos_cursor,occ);
}
@ -255,7 +252,7 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
// write map changes back to DF.
MC.WriteAll();
// Is this necessary? Is "forbid" a dirtyable attribute like "dig" is?
Maps->WriteDirtyBit(cx/16, cy/16, cz, true);
Maps::WriteDirtyBit(cx/16, cy/16, cz, true);
}
c->con.print("Done. %d items %s.\n", dumped_total, destroy ? "marked for destruction" : "quickdumped");
return CR_OK;

@ -2,12 +2,9 @@
#include "Console.h"
#include "Export.h"
#include "PluginManager.h"
#include "modules/Maps.h"
#include "DataDefs.h"
#include "df/world.h"
#include "df/map_block.h"
#include "df/block_square_event.h"
#include "df/block_square_event_material_spatterst.h"
#include "df/item_actual.h"
#include "df/unit.h"
#include "df/unit_spatter.h"
@ -19,6 +16,7 @@
using std::vector;
using std::string;
using namespace DFHack;
using namespace DFHack::Simple;
using df::global::world;
using df::global::cursor;
@ -115,16 +113,6 @@ command_result cleanunits (Core * c)
return CR_OK;
}
// This is slightly different from what's in the Maps module - it takes tile coordinates rather than block coordinates
df::map_block *getBlock (int32_t x, int32_t y, int32_t z)
{
if ((x < 0) || (y < 0) || (z < 0))
return NULL;
if ((x >= world->map.x_count) || (y >= world->map.y_count) || (z >= world->map.z_count))
return NULL;
return world->map.block_index[x >> 4][y >> 4][z];
}
DFhackCExport command_result spotclean (Core * c, vector <string> & parameters)
{
// HOTKEY COMMAND: CORE ALREADY SUSPENDED
@ -133,7 +121,7 @@ DFhackCExport command_result spotclean (Core * c, vector <string> & parameters)
c->con.printerr("The cursor is not active.\n");
return CR_FAILURE;
}
df::map_block *block = getBlock(cursor->x, cursor->y, cursor->z);
df::map_block *block = Maps::getBlockAbs(cursor->x, cursor->y, cursor->z);
if (block == NULL)
{
c->con.printerr("Invalid map block selected!\n");

@ -14,7 +14,6 @@ using namespace std;
#include "PluginManager.h"
#include <vector>
#include <string>
#include "modules/Maps.h"
#include "modules/Items.h"
#include "modules/Units.h"
#include "modules/Materials.h"

@ -6,9 +6,7 @@
#include "PluginManager.h"
#include "DataDefs.h"
#include "df/world.h"
#include "df/map_block.h"
#include "df/tile_dig_designation.h"
#include "modules/Maps.h"
#include "TileTypes.h"
using std::vector;
@ -17,16 +15,7 @@ using namespace DFHack;
using df::global::world;
using namespace DFHack;
// This is slightly different from what's in the Maps module - it takes tile coordinates rather than block coordinates
df::map_block *getBlock (int32_t x, int32_t y, int32_t z)
{
if ((x < 0) || (y < 0) || (z < 0))
return NULL;
if ((x >= world->map.x_count) || (y >= world->map.y_count) || (z >= world->map.z_count))
return NULL;
return world->map.block_index[x >> 4][y >> 4][z];
}
using namespace DFHack::Simple;
DFhackCExport command_result df_deramp (Core * c, vector <string> & parameters)
{
@ -51,7 +40,7 @@ DFhackCExport command_result df_deramp (Core * c, vector <string> & parameters)
for (int i = 0; i < blocks_total; i++)
{
df::map_block *block = world->map.map_blocks[i];
df::map_block *above = getBlock(block->map_pos.x, block->map_pos.y, block->map_pos.z + 1);
df::map_block *above = Maps::getBlockAbs(block->map_pos.x, block->map_pos.y, block->map_pos.z + 1);
for (int x = 0; x < 16; x++)
{

@ -17,7 +17,7 @@ using MapExtras::MapCache;
using namespace DFHack;
//Function pointer type for whole-map tile checks.
typedef void (*checkTile)(DFHack::DFCoord, MapExtras::MapCache *);
typedef void (*checkTile)(DFHack::DFCoord, MapExtras::MapCache &);
//Forward Declarations for Commands
DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::string> & params);
@ -28,10 +28,10 @@ DFhackCExport command_result setAllMatching(DFHack::Core * c, checkTile checkPro
DFHack::DFCoord minCoord = DFHack::DFCoord(0, 0, 0),
DFHack::DFCoord maxCoord = DFHack::DFCoord(0xFFFF, 0xFFFF, 0xFFFF));
void allHigh(DFHack::DFCoord coord, MapExtras::MapCache * map);
void allNormal(DFHack::DFCoord coord, MapExtras::MapCache * map);
void allLow(DFHack::DFCoord coord, MapExtras::MapCache * map);
void allRestricted(DFHack::DFCoord coord, MapExtras::MapCache * map);
void allHigh(DFHack::DFCoord coord, MapExtras::MapCache & map);
void allNormal(DFHack::DFCoord coord, MapExtras::MapCache & map);
void allLow(DFHack::DFCoord coord, MapExtras::MapCache & map);
void allRestricted(DFHack::DFCoord coord, MapExtras::MapCache & map);
DFhackCExport const char * plugin_name ( void )
{
@ -57,8 +57,8 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
//Maximum map size.
uint32_t x_max,y_max,z_max;
//Source and target traffic types.
e_traffic source = traffic_normal;
e_traffic target = traffic_normal;
df::tile_traffic source = df::tile_traffic::Normal;
df::tile_traffic target = df::tile_traffic::Normal;
//Option flags
bool updown = false;
bool checkpit = true;
@ -89,13 +89,13 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
switch (toupper(params[i][0]))
{
case 'H':
target = traffic_high; break;
target = df::tile_traffic::High; break;
case 'N':
target = traffic_normal; break;
target = df::tile_traffic::Normal; break;
case 'L':
target = traffic_low; break;
target = df::tile_traffic::Low; break;
case 'R':
target = traffic_restricted; break;
target = df::tile_traffic::Restricted; break;
case 'X':
updown = true; break;
case 'B':
@ -108,18 +108,16 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
//Initialization.
c->Suspend();
DFHack::Maps * Maps = c->getMaps();
DFHack::Gui * Gui = c->getGui();
// init the map
if(!Maps->Start())
if (!Maps::IsValid())
{
c->con.printerr("Can't init map. Make sure you have a map loaded in DF.\n");
c->con.printerr("Map is not available!\n");
c->Resume();
return CR_FAILURE;
}
int32_t cx, cy, cz;
Maps->getSize(x_max,y_max,z_max);
Maps::getSize(x_max,y_max,z_max);
uint32_t tx_max = x_max * 16;
uint32_t ty_max = y_max * 16;
Gui->getCursorCoords(cx,cy,cz);
@ -131,20 +129,19 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
}
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
MapExtras::MapCache * MCache = new MapExtras::MapCache(Maps);
MapExtras::MapCache MCache;
DFHack::t_designation des = MCache->designationAt(xy);
int16_t tt = MCache->tiletypeAt(xy);
DFHack::t_occupancy oc;
df::tile_designation des = MCache.designationAt(xy);
int16_t tt = MCache.tiletypeAt(xy);
df::tile_occupancy oc;
if (checkbuilding)
oc = MCache->occupancyAt(xy);
oc = MCache.occupancyAt(xy);
source = des.bits.traffic;
source = (df::tile_traffic)des.bits.traffic;
if(source == target)
{
c->con.printerr("This tile is already set to the target traffic type.\n");
delete MCache;
c->Resume();
return CR_FAILURE;
}
@ -152,7 +149,6 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
if(DFHack::isWallTerrain(tt))
{
c->con.printerr("This tile is a wall. Please select a passable tile.\n");
delete MCache;
c->Resume();
return CR_FAILURE;
}
@ -160,7 +156,6 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
if(checkpit && DFHack::isOpenTerrain(tt))
{
c->con.printerr("This tile is a hole. Please select a passable tile.\n");
delete MCache;
c->Resume();
return CR_FAILURE;
}
@ -168,7 +163,6 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
if(checkbuilding && oc.bits.building)
{
c->con.printerr("This tile contains a building. Please select an empty tile.\n");
delete MCache;
c->Resume();
return CR_FAILURE;
}
@ -184,25 +178,25 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
xy = flood.top();
flood.pop();
des = MCache->designationAt(xy);
des = MCache.designationAt(xy);
if (des.bits.traffic != source) continue;
tt = MCache->tiletypeAt(xy);
tt = MCache.tiletypeAt(xy);
if(DFHack::isWallTerrain(tt)) continue;
if(checkpit && DFHack::isOpenTerrain(tt)) continue;
if (checkbuilding)
{
oc = MCache->occupancyAt(xy);
oc = MCache.occupancyAt(xy);
if(oc.bits.building) continue;
}
//This tile is ready. Set its traffic level and add surrounding tiles.
if (MCache->testCoord(xy))
if (MCache.testCoord(xy))
{
des.bits.traffic = target;
MCache->setDesignationAt(xy,des);
MCache.setDesignationAt(xy,des);
if (xy.x > 0)
{
@ -236,7 +230,7 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
}
}
MCache->WriteAll();
MCache.WriteAll();
c->Resume();
return CR_OK;
}
@ -245,7 +239,7 @@ enum e_checktype {no_check, check_equal, check_nequal};
DFhackCExport command_result alltraffic(DFHack::Core * c, std::vector<std::string> & params)
{
void (*proc)(DFHack::DFCoord, MapExtras::MapCache *) = allNormal;
void (*proc)(DFHack::DFCoord, MapExtras::MapCache &) = allNormal;
//Loop through parameters
for(int i = 0; i < params.size();i++)
@ -289,26 +283,24 @@ DFhackCExport command_result setAllMatching(DFHack::Core * c, checkTile checkPro
//Initialization.
c->Suspend();
DFHack::Maps * Maps = c->getMaps();
DFHack::Gui * Gui = c->getGui();
// init the map
if(!Maps->Start())
if (!Maps::IsValid())
{
c->con.printerr("Can't init map. Make sure you have a map loaded in DF.\n");
c->con.printerr("Map is not available!\n");
c->Resume();
return CR_FAILURE;
}
//Maximum map size.
uint32_t x_max,y_max,z_max;
Maps->getSize(x_max,y_max,z_max);
Maps::getSize(x_max,y_max,z_max);
uint32_t tx_max = x_max * 16;
uint32_t ty_max = y_max * 16;
//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)
@ -330,7 +322,7 @@ DFhackCExport command_result setAllMatching(DFHack::Core * c, checkTile checkPro
return CR_FAILURE;
}
MapExtras::MapCache * MCache = new MapExtras::MapCache(Maps);
MapExtras::MapCache MCache;
c->con.print("Setting traffic...\n");
@ -347,34 +339,34 @@ DFhackCExport command_result setAllMatching(DFHack::Core * c, checkTile checkPro
}
}
MCache->WriteAll();
MCache.WriteAll();
c->con.print("Complete!\n");
c->Resume();
return CR_OK;
}
//Unconditionally set map to target traffic type
void allHigh(DFHack::DFCoord coord, MapExtras::MapCache * map)
void allHigh(DFHack::DFCoord coord, MapExtras::MapCache &map)
{
DFHack::t_designation des = map->designationAt(coord);
des.bits.traffic = traffic_high;
map->setDesignationAt(coord, des);
df::tile_designation des = map.designationAt(coord);
des.bits.traffic = df::tile_traffic::High;
map.setDesignationAt(coord, des);
}
void allNormal(DFHack::DFCoord coord, MapExtras::MapCache * map)
void allNormal(DFHack::DFCoord coord, MapExtras::MapCache &map)
{
DFHack::t_designation des = map->designationAt(coord);
des.bits.traffic = traffic_normal;
map->setDesignationAt(coord, des);
df::tile_designation des = map.designationAt(coord);
des.bits.traffic = df::tile_traffic::Normal;
map.setDesignationAt(coord, des);
}
void allLow(DFHack::DFCoord coord, MapExtras::MapCache * map)
void allLow(DFHack::DFCoord coord, MapExtras::MapCache &map)
{
DFHack::t_designation des = map->designationAt(coord);
des.bits.traffic = traffic_low;
map->setDesignationAt(coord, des);
df::tile_designation des = map.designationAt(coord);
des.bits.traffic = df::tile_traffic::Low;
map.setDesignationAt(coord, des);
}
void allRestricted(DFHack::DFCoord coord, MapExtras::MapCache * map)
void allRestricted(DFHack::DFCoord coord, MapExtras::MapCache &map)
{
DFHack::t_designation des = map->designationAt(coord);
des.bits.traffic = traffic_restricted;
map->setDesignationAt(coord, des);
df::tile_designation des = map.designationAt(coord);
des.bits.traffic = df::tile_traffic::Restricted;
map.setDesignationAt(coord, des);
}

@ -169,7 +169,6 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
int32_t x,y,z;
uint32_t x_max,y_max,z_max;
DFHack::Maps * Maps;
DFHack::Gui * Position;
for(int i = 0; i < parameters.size();i++)
{
@ -360,16 +359,14 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
else if(command.empty())
{
c->Suspend();
Maps = c->getMaps();
Maps->Start();
Maps->getSize(x_max,y_max,z_max);
Maps::getSize(x_max,y_max,z_max);
Position = c->getGui();
do
{
if(!Maps->Start())
if (!Maps::IsValid())
{
c->con << "Can't see any DF map loaded." << endl;
break;
break;;
}
if(!Position->getCursorCoords(x,y,z))
{
@ -377,7 +374,7 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
break;
}
c->con << "cursor coords: " << x << "/" << y << "/" << z << endl;
MapCache mcache(Maps);
MapCache mcache;
DFHack::DFCoord cursor(x,y,z);
coord_vec all_tiles = brush->points(mcache,cursor);
c->con << "working..." << endl;
@ -389,7 +386,7 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
mcache.setTiletypeAt(*iter, 331);
mcache.setTemp1At(*iter,10015);
mcache.setTemp2At(*iter,10015);
DFHack::t_designation des = mcache.designationAt(*iter);
df::tile_designation des = mcache.designationAt(*iter);
des.bits.flow_size = 0;
mcache.setDesignationAt(*iter, des);
iter ++;
@ -411,8 +408,8 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
{
mcache.setTiletypeAt(*iter, 90);
DFHack::t_designation a = mcache.designationAt(*iter);
a.bits.liquid_type = DFHack::liquid_water;
df::tile_designation a = mcache.designationAt(*iter);
a.bits.liquid_type = df::tile_liquid::Water;
a.bits.liquid_static = false;
a.bits.flow_size = 7;
mcache.setTemp1At(*iter,10015);
@ -434,7 +431,7 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
while (iter != all_tiles.end())
{
DFHack::DFCoord current = *iter;
DFHack::t_designation des = mcache.designationAt(current);
df::tile_designation des = mcache.designationAt(current);
des.bits.water_salt = false;
des.bits.water_stagnant = false;
mcache.setDesignationAt(current,des);
@ -455,9 +452,8 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
iter ++;
continue;
}
DFHack::t_designation des = mcache.designationAt(current);
df::tile_designation des = mcache.designationAt(current);
uint16_t tt = mcache.tiletypeAt(current);
DFHack::naked_designation & flow = des.bits;
// don't put liquids into places where they don't belong...
if(!DFHack::FlowPassable(tt))
{
@ -468,27 +464,27 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
{
if(setmode == "s.")
{
flow.flow_size = amount;
des.bits.flow_size = amount;
}
else if(setmode == "s+")
{
if(flow.flow_size < amount)
flow.flow_size = amount;
if(des.bits.flow_size < amount)
des.bits.flow_size = amount;
}
else if(setmode == "s-")
{
if (flow.flow_size > amount)
flow.flow_size = amount;
if (des.bits.flow_size > amount)
des.bits.flow_size = amount;
}
if(amount != 0 && mode == "magma")
{
flow.liquid_type = DFHack::liquid_magma;
des.bits.liquid_type = df::tile_liquid::Magma;
mcache.setTemp1At(current,12000);
mcache.setTemp2At(current,12000);
}
else if(amount != 0 && mode == "water")
{
flow.liquid_type = DFHack::liquid_water;
des.bits.liquid_type = df::tile_liquid::Water;
mcache.setTemp1At(current,10015);
mcache.setTemp2At(current,10015);
}
@ -531,7 +527,6 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
c->con << "OK" << endl;
else
c->con << "Something failed horribly! RUN!" << endl;
Maps->Finish();
} while (0);
c->Resume();
}

@ -99,17 +99,16 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre
return CR_OK;
}
c->Suspend();
DFHack::Maps *maps = c->getMaps();
if (!maps->Start())
if (!Maps::IsValid())
{
c->con.printerr( "Cannot get map info!\n");
c->con.printerr("Map is not available!\n");
c->Resume();
return CR_FAILURE;
}
DFHack::Gui * Gui = c->getGui();
uint32_t x_max, y_max, z_max;
maps->getSize(x_max, y_max, z_max);
MapExtras::MapCache map(maps);
Maps::getSize(x_max, y_max, z_max);
MapExtras::MapCache map;
DFHack::Vegetation *veg = c->getVegetation();
if (!veg->all_plants)
{
@ -138,7 +137,7 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre
if(Gui->getCursorCoords(x,y,z))
{
vector<DFHack::df_plant *> * alltrees;
if(maps->ReadVegetation(x/16,y/16,z,alltrees))
if(Maps::ReadVegetation(x/16,y/16,z,alltrees))
{
bool didit = false;
for(size_t i = 0 ; i < alltrees->size(); i++)
@ -168,7 +167,6 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre
}
// Cleanup
veg->Finish();
maps->Finish();
c->Resume();
return CR_OK;
}
@ -212,16 +210,14 @@ DFhackCExport command_result df_grow (Core * c, vector <string> & parameters)
}
}
c->Suspend();
DFHack::Maps *maps = c->getMaps();
Console & con = c->con;
if (!maps->Start())
if (!Maps::IsValid())
{
con.printerr("Cannot get map info!\n");
c->con.printerr("Map is not available!\n");
c->Resume();
return CR_FAILURE;
}
//maps->getSize(x_max, y_max, z_max);
MapExtras::MapCache map(maps);
MapExtras::MapCache map;
DFHack::Vegetation *veg = c->getVegetation();
if (!veg->all_plants)
{
@ -234,7 +230,7 @@ DFhackCExport command_result df_grow (Core * c, vector <string> & parameters)
if(Gui->getCursorCoords(x,y,z))
{
vector<DFHack::df_plant *> * alltrees;
if(maps->ReadVegetation(x/16,y/16,z,alltrees))
if(Maps::ReadVegetation(x/16,y/16,z,alltrees))
{
for(size_t i = 0 ; i < alltrees->size(); i++)
{
@ -266,7 +262,6 @@ DFhackCExport command_result df_grow (Core * c, vector <string> & parameters)
// Cleanup
veg->Finish();
maps->Finish();
c->Resume();
return CR_OK;
}

@ -99,196 +99,182 @@ DFhackCExport command_result df_probe (Core * c, vector <string> & parameters)
DFHack::Gui *Gui = c->getGui();
DFHack::Materials *Materials = c->getMaterials();
DFHack::VersionInfo* mem = c->vinfo;
DFHack::Maps *Maps = c->getMaps();
std::vector<t_matglossInorganic> inorganic;
bool hasmats = Materials->CopyInorganicMaterials(inorganic);
if(!Maps->Start())
if (!Maps::IsValid())
{
con.printerr("Unable to access map data!\n");
c->con.printerr("Map is not available!\n");
c->Resume();
return CR_FAILURE;
}
else
{
MapExtras::MapCache mc (Maps);
MapExtras::MapCache mc;
int32_t regionX, regionY, regionZ;
Maps->getPosition(regionX,regionY,regionZ);
int32_t regionX, regionY, regionZ;
Maps::getPosition(regionX,regionY,regionZ);
bool have_features = Maps->StartFeatures();
int32_t cursorX, cursorY, cursorZ;
Gui->getCursorCoords(cursorX,cursorY,cursorZ);
if(cursorX == -30000)
{
con.printerr("No cursor; place cursor over tile to probe.\n");
}
else
{
DFCoord cursor (cursorX,cursorY,cursorZ);
int32_t cursorX, cursorY, cursorZ;
Gui->getCursorCoords(cursorX,cursorY,cursorZ);
if(cursorX == -30000)
{
con.printerr("No cursor; place cursor over tile to probe.\n");
c->Resume();
return CR_FAILURE;
}
DFCoord cursor (cursorX,cursorY,cursorZ);
uint32_t blockX = cursorX / 16;
uint32_t tileX = cursorX % 16;
uint32_t blockY = cursorY / 16;
uint32_t tileY = cursorY % 16;
uint32_t blockX = cursorX / 16;
uint32_t tileX = cursorX % 16;
uint32_t blockY = cursorY / 16;
uint32_t tileY = cursorY % 16;
MapExtras::Block * b = mc.BlockAt(cursor/16);
mapblock40d & block = b->raw;
if(b && b->valid)
{
con.print("block addr: 0x%x\n\n", block.origin);
MapExtras::Block * b = mc.BlockAt(cursor/16);
if(!b && !b->valid)
{
con.printerr("No data.\n");
c->Resume();
return CR_OK;
}
mapblock40d & block = b->raw;
con.print("block addr: 0x%x\n\n", block.origin);
/*
if (showBlock)
{
con.print("block flags:\n");
print_bits<uint32_t>(block.blockflags.whole,con);
con.print("\n\n");
}
if (showBlock)
{
con.print("block flags:\n");
print_bits<uint32_t>(block.blockflags.whole,con);
con.print("\n\n");
}
*/
int16_t tiletype = mc.tiletypeAt(cursor);
naked_designation &des = block.designation[tileX][tileY].bits;
int16_t tiletype = mc.tiletypeAt(cursor);
df::tile_designation &des = block.designation[tileX][tileY];
/*
if(showDesig)
{
con.print("designation\n");
print_bits<uint32_t>(block.designation[tileX][tileY].whole,
con);
con.print("\n\n");
}
if(showDesig)
{
con.print("designation\n");
print_bits<uint32_t>(block.designation[tileX][tileY].whole,
con);
con.print("\n\n");
}
if(showOccup)
{
con.print("occupancy\n");
print_bits<uint32_t>(block.occupancy[tileX][tileY].whole,
con);
con.print("\n\n");
}
if(showOccup)
{
con.print("occupancy\n");
print_bits<uint32_t>(block.occupancy[tileX][tileY].whole,
con);
con.print("\n\n");
}
*/
// tiletype
con.print("tiletype: %d", tiletype);
if(tileName(tiletype))
con.print(" = %s",tileName(tiletype));
con.print("\n");
// tiletype
con.print("tiletype: %d", tiletype);
if(tileName(tiletype))
con.print(" = %s",tileName(tiletype));
con.print("\n");
DFHack::TileShape shape = tileShape(tiletype);
DFHack::TileMaterial material = tileMaterial(tiletype);
DFHack::TileSpecial special = tileSpecial(tiletype);
con.print("%-10s: %4d %s\n","Class" ,shape,
TileShapeString[ shape ]);
con.print("%-10s: %4d %s\n","Material" ,
material,TileMaterialString[ material ]);
con.print("%-10s: %4d %s\n","Special" ,
special, TileSpecialString[ special ]);
con.print("%-10s: %4d\n" ,"Variant" ,
tileVariant(tiletype));
con.print("%-10s: %s\n" ,"Direction",
tileDirection(tiletype).getStr());
con.print("\n");
DFHack::TileShape shape = tileShape(tiletype);
DFHack::TileMaterial material = tileMaterial(tiletype);
DFHack::TileSpecial special = tileSpecial(tiletype);
con.print("%-10s: %4d %s\n","Class" ,shape,
TileShapeString[ shape ]);
con.print("%-10s: %4d %s\n","Material" ,
material,TileMaterialString[ material ]);
con.print("%-10s: %4d %s\n","Special" ,
special, TileSpecialString[ special ]);
con.print("%-10s: %4d\n" ,"Variant" ,
tileVariant(tiletype));
con.print("%-10s: %s\n" ,"Direction",
tileDirection(tiletype).getStr());
con.print("\n");
con.print("temperature1: %d U\n",mc.temperature1At(cursor));
con.print("temperature2: %d U\n",mc.temperature2At(cursor));
con.print("temperature1: %d U\n",mc.temperature1At(cursor));
con.print("temperature2: %d U\n",mc.temperature2At(cursor));
// biome, geolayer
con << "biome: " << des.biome << std::endl;
con << "geolayer: " << des.geolayer_index
<< std::endl;
int16_t base_rock = mc.baseMaterialAt(cursor);
if(base_rock != -1)
{
con << "Layer material: " << dec << base_rock;
if(hasmats)
con << " / " << inorganic[base_rock].id
<< " / "
<< inorganic[base_rock].name
<< endl;
else
con << endl;
}
int16_t vein_rock = mc.veinMaterialAt(cursor);
if(vein_rock != -1)
{
con << "Vein material (final): " << dec << vein_rock;
if(hasmats)
con << " / " << inorganic[vein_rock].id
<< " / "
<< inorganic[vein_rock].name
<< endl;
else
con << endl;
}
// liquids
if(des.flow_size)
{
if(des.liquid_type == DFHack::liquid_magma)
con <<"magma: ";
else con <<"water: ";
con << des.flow_size << std::endl;
}
if(des.flow_forbid)
con << "flow forbid" << std::endl;
if(des.pile)
con << "stockpile?" << std::endl;
if(des.rained)
con << "rained?" << std::endl;
if(des.smooth)
con << "smooth?" << std::endl;
if(des.water_salt)
con << "salty" << endl;
if(des.water_stagnant)
con << "stagnant" << endl;
// biome, geolayer
con << "biome: " << des.bits.biome << std::endl;
con << "geolayer: " << des.bits.geolayer_index
<< std::endl;
int16_t base_rock = mc.baseMaterialAt(cursor);
if(base_rock != -1)
{
con << "Layer material: " << dec << base_rock;
if(hasmats)
con << " / " << inorganic[base_rock].id
<< " / "
<< inorganic[base_rock].name
<< endl;
else
con << endl;
}
int16_t vein_rock = mc.veinMaterialAt(cursor);
if(vein_rock != -1)
{
con << "Vein material (final): " << dec << vein_rock;
if(hasmats)
con << " / " << inorganic[vein_rock].id
<< " / "
<< inorganic[vein_rock].name
<< endl;
else
con << endl;
}
// liquids
if(des.bits.flow_size)
{
if(des.bits.liquid_type == df::tile_liquid::Magma)
con <<"magma: ";
else con <<"water: ";
con << des.bits.flow_size << std::endl;
}
if(des.bits.flow_forbid)
con << "flow forbid" << std::endl;
if(des.bits.pile)
con << "stockpile?" << std::endl;
if(des.bits.rained)
con << "rained?" << std::endl;
if(des.bits.smooth)
con << "smooth?" << std::endl;
if(des.bits.water_salt)
con << "salty" << endl;
if(des.bits.water_stagnant)
con << "stagnant" << endl;
#define PRINT_FLAG( X ) con.print("%-16s= %c\n", #X , ( des.X ? 'Y' : ' ' ) )
PRINT_FLAG( hidden );
PRINT_FLAG( light );
PRINT_FLAG( skyview );
PRINT_FLAG( subterranean );
PRINT_FLAG( water_table );
PRINT_FLAG( rained );
#define PRINT_FLAG( X ) con.print("%-16s= %c\n", #X , ( des.X ? 'Y' : ' ' ) )
PRINT_FLAG( bits.hidden );
PRINT_FLAG( bits.light );
PRINT_FLAG( bits.outside );
PRINT_FLAG( bits.subterranean );
PRINT_FLAG( bits.water_table );
PRINT_FLAG( bits.rained );
DFCoord pc(blockX, blockY);
df::coord2d pc(blockX, blockY);
if(have_features)
{
t_feature * local = 0;
t_feature * global = 0;
Maps->ReadFeatures(&(b->raw),&local,&global);
PRINT_FLAG( feature_local );
if(local)
{
con.print("%-16s", "");
con.print(" %4d", block.local_feature);
con.print(" (%2d)", local->type);
con.print(" addr 0x%X ", local->origin);
con.print(" %s\n", sa_feature(local->type));
}
PRINT_FLAG( feature_global );
if(global)
{
con.print("%-16s", "");
con.print(" %4d", block.global_feature);
con.print(" (%2d)", global->type);
con.print(" %s\n", sa_feature(global->type));
}
}
else
{
PRINT_FLAG( feature_local );
PRINT_FLAG( feature_global );
}
#undef PRINT_FLAG
con << "local feature idx: " << block.local_feature
<< endl;
con << "global feature idx: " << block.global_feature
<< endl;
con << "mystery: " << block.mystery << endl;
con << std::endl;
}
else
{
con.printerr("No data.\n");
}
}
t_feature local;
t_feature global;
Maps::ReadFeatures(&(b->raw),&local,&global);
PRINT_FLAG( bits.feature_local );
if(local.type != -1)
{
con.print("%-16s", "");
con.print(" %4d", block.local_feature);
con.print(" (%2d)", local.type);
con.print(" addr 0x%X ", local.origin);
con.print(" %s\n", sa_feature(local.type));
}
PRINT_FLAG( bits.feature_global );
if(global.type != -1)
{
con.print("%-16s", "");
con.print(" %4d", block.global_feature);
con.print(" (%2d)", global.type);
con.print(" %s\n", sa_feature(global.type));
}
#undef PRINT_FLAG
con << "local feature idx: " << block.local_feature
<< endl;
con << "global feature idx: " << block.global_feature
<< endl;
con << "mystery: " << block.mystery << endl;
con << std::endl;
c->Resume();
return CR_OK;
}

@ -68,9 +68,6 @@ bool operator>(const matdata & q1, const matdata & q2)
typedef std::map<int16_t, matdata> MatMap;
typedef std::vector< pair<int16_t, matdata> > MatSorter;
typedef std::vector<DFHack::t_feature> FeatureList;
typedef std::vector<DFHack::t_feature*> FeatureListPointer;
typedef std::map<DFHack::DFCoord, FeatureListPointer> FeatureMap;
typedef std::vector<DFHack::df_plant *> PlantList;
#define TO_PTR_VEC(obj_vec, ptr_vec) \
@ -196,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++)
{
@ -203,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"
@ -215,21 +217,21 @@ 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;
}
}
uint32_t x_max = 0, y_max = 0, z_max = 0;
c->Suspend();
DFHack::Maps *maps = c->getMaps();
if (!maps->Start())
if (!Maps::IsValid())
{
con.printerr("Cannot get map info!\n");
c->con.printerr("Map is not available!\n");
c->Resume();
return CR_FAILURE;
}
maps->getSize(x_max, y_max, z_max);
MapExtras::MapCache map(maps);
Maps::getSize(x_max, y_max, z_max);
MapExtras::MapCache map;
DFHack::Materials *mats = c->getMaterials();
if (!mats->df_inorganic)
@ -244,10 +246,8 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
showPlants = false;
}
FeatureList globalFeatures;
FeatureMap localFeatures;
DFHack::t_feature *blockFeatureGlobal = 0;
DFHack::t_feature *blockFeatureLocal = 0;
DFHack::t_feature blockFeatureGlobal;
DFHack::t_feature blockFeatureLocal;
bool hasAquifer = false;
bool hasDemonTemple = false;
@ -261,16 +261,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
matdata liquidWater;
matdata liquidMagma;
matdata aquiferTiles;
if (!(showSlade && maps->ReadGlobalFeatures(globalFeatures)))
{
con.printerr("Unable to read global features; slade won't be listed!\n");
}
if (!maps->ReadLocalFeatures(localFeatures))
{
con.printerr("Unable to read local features; adamantine and demon temples won't be listed.\n" );
}
matdata tubeTiles;
uint32_t vegCount = 0;
DFHack::Vegetation *veg = c->getVegetation();
@ -286,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,23 +285,13 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
}
{ // Find features
uint16_t index = b->raw.global_feature;
if (index != -1 && index < globalFeatures.size())
{
blockFeatureGlobal = &globalFeatures[index];
}
uint32_t index = b->raw.global_feature;
if (index != -1)
Maps::GetGlobalFeature(blockFeatureGlobal, index);
index = b->raw.local_feature;
FeatureMap::const_iterator it = localFeatures.find(blockCoord);
if (it != localFeatures.end())
{
FeatureListPointer features = it->second;
if (index != -1 && index < features.size())
{
blockFeatureLocal = features[index];
}
}
if (index != -1)
Maps::GetLocalFeature(blockFeatureLocal, blockCoord, index);
}
int global_z = df::global::world->map.region_z + z;
@ -320,9 +301,9 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
{
for(uint32_t x = 0; x < 16; x++)
{
DFHack::DFCoord coord(x, y);
DFHack::t_designation des = b->DesignationAt(coord);
DFHack::t_occupancy occ = b->OccupancyAt(coord);
df::coord2d coord(x, y);
df::tile_designation des = b->DesignationAt(coord);
df::tile_occupancy occ = b->OccupancyAt(coord);
// Skip hidden tiles
if (!showHidden && des.bits.hidden)
@ -346,7 +327,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
// Check for liquid
if (des.bits.flow_size)
{
if (des.bits.liquid_type == liquid_magma)
if (des.bits.liquid_type == df::tile_liquid::Magma)
liquidMagma.add(global_z);
else
liquidWater.add(global_z);
@ -368,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;
}
@ -386,25 +377,25 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
veinMats[b->veinMaterialAt(coord)].add(global_z);
break;
case DFHack::FEATSTONE:
if (blockFeatureLocal && des.bits.feature_local)
if (blockFeatureLocal.type != -1 && des.bits.feature_local)
{
if (blockFeatureLocal->type == DFHack::feature_Adamantine_Tube
&& blockFeatureLocal->main_material == 0) // stone
if (blockFeatureLocal.type == df::feature_type::deep_special_tube
&& blockFeatureLocal.main_material == 0) // stone
{
veinMats[blockFeatureLocal->sub_material].add(global_z);
veinMats[blockFeatureLocal.sub_material].add(global_z);
}
else if (showTemple
&& blockFeatureLocal->type == DFHack::feature_Hell_Temple)
&& blockFeatureLocal.type == df::feature_type::deep_surface_portal)
{
hasDemonTemple = true;
}
}
if (showSlade && blockFeatureGlobal && des.bits.feature_global
&& blockFeatureGlobal->type == DFHack::feature_Underworld
&& blockFeatureGlobal->main_material == 0) // stone
if (showSlade && blockFeatureGlobal.type != -1 && des.bits.feature_global
&& blockFeatureGlobal.type == df::feature_type::feature_underworld_from_layer
&& blockFeatureGlobal.main_material == 0) // stone
{
layerMats[blockFeatureGlobal->sub_material].add(global_z);
layerMats[blockFeatureGlobal.sub_material].add(global_z);
}
break;
case DFHack::OBSIDIAN:
@ -419,12 +410,12 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
if (showPlants)
{
PlantList * plants;
if (maps->ReadVegetation(b_x, b_y, z, plants))
if (Maps::ReadVegetation(b_x, b_y, z, plants))
{
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)
{
@ -492,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;
@ -508,7 +505,6 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
veg->Finish();
}
mats->Finish();
maps->Finish();
c->Resume();
con << std::endl;
return CR_OK;

@ -12,25 +12,25 @@
#include "modules/Gui.h"
using MapExtras::MapCache;
using namespace DFHack;
using df::global::world;
/*
* Anything that might reveal Hell is unsafe.
*/
bool isSafe(uint32_t x, uint32_t y, uint32_t z, DFHack::Maps *Maps)
bool isSafe(df::coord c)
{
DFHack::t_feature *local_feature = NULL;
DFHack::t_feature *global_feature = NULL;
DFHack::t_feature local_feature;
DFHack::t_feature global_feature;
// get features of block
// error -> obviously not safe to manipulate
if(!Maps->ReadFeatures(x,y,z,&local_feature,&global_feature))
{
if(!Maps::ReadFeatures(c.x >> 4,c.y >> 4,c.z,&local_feature,&global_feature))
return false;
}
// Adamantine tubes and temples lead to Hell
if (local_feature && local_feature->type != DFHack::feature_Other)
if (local_feature.type == df::feature_type::deep_special_tube || local_feature.type == df::feature_type::deep_surface_portal)
return false;
// And Hell *is* Hell.
if (global_feature && global_feature->type == DFHack::feature_Underworld)
if (global_feature.type == df::feature_type::feature_underworld_from_layer)
return false;
// otherwise it's safe.
return true;
@ -38,9 +38,7 @@ bool isSafe(uint32_t x, uint32_t y, uint32_t z, DFHack::Maps *Maps)
struct hideblock
{
uint32_t x;
uint32_t y;
uint32_t z;
df::coord c;
uint8_t hiddens [16][16];
};
@ -160,7 +158,6 @@ DFhackCExport command_result reveal(DFHack::Core * c, std::vector<std::string> &
}
c->Suspend();
DFHack::Maps *Maps =c->getMaps();
DFHack::World *World =c->getWorld();
t_gamemodes gm;
World->ReadGameMode(gm);
@ -170,51 +167,33 @@ DFhackCExport command_result reveal(DFHack::Core * c, std::vector<std::string> &
c->Resume();
return CR_FAILURE;
}
if(!Maps->Start())
if (!Maps::IsValid())
{
con.printerr("Can't init map.\n");
c->con.printerr("Map is not available!\n");
c->Resume();
return CR_FAILURE;
}
if(no_hell && !Maps->StartFeatures())
{
con.printerr("Unable to read local features; can't reveal map safely.\n");
c->Resume();
return CR_FAILURE;
}
Maps->getSize(x_max,y_max,z_max);
Maps::getSize(x_max,y_max,z_max);
hidesaved.reserve(x_max * y_max * z_max);
for(uint32_t x = 0; x< x_max;x++)
for (uint32_t i = 0; i < world->map.map_blocks.size(); i++)
{
for(uint32_t y = 0; y< y_max;y++)
df::map_block *block = world->map.map_blocks[i];
// in 'no-hell'/'safe' mode, don't reveal blocks with hell and adamantine
if (no_hell && !isSafe(block->map_pos))
continue;
hideblock hb;
hb.c = block->map_pos;
DFHack::designations40d & designations = block->designation;
// for each tile in block
for (uint32_t x = 0; x < 16; x++) for (uint32_t y = 0; y < 16; y++)
{
for(uint32_t z = 0; z< z_max;z++)
{
df_block *block = Maps->getBlock(x,y,z);
if(block)
{
// in 'no-hell'/'safe' mode, don't reveal blocks with hell and adamantine
if (no_hell && !isSafe(x, y, z, Maps))
continue;
hideblock hb;
hb.x = x;
hb.y = y;
hb.z = z;
DFHack::designations40d & designations = block->designation;
// for each tile in block
for (uint32_t i = 0; i < 16;i++) for (uint32_t j = 0; j < 16;j++)
{
// save hidden state of tile
hb.hiddens[i][j] = designations[i][j].bits.hidden;
// set to revealed
designations[i][j].bits.hidden = 0;
}
hidesaved.push_back(hb);
}
}
// save hidden state of tile
hb.hiddens[x][y] = designations[x][y].bits.hidden;
// set to revealed
designations[x][y].bits.hidden = 0;
}
hidesaved.push_back(hb);
}
if(no_hell)
{
@ -255,7 +234,7 @@ DFhackCExport command_result unreveal(DFHack::Core * c, std::vector<std::string>
return CR_FAILURE;
}
c->Suspend();
DFHack::Maps *Maps =c->getMaps();
DFHack::World *World =c->getWorld();
t_gamemodes gm;
World->ReadGameMode(gm);
@ -265,17 +244,16 @@ DFhackCExport command_result unreveal(DFHack::Core * c, std::vector<std::string>
c->Resume();
return CR_FAILURE;
}
Maps = c->getMaps();
if(!Maps->Start())
if (!Maps::IsValid())
{
con.printerr("Can't init map.\n");
c->con.printerr("Map is not available!\n");
c->Resume();
return CR_FAILURE;
}
// Sanity check: map size
uint32_t x_max_b, y_max_b, z_max_b;
Maps->getSize(x_max_b,y_max_b,z_max_b);
Maps::getSize(x_max_b,y_max_b,z_max_b);
if(x_max != x_max_b || y_max != y_max_b || z_max != z_max_b)
{
con.printerr("The map is not of the same size...\n");
@ -283,15 +261,13 @@ DFhackCExport command_result unreveal(DFHack::Core * c, std::vector<std::string>
return CR_FAILURE;
}
// FIXME: add more sanity checks / MAP ID
for(size_t i = 0; i < hidesaved.size();i++)
{
hideblock & hb = hidesaved[i];
df_block * b = Maps->getBlock(hb.x,hb.y,hb.z);
for (uint32_t i = 0; i < 16;i++) for (uint32_t j = 0; j < 16;j++)
df::map_block * b = Maps::getBlockAbs(hb.c.x,hb.c.y,hb.c.z);
for (uint32_t x = 0; x < 16;x++) for (uint32_t y = 0; y < 16;y++)
{
b->designation[i][j].bits.hidden = hb.hiddens[i][j];
b->designation[x][y].bits.hidden = hb.hiddens[x][y];
}
}
// give back memory.
@ -336,13 +312,11 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string>
}
c->Suspend();
uint32_t x_max,y_max,z_max;
Maps * Maps = c->getMaps();
Gui * Gui = c->getGui();
World * World = c->getWorld();
// init the map
if(!Maps->Start())
if (!Maps::IsValid())
{
c->con.printerr("Can't init map. Make sure you have a map loaded in DF.\n");
c->con.printerr("Map is not available!\n");
c->Resume();
return CR_FAILURE;
}
@ -361,7 +335,7 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string>
return CR_FAILURE;
}
int32_t cx, cy, cz;
Maps->getSize(x_max,y_max,z_max);
Maps::getSize(x_max,y_max,z_max);
uint32_t tx_max = x_max * 16;
uint32_t ty_max = y_max * 16;
@ -373,7 +347,7 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string>
return CR_FAILURE;
}
DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
MapCache * MCache = new MapCache(Maps);
MapCache * MCache = new MapCache;
int16_t tt = MCache->tiletypeAt(xy);
if(isWallTerrain(tt))
{
@ -383,24 +357,15 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string>
return CR_FAILURE;
}
// hide all tiles, flush cache
Maps->getSize(x_max,y_max,z_max);
Maps::getSize(x_max,y_max,z_max);
for(uint32_t x = 0; x< x_max;x++)
for(uint32_t i = 0; i < world->map.map_blocks.size(); i++)
{
for(uint32_t y = 0; y< y_max;y++)
df::map_block * b = world->map.map_blocks[i];
// change the hidden flag to 0
for (uint32_t x = 0; x < 16; x++) for (uint32_t y = 0; y < 16; y++)
{
for(uint32_t z = 0; z< z_max;z++)
{
df_block * b = Maps->getBlock(x,y,z);
if(b)
{
// change the hidden flag to 0
for (uint32_t i = 0; i < 16;i++) for (uint32_t j = 0; j < 16;j++)
{
b->designation[i][j].bits.hidden = 1;
}
}
}
b->designation[x][y].bits.hidden = 1;
}
}
MCache->trash();
@ -419,7 +384,7 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string>
if(!MCache->testCoord(current))
continue;
int16_t tt = MCache->tiletypeAt(current);
t_designation des = MCache->designationAt(current);
df::tile_designation des = MCache->designationAt(current);
if(!des.bits.hidden)
{
continue;

@ -19,6 +19,7 @@ using std::set;
#include "modules/Gui.h"
#include "TileTypes.h"
#include "modules/MapCache.h"
#include "df/tile_dig_designation.h"
using namespace MapExtras;
using namespace DFHack;
@ -640,7 +641,6 @@ DFhackCExport command_result df_tiletypes (Core * c, vector <string> & parameter
uint32_t x_max = 0, y_max = 0, z_max = 0;
int32_t x = 0, y = 0, z = 0;
DFHack::Maps *maps;
DFHack::Gui *gui;
for(int i = 0; i < parameters.size();i++)
{
@ -754,15 +754,14 @@ DFhackCExport command_result df_tiletypes (Core * c, vector <string> & parameter
}
c->Suspend();
maps = c->getMaps();
gui = c->getGui();
if (!maps->Start())
if (!Maps::IsValid())
{
c->con.printerr("Cannot get map info!\n");
c->con.printerr("Map is not available!\n");
c->Resume();
return CR_FAILURE;
}
maps->getSize(x_max, y_max, z_max);
Maps::getSize(x_max, y_max, z_max);
if (!(gui->Start() && gui->getCursorCoords(x,y,z)))
{
@ -773,20 +772,20 @@ DFhackCExport command_result df_tiletypes (Core * c, vector <string> & parameter
c->con.print("Cursor coords: (%d, %d, %d)\n",x,y,z);
DFHack::DFCoord cursor(x,y,z);
MapExtras::MapCache map(maps);
MapExtras::MapCache map;
coord_vec all_tiles = brush->points(map, cursor);
c->con.print("working...\n");
for (coord_vec::iterator iter = all_tiles.begin(); iter != all_tiles.end(); ++iter)
{
const DFHack::TileRow *source = DFHack::getTileRow(map.tiletypeAt(*iter));
DFHack::t_designation des = map.designationAt(*iter);
df::tile_designation des = map.designationAt(*iter);
if ((filter.shape > -1 && filter.shape != source->shape)
|| (filter.material > -1 && filter.material != source->material)
|| (filter.special > -1 && filter.special != source->special)
|| (filter.variant > -1 && filter.variant != source->variant)
|| (filter.dig > -1 && (filter.dig != 0) != (des.bits.dig != DFHack::designation_no))
|| (filter.dig > -1 && (filter.dig != 0) != (des.bits.dig != df::tile_dig_designation::No))
)
{
continue;
@ -865,7 +864,7 @@ DFhackCExport command_result df_tiletypes (Core * c, vector <string> & parameter
if (paint.skyview > -1)
{
des.bits.skyview = paint.skyview;
des.bits.outside = paint.skyview;
}
// Remove liquid from walls, etc
@ -891,7 +890,6 @@ DFhackCExport command_result df_tiletypes (Core * c, vector <string> & parameter
{
c->con.printerr("Something failed horribly! RUN!\n");
}
maps->Finish();
c->Resume();
}
}

@ -10,10 +10,12 @@
#include "PluginManager.h"
#include "modules/Maps.h"
#include "modules/World.h"
#include "modules/MapCache.h"
#include "modules/Gui.h"
using MapExtras::MapCache;
#include "TileTypes.h"
using namespace DFHack;
using namespace DFHack::Simple;
using df::global::world;
DFhackCExport command_result tubefill(DFHack::Core * c, std::vector<std::string> & params);
@ -36,14 +38,8 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
DFhackCExport command_result tubefill(DFHack::Core * c, std::vector<std::string> & params)
{
uint32_t x_max,y_max,z_max;
DFHack::designations40d designations;
DFHack::tiletypes40d tiles;
int32_t oldT, newT;
uint64_t count = 0;
int dirty=0;
for(int i = 0; i < params.size();i++)
{
if(params[i] == "help" || params[i] == "?")
@ -55,71 +51,58 @@ DFhackCExport command_result tubefill(DFHack::Core * c, std::vector<std::string>
}
}
c->Suspend();
DFHack::Maps *Mapz = c->getMaps();
// init the map
if (!Mapz->Start())
if (!Maps::IsValid())
{
c->con.printerr("Can't init map.\n");
c->Resume();
return CR_FAILURE;
}
Mapz->getSize(x_max,y_max,z_max);
if(!Mapz->StartFeatures())
{
c->con.printerr("Can't get map features.\n");
c->con.printerr("Map is not available!\n");
c->Resume();
return CR_FAILURE;
}
// walk the map
for (uint32_t x = 0; x< x_max;x++)
for (uint32_t i = 0; i < world->map.map_blocks.size(); i++)
{
for (uint32_t y = 0; y< y_max;y++)
df::map_block *block = world->map.map_blocks[i];
df::map_block *above = Maps::getBlockAbs(block->map_pos.x, block->map_pos.y, block->map_pos.z + 1);
if (block->local_feature == -1)
continue;
DFHack::t_feature feature;
DFCoord coord(block->map_pos.x >> 4, block->map_pos.y >> 4, block->map_pos.z);
if (!Maps::GetLocalFeature(feature, coord, block->local_feature))
continue;
if (feature.type != df::feature_type::deep_special_tube)
continue;
for (uint32_t x = 0; x < 16; x++)
{
for (uint32_t z = 0; z< z_max;z++)
for (uint32_t y = 0; y < 16; y++)
{
DFHack::t_feature * locf = 0;
DFHack::t_feature * glof = 0;
if (Mapz->ReadFeatures(x,y,z,&locf,&glof))
{
// we're looking for addy tubes
if(!locf) continue;
if(locf->type != DFHack::feature_Adamantine_Tube) continue;
if (!block->designation[x][y].bits.feature_local)
continue;
dirty=0;
Mapz->ReadDesignations(x,y,z, &designations);
Mapz->ReadTileTypes(x,y,z, &tiles);
// Is the tile already a wall?
if (tileShape(block->tiletype[x][y]) == WALL)
continue;
for (uint32_t ty=0;ty<16;++ty)
{
for (uint32_t tx=0;tx<16;++tx)
{
if(!designations[tx][ty].bits.feature_local) continue;
oldT = tiles[tx][ty];
if ( DFHack::tileShape(oldT) != DFHack::WALL )
{
//Current tile is not a wall.
//Set current tile, as accurately as can be expected
//newT = DFHack::findSimilarTileType(oldT,DFHack::WALL);
newT = DFHack::findTileType( DFHack::WALL, DFHack::FEATSTONE, DFHack::tilevariant_invalid, DFHack::TILE_NORMAL, DFHack::TileDirection() );
// Does the tile contain liquid?
if (block->designation[x][y].bits.flow_size)
continue;
//If no change, skip it (couldn't find a good tile type)
if ( oldT == newT) continue;
//Set new tile type, clear designation
tiles[tx][ty] = newT;
dirty=1;
++count;
}
}
}
//If anything was changed, write it all.
if (dirty)
// Set current tile, as accurately as can be expected
// block->tiletype[x][y] = findSimilarTileType(block->tiletype[x][y], WALL);
// Check the tile above this one, in case we need to add a floor
if (above)
{
if ((tileShape(above->tiletype[x][y]) == EMPTY) || (tileShape(above->tiletype[x][y]) == RAMP_TOP))
{
Mapz->WriteTileTypes(x,y,z, &tiles);
// if this tile isn't a local feature, it's likely the tile underneath was originally just a floor
// it's also possible there was just solid non-feature stone above, but we don't care enough to check
if (!above->designation[x][y].bits.feature_local)
continue;
above->tiletype[x][y] = findTileType(FLOOR, FEATSTONE, tilevariant_invalid, TILE_NORMAL, TileDirection());
}
}
block->tiletype[x][y] = findTileType(WALL, FEATSTONE, tilevariant_invalid, TILE_NORMAL, TileDirection());
++count;
}
}
}

@ -70,7 +70,7 @@ enum circle_what
bool dig (MapExtras::MapCache & MCache,
circle_what what,
e_designation type,
df::tile_dig_designation type,
int32_t x, int32_t y, int32_t z,
int x_max, int y_max
)
@ -90,7 +90,7 @@ bool dig (MapExtras::MapCache & MCache,
return false;
}
uint16_t tt = MCache.tiletypeAt(at);
t_designation des = MCache.designationAt(at);
df::tile_designation des = MCache.designationAt(at);
// could be potentially used to locate hidden constructions?
if(tileMaterial(tt) == CONSTRUCTED && !des.bits.hidden)
return false;
@ -107,7 +107,7 @@ bool dig (MapExtras::MapCache & MCache,
break;
}
if(isFloorTerrain(tt)
&& (type == designation_d_stair || type == designation_channel)
&& (type == df::tile_dig_designation::DownStair || type == df::tile_dig_designation::Channel)
&& ts != TREE_OK
&& ts != TREE_DEAD
)
@ -115,7 +115,7 @@ bool dig (MapExtras::MapCache & MCache,
std::cerr << "allowing tt" << tt << ", is floor\n";
break;
}
if(isStairTerrain(tt) && type == designation_channel )
if(isStairTerrain(tt) && type == df::tile_dig_designation::Channel )
break;
return false;
}
@ -124,25 +124,25 @@ bool dig (MapExtras::MapCache & MCache,
switch(what)
{
case circle_set:
if(des.bits.dig == designation_no)
if(des.bits.dig == df::tile_dig_designation::No)
{
des.bits.dig = type;
}
break;
case circle_unset:
if (des.bits.dig != designation_no)
if (des.bits.dig != df::tile_dig_designation::No)
{
des.bits.dig = designation_no;
des.bits.dig = df::tile_dig_designation::No;
}
break;
case circle_invert:
if(des.bits.dig == designation_no)
if(des.bits.dig == df::tile_dig_designation::No)
{
des.bits.dig = type;
}
else
{
des.bits.dig = designation_no;
des.bits.dig = df::tile_dig_designation::No;
}
break;
}
@ -153,7 +153,7 @@ bool dig (MapExtras::MapCache & MCache,
bool lineX (MapExtras::MapCache & MCache,
circle_what what,
e_designation type,
df::tile_dig_designation type,
int32_t y1, int32_t y2, int32_t x, int32_t z,
int x_max, int y_max
)
@ -167,7 +167,7 @@ bool lineX (MapExtras::MapCache & MCache,
bool lineY (MapExtras::MapCache & MCache,
circle_what what,
e_designation type,
df::tile_dig_designation type,
int32_t x1, int32_t x2, int32_t y, int32_t z,
int x_max, int y_max
)
@ -183,7 +183,7 @@ DFhackCExport command_result digcircle (Core * c, vector <string> & parameters)
{
static bool filled = false;
static circle_what what = circle_set;
static e_designation type = designation_default;
static df::tile_dig_designation type = df::tile_dig_designation::Default;
static int diameter = 0;
auto saved_d = diameter;
bool force_help = false;
@ -215,27 +215,27 @@ DFhackCExport command_result digcircle (Core * c, vector <string> & parameters)
}
else if(parameters[i] == "dig")
{
type = designation_default;
type = df::tile_dig_designation::Default;
}
else if(parameters[i] == "ramp")
{
type = designation_ramp;
type = df::tile_dig_designation::Ramp;
}
else if(parameters[i] == "dstair")
{
type = designation_d_stair;
type = df::tile_dig_designation::DownStair;
}
else if(parameters[i] == "ustair")
{
type = designation_u_stair;
type = df::tile_dig_designation::UpStair;
}
else if(parameters[i] == "xstair")
{
type = designation_ud_stair;
type = df::tile_dig_designation::UpDownStair;
}
else if(parameters[i] == "chan")
{
type = designation_channel;
type = df::tile_dig_designation::Channel;
}
else if (!from_string(diameter,parameters[i], std::dec))
{
@ -275,18 +275,17 @@ DFhackCExport command_result digcircle (Core * c, vector <string> & parameters)
int32_t cx, cy, cz;
c->Suspend();
Gui * gui = c->getGui();
Maps * maps = c->getMaps();
if(!maps->Start())
if (!Maps::IsValid())
{
c->con.printerr("Map is not available!\n");
c->Resume();
c->con.printerr("Can't init the map...\n");
return CR_FAILURE;
}
uint32_t x_max, y_max, z_max;
maps->getSize(x_max,y_max,z_max);
Maps::getSize(x_max,y_max,z_max);
MapExtras::MapCache MCache (maps);
MapExtras::MapCache MCache;
if(!gui->getCursorCoords(cx,cy,cz) || cx == -30000)
{
c->Resume();
@ -726,13 +725,12 @@ enum explo_what
EXPLO_DESIGNATED,
};
bool stamp_pattern (DFHack::Maps * maps,
uint32_t bx, uint32_t by, int z_level,
bool stamp_pattern (uint32_t bx, uint32_t by, int z_level,
digmask & dm, explo_how how, explo_what what,
int x_max, int y_max
)
{
df_block * bl = maps->getBlock(bx,by,z_level);
df::map_block * bl = Maps::getBlock(bx,by,z_level);
if(!bl)
return false;
int x = 0,mx = 16;
@ -749,34 +747,34 @@ bool stamp_pattern (DFHack::Maps * maps,
my = 15;
for(; y < my; y++)
{
naked_designation & des = bl->designation[x][y].bits;
df::tile_designation & des = bl->designation[x][y];
short unsigned int tt = bl->tiletype[x][y];
// could be potentially used to locate hidden constructions?
if(tileMaterial(tt) == CONSTRUCTED && !des.hidden)
if(tileMaterial(tt) == CONSTRUCTED && !des.bits.hidden)
continue;
if(!isWallTerrain(tt) && !des.hidden)
if(!isWallTerrain(tt) && !des.bits.hidden)
continue;
if(how == EXPLO_CLEAR)
{
des.dig = designation_no;
des.bits.dig = df::tile_dig_designation::No;
continue;
}
if(dm[y][x])
{
if(what == EXPLO_ALL
|| des.dig == designation_default && what == EXPLO_DESIGNATED
|| des.hidden && what == EXPLO_HIDDEN)
|| des.bits.dig == df::tile_dig_designation::Default && what == EXPLO_DESIGNATED
|| des.bits.hidden && what == EXPLO_HIDDEN)
{
des.dig = designation_default;
des.bits.dig = df::tile_dig_designation::Default;
}
}
else if(what == EXPLO_DESIGNATED)
{
des.dig = designation_no;
des.bits.dig = df::tile_dig_designation::No;
}
}
}
bl->flags.set(BLOCK_DESIGNATED);
bl->flags.set(df::block_flags::Designated);
return true;
};
@ -854,15 +852,14 @@ DFhackCExport command_result expdig (Core * c, vector <string> & parameters)
}
c->Suspend();
Gui * gui = c->getGui();
Maps * maps = c->getMaps();
uint32_t x_max, y_max, z_max;
if(!maps->Start())
if (!Maps::IsValid())
{
c->con.printerr("Map is not available!\n");
c->Resume();
c->con.printerr("Can't init the map...\n");
return CR_FAILURE;
}
maps->getSize(x_max,y_max,z_max);
Maps::getSize(x_max,y_max,z_max);
int32_t xzzz,yzzz,z_level;
if(!gui->getViewCoords(xzzz,yzzz,z_level))
{
@ -878,7 +875,7 @@ DFhackCExport command_result expdig (Core * c, vector <string> & parameters)
for(int32_t y = 0 ; y < y_max; y++)
{
which = (4*x + y) % 5;
stamp_pattern(maps, x,y_max - 1 - y, z_level, diag5[which],
stamp_pattern(x,y_max - 1 - y, z_level, diag5[which],
how, what, x_max, y_max);
}
}
@ -891,7 +888,7 @@ DFhackCExport command_result expdig (Core * c, vector <string> & parameters)
for(int32_t y = 0 ; y < y_max; y++)
{
which = (4*x + 1000-y) % 5;
stamp_pattern(maps, x,y_max - 1 - y, z_level, diag5r[which],
stamp_pattern(x,y_max - 1 - y, z_level, diag5r[which],
how, what, x_max, y_max);
}
}
@ -904,7 +901,7 @@ DFhackCExport command_result expdig (Core * c, vector <string> & parameters)
which = x % 3;
for(int32_t y = 0 ; y < y_max; y++)
{
stamp_pattern(maps, x, y, z_level, ladder[which],
stamp_pattern(x, y, z_level, ladder[which],
how, what, x_max, y_max);
}
}
@ -917,7 +914,7 @@ DFhackCExport command_result expdig (Core * c, vector <string> & parameters)
which = y % 3;
for(uint32_t x = 0; x < x_max; x++)
{
stamp_pattern(maps, x, y, z_level, ladderr[which],
stamp_pattern(x, y, z_level, ladderr[which],
how, what, x_max, y_max);
}
}
@ -927,7 +924,7 @@ DFhackCExport command_result expdig (Core * c, vector <string> & parameters)
// middle + recentering for the image
int xmid = x_max * 8 - 8;
int ymid = y_max * 8 - 8;
MapExtras::MapCache mx (maps);
MapExtras::MapCache mx;
for(int x = 0; x < 16; x++)
for(int y = 0; y < 16; y++)
{
@ -935,14 +932,14 @@ DFhackCExport command_result expdig (Core * c, vector <string> & parameters)
short unsigned int tt = mx.tiletypeAt(pos);
if(tt == 0)
continue;
t_designation des = mx.designationAt(pos);
df::tile_designation des = mx.designationAt(pos);
if(tileMaterial(tt) == CONSTRUCTED && !des.bits.hidden)
continue;
if(!isWallTerrain(tt) && !des.bits.hidden)
continue;
if(cross[y][x])
{
des.bits.dig = designation_default;
des.bits.dig = df::tile_dig_designation::Default;
mx.setDesignationAt(pos,des);
}
}
@ -952,7 +949,7 @@ DFhackCExport command_result expdig (Core * c, vector <string> & parameters)
{
for(int32_t y = 0 ; y < y_max; y++)
{
stamp_pattern(maps, x, y, z_level, all_tiles,
stamp_pattern(x, y, z_level, all_tiles,
how, what, x_max, y_max);
}
}
@ -983,17 +980,15 @@ DFhackCExport command_result vdig (Core * c, vector <string> & parameters)
Console & con = c->con;
DFHack::Maps * Maps = c->getMaps();
DFHack::Gui * Gui = c->getGui();
// init the map
if(!Maps->Start())
if (!Maps::IsValid())
{
con.printerr("Can't init map. Make sure you have a map loaded in DF.\n");
c->con.printerr("Map is not available!\n");
return CR_FAILURE;
}
int32_t cx, cy, cz;
Maps->getSize(x_max,y_max,z_max);
Maps::getSize(x_max,y_max,z_max);
uint32_t tx_max = x_max * 16;
uint32_t ty_max = y_max * 16;
Gui->getCursorCoords(cx,cy,cz);
@ -1008,8 +1003,8 @@ DFhackCExport command_result vdig (Core * c, vector <string> & parameters)
con.printerr("I won't dig the borders. That would be cheating!\n");
return CR_FAILURE;
}
MapExtras::MapCache * MCache = new MapExtras::MapCache(Maps);
DFHack::t_designation des = MCache->designationAt(xy);
MapExtras::MapCache * MCache = new MapExtras::MapCache;
df::tile_designation des = MCache->designationAt(xy);
int16_t tt = MCache->tiletypeAt(xy);
int16_t veinmat = MCache->veinMaterialAt(xy);
if( veinmat == -1 )
@ -1034,9 +1029,9 @@ DFhackCExport command_result vdig (Core * c, vector <string> & parameters)
continue;
// found a good tile, dig+unset material
DFHack::t_designation des = MCache->designationAt(current);
DFHack::t_designation des_minus;
DFHack::t_designation des_plus;
df::tile_designation des = MCache->designationAt(current);
df::tile_designation des_minus;
df::tile_designation des_plus;
des_plus.whole = des_minus.whole = 0;
int16_t vmat_minus = -1;
int16_t vmat_plus = -1;
@ -1095,32 +1090,32 @@ DFhackCExport command_result vdig (Core * c, vector <string> & parameters)
{
flood.push(current-1);
if(des_minus.bits.dig == DFHack::designation_d_stair)
des_minus.bits.dig = DFHack::designation_ud_stair;
if(des_minus.bits.dig == df::tile_dig_designation::DownStair)
des_minus.bits.dig = df::tile_dig_designation::UpDownStair;
else
des_minus.bits.dig = DFHack::designation_u_stair;
des_minus.bits.dig = df::tile_dig_designation::UpStair;
MCache->setDesignationAt(current-1,des_minus);
des.bits.dig = DFHack::designation_d_stair;
des.bits.dig = df::tile_dig_designation::DownStair;
}
if(current.z < z_max - 1 && above && vmat_plus == vmat2)
{
flood.push(current+ 1);
if(des_plus.bits.dig == DFHack::designation_u_stair)
des_plus.bits.dig = DFHack::designation_ud_stair;
if(des_plus.bits.dig == df::tile_dig_designation::UpStair)
des_plus.bits.dig = df::tile_dig_designation::UpDownStair;
else
des_plus.bits.dig = DFHack::designation_d_stair;
des_plus.bits.dig = df::tile_dig_designation::DownStair;
MCache->setDesignationAt(current+1,des_plus);
if(des.bits.dig == DFHack::designation_d_stair)
des.bits.dig = DFHack::designation_ud_stair;
if(des.bits.dig == df::tile_dig_designation::DownStair)
des.bits.dig = df::tile_dig_designation::UpDownStair;
else
des.bits.dig = DFHack::designation_u_stair;
des.bits.dig = df::tile_dig_designation::UpStair;
}
}
if(des.bits.dig == DFHack::designation_no)
des.bits.dig = DFHack::designation_default;
if(des.bits.dig == df::tile_dig_designation::No)
des.bits.dig = df::tile_dig_designation::Default;
MCache->setDesignationAt(current,des);
}
}