Rename single character member variables from DFTileTypes to something sensible.

develop
Petr Mrázek 2011-04-17 11:37:36 +02:00
parent 6e607d45d9
commit e255a2cba6
13 changed files with 100 additions and 68 deletions

@ -243,11 +243,11 @@ namespace DFHack
struct TileRow
{
const char * name;
TileClass c;
TileMaterial m;
TileVariant v;
TileSpecial s;
TileDirection d;
TileClass shape;
TileMaterial material;
TileVariant variant;
TileSpecial special;
TileDirection direction;
};
#define TILE_TYPE_ARRAY_LENGTH 520
@ -886,7 +886,7 @@ namespace DFHack
inline
bool LowPassable(uint16_t tiletype)
{
switch(DFHack::tileTypeTable[tiletype].c)
switch(DFHack::tileTypeTable[tiletype].shape)
{
case DFHack::EMPTY:
case DFHack::STAIR_DOWN:
@ -902,7 +902,7 @@ namespace DFHack
inline
bool HighPassable(uint16_t tiletype)
{
switch(DFHack::tileTypeTable[tiletype].c)
switch(DFHack::tileTypeTable[tiletype].shape)
{
case DFHack::EMPTY:
case DFHack::STAIR_DOWN:
@ -926,44 +926,44 @@ namespace DFHack
inline
bool FlowPassable(uint16_t tiletype)
{
TileClass tc = tileTypeTable[tiletype].c;
TileClass tc = tileTypeTable[tiletype].shape;
return tc != WALL && tc != PILLAR && tc != TREE_DEAD && tc != TREE_OK;
};
inline
bool isWallTerrain(int in)
{
return tileTypeTable[in].c >= WALL && tileTypeTable[in].c <= FORTIFICATION ;
return tileTypeTable[in].shape >= WALL && tileTypeTable[in].shape <= FORTIFICATION ;
}
inline
bool isFloorTerrain(int in)
{
return tileTypeTable[in].c >= FLOOR && tileTypeTable[in].c <= PEBBLES;
return tileTypeTable[in].shape >= FLOOR && tileTypeTable[in].shape <= PEBBLES;
}
inline
bool isRampTerrain(int in)
{
return tileTypeTable[in].c == RAMP;
return tileTypeTable[in].shape == RAMP;
}
inline
bool isStairTerrain(int in)
{
return tileTypeTable[in].c >= STAIR_UP && tileTypeTable[in].c <= STAIR_UPDOWN;
return tileTypeTable[in].shape >= STAIR_UP && tileTypeTable[in].shape <= STAIR_UPDOWN;
}
inline
bool isOpenTerrain(int in)
{
return tileTypeTable[in].c == EMPTY;
return tileTypeTable[in].shape == EMPTY;
}
inline
int getVegetationType(int in)
{
return tileTypeTable[in].c;
return tileTypeTable[in].shape;
}
//zilpin: for convenience, when you'll be using the tile information a lot.
@ -984,11 +984,11 @@ namespace DFHack
{
int32_t tt;
for(tt=0;tt<TILE_TYPE_ARRAY_LENGTH; ++tt){
if( tclass>-1 ) if( tclass != tileTypeTable[tt].c ) continue;
if( tmat>-1 ) if( tmat != tileTypeTable[tt].m ) continue;
if( tvar>-1 ) if( tvar != tileTypeTable[tt].v ) continue;
if( tspecial>-1 ) if( tspecial != tileTypeTable[tt].s ) continue;
if( tdir.whole ) if( tdir.whole != tileTypeTable[tt].d.whole ) continue;
if( tclass>-1 ) if( tclass != tileTypeTable[tt].shape ) continue;
if( tmat>-1 ) if( tmat != tileTypeTable[tt].material ) continue;
if( tvar>-1 ) if( tvar != tileTypeTable[tt].variant ) continue;
if( tspecial>-1 ) if( tspecial != tileTypeTable[tt].special ) continue;
if( tdir.whole ) if( tdir.whole != tileTypeTable[tt].direction.whole ) continue;
//Match!
return tt;
}
@ -1023,20 +1023,20 @@ namespace DFHack
#endif
for(tt=0;tt<TILE_TYPE_ARRAY_LENGTH; ++tt){
if( tclass == tileTypeTable[tt].c ){
if( tclass == tileTypeTable[tt].shape ){
//shortcut null entries
if(!tileTypeTable[tt].name) continue;
//Special flag match is absolutely mandatory!
if( source->s != tileTypeTable[tt].s ) continue;
if( source->special != tileTypeTable[tt].special ) continue;
maybe=tt; value=0;
//Material is high-value match
if( tileTypeTable[tt].m == source->m ) value|=8;
if( tileTypeTable[tt].material == source->material ) value|=8;
//Direction is medium value match
if( tileTypeTable[tt].d.whole == source->d.whole ) value|=4;
if( tileTypeTable[tt].direction.whole == source->direction.whole ) value|=4;
//Variant is low-value match
if( tileTypeTable[tt].v == source->v ) value|=1;
if( tileTypeTable[tt].variant == source->variant ) value|=1;
//Check value against last match
if( value>matchv ){

@ -20,7 +20,7 @@ void SquashVeins (DFHack::Maps *m, DFHack::DFCoord bcoord, DFHack::mapblock40d &
for (uint32_t k = 0; k< 16;k++)
{
int16_t tt = mb.tiletypes[k][j];
DFHack::TileMaterial mat = DFHack::tileTypeTable[tt].m;
DFHack::TileMaterial mat = DFHack::tileTypeTable[tt].material;
if(mat == DFHack::VEIN)
{
for(int i = (int) veins.size() - 1; i >= 0;i--)

@ -38,7 +38,8 @@ void sort(int32_t &a,int32_t &b)
a = c;
}
}
void printVecOfVec(ostream &out, vector<vector<vector<string> > >vec,char sep){
void printVecOfVec(ostream &out, vector<vector<vector<string> > >vec,char sep)
{
for(int k=0;k<vec.size();k++){
for(int i =0;i<vec[k].size();i++){
for(int j=0;j<vec[k][i].size();j++){
@ -180,7 +181,8 @@ int main (int numargs, const char ** args)
while(1){
int32_t cx1,cy1,cz1;
cx1 = -30000;
while(cx1 == -30000){
while(cx1 == -30000)
{
DF->ForceResume();
cout << "Set cursor at first position, then press any key";
cin.ignore();
@ -195,7 +197,8 @@ int main (int numargs, const char ** args)
int32_t cx2,cy2,cz2;
cx2 = -30000;
while(cx2 == -30000){
while(cx2 == -30000)
{
DF->Resume();
cout << "Set cursor at second position, then press any key";
cin.ignore();
@ -254,12 +257,36 @@ int main (int numargs, const char ** args)
for(int xx = xstart; xx <= xend;xx++)
{
int xidx = xx+(16*(x-tx1)-(cx1%16));
if(DFHack::isOpenTerrain(block.tiletypes[xx][yy]) || DFHack::isFloorTerrain(block.tiletypes[xx][yy])) {dig[zidx][yidx][xidx] = "d";}
else if(DFHack::STAIR_DOWN == DFHack::tileTypeTable[block.tiletypes[xx][yy]].c){ dig [zidx][yidx][xidx] = "j"; build [zidx][yidx][xidx] = "Cd";}
else if(DFHack::STAIR_UP == DFHack::tileTypeTable[block.tiletypes[xx][yy]].c){ dig [zidx][yidx][xidx] = "u"; build [zidx][yidx][xidx] = "Cu";}
else if(DFHack::STAIR_UPDOWN == DFHack::tileTypeTable[block.tiletypes[xx][yy]].c){ dig [zidx][yidx][xidx] = "i"; build [zidx][yidx][xidx] = "Cx";}
else if(DFHack::isRampTerrain(block.tiletypes[xx][yy])){dig [zidx][yidx][xidx] = "r";build [zidx][yidx][xidx] = "Cr";}
else if(DFHack::isWallTerrain(block.tiletypes[xx][yy])){build [zidx][yidx][xidx] = "Cw";}
int16_t tt = block.tiletypes[xx][yy];
DFHack::TileClass ts = DFHack::tileTypeTable[tt].shape;
if(DFHack::isOpenTerrain(tt) || DFHack::isFloorTerrain(tt))
{
dig[zidx][yidx][xidx] = "d";
}
else if(DFHack::STAIR_DOWN == ts)
{
dig [zidx][yidx][xidx] = "j";
build [zidx][yidx][xidx] = "Cd";
}
else if(DFHack::STAIR_UP == ts)
{
dig [zidx][yidx][xidx] = "u";
build [zidx][yidx][xidx] = "Cu";
}
else if(DFHack::STAIR_UPDOWN == ts)
{
dig [zidx][yidx][xidx] = "i";
build [zidx][yidx][xidx] = "Cx";
}
else if(DFHack::isRampTerrain(tt))
{
dig [zidx][yidx][xidx] = "r";
build [zidx][yidx][xidx] = "Cr";
}
else if(DFHack::isWallTerrain(tt))
{
build [zidx][yidx][xidx] = "Cw";
}
}
yidx++;
}

@ -165,7 +165,7 @@ int dig(DFHack::Maps* Maps,
{
if (/*designations[lx][ly].bits.hidden == 0 && */
designations[lx][ly].bits.dig == 0 &&
vec_count(targets, DFHack::tileTypeTable[tiles[lx][ly]].c) > 0)
vec_count(targets, DFHack::tileTypeTable[tiles[lx][ly]].shape) > 0)
{
DigTarget dt(
x, y, z,

@ -78,7 +78,7 @@ void dig(DFHack::Maps* layers, DFHack::Gui* Gui, ::std::vector< ::std::string >&
// ::std::cout << ::std::hex << "designations: " << designations[x_locl][y_locl].bits.dig << ::std::dec << ::std::endl;
if (designations[x_locl][y_locl].bits.dig == DFHack::designation_no && DFHack::tileTypeTable[tiles[x_locl][y_locl]].c == DFHack::WALL) {
if (designations[x_locl][y_locl].bits.dig == DFHack::designation_no && DFHack::tileTypeTable[tiles[x_locl][y_locl]].shape == DFHack::WALL) {
DFHack::e_designation type = DFHack::designation_no;
switch ((char) *chr_it) {
case 'd':

@ -719,7 +719,7 @@ int main (void)
tp = getTileTypeP(block.tiletypes[x][y]);
d = &block.designation[x][y];
//Only modify this level if it's 'empty'
if ( EMPTY != tp->c && RAMP_TOP != tp->c && STAIR_DOWN != tp->c && DFHack::TILE_STREAM_TOP != tp->s)
if ( EMPTY != tp->shape && RAMP_TOP != tp->shape && STAIR_DOWN != tp->shape && DFHack::TILE_STREAM_TOP != tp->shape)
{
continue;
}
@ -787,7 +787,7 @@ int main (void)
tpat=pattern[x][y];
//Tile type material categories
switch ( tp->m )
switch ( tp->material )
{
case AIR:
++emptycount;
@ -804,7 +804,7 @@ int main (void)
//basicly, ignored.
break;
default:
if ( EMPTY == tp->c || RAMP_TOP == tp->c || STAIR_DOWN == tp->c )
if ( EMPTY == tp->shape || RAMP_TOP == tp->shape || STAIR_DOWN == tp->shape )
{
++emptycount;
}
@ -949,7 +949,7 @@ int main (void)
if ( tpat && tpat!=3 && exposemagma )
{
//Leave certain tiles unchanged.
switch ( tp->m )
switch ( tp->material )
{
case HFS:
case FEATSTONE:
@ -1026,7 +1026,7 @@ int main (void)
case 2:
//Wall.
//First guess based on current material
switch ( tp->m )
switch ( tp->material )
{
case OBSIDIAN:
t=wmagma;
@ -1096,7 +1096,7 @@ int main (void)
if ( aquify )
{
//Only normal stone types can be aquified
if ( tp->m!=MAGMA && tp->m!=FEATSTONE && tp->m!=HFS )
if ( tp->material!=MAGMA && tp->material!=FEATSTONE && tp->material!=HFS )
{
//Only place next to the hole.
//If no hole, place in middle.
@ -1221,7 +1221,7 @@ int main (void)
}
//Tile material check.
switch ( tp->m )
switch ( tp->material )
{
case OBSIDIAN:
t=340;

@ -77,11 +77,11 @@ int main (int argc, char **argv)
{
fprintf(f," %*i ; %-*s ; %-*s ; %*c ; %-*s ; %-*s ; %s\n",
Size[0], i,
Size[1], ( tileTypeTable[i].name ? TileClassString[ tileTypeTable[i].c ] : "" ),
Size[2], ( tileTypeTable[i].name ? TileMaterialString[ tileTypeTable[i].m ] : "" ),
Size[3], ( tileTypeTable[i].v ? '0'+tileTypeTable[i].v : ' ' ),
Size[4], ( tileTypeTable[i].s ? TileSpecialString[ tileTypeTable[i].s ] : "" ),
Size[5], ( tileTypeTable[i].d.whole ? tileTypeTable[i].d.getStr() : "" ),
Size[1], ( tileTypeTable[i].name ? TileClassString[ tileTypeTable[i].shape ] : "" ),
Size[2], ( tileTypeTable[i].name ? TileMaterialString[ tileTypeTable[i].material ] : "" ),
Size[3], ( tileTypeTable[i].variant ? '0'+tileTypeTable[i].variant : ' ' ),
Size[4], ( tileTypeTable[i].special ? TileSpecialString[ tileTypeTable[i].special ] : "" ),
Size[5], ( tileTypeTable[i].direction.whole ? tileTypeTable[i].direction.getStr() : "" ),
( tileTypeTable[i].name ? tileTypeTable[i].name : "" ),
0
);

@ -91,7 +91,7 @@ int main (void)
//Only the remove ramp designation (ignore channel designation, etc)
oldT = tiles[tx][ty];
if ( DFHack::designation_default == designations[tx][ty].bits.dig
&& DFHack::RAMP==DFHack::tileTypeTable[oldT].c)
&& DFHack::RAMP==DFHack::tileTypeTable[oldT].shape)
{
//Current tile is a ramp.
//Set current tile, as accurately as can be expected
@ -104,7 +104,7 @@ int main (void)
designations[tx][ty].bits.dig = DFHack::designation_no;
//Check the tile above this one, in case a downward slope needs to be removed.
if ( DFHack::RAMP_TOP == DFHack::tileTypeTable[tilesAbove[tx][ty]].c )
if ( DFHack::RAMP_TOP == DFHack::tileTypeTable[tilesAbove[tx][ty]].shape )
{
tilesAbove[tx][ty] = 32;
}
@ -112,7 +112,7 @@ int main (void)
++count;
}
// ramp fixer
else if(DFHack::RAMP!=DFHack::tileTypeTable[oldT].c && DFHack::RAMP_TOP == DFHack::tileTypeTable[tilesAbove[tx][ty]].c)
else if(DFHack::RAMP!=DFHack::tileTypeTable[oldT].shape && DFHack::RAMP_TOP == DFHack::tileTypeTable[tilesAbove[tx][ty]].shape)
{
tilesAbove[tx][ty] = 32;
countbad++;

@ -87,7 +87,7 @@ int main (void)
{
if(!designations[tx][ty].bits.feature_local) continue;
oldT = tiles[tx][ty];
DFHack::TileClass ttype = DFHack::tileTypeTable[oldT].c;
DFHack::TileClass ttype = DFHack::tileTypeTable[oldT].shape;
if ( ttype != DFHack::WALL )
{
//Current tile is not a wall.

@ -111,12 +111,11 @@ int main (int numargs, const char ** args)
if(tileTypeTable[tiletype].name)
std::cout << " = " << tileTypeTable[tiletype].name << std::endl;
printf("%-10s: %4d %s\n","Class",tileTypeTable[tiletype].c,TileClassString[ tileTypeTable[tiletype].c ]);
printf("%-10s: %4d %s\n","Material",tileTypeTable[tiletype].c,TileMaterialString[ tileTypeTable[tiletype].m ]);
printf("%-10s: %4d %s\n","Special",tileTypeTable[tiletype].c,TileSpecialString[ tileTypeTable[tiletype].s ]);
printf("%-10s: %4d\n","Variant",tileTypeTable[tiletype].v);
printf("%-10s: %s\n","Direction",tileTypeTable[tiletype].d.getStr());
printf("%-10s: %4d %s\n","Class",tileTypeTable[tiletype].shape,TileClassString[ tileTypeTable[tiletype].shape ]);
printf("%-10s: %4d %s\n","Material",tileTypeTable[tiletype].material,TileMaterialString[ tileTypeTable[tiletype].material ]);
printf("%-10s: %4d %s\n","Special",tileTypeTable[tiletype].special,TileSpecialString[ tileTypeTable[tiletype].special ]);
printf("%-10s: %4d\n","Variant",tileTypeTable[tiletype].variant);
printf("%-10s: %s\n","Direction",tileTypeTable[tiletype].direction.getStr());
std::cout << std::endl;
std::cout <<"temperature1: " << mc.temperature1At(cursor) << " U" << std::endl;

@ -158,13 +158,13 @@ int main (int argc, const char* argv[])
// read data
Maps->ReadBlock40d(x,y,z, &Block);
//Maps->ReadTileTypes(x,y,z, &tiletypes);
//Maps->ReadDesignations(x,y,z, &designations);
DFHack::tiletypes40d & tt = Block.tiletypes;
memset(tempvein, -1, sizeof(tempvein));
veins.clear();
Maps->ReadVeins(x,y,z,&veins);
if(showbaselayers)
{
// get the layer materials
@ -172,6 +172,9 @@ int main (int argc, const char* argv[])
{
for (uint32_t yy = 0; yy< 16;yy++)
{
DFHack::TileMaterial mat = DFHack::tileTypeTable[tt[xx][yy]].material;
if(mat != DFHack::SOIL && mat != DFHack::STONE)
continue;
uint8_t test = Block.designation[xx][yy].bits.biome;
if(test > maximum_regionoffset)
maximum_regionoffset = test;
@ -197,6 +200,9 @@ int main (int argc, const char* argv[])
//iterate through the bits
for (uint32_t k = 0; k< 16;k++)
{
DFHack::TileMaterial mat = DFHack::tileTypeTable[tt[k][j]].material;
if(mat != DFHack::VEIN)
continue;
// 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)

@ -127,8 +127,8 @@ int main (int argc, char* argv[])
bool above = 0;
bool sides = 0;
bool unhide = 1;
// by tile class, determine behavior and action
switch (r->c)
// by tile shape, determine behavior and action
switch (r->shape)
{
// walls:
case WALL:

@ -93,7 +93,7 @@ void putwch(int x, int y, int znak, int color)
void puttile(int x, int y, int tiletype, int color)
{
unsigned int znak;
switch(tileTypeTable[tiletype].c)
switch(tileTypeTable[tiletype].shape)
{
case EMPTY:
znak = ' ';
@ -199,7 +199,7 @@ void clrscr()
*/
int pickColor(int tiletype)
{
switch(tileTypeTable[tiletype].m)
switch(tileTypeTable[tiletype].material)
{
case AIR:
return COLOR_BLACK;
@ -792,8 +792,8 @@ int main(int argc, char *argv[])
{
for(int x = 0; x < 16; x++) for(int y = 0; y < 16; y++)
{
TileClass tc = tileTypeTable[Block->tiletypes[x][y]].c;
TileMaterial tm = tileTypeTable[Block->tiletypes[x][y]].m;
TileClass tc = tileTypeTable[Block->tiletypes[x][y]].shape;
TileMaterial tm = tileTypeTable[Block->tiletypes[x][y]].material;
if( tc == WALL && tm == VEIN || tc == TREE_OK || tc == TREE_DEAD)
{
Block->designation[x][y].bits.dig = designation_default;