2010-04-10 18:08:21 -06:00
|
|
|
#include <iostream>
|
|
|
|
#include <integers.h>
|
|
|
|
#include <string.h> // for memset
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <stack>
|
|
|
|
#include <map>
|
|
|
|
#include <stdio.h>
|
2010-04-18 20:42:27 -06:00
|
|
|
#include <cstdlib>
|
2010-04-10 18:08:21 -06:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include <DFTypes.h>
|
|
|
|
#include <DFTileTypes.h>
|
2010-05-23 15:06:10 -06:00
|
|
|
#include <DFContextManager.h>
|
|
|
|
#include <DFContext.h>
|
2010-04-10 18:08:21 -06:00
|
|
|
#include <modules/Maps.h>
|
|
|
|
#include <modules/Position.h>
|
|
|
|
#include <modules/Materials.h>
|
|
|
|
#include <DFTileTypes.h>
|
2010-04-18 20:42:27 -06:00
|
|
|
#include <argstream.h>
|
2010-04-10 18:08:21 -06:00
|
|
|
|
|
|
|
#define MAX_DIM 0x300
|
|
|
|
class Point
|
|
|
|
{
|
|
|
|
public:
|
2010-04-18 20:42:27 -06:00
|
|
|
Point(uint32_t x, uint32_t y, uint32_t z)
|
2010-04-10 18:08:21 -06:00
|
|
|
{
|
|
|
|
this->x = x;
|
|
|
|
this->y = y;
|
2010-04-18 20:42:27 -06:00
|
|
|
this->z = z;
|
|
|
|
}
|
|
|
|
Point()
|
|
|
|
{
|
|
|
|
x = y = z = 0;
|
2010-04-10 18:08:21 -06:00
|
|
|
}
|
|
|
|
bool operator==(const Point &other) const
|
|
|
|
{
|
2010-04-18 20:42:27 -06:00
|
|
|
return (other.x == x && other.y == y && other.z == z);
|
2010-04-10 18:08:21 -06:00
|
|
|
}
|
|
|
|
bool operator<(const Point &other) const
|
|
|
|
{
|
2010-04-18 21:37:57 -06:00
|
|
|
return ( (z*MAX_DIM*MAX_DIM + y*MAX_DIM + x) < (other.z*MAX_DIM*MAX_DIM + other.y*MAX_DIM + other.x));
|
2010-04-10 18:08:21 -06:00
|
|
|
}
|
|
|
|
Point operator/(int number) const
|
|
|
|
{
|
2010-04-18 20:42:27 -06:00
|
|
|
return Point(x/number, y/number, z);
|
2010-04-10 18:08:21 -06:00
|
|
|
}
|
|
|
|
Point operator%(int number) const
|
|
|
|
{
|
2010-04-18 20:42:27 -06:00
|
|
|
return Point(x%number, y%number, z);
|
|
|
|
}
|
|
|
|
Point operator-(int number) const
|
|
|
|
{
|
|
|
|
return Point(x,y,z-number);
|
|
|
|
}
|
|
|
|
Point operator+(int number) const
|
|
|
|
{
|
|
|
|
return Point(x,y,z+number);
|
2010-04-10 18:08:21 -06:00
|
|
|
}
|
|
|
|
uint32_t x;
|
|
|
|
uint32_t y;
|
2010-04-18 20:42:27 -06:00
|
|
|
uint32_t z;
|
2010-04-10 18:08:21 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
class Block
|
|
|
|
{
|
|
|
|
public:
|
2010-04-18 20:42:27 -06:00
|
|
|
Block(DFHack::Maps *_m, Point _bcoord)
|
2010-04-10 18:08:21 -06:00
|
|
|
{
|
|
|
|
vector <DFHack::t_vein> veins;
|
|
|
|
m = _m;
|
|
|
|
dirty = false;
|
|
|
|
valid = false;
|
2010-04-18 20:42:27 -06:00
|
|
|
bcoord = _bcoord;
|
|
|
|
if(m->ReadBlock40d(bcoord.x,bcoord.y,bcoord.z,&raw))
|
2010-04-10 18:08:21 -06:00
|
|
|
{
|
|
|
|
memset(materials,-1,sizeof(materials));
|
|
|
|
memset(bitmap,0,sizeof(bitmap));
|
2010-04-18 20:42:27 -06:00
|
|
|
m->ReadVeins(bcoord.x,bcoord.y,bcoord.z,&veins);
|
2010-04-10 18:08:21 -06:00
|
|
|
// for each vein
|
|
|
|
for(int i = 0; i < (int)veins.size();i++)
|
|
|
|
{
|
|
|
|
//iterate through vein rows
|
|
|
|
for(uint32_t j = 0;j<16;j++)
|
|
|
|
{
|
|
|
|
//iterate through the bits
|
|
|
|
for (uint32_t k = 0; k< 16;k++)
|
|
|
|
{
|
|
|
|
// check if it's really a vein (FIXME: doing this too many times)
|
|
|
|
int16_t tt = raw.tiletypes[k][j];
|
|
|
|
if(DFHack::isWallTerrain(tt) && DFHack::tileTypeTable[tt].m == DFHack::VEIN)
|
|
|
|
{
|
|
|
|
// and the bit array with a one-bit mask, check if the bit is set
|
|
|
|
bool set = !!(((1 << k) & veins[i].assignment[j]) >> k);
|
|
|
|
if(set)
|
|
|
|
{
|
|
|
|
// store matgloss
|
|
|
|
materials[k][j] = veins[i].type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
valid = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int16_t MaterialAt(Point p)
|
|
|
|
{
|
|
|
|
return materials[p.x][p.y];
|
|
|
|
}
|
|
|
|
void ClearMaterialAt(Point p)
|
|
|
|
{
|
|
|
|
materials[p.x][p.y] = -1;
|
|
|
|
}
|
|
|
|
int16_t TileTypeAt(Point p)
|
|
|
|
{
|
|
|
|
return raw.tiletypes[p.x][p.y];
|
|
|
|
}
|
|
|
|
DFHack::t_designation DesignationAt(Point p)
|
|
|
|
{
|
|
|
|
return raw.designation[p.x][p.y];
|
|
|
|
}
|
2010-04-10 18:56:56 -06:00
|
|
|
bool setDesignationAt(Point p, DFHack::t_designation des)
|
2010-04-10 18:08:21 -06:00
|
|
|
{
|
2010-04-10 18:56:56 -06:00
|
|
|
if(!valid) return false;
|
2010-04-10 18:08:21 -06:00
|
|
|
dirty = true;
|
|
|
|
//printf("setting block %d/%d/%d , %d %d\n",x,y,z, p.x, p.y);
|
|
|
|
raw.designation[p.x][p.y] = des;
|
2010-04-10 18:56:56 -06:00
|
|
|
return true;
|
2010-04-10 18:08:21 -06:00
|
|
|
}
|
|
|
|
bool WriteDesignations ()
|
|
|
|
{
|
2010-04-10 18:56:56 -06:00
|
|
|
if(!valid) return false;
|
2010-04-10 18:08:21 -06:00
|
|
|
if(dirty)
|
|
|
|
{
|
|
|
|
//printf("writing %d/%d/%d\n",x,y,z);
|
2010-04-18 20:42:27 -06:00
|
|
|
m->WriteDesignations(bcoord.x,bcoord.y,bcoord.z, &raw.designation);
|
|
|
|
m->WriteDirtyBit(bcoord.x,bcoord.y,bcoord.z,true);
|
2010-04-10 18:08:21 -06:00
|
|
|
}
|
2010-04-10 18:56:56 -06:00
|
|
|
return true;
|
2010-04-10 18:08:21 -06:00
|
|
|
}
|
2010-04-15 14:14:55 -06:00
|
|
|
volatile bool valid;
|
|
|
|
volatile bool dirty;
|
2010-04-10 18:08:21 -06:00
|
|
|
DFHack::Maps * m;
|
|
|
|
DFHack::mapblock40d raw;
|
2010-04-18 20:42:27 -06:00
|
|
|
Point bcoord;
|
2010-04-10 18:08:21 -06:00
|
|
|
int16_t materials[16][16];
|
|
|
|
int8_t bitmap[16][16];
|
|
|
|
};
|
|
|
|
|
2010-04-18 20:42:27 -06:00
|
|
|
class MapCache
|
2010-04-10 18:08:21 -06:00
|
|
|
{
|
|
|
|
public:
|
2010-04-18 20:42:27 -06:00
|
|
|
MapCache(DFHack::Maps * Maps)
|
2010-04-10 18:08:21 -06:00
|
|
|
{
|
|
|
|
valid = 0;
|
|
|
|
this->Maps = Maps;
|
|
|
|
Maps->getSize(x_bmax, y_bmax, z_max);
|
2010-04-18 20:42:27 -06:00
|
|
|
valid = true;
|
2010-04-10 18:08:21 -06:00
|
|
|
};
|
2010-04-18 20:42:27 -06:00
|
|
|
~MapCache()
|
2010-04-10 18:08:21 -06:00
|
|
|
{
|
|
|
|
map<Point, Block *>::iterator p;
|
|
|
|
for(p = blocks.begin(); p != blocks.end(); p++)
|
|
|
|
{
|
|
|
|
delete p->second;
|
|
|
|
//cout << stonetypes[p->first].id << " : " << p->second << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool isValid ()
|
|
|
|
{
|
|
|
|
return valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
Block * BlockAt (Point blockcoord)
|
|
|
|
{
|
|
|
|
if(!valid) return 0;
|
|
|
|
|
|
|
|
map <Point, Block*>::iterator iter = blocks.find(blockcoord);
|
|
|
|
if(iter != blocks.end())
|
|
|
|
{
|
|
|
|
return (*iter).second;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-04-18 20:42:27 -06:00
|
|
|
if(blockcoord.x < x_bmax && blockcoord.y < y_bmax && blockcoord.z < z_max)
|
2010-04-15 14:14:55 -06:00
|
|
|
{
|
2010-04-18 20:42:27 -06:00
|
|
|
Block * nblo = new Block(Maps,blockcoord);
|
2010-04-15 14:14:55 -06:00
|
|
|
blocks[blockcoord] = nblo;
|
|
|
|
return nblo;
|
|
|
|
}
|
|
|
|
return 0;
|
2010-04-10 18:08:21 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t tiletypeAt (Point tilecoord)
|
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
return b->TileTypeAt(tilecoord % 16);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int16_t materialAt (Point tilecoord)
|
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
return b->MaterialAt(tilecoord % 16);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
bool clearMaterialAt (Point tilecoord)
|
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
b->ClearMaterialAt(tilecoord % 16);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DFHack::t_designation designationAt (Point tilecoord)
|
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
return b->DesignationAt(tilecoord % 16);
|
|
|
|
}
|
|
|
|
DFHack:: t_designation temp;
|
|
|
|
temp.whole = 0;
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
bool setDesignationAt (Point tilecoord, DFHack::t_designation des)
|
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
b->setDesignationAt(tilecoord % 16, des);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2010-04-18 20:42:27 -06:00
|
|
|
bool testCoord (Point tilecoord)
|
|
|
|
{
|
|
|
|
Block * b= BlockAt(tilecoord / 16);
|
|
|
|
if(b && b->valid)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2010-04-10 18:08:21 -06:00
|
|
|
|
|
|
|
bool WriteAll()
|
|
|
|
{
|
|
|
|
map<Point, Block *>::iterator p;
|
|
|
|
for(p = blocks.begin(); p != blocks.end(); p++)
|
|
|
|
{
|
|
|
|
p->second->WriteDesignations();
|
|
|
|
//cout << stonetypes[p->first].id << " : " << p->second << endl;
|
|
|
|
}
|
2010-04-10 18:56:56 -06:00
|
|
|
return true;
|
2010-04-10 18:08:21 -06:00
|
|
|
}
|
|
|
|
private:
|
2010-04-15 14:14:55 -06:00
|
|
|
volatile bool valid;
|
2010-04-10 18:08:21 -06:00
|
|
|
uint32_t x_bmax;
|
|
|
|
uint32_t y_bmax;
|
|
|
|
uint32_t x_tmax;
|
|
|
|
uint32_t y_tmax;
|
2010-04-18 20:42:27 -06:00
|
|
|
uint32_t z_max;
|
2010-04-10 18:08:21 -06:00
|
|
|
DFHack::Maps * Maps;
|
|
|
|
map<Point, Block *> blocks;
|
|
|
|
};
|
|
|
|
|
2010-04-18 20:42:27 -06:00
|
|
|
int main (int argc, char* argv[])
|
2010-04-10 18:08:21 -06:00
|
|
|
{
|
2010-04-18 20:42:27 -06:00
|
|
|
// Command line options
|
|
|
|
bool updown = false;
|
|
|
|
argstream as(argc,argv);
|
|
|
|
|
|
|
|
as >>option('x',"updown",updown,"Dig up and down stairs to reach other z-levels.")
|
|
|
|
>>help();
|
|
|
|
|
|
|
|
// sane check
|
|
|
|
if (!as.isOk())
|
|
|
|
{
|
|
|
|
cout << as.errorLog();
|
|
|
|
return 1;
|
|
|
|
}
|
2010-05-23 15:06:10 -06:00
|
|
|
|
|
|
|
DFHack::ContextManager DFMgr("Memory.xml");
|
|
|
|
DFHack::Context * DF;
|
2010-04-10 18:08:21 -06:00
|
|
|
try
|
|
|
|
{
|
2010-05-23 15:06:10 -06:00
|
|
|
DF = DFMgr.getSingleContext();
|
|
|
|
DF->Attach();
|
2010-04-10 18:08:21 -06:00
|
|
|
}
|
|
|
|
catch (exception& e)
|
|
|
|
{
|
|
|
|
cerr << e.what() << endl;
|
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t x_max,y_max,z_max;
|
2010-05-23 15:06:10 -06:00
|
|
|
DFHack::Maps * Maps = DF->getMaps();
|
|
|
|
DFHack::Materials * Mats = DF->getMaterials();
|
|
|
|
DFHack::Position * Pos = DF->getPosition();
|
2010-04-10 18:08:21 -06:00
|
|
|
|
|
|
|
// init the map
|
|
|
|
if(!Maps->Start())
|
|
|
|
{
|
2010-04-10 18:32:50 -06:00
|
|
|
cerr << "Can't init map. Make sure you have a map loaded in DF." << endl;
|
2010-05-23 15:06:10 -06:00
|
|
|
DF->Detach();
|
2010-04-10 18:08:21 -06:00
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t cx, cy, cz;
|
|
|
|
Maps->getSize(x_max,y_max,z_max);
|
2010-04-15 14:14:55 -06:00
|
|
|
uint32_t tx_max = x_max * 16;
|
|
|
|
uint32_t ty_max = y_max * 16;
|
|
|
|
|
2010-04-10 18:08:21 -06:00
|
|
|
Pos->getCursorCoords(cx,cy,cz);
|
|
|
|
while(cx == -30000)
|
|
|
|
{
|
|
|
|
cerr << "Cursor is not active. Point the cursor at a vein." << endl;
|
2010-05-23 15:06:10 -06:00
|
|
|
DF->Resume();
|
2010-04-10 18:08:21 -06:00
|
|
|
cin.ignore();
|
2010-05-23 15:06:10 -06:00
|
|
|
DF->Suspend();
|
2010-04-10 18:08:21 -06:00
|
|
|
Pos->getCursorCoords(cx,cy,cz);
|
|
|
|
}
|
2010-04-18 20:42:27 -06:00
|
|
|
Point xy ((uint32_t)cx,(uint32_t)cy,cz);
|
2010-04-15 14:14:55 -06:00
|
|
|
if(xy.x == 0 || xy.x == tx_max - 1 || xy.y == 0 || xy.y == ty_max - 1)
|
|
|
|
{
|
|
|
|
cerr << "I won't dig the borders. That would be cheating!" << endl;
|
2010-05-23 15:06:10 -06:00
|
|
|
DF->Detach();
|
2010-04-15 14:14:55 -06:00
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
2010-04-18 21:37:57 -06:00
|
|
|
MapCache * MCache = new MapCache(Maps);
|
2010-04-10 18:08:21 -06:00
|
|
|
|
2010-04-15 14:14:55 -06:00
|
|
|
|
2010-04-18 21:37:57 -06:00
|
|
|
DFHack::t_designation des = MCache->designationAt(xy);
|
|
|
|
int16_t tt = MCache->tiletypeAt(xy);
|
|
|
|
int16_t veinmat = MCache->materialAt(xy);
|
2010-04-10 18:08:21 -06:00
|
|
|
|
|
|
|
if( veinmat == -1 )
|
|
|
|
{
|
|
|
|
cerr << "This tile is non-vein. Bye :)" << endl;
|
2010-04-18 21:37:57 -06:00
|
|
|
delete MCache;
|
2010-05-23 15:06:10 -06:00
|
|
|
DF->Detach();
|
2010-04-10 18:08:21 -06:00
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
2010-04-10 18:32:50 -06:00
|
|
|
printf("%d/%d/%d tiletype: %d, veinmat: %d, designation: 0x%x ... DIGGING!\n", cx,cy,cz, tt, veinmat, des.whole);
|
2010-04-10 18:08:21 -06:00
|
|
|
stack <Point> flood;
|
|
|
|
flood.push(xy);
|
2010-04-15 14:14:55 -06:00
|
|
|
|
2010-04-10 18:08:21 -06:00
|
|
|
|
|
|
|
while( !flood.empty() )
|
|
|
|
{
|
|
|
|
Point current = flood.top();
|
|
|
|
flood.pop();
|
2010-04-18 21:37:57 -06:00
|
|
|
int16_t vmat2 = MCache->materialAt(current);
|
2010-04-10 18:08:21 -06:00
|
|
|
|
|
|
|
if(vmat2!=veinmat)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// found a good tile, dig+unset material
|
2010-04-18 20:42:27 -06:00
|
|
|
|
2010-04-18 21:37:57 -06:00
|
|
|
DFHack::t_designation des = MCache->designationAt(current);
|
2010-04-18 20:42:27 -06:00
|
|
|
DFHack::t_designation des_minus;
|
|
|
|
DFHack::t_designation des_plus;
|
2010-04-18 21:37:57 -06:00
|
|
|
des_plus.whole = des_minus.whole = 0;
|
|
|
|
int16_t vmat_minus = -1;
|
|
|
|
int16_t vmat_plus = -1;
|
2010-04-18 20:42:27 -06:00
|
|
|
bool below = 0;
|
|
|
|
bool above = 0;
|
|
|
|
if(updown)
|
|
|
|
{
|
2010-04-18 21:37:57 -06:00
|
|
|
if(MCache->testCoord(current-1))
|
2010-04-18 20:42:27 -06:00
|
|
|
{
|
|
|
|
below = 1;
|
2010-04-18 21:37:57 -06:00
|
|
|
des_minus = MCache->designationAt(current-1);
|
|
|
|
vmat_minus = MCache->materialAt(current-1);
|
2010-04-18 20:42:27 -06:00
|
|
|
}
|
2010-04-18 21:37:57 -06:00
|
|
|
|
|
|
|
if(MCache->testCoord(current+1))
|
2010-04-18 20:42:27 -06:00
|
|
|
{
|
|
|
|
above = 1;
|
2010-04-18 21:37:57 -06:00
|
|
|
des_plus = MCache->designationAt(current+1);
|
|
|
|
vmat_plus = MCache->materialAt(current+1);
|
2010-04-18 20:42:27 -06:00
|
|
|
}
|
|
|
|
}
|
2010-04-18 21:37:57 -06:00
|
|
|
if(MCache->testCoord(current))
|
2010-04-10 18:08:21 -06:00
|
|
|
{
|
2010-04-18 21:37:57 -06:00
|
|
|
MCache->clearMaterialAt(current);
|
2010-04-15 14:14:55 -06:00
|
|
|
if(current.x < tx_max - 2)
|
2010-04-10 18:08:21 -06:00
|
|
|
{
|
2010-04-18 20:42:27 -06:00
|
|
|
flood.push(Point(current.x + 1, current.y, current.z));
|
2010-04-15 14:14:55 -06:00
|
|
|
if(current.y < ty_max - 2)
|
2010-04-10 18:08:21 -06:00
|
|
|
{
|
2010-04-18 20:42:27 -06:00
|
|
|
flood.push(Point(current.x + 1, current.y + 1,current.z));
|
|
|
|
flood.push(Point(current.x, current.y + 1,current.z));
|
2010-04-10 18:08:21 -06:00
|
|
|
}
|
2010-04-15 14:14:55 -06:00
|
|
|
if(current.y > 1)
|
2010-04-10 18:08:21 -06:00
|
|
|
{
|
2010-04-18 20:42:27 -06:00
|
|
|
flood.push(Point(current.x + 1, current.y - 1,current.z));
|
|
|
|
flood.push(Point(current.x, current.y - 1,current.z));
|
2010-04-10 18:08:21 -06:00
|
|
|
}
|
|
|
|
}
|
2010-04-15 14:14:55 -06:00
|
|
|
if(current.x > 1)
|
2010-04-10 18:08:21 -06:00
|
|
|
{
|
2010-04-18 20:42:27 -06:00
|
|
|
flood.push(Point(current.x - 1, current.y,current.z));
|
2010-04-15 14:14:55 -06:00
|
|
|
if(current.y < ty_max - 2)
|
2010-04-10 18:08:21 -06:00
|
|
|
{
|
2010-04-18 20:42:27 -06:00
|
|
|
flood.push(Point(current.x - 1, current.y + 1,current.z));
|
|
|
|
flood.push(Point(current.x, current.y + 1,current.z));
|
2010-04-10 18:08:21 -06:00
|
|
|
}
|
2010-04-15 14:14:55 -06:00
|
|
|
if(current.y > 1)
|
2010-04-10 18:08:21 -06:00
|
|
|
{
|
2010-04-18 20:42:27 -06:00
|
|
|
flood.push(Point(current.x - 1, current.y - 1,current.z));
|
|
|
|
flood.push(Point(current.x, current.y - 1,current.z));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(updown)
|
|
|
|
{
|
|
|
|
if(current.z > 0 && below && vmat_minus == vmat2)
|
|
|
|
{
|
2010-04-18 21:37:57 -06:00
|
|
|
flood.push(current-1);
|
2010-04-18 20:42:27 -06:00
|
|
|
|
|
|
|
if(des_minus.bits.dig == DFHack::designation_d_stair)
|
|
|
|
des_minus.bits.dig = DFHack::designation_ud_stair;
|
|
|
|
else
|
|
|
|
des_minus.bits.dig = DFHack::designation_u_stair;
|
2010-04-18 21:37:57 -06:00
|
|
|
MCache->setDesignationAt(current-1,des_minus);
|
2010-04-18 20:42:27 -06:00
|
|
|
|
|
|
|
des.bits.dig = DFHack::designation_d_stair;
|
|
|
|
}
|
|
|
|
if(current.z < z_max - 1 && above && vmat_plus == vmat2)
|
|
|
|
{
|
2010-04-18 21:37:57 -06:00
|
|
|
flood.push(current+ 1);
|
2010-04-18 20:42:27 -06:00
|
|
|
|
|
|
|
if(des_plus.bits.dig == DFHack::designation_u_stair)
|
|
|
|
des_plus.bits.dig = DFHack::designation_ud_stair;
|
|
|
|
else
|
|
|
|
des_plus.bits.dig = DFHack::designation_d_stair;
|
2010-04-18 21:37:57 -06:00
|
|
|
MCache->setDesignationAt(current+1,des_plus);
|
2010-04-18 20:42:27 -06:00
|
|
|
|
|
|
|
if(des.bits.dig == DFHack::designation_d_stair)
|
|
|
|
des.bits.dig = DFHack::designation_ud_stair;
|
|
|
|
else
|
|
|
|
des.bits.dig = DFHack::designation_u_stair;
|
2010-04-10 18:08:21 -06:00
|
|
|
}
|
|
|
|
}
|
2010-04-18 20:42:27 -06:00
|
|
|
if(des.bits.dig == DFHack::designation_no)
|
|
|
|
des.bits.dig = DFHack::designation_default;
|
2010-04-18 21:37:57 -06:00
|
|
|
MCache->setDesignationAt(current,des);
|
2010-04-10 18:08:21 -06:00
|
|
|
}
|
|
|
|
}
|
2010-04-18 21:37:57 -06:00
|
|
|
MCache->WriteAll();
|
|
|
|
delete MCache;
|
2010-05-23 15:06:10 -06:00
|
|
|
DF->Detach();
|
2010-04-10 18:08:21 -06:00
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cout << "Done. Press any key to continue" << endl;
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|