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