Fixed includes, unified formatting.

develop
Petr Mrázek 2010-10-25 04:39:14 +02:00
parent 36fb3a2c6a
commit 70cb93d9f4
5 changed files with 1722 additions and 1537 deletions

@ -30,9 +30,9 @@ distribution.
namespace DFHack
{
// tile class -- determines the general shape of the tile
// enum and lookup table for string names created using X macros
#define TILECLASS_MACRO \
// tile class -- determines the general shape of the tile
// enum and lookup table for string names created using X macros
#define TILECLASS_MACRO \
X(EMPTY, "") \
X(WALL, "") \
X(PILLAR, "") \
@ -51,32 +51,32 @@ namespace DFHack
X(SHRUB_OK, "") \
X(BOULDER, "") \
X(PEBBLES, "")
//end TILECLASS_MACRO
//define tile class enum
#define X(name,comment) name,
enum TileClass {
tileclass_invalid=-1,
TILECLASS_MACRO
tileclass_count,
};
#undef X
//Visual Studio screams if you don't do this for the const char* arrays
#ifndef char_p
typedef char * char_p;
#endif
//set tile class string lookup table (e.g. for printing to user)
#define X(name,comment) #name,
const char_p TileClassString[tileclass_count+1] = {
TILECLASS_MACRO
NULL
};
#undef X
#define TILEMATERIAL_MACRO \
//end TILECLASS_MACRO
//define tile class enum
#define X(name,comment) name,
enum TileClass {
tileclass_invalid=-1,
TILECLASS_MACRO
tileclass_count,
};
#undef X
//Visual Studio screams if you don't do this for the const char* arrays
#ifndef char_p
typedef char * char_p;
#endif
//set tile class string lookup table (e.g. for printing to user)
#define X(name,comment) #name,
const char_p TileClassString[tileclass_count+1] = {
TILECLASS_MACRO
0
};
#undef X
#define TILEMATERIAL_MACRO \
X(AIR, "empty" ) \
X(SOIL, "ordinary soil. material depends on geology" ) \
X(STONE, "ordinary layer stone. material depends on geology" ) \
@ -96,30 +96,30 @@ namespace DFHack
X(ASHES, "what remains from a FIRE" ) \
X(CONSTRUCTED,"tile material depends on the construction present" ) \
X(CYAN_GLOW, "the glowy stuff that disappears from the demon temple when you take the sword." )
//end TILEMATERIAL_MACRO
//end TILEMATERIAL_MACRO
// material enum
#define X(name,comment) name,
enum TileMaterial {
tilematerial_invalid=-1,
TILEMATERIAL_MACRO
tilematerial_count,
};
#undef X
//string lookup table (e.g. for printing to user)
#define X(name,comment) #name,
const char_p TileMaterialString[tilematerial_count+1] = {
TILEMATERIAL_MACRO
NULL
};
#undef X
// Special specials of the tile.
// Not the best way to do this, but compatible with existing code.
// When the TileType class gets created, everything should be re-thought.
#define TILESPECIAL_MACRO \
#define X(name,comment) name,
enum TileMaterial {
tilematerial_invalid=-1,
TILEMATERIAL_MACRO
tilematerial_count,
};
#undef X
//string lookup table (e.g. for printing to user)
#define X(name,comment) #name,
const char_p TileMaterialString[tilematerial_count+1] = {
TILEMATERIAL_MACRO
0
};
#undef X
// Special specials of the tile.
// Not the best way to do this, but compatible with existing code.
// When the TileType class gets created, everything should be re-thought.
#define TILESPECIAL_MACRO \
X(NORMAL, "Default for all type, nothing present" ) \
X(SPECIAL, "General purpose, for any unique tile which can not otherwise be differenciated" ) \
X(POOL, "Murky Pool, will gather water from rain" ) \
@ -133,129 +133,134 @@ namespace DFHack
X(DAMAGED, "Walls being dug" ) \
X(WORN, "Walls being dug ??" ) \
X(SMOOTH, "Walls and floors." )
//end TILESPECIAL_MACRO
//special enum
#define X(name,comment) TILE_##name,
enum TileSpecial {
tilespecial_invalid=-1,
TILESPECIAL_MACRO
tilespecial_count,
};
#undef X
//string lookup table (e.g. for printing to user)
#define X(name,comment) #name,
const char_p TileSpecialString[tilespecial_count+1] = {
TILESPECIAL_MACRO
NULL
};
#undef X
//end TILESPECIAL_MACRO
//special enum
#define X(name,comment) TILE_##name,
enum TileSpecial {
tilespecial_invalid=-1,
TILESPECIAL_MACRO
tilespecial_count,
};
#undef X
//string lookup table (e.g. for printing to user)
#define X(name,comment) #name,
const char_p TileSpecialString[tilespecial_count+1] = {
TILESPECIAL_MACRO
0
};
#undef X
// variants are used for tiles, where there are multiple variants of the same - like grass floors
enum TileVariant
{
tilevariant_invalid=-1,
VAR_1, //Yes, the value of VAR_1 is 0. It's legacy. Deal with it.
tilevariant_invalid=-1,
VAR_1, //Yes, the value of VAR_1 is 0. It's legacy. Deal with it.
VAR_2,
VAR_3,
VAR_4,
};
//Mainly walls and rivers
//Byte values are used because walls can have either 1 or 2 in any given direction.
const int TileDirectionCount = 4;
union TileDirection
{
uint32_t whole;
unsigned char b[TileDirectionCount];
struct {
//Maybe should add 'up' and 'down' for Z-levels?
unsigned char north,south,west,east;
};
inline TileDirection()
{
whole = 0;
}
TileDirection( uint32_t whole_bits)
{
whole = whole_bits;
}
TileDirection( unsigned char North, unsigned char South, unsigned char West, unsigned char East )
{
north=North; south=South; east=East; west=West;
}
TileDirection( const char *dir )
{
//This one just made for fun.
//Supports N S E W
const char *p = dir;
unsigned char *l=NULL;
north=south=east=west=0;
if(!dir) return;
for( ;*p;++p){
switch(*p){
case 'N': //North / Up
case 'n':
++north; l=&north; break;
case 'S': //South / Down
case 's':
++south; l=&south; break;
case 'E': //East / Right
case 'e':
++east; l=&east; break;
case 'W': //West / Left
case 'w':
++west; l=&west; break;
case '-':
case ' ':
//Explicitly ensure dash and space are ignored.
//Other characters/symbols may be assigned in the future.
break;
default:
if( l && '0' <= *p && '9' >= *p )
*l += *p - '0';
break;
}
}
}
//may be useful for some situations
inline uint32_t sum() const {
return 0L + north + south + east + west;
}
//Gives a string that represents the direction.
//This is a static string, overwritten with every call!
//Support values > 2 even though they should never happen.
//Copy string if it will be used.
inline char * getStr() const {
static char str[16];
//type punning trick
*( (uint64_t *)str ) = *( (uint64_t *)"--------" );
str[8]=0;
#define DIRECTION(x,i,c) \
if(x){ \
str[i]=c; \
if(1==x) ; \
else if(2==x) str[i+1]=c; \
else str[i+1]='0'+x; \
}
DIRECTION(north,0,'N')
DIRECTION(south,2,'S')
DIRECTION(west,4,'W')
DIRECTION(east,6,'E')
#undef DIRECTION
return str;
}
};
//Mainly walls and rivers
//Byte values are used because walls can have either 1 or 2 in any given direction.
const int TileDirectionCount = 4;
union TileDirection
{
uint32_t whole;
unsigned char b[TileDirectionCount];
struct
{
//Maybe should add 'up' and 'down' for Z-levels?
unsigned char north,south,west,east;
};
inline TileDirection()
{
whole = 0;
}
TileDirection( uint32_t whole_bits)
{
whole = whole_bits;
}
TileDirection( unsigned char North, unsigned char South, unsigned char West, unsigned char East )
{
north=North; south=South; east=East; west=West;
}
TileDirection( const char *dir )
{
//This one just made for fun.
//Supports N S E W
const char *p = dir;
unsigned char *l=0;
north=south=east=west=0;
if(!dir) return;
for( ;*p;++p)
{
switch(*p)
{
case 'N': //North / Up
case 'n':
++north; l=&north; break;
case 'S': //South / Down
case 's':
++south; l=&south; break;
case 'E': //East / Right
case 'e':
++east; l=&east; break;
case 'W': //West / Left
case 'w':
++west; l=&west; break;
case '-':
case ' ':
//Explicitly ensure dash and space are ignored.
//Other characters/symbols may be assigned in the future.
break;
default:
if( l && '0' <= *p && '9' >= *p )
*l += *p - '0';
break;
}
}
}
//may be useful for some situations
inline uint32_t sum() const
{
return 0L + north + south + east + west;
}
//Gives a string that represents the direction.
//This is a static string, overwritten with every call!
//Support values > 2 even though they should never happen.
//Copy string if it will be used.
inline char * getStr() const
{
static char str[16];
//type punning trick
*( (uint64_t *)str ) = *( (uint64_t *)"--------" );
str[8]=0;
#define DIRECTION(x,i,c) \
if(x){ \
str[i]=c; \
if(1==x) ; \
else if(2==x) str[i+1]=c; \
else str[i+1]='0'+x; \
}
DIRECTION(north,0,'N')
DIRECTION(south,2,'S')
DIRECTION(west,4,'W')
DIRECTION(east,6,'E')
#undef DIRECTION
return str;
}
};
struct TileRow
{
@ -263,11 +268,11 @@ namespace DFHack
TileClass c;
TileMaterial m;
TileVariant v;
TileSpecial s;
TileDirection d;
TileSpecial s;
TileDirection d;
};
#define TILE_TYPE_ARRAY_LENGTH 520
#define TILE_TYPE_ARRAY_LENGTH 520
const TileRow tileTypeTable[TILE_TYPE_ARRAY_LENGTH] =
{
@ -890,7 +895,7 @@ namespace DFHack
// 510
{"constructed wall",WALL,CONSTRUCTED, VAR_1 ,TILE_NORMAL, "N-----E-" },
{"constructed wall",WALL,CONSTRUCTED, VAR_1 ,TILE_NORMAL, "N---W---" },
{"constructed wall",WALL,CONSTRUCTED, VAR_1 ,TILE_NORMAL, "--S-W---" },
{"constructed wall",WALL,CONSTRUCTED, VAR_1 ,TILE_NORMAL, "--S-W---" },
{"constructed wall",WALL,CONSTRUCTED, VAR_1 ,TILE_NORMAL, "N-S-----" },
{"constructed wall",WALL,CONSTRUCTED, VAR_1 ,TILE_NORMAL, "----W-E-" },
{"constructed stair up/down",STAIR_UPDOWN,CONSTRUCTED, VAR_1},
@ -936,91 +941,89 @@ namespace DFHack
return tileTypeTable[in].c;
}
//zilpin: for convenience, when you'll be using the tile information a lot.
//zilpin: for convenience, when you'll be using the tile information a lot.
inline const
TileRow * getTileTypeP(int in)
{
if( in<0 || in>=TILE_TYPE_ARRAY_LENGTH ) return NULL;
if( in<0 || in>=TILE_TYPE_ARRAY_LENGTH ) return 0;
return ( const TileRow * ) &tileTypeTable[in];
}
//zilpin: Find the first tile entry which matches the given search criteria.
//All parameters are optional.
//To omit, use the 'invalid' enum for that type (e.g. tileclass_invalid, tilematerial_invalid, etc)
//For tile directions, pass NULL to omit.
//Returns matching index in tileTypeTable, or -1 if none found.
inline
int32_t findTileType( const TileClass tclass, const TileMaterial tmat, const TileVariant tvar, const TileSpecial tspecial, const TileDirection tdir )
{
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;
//Match!
return tt;
}
return -1;
}
//Convenience version of the above, to pass strings as the direction
inline
int32_t findTileType( const TileClass tclass, const TileMaterial tmat, const TileVariant tvar, const TileSpecial tspecial, const char *tdirStr )
{
if(tdirStr){
TileDirection tdir(tdirStr);
return findTileType(tclass,tmat,tvar,tspecial, tdir );
}else{
return findTileType(tclass,tmat,tvar,tspecial, NULL );
}
}
//zilpin: Find a tile type similar to the one given, but with a different class.
//Useful for tile-editing operations.
//If no match found, returns the sourceType
//Definitely needs improvement for wall directions, etc.
inline
int32_t findSimilarTileType( const int32_t sourceTileType, const TileClass tclass ){
int32_t tt, maybe=0, match=0;
int value=0, matchv=0;
const TileRow *source = &tileTypeTable[sourceTileType];
const char * sourcename = source->name;
const uint32_t sourcenameint = *((const uint32_t *)sourcename);
#ifdef assert
assert( sourceTileType >=0 && sourceTileType < TILE_TYPE_ARRAY_LENGTH );
#endif
for(tt=0;tt<TILE_TYPE_ARRAY_LENGTH; ++tt){
if( tclass == tileTypeTable[tt].c ){
//shortcut null entries
if(!tileTypeTable[tt].name) continue;
//Special flag match is absolutely mandatory!
if( source->s != tileTypeTable[tt].s ) continue;
maybe=tt; value=0;
//Material is high-value match
if( tileTypeTable[tt].m == source->m ) value|=8;
//Direction is medium value match
if( tileTypeTable[tt].d.whole == source->d.whole ) value|=4;
//Variant is low-value match
if( tileTypeTable[tt].v == source->v ) value|=1;
//Check value against last match
if( value>matchv ){
match=tt;
matchv=value;
}
}
}
if( match ) return match;
return sourceTileType;
}
//zilpin: Find the first tile entry which matches the given search criteria.
//All parameters are optional.
//To omit, use the 'invalid' enum for that type (e.g. tileclass_invalid, tilematerial_invalid, etc)
//For tile directions, pass NULL to omit.
//Returns matching index in tileTypeTable, or -1 if none found.
inline
int32_t findTileType( const TileClass tclass, const TileMaterial tmat, const TileVariant tvar, const TileSpecial tspecial, const TileDirection tdir )
{
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;
//Match!
return tt;
}
return -1;
}
//Convenience version of the above, to pass strings as the direction
inline
int32_t findTileType( const TileClass tclass, const TileMaterial tmat, const TileVariant tvar, const TileSpecial tspecial, const char *tdirStr )
{
if(tdirStr){
TileDirection tdir(tdirStr);
return findTileType(tclass,tmat,tvar,tspecial, tdir );
}else{
return findTileType(tclass,tmat,tvar,tspecial, 0 );
}
}
//zilpin: Find a tile type similar to the one given, but with a different class.
//Useful for tile-editing operations.
//If no match found, returns the sourceType
//Definitely needs improvement for wall directions, etc.
inline
int32_t findSimilarTileType( const int32_t sourceTileType, const TileClass tclass ){
int32_t tt, maybe=0, match=0;
int value=0, matchv=0;
const TileRow *source = &tileTypeTable[sourceTileType];
const char * sourcename = source->name;
const uint32_t sourcenameint = *((const uint32_t *)sourcename);
#ifdef assert
assert( sourceTileType >=0 && sourceTileType < TILE_TYPE_ARRAY_LENGTH );
#endif
for(tt=0;tt<TILE_TYPE_ARRAY_LENGTH; ++tt){
if( tclass == tileTypeTable[tt].c ){
//shortcut null entries
if(!tileTypeTable[tt].name) continue;
//Special flag match is absolutely mandatory!
if( source->s != tileTypeTable[tt].s ) continue;
maybe=tt; value=0;
//Material is high-value match
if( tileTypeTable[tt].m == source->m ) value|=8;
//Direction is medium value match
if( tileTypeTable[tt].d.whole == source->d.whole ) value|=4;
//Variant is low-value match
if( tileTypeTable[tt].v == source->v ) value|=1;
//Check value against last match
if( value>matchv ){
match=tt;
matchv=value;
}
}
}
if( match ) return match;
return sourceTileType;
}
}

@ -5,6 +5,7 @@
#include <map>
#include <stddef.h>
#include <assert.h>
#include <string.h>
using namespace std;
#include <DFHack.h>
@ -20,20 +21,20 @@ int main (void)
DFHack::tiletypes40d tiles;
DFHack::tiletypes40d tilesAbove;
//DFHack::TileRow *ptile;
int32_t oldT, newT;
int16_t t;
//DFHack::TileRow *ptile;
int32_t oldT, newT;
int16_t t;
int dirty=0, count=0;
int dirty=0, count=0;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF = DFMgr.getSingleContext();
//sanity check
assert( sizeof(designations) == (16*16*sizeof(DFHack::t_designation)) );
//sanity check
assert( sizeof(designations) == (16*16*sizeof(DFHack::t_designation)) );
//Init
try
//Init
try
{
DF->Attach();
}
@ -48,7 +49,7 @@ int main (void)
DFHack::Maps *Mapz = DF->getMaps();
// init the map
if(!Mapz->Start())
if (!Mapz->Start())
{
cerr << "Can't init map." << endl;
#ifndef LINUX_BUILD
@ -62,67 +63,75 @@ int main (void)
uint8_t zeroes [16][16] = {0};
// walk the map
for(uint32_t x = 0; x< x_max;x++)
for (uint32_t x = 0; x< x_max;x++)
{
for(uint32_t y = 0; y< y_max;y++)
for (uint32_t y = 0; y< y_max;y++)
{
for(uint32_t z = 0; z< z_max;z++)
for (uint32_t z = 0; z< z_max;z++)
{
if(Mapz->isValidBlock(x,y,z))
if (Mapz->isValidBlock(x,y,z))
{
dirty=0;
dirty=0;
Mapz->ReadDesignations(x,y,z, &designations);
Mapz->ReadTileTypes(x,y,z, &tiles);
if(Mapz->isValidBlock(x,y,z+1)){
Mapz->ReadTileTypes(x,y,z+1, &tilesAbove);
}else{
memset(&tilesAbove,0,sizeof(tilesAbove));
}
for(uint32_t ty=0;ty<16;++ty){
for(uint32_t tx=0;tx<16;++tx){
//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
){
//Current tile is a ramp.
//Set current tile, as accurately as can be expected
newT = DFHack::findSimilarTileType(oldT,DFHack::FLOOR);
//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;
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 ){
tilesAbove[tx][ty] = 32;
}
dirty=-1;
++count;
}
}
}
//If anything was changed, write it all.
if(dirty){
Mapz->WriteDesignations(x,y,z, &designations);
Mapz->WriteTileTypes(x,y,z, &tiles);
if(Mapz->isValidBlock(x,y,z+1)){
Mapz->WriteTileTypes(x,y,z+1, &tilesAbove);
}
}
Mapz->ReadTileTypes(x,y,z, &tiles);
if (Mapz->isValidBlock(x,y,z+1))
{
Mapz->ReadTileTypes(x,y,z+1, &tilesAbove);
}
else
{
memset(&tilesAbove,0,sizeof(tilesAbove));
}
for (uint32_t ty=0;ty<16;++ty)
{
for (uint32_t tx=0;tx<16;++tx)
{
//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)
{
//Current tile is a ramp.
//Set current tile, as accurately as can be expected
newT = DFHack::findSimilarTileType(oldT,DFHack::FLOOR);
//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;
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 )
{
tilesAbove[tx][ty] = 32;
}
dirty=-1;
++count;
}
}
}
//If anything was changed, write it all.
if (dirty)
{
Mapz->WriteDesignations(x,y,z, &designations);
Mapz->WriteTileTypes(x,y,z, &tiles);
if (Mapz->isValidBlock(x,y,z+1))
{
Mapz->WriteTileTypes(x,y,z+1, &tilesAbove);
}
}
}
}
}
}
DF->Detach();
cout << "Found and changed " << count << " tiles." << endl;
#ifndef LINUX_BUILD
cout << "Found and changed " << count << " tiles." << endl;
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
#endif
return 0;
}

File diff suppressed because it is too large Load Diff

@ -17,77 +17,84 @@ using namespace DFHack;
int main (int argc, char **argv)
{
FILE *f=stdout;
const int Columns = 7;
const char * Headings[Columns] = {"TileTypeID","Class","Material","V","Special","Direction","Description"};
size_t Size[ Columns ] = {};
int i;
FILE *f=stdout;
const int Columns = 7;
const char * Headings[Columns] = {"TileTypeID","Class","Material","V","Special","Direction","Description"};
size_t Size[ Columns ] = {};
int i;
//First, figure out column widths.
for(i=0;i<Columns;++i){
Size[i]=strlen(Headings[i])+1;
}
//First, figure out column widths.
for(i=0;i<Columns;++i)
{
Size[i]=strlen(Headings[i])+1;
}
//Classes
fprintf(f,"\nTile Type Classes:\n");
for(i=0;i<tileclass_count;++i){
Size[1]=max<size_t>(Size[1],strlen(TileClassString[i]));
fprintf(f,"%4i ; %s\n", i, TileClassString[i] ,0 );
}
//Classes
fprintf(f,"\nTile Type Classes:\n");
for(i=0;i<tileclass_count;++i)
{
Size[1]=max<size_t>(Size[1],strlen(TileClassString[i]));
fprintf(f,"%4i ; %s\n", i, TileClassString[i] ,0 );
}
//Materials
fprintf(f,"\nTile Type Materials:\n");
for(i=0;i<tilematerial_count;++i){
Size[2]=max<size_t>(Size[2],strlen(TileMaterialString[i]));
fprintf(f,"%4i ; %s\n", i, TileMaterialString[i] ,0 );
}
//Materials
fprintf(f,"\nTile Type Materials:\n");
for(i=0;i<tilematerial_count;++i)
{
Size[2]=max<size_t>(Size[2],strlen(TileMaterialString[i]));
fprintf(f,"%4i ; %s\n", i, TileMaterialString[i] ,0 );
}
//Specials
fprintf(f,"\nTile Type Specials:\n");
for(i=0;i<tilespecial_count;++i){
Size[4]=max<size_t>(Size[4],strlen(TileSpecialString[i]));
fprintf(f,"%4i ; %s\n", i, TileSpecialString[i] ,0 );
}
//Specials
fprintf(f,"\nTile Type Specials:\n");
for(i=0;i<tilespecial_count;++i)
{
Size[4]=max<size_t>(Size[4],strlen(TileSpecialString[i]));
fprintf(f,"%4i ; %s\n", i, TileSpecialString[i] ,0 );
}
/* - Not needed for now -
//Direction is tricky
for(i=0;i<TILE_TYPE_ARRAY_LENGTH;++i)
Size[5]=max(Size[5], tileTypeTable[i].d.sum()+1 );
*/
/* - Not needed for now -
//Direction is tricky
for(i=0;i<TILE_TYPE_ARRAY_LENGTH;++i)
Size[5]=max(Size[5], tileTypeTable[i].d.sum()+1 );
*/
//Print the headings first.
fprintf(f,"\nTile Types:\n");
for(i=0;i<Columns;++i){
if(i) putc(';',f);
fprintf(f," %-*s ",Size[i],Headings[i],0);
}
fprintf(f,"\n");
//Print the headings first.
fprintf(f,"\nTile Types:\n");
for(i=0;i<Columns;++i)
{
if(i) putc(';',f);
fprintf(f," %-*s ",Size[i],Headings[i],0);
}
fprintf(f,"\n");
//Process the whole array.
//A macro should be used for making the strings safe, but they are left in naked ? blocks
//to illustrate the array references more clearly.
for(i=0;i<TILE_TYPE_ARRAY_LENGTH;++i){
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() : "" ),
( tileTypeTable[i].name ? tileTypeTable[i].name : "" ),
0
);
}
fprintf(f,"\n");
//Process the whole array.
//A macro should be used for making the strings safe, but they are left in naked ? blocks
//to illustrate the array references more clearly.
for(i=0;i<TILE_TYPE_ARRAY_LENGTH;++i)
{
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() : "" ),
( tileTypeTable[i].name ? tileTypeTable[i].name : "" ),
0
);
}
fprintf(f,"\n");
#ifndef LINUX_BUILD
if( 1== argc){
cout << "Done. Press any key to continue" << endl;
cin.ignore();
}
if( 1== argc)
{
cout << "Done. Press any key to continue" << endl;
cin.ignore();
}
#endif
return 0;
}

@ -18,7 +18,7 @@ int main (int numargs, const char ** args)
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF = DFMgr.getSingleContext();
BEGIN_PROBE:
BEGIN_PROBE:
try
{
DF->Attach();
@ -91,11 +91,11 @@ BEGIN_PROBE:
if(tileTypeTable[tiletype].name)
std::cout << " = " << tileTypeTable[tiletype].name << std::endl;
printf("%-10s: %4d %s\n","Class",tileTypeTable[tiletype].c,TileClassString[ tileTypeTable[tiletype].c ] , 0);
printf("%-10s: %4d %s\n","Material",tileTypeTable[tiletype].c,TileMaterialString[ tileTypeTable[tiletype].m ] , 0);
printf("%-10s: %4d %s\n","Special",tileTypeTable[tiletype].c,TileSpecialString[ tileTypeTable[tiletype].s ] , 0);
printf("%-10s: %4d\n","Variant",tileTypeTable[tiletype].v , 0);
printf("%-10s: %s\n","Direction",tileTypeTable[tiletype].d.getStr() , 0);
printf("%-10s: %4d %s\n","Class",tileTypeTable[tiletype].c,TileClassString[ tileTypeTable[tiletype].c ] , 0);
printf("%-10s: %4d %s\n","Material",tileTypeTable[tiletype].c,TileMaterialString[ tileTypeTable[tiletype].m ] , 0);
printf("%-10s: %4d %s\n","Special",tileTypeTable[tiletype].c,TileSpecialString[ tileTypeTable[tiletype].s ] , 0);
printf("%-10s: %4d\n","Variant",tileTypeTable[tiletype].v , 0);
printf("%-10s: %s\n","Direction",tileTypeTable[tiletype].d.getStr() , 0);
std::cout << std::endl;
@ -125,46 +125,44 @@ BEGIN_PROBE:
uint32_t designato = block.origin + designatus + (tileX * 16 + tileY) * sizeof(t_designation);
printf("designation offset: 0x%x\n", designato);
#define PRINT_FLAG( X ) printf("%-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 );
planecoord pc;
pc.dim.x=blockX; pc.dim.y=blockY;
PRINT_FLAG( feature_local );
if( des.feature_local ){
printf("%-16s %4d (%2d) %s\n", "",
block.local_feature,
local_features[pc][block.local_feature]->type,
sa_feature[local_features[pc][block.local_feature]->type]
);
}
PRINT_FLAG( feature_global );
if( des.feature_global ){
printf("%-16s %4d (%2d) %s\n", "",
block.global_feature,
global_features[block.global_feature].type,
sa_feature[global_features[block.global_feature].type]
);
}
#undef PRINT_FLAG
#define PRINT_FLAG( X ) printf("%-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 );
planecoord pc;
pc.dim.x=blockX; pc.dim.y=blockY;
PRINT_FLAG( feature_local );
if( des.feature_local )
{
printf("%-16s %4d (%2d) %s\n", "",
block.local_feature,
local_features[pc][block.local_feature]->type,
sa_feature[local_features[pc][block.local_feature]->type]
);
}
PRINT_FLAG( feature_global );
if( des.feature_global ){
printf("%-16s %4d (%2d) %s\n", "",
block.global_feature,
global_features[block.global_feature].type,
sa_feature[global_features[block.global_feature].type]
);
}
#undef PRINT_FLAG
std::cout << std::endl;
}
}
DF->Detach();
DF->Detach();
#ifndef LINUX_BUILD
//std::cout << "Done. Press any key to continue" << std::endl;
std::cout << "Press any key to refresh..." << std::endl;
cin.ignore();
goto BEGIN_PROBE;
std::cout << "Press any key to refresh..." << std::endl;
cin.ignore();
goto BEGIN_PROBE;
#endif
return 0;
}