Move TileTypes to XML, part 1 - a bunch of stuff is now broken

develop
Quietust 2012-02-13 16:56:33 -06:00
parent 9f43d61c2c
commit d0a8c2edd8
17 changed files with 270 additions and 1069 deletions

@ -28,753 +28,105 @@ distribution.
namespace DFHack
{
const TileRow tileTypeTable[TILE_TYPE_ARRAY_LENGTH] =
df::tiletype findSimilarTileType (const df::tiletype sourceTileType, const df::tiletype_shape tshape)
{
// 0x000
{ "void", tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "ramp top", RAMP_TOP, AIR, VAR_1 },
{ "murky pool", POOL, SOIL, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
df::tiletype match = tiletype::Void;
int value = 0, matchv = 0;
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
// 0x010
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "driftwood", FLOOR, DRIFTWOOD, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "tree", TREE_OK, SOIL, VAR_1 },
{ "ice stair up/down", STAIR_UPDOWN, ICE, VAR_1 },
{ "ice stair down", STAIR_DOWN, ICE, VAR_1 },
{ "ice stair up", STAIR_UP, ICE, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
// 0x020
{ "empty space", EMPTY, AIR, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "shrub", SHRUB_OK, SOIL, VAR_1 },
{ "chasm", ENDLESS_PIT, AIR, VAR_1 },
{ "obsidian stair up/down", STAIR_UPDOWN, OBSIDIAN, VAR_1 },
{ "obsidian stair down", STAIR_DOWN, OBSIDIAN, VAR_1 },
{ "obsidian stair up", STAIR_UP, OBSIDIAN, VAR_1 },
{ "soil stair up/down", STAIR_UPDOWN, SOIL, VAR_1 },
{ "soil stair down", STAIR_DOWN, SOIL, VAR_1 },
{ "soil stair up", STAIR_UP, SOIL, VAR_1 },
{ "eerie pit", ENDLESS_PIT, HFS, VAR_1 },
{ "smooth stone floor", FLOOR, STONE, VAR_1, TILE_SMOOTH },
{ "smooth obsidian floor", FLOOR, OBSIDIAN, VAR_1, TILE_SMOOTH },
{ "smooth featstone floor", FLOOR, FEATSTONE, VAR_1, TILE_SMOOTH },
{ "smooth vein floor", FLOOR, VEIN, VAR_1, TILE_SMOOTH },
{ "smooth ice floor", FLOOR, ICE, VAR_1, TILE_SMOOTH },
// 0x030
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "light grass stair up/down", STAIR_UPDOWN, GRASS, VAR_1 },
{ "light grass stair down", STAIR_DOWN, GRASS, VAR_1 },
{ "light grass stair up", STAIR_UP, GRASS, VAR_1 },
{ "dark grass stair up/down", STAIR_UPDOWN, GRASS2, VAR_1 },
{ "dark grass stair down", STAIR_DOWN, GRASS2, VAR_1 },
{ "dark grass stair up", STAIR_UP, GRASS2, VAR_1 },
{ "stone stair up/down", STAIR_UPDOWN, STONE, VAR_1 },
{ "stone stair down", STAIR_DOWN, STONE, VAR_1 },
{ "stone stair up", STAIR_UP, STONE, VAR_1 },
{ "vein stair up/down", STAIR_UPDOWN, VEIN, VAR_1 },
{ "vein stair down", STAIR_DOWN, VEIN, VAR_1 },
{ "vein stair up", STAIR_UP, VEIN, VAR_1 },
{ "featstone stair up/down", STAIR_UPDOWN, FEATSTONE, VAR_1 },
{ "featstone stair down", STAIR_DOWN, FEATSTONE, VAR_1 },
{ "featstone stair up", STAIR_UP, FEATSTONE, VAR_1 },
// 0x040
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "stone fortification", FORTIFICATION, STONE, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "campfire", FLOOR, CAMPFIRE, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "fire", FLOOR, FIRE, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "stone pillar", PILLAR, STONE, VAR_1 },
// 0x050
{ "obsidian pillar", PILLAR, OBSIDIAN, VAR_1, TILE_SMOOTH },
{ "featstone pillar", PILLAR, FEATSTONE, VAR_1, TILE_SMOOTH },
{ "vein pillar", PILLAR, VEIN, VAR_1, TILE_SMOOTH },
{ "ice pillar", PILLAR, ICE, VAR_1, TILE_SMOOTH },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "waterfall", FLOOR, SOIL, VAR_1, TILE_WATERFALL }, // verify material
{ "river source", FLOOR, SOIL, VAR_1, TILE_RIVER_SOURCE }, // verify material
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
// 0x060
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
// 0x070
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
// 0x080
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
// 0x090
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
// 0x0A0
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
// 0x0B0
{ "cracked stone wall", WALL, STONE, VAR_1, TILE_CRACKED },
{ "damaged stone wall", WALL, STONE, VAR_1, TILE_DAMAGED },
{ "worn stone wall", WALL, STONE, VAR_1, TILE_WORN },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
// 0x0C0
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
// 0x0D0
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "stone wall", WALL, STONE, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
// 0x0E0
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "sapling", SAPLING_OK, SOIL, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "dry grass ramp", RAMP, GRASS_DRY, VAR_1 },
{ "dead grass ramp", RAMP, GRASS_DEAD, VAR_1 },
{ "light grass ramp", RAMP, GRASS, VAR_1 },
{ "dark grass ramp", RAMP, GRASS2, VAR_1 },
{ "stone ramp", RAMP, STONE, VAR_1 },
{ "obsidian ramp", RAMP, OBSIDIAN, VAR_1 },
{ "featstone ramp", RAMP, FEATSTONE, VAR_1 },
// 0x0F0
{ "vein ramp", RAMP, VEIN, VAR_1 },
{ "soil ramp", RAMP, SOIL, VAR_1 },
{ "ashes", FLOOR, ASHES, VAR_1 },
{ "ashes", FLOOR, ASHES, VAR_2 },
{ "ashes", FLOOR, ASHES, VAR_3 },
{ "ice ramp", RAMP, ICE, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
// 0x100
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "ice floor", FLOOR, ICE, VAR_2 },
{ "ice floor", FLOOR, ICE, VAR_3 },
{ "ice floor", FLOOR, ICE, VAR_4 },
{ "furrowed soil", FLOOR, SOIL, VAR_1 },
{ "ice floor", FLOOR, ICE, VAR_1 },
{ "semi-molten rock", WALL, MAGMA, VAR_1 }, // unminable magma wall
{ "magma flow", FLOOR, MAGMA, VAR_1 },
{ "soil wall", WALL, SOIL, VAR_1 },
{ "glowing barrier", WALL, CYAN_GLOW, VAR_1 },
{ "glowing floor", FLOOR, CYAN_GLOW, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "smooth obsidian wall RD2", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "--SS--E-" },
{ "smooth obsidian wall R2D", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "--S---EE" },
{ "smooth obsidian wall R2U", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "N-----EE" },
// 0x110
{ "smooth obsidian wall RU2", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "NN----E-" },
{ "smooth obsidian wall L2U", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "N---WW--" },
{ "smooth obsidian wall LU2", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "NN--W---" },
{ "smooth obsidian wall L2D", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "--S-WW--" },
{ "smooth obsidian wall LD2", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "--SSW---" },
{ "smooth obsidian wall LRUD", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "N-S-W-E-" },
{ "smooth obsidian wall RUD", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "N-S---E-" },
{ "smooth obsidian wall LRD", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "--S-W-E-" },
{ "smooth obsidian wall LRU", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "N---W-E-" },
{ "smooth obsidian wall LUD", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "N-S-W---" },
{ "smooth obsidian wall RD", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "--S---E-" },
{ "smooth obsidian wall RU", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "N-----E-" },
{ "smooth obsidian wall LU", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "N---W---" },
{ "smooth obsidian wall LD", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "--S-W---" },
{ "smooth obsidian wall UD", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "N-S-----" },
{ "smooth obsidian wall LR", WALL, OBSIDIAN, VAR_1, TILE_SMOOTH, "----W-E-" },
// 0x120
{ "smooth featstone wall RD2", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "--SS--E-" },
{ "smooth featstone wall R2D", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "--S---EE" },
{ "smooth featstone wall R2U", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "N-----EE" },
{ "smooth featstone wall RU2", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "NN----E-" },
{ "smooth featstone wall L2U", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "N---WW--" },
{ "smooth featstone wall LU2", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "NN--W---" },
{ "smooth featstone wall L2D", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "--S-WW--" },
{ "smooth featstone wall LD2", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "--SSW---" },
{ "smooth featstone wall LRUD", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "N-S-W-E-" },
{ "smooth featstone wall RUD", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "N-S---E-" },
{ "smooth featstone wall LRD", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "--S-W-E-" },
{ "smooth featstone wall LRU", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "N---W-E-" },
{ "smooth featstone wall LUD", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "N-S-W---" },
{ "smooth featstone wall RD", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "--S---E-" },
{ "smooth featstone wall RU", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "N-----E-" },
{ "smooth featstone wall LU", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "N---W---" },
// 0x130
{ "smooth featstone wall LD", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "--S-W---" },
{ "smooth featstone wall UD", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "N-S-----" },
{ "smooth featstone wall LR", WALL, FEATSTONE, VAR_1, TILE_SMOOTH, "----W-E-" },
{ "smooth stone wall RD2", WALL, STONE, VAR_1, TILE_SMOOTH, "--SS--E-" },
{ "smooth stone wall R2D", WALL, STONE, VAR_1, TILE_SMOOTH, "--S---EE" },
{ "smooth stone wall R2U", WALL, STONE, VAR_1, TILE_SMOOTH, "N-----EE" },
{ "smooth stone wall RU2", WALL, STONE, VAR_1, TILE_SMOOTH, "NN----E-" },
{ "smooth stone wall L2U", WALL, STONE, VAR_1, TILE_SMOOTH, "N---WW--" },
{ "smooth stone wall LU2", WALL, STONE, VAR_1, TILE_SMOOTH, "NN--W---" },
{ "smooth stone wall L2D", WALL, STONE, VAR_1, TILE_SMOOTH, "--S-WW--" },
{ "smooth stone wall LD2", WALL, STONE, VAR_1, TILE_SMOOTH, "--SSW---" },
{ "smooth stone wall LRUD", WALL, STONE, VAR_1, TILE_SMOOTH, "N-S-W-E-" },
{ "smooth stone wall RUD", WALL, STONE, VAR_1, TILE_SMOOTH, "N-S---E-" },
{ "smooth stone wall LRD", WALL, STONE, VAR_1, TILE_SMOOTH, "--S-W-E-" },
{ "smooth stone wall LRU", WALL, STONE, VAR_1, TILE_SMOOTH, "N---W-E-" },
{ "smooth stone wall LUD", WALL, STONE, VAR_1, TILE_SMOOTH, "N-S-W---" },
// 0x140
{ "smooth stone wall RD", WALL, STONE, VAR_1, TILE_SMOOTH, "--S---E-" },
{ "smooth stone wall RU", WALL, STONE, VAR_1, TILE_SMOOTH, "N-----E-" },
{ "smooth stone wall LU", WALL, STONE, VAR_1, TILE_SMOOTH, "N---W---" },
{ "smooth stone wall LD", WALL, STONE, VAR_1, TILE_SMOOTH, "--S-W---" },
{ "smooth stone wall UD", WALL, STONE, VAR_1, TILE_SMOOTH, "N-S-----" },
{ "smooth stone wall LR", WALL, STONE, VAR_1, TILE_SMOOTH, "----W-E-" },
{ "obsidian fortification", FORTIFICATION, OBSIDIAN, VAR_1 },
{ "featstone fortification", FORTIFICATION, FEATSTONE, VAR_1 },
{ "cracked obsidian wall", WALL, OBSIDIAN, VAR_1, TILE_CRACKED },
{ "damaged obsidian wall", WALL, OBSIDIAN, VAR_1, TILE_DAMAGED },
{ "worn obsidian wall", WALL, OBSIDIAN, VAR_1, TILE_WORN },
{ "obsidian wall", WALL, OBSIDIAN, VAR_1 },
{ "cracked featstone wall", WALL, FEATSTONE, VAR_1, TILE_CRACKED },
{ "damaged featstone wall", WALL, FEATSTONE, VAR_1, TILE_DAMAGED },
{ "worn featstone wall", WALL, FEATSTONE, VAR_1, TILE_WORN },
{ "featstone wall", WALL, FEATSTONE, VAR_1 },
// 0x150
{ "stone floor 1", FLOOR, STONE, VAR_1 },
{ "stone floor 2", FLOOR, STONE, VAR_2 },
{ "stone floor 3", FLOOR, STONE, VAR_3 },
{ "stone floor 4", FLOOR, STONE, VAR_4 },
{ "obsidian floor 1", FLOOR, OBSIDIAN, VAR_1 },
{ "obsidian floor 2", FLOOR, OBSIDIAN, VAR_2 },
{ "obsidian floor 3", FLOOR, OBSIDIAN, VAR_3 },
{ "obsidian floor 4", FLOOR, OBSIDIAN, VAR_4 },
{ "featstone floor 1", FLOOR, FEATSTONE, VAR_1 },
{ "featstone floor 2", FLOOR, FEATSTONE, VAR_2 },
{ "featstone floor 3", FLOOR, FEATSTONE, VAR_3 },
{ "featstone floor 4", FLOOR, FEATSTONE, VAR_4 },
{ "dark grass 1", FLOOR, GRASS2, VAR_1 },
{ "dark grass 2", FLOOR, GRASS2, VAR_2 },
{ "dark grass 3", FLOOR, GRASS2, VAR_3 },
{ "dark grass 4", FLOOR, GRASS2, VAR_4 },
// 0x160
{ "soil floor 1", FLOOR, SOIL, VAR_1 },
{ "soil floor 2", FLOOR, SOIL, VAR_2 },
{ "soil floor 3", FLOOR, SOIL, VAR_3 },
{ "soil floor 4", FLOOR, SOIL, VAR_4 },
{ "wet soil floor 1", FLOOR, SOIL, VAR_1 },
{ "wet soil floor 2", FLOOR, SOIL, VAR_2 },
{ "wet soil floor 3", FLOOR, SOIL, VAR_3 },
{ "wet soil floor 4", FLOOR, SOIL, VAR_4 },
{ "ice fortification", FORTIFICATION, ICE, VAR_1 },
{ "cracked ice wall", WALL, ICE, VAR_1, TILE_CRACKED },
{ "damaged ice wall", WALL, ICE, VAR_1, TILE_DAMAGED },
{ "worn ice wall", WALL, ICE, VAR_1, TILE_WORN },
{ "ice wall", WALL, ICE, VAR_1 },
{ "river N", RIVER_BED, SOIL, VAR_1, TILE_NORMAL, "N" },
{ "river S", RIVER_BED, SOIL, VAR_1, TILE_NORMAL, "S" },
{ "river E", RIVER_BED, SOIL, VAR_1, TILE_NORMAL, "E" },
// 0x170
{ "river W", RIVER_BED, SOIL, VAR_1, TILE_NORMAL, "W" },
{ "river NW", RIVER_BED, SOIL, VAR_1, TILE_NORMAL, "NW" },
{ "river NE", RIVER_BED, SOIL, VAR_1, TILE_NORMAL, "NE" },
{ "river SW", RIVER_BED, SOIL, VAR_1, TILE_NORMAL, "SW" },
{ "river SE", RIVER_BED, SOIL, VAR_1, TILE_NORMAL, "SE" },
{ "brook bed N", BROOK_BED, SOIL, VAR_1, TILE_NORMAL, "N" },
{ "brook bed S", BROOK_BED, SOIL, VAR_1, TILE_NORMAL, "S" },
{ "brook bed E", BROOK_BED, SOIL, VAR_1, TILE_NORMAL, "E" },
{ "brook bed W", BROOK_BED, SOIL, VAR_1, TILE_NORMAL, "W" },
{ "brook bed NW", BROOK_BED, SOIL, VAR_1, TILE_NORMAL, "NW" },
{ "brook bed NE", BROOK_BED, SOIL, VAR_1, TILE_NORMAL, "NE" },
{ "brook bed SW", BROOK_BED, SOIL, VAR_1, TILE_NORMAL, "SW" },
{ "brook bed SE", BROOK_BED, SOIL, VAR_1, TILE_NORMAL, "SE" },
{ "brook top", BROOK_TOP, SOIL, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
// 0x180
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "dry grass 1", FLOOR, GRASS_DRY, VAR_1 },
{ "dry grass 2", FLOOR, GRASS_DRY, VAR_2 },
{ "dry grass 3", FLOOR, GRASS_DRY, VAR_3 },
{ "dry grass 4", FLOOR, GRASS_DRY, VAR_4 },
{ "dead tree", TREE_DEAD, SOIL, VAR_1 },
{ "dead sapling", SAPLING_DEAD, SOIL, VAR_1 },
{ "dead shrub", SHRUB_DEAD, SOIL, VAR_1 },
{ "dead grass 1", FLOOR, GRASS_DEAD, VAR_1 },
{ "dead grass 2", FLOOR, GRASS_DEAD, VAR_2 },
{ "dead grass 3", FLOOR, GRASS_DEAD, VAR_3 },
{ "dead grass 4", FLOOR, GRASS_DEAD, VAR_4 },
{ "light grass 1", FLOOR, GRASS, VAR_1 },
{ "light grass 2", FLOOR, GRASS, VAR_2 },
// 0x190
{ "light grass 3", FLOOR, GRASS, VAR_3 },
{ "light grass 4", FLOOR, GRASS, VAR_4 },
{ "boulder", BOULDER, STONE, VAR_1 },
{ "obsidian boulder", BOULDER, OBSIDIAN, VAR_1 },
{ "featstone boulder", BOULDER, FEATSTONE, VAR_1 },
{ "stone pebbles 1", PEBBLES, STONE, VAR_1 },
{ "stone pebbles 2", PEBBLES, STONE, VAR_2 },
{ "stone pebbles 3", PEBBLES, STONE, VAR_3 },
{ "stone pebbles 4", PEBBLES, STONE, VAR_4 },
{ "obsidian pebbles 1", PEBBLES, OBSIDIAN, VAR_1 },
{ "obsidian pebbles 2", PEBBLES, OBSIDIAN, VAR_2 },
{ "obsidian pebbles 3", PEBBLES, OBSIDIAN, VAR_3 },
{ "obsidian pebbles 4", PEBBLES, OBSIDIAN, VAR_4 },
{ "featstone pebbles 1", PEBBLES, FEATSTONE, VAR_1 },
{ "featstone pebbles 2", PEBBLES, FEATSTONE, VAR_2 },
{ "featstone pebbles 3", PEBBLES, FEATSTONE, VAR_3 },
// 0x1A0
{ "featstone pebbles 4", PEBBLES, FEATSTONE, VAR_4 },
{ "smooth vein wall RD2", WALL, VEIN, VAR_1, TILE_SMOOTH, "--SS--E-" },
{ "smooth vein wall R2D", WALL, VEIN, VAR_1, TILE_SMOOTH, "--S---EE" },
{ "smooth vein wall R2U", WALL, VEIN, VAR_1, TILE_SMOOTH, "N-----EE" },
{ "smooth vein wall RU2", WALL, VEIN, VAR_1, TILE_SMOOTH, "NN----E-" },
{ "smooth vein wall L2U", WALL, VEIN, VAR_1, TILE_SMOOTH, "N---WW--" },
{ "smooth vein wall LU2", WALL, VEIN, VAR_1, TILE_SMOOTH, "NN--W---" },
{ "smooth vein wall L2D", WALL, VEIN, VAR_1, TILE_SMOOTH, "--S-WW--" },
{ "smooth vein wall LD2", WALL, VEIN, VAR_1, TILE_SMOOTH, "--SSW---" },
{ "smooth vein wall LRUD", WALL, VEIN, VAR_1, TILE_SMOOTH, "N-S-W-E-" },
{ "smooth vein wall RUD", WALL, VEIN, VAR_1, TILE_SMOOTH, "N-S---E-" },
{ "smooth vein wall LRD", WALL, VEIN, VAR_1, TILE_SMOOTH, "--S-W-E-" },
{ "smooth vein wall LRU", WALL, VEIN, VAR_1, TILE_SMOOTH, "N---W-E-" },
{ "smooth vein wall LUD", WALL, VEIN, VAR_1, TILE_SMOOTH, "N-S-W---" },
{ "smooth vein wall RD", WALL, VEIN, VAR_1, TILE_SMOOTH, "--S---E-" },
{ "smooth vein wall RU", WALL, VEIN, VAR_1, TILE_SMOOTH, "N-----E-" },
// 0x1B0
{ "smooth vein wall LU", WALL, VEIN, VAR_1, TILE_SMOOTH, "N---W---" },
{ "smooth vein wall LD", WALL, VEIN, VAR_1, TILE_SMOOTH, "--S-W---" },
{ "smooth vein wall UD", WALL, VEIN, VAR_1, TILE_SMOOTH, "N-S-----" },
{ "smooth vein wall LR", WALL, VEIN, VAR_1, TILE_SMOOTH, "----W-E-" },
{ "vein fortification", FORTIFICATION, VEIN, VAR_1 },
{ "cracked vein wall", WALL, VEIN, VAR_1, TILE_CRACKED },
{ "damaged vein wall", WALL, VEIN, VAR_1, TILE_DAMAGED },
{ "worn vein wall", WALL, VEIN, VAR_1, TILE_WORN },
{ "vein wall", WALL, VEIN, VAR_1 },
{ "vein floor 1", FLOOR, VEIN, VAR_1 },
{ "vein floor 2", FLOOR, VEIN, VAR_2 },
{ "vein floor 3", FLOOR, VEIN, VAR_3 },
{ "vein floor 4", FLOOR, VEIN, VAR_4 },
{ "vein boulder", BOULDER, VEIN, VAR_1 },
{ "vein pebbles 1", PEBBLES, VEIN, VAR_1 },
{ "vein pebbles 2", PEBBLES, VEIN, VAR_2 },
// 0x1C0
{ "vein pebbles 3", PEBBLES, VEIN, VAR_3 },
{ "vein pebbles 4", PEBBLES, VEIN, VAR_4 },
{ "smooth ice wall RD2", WALL, ICE, VAR_1, TILE_SMOOTH, "--SS--E-" },
{ "smooth ice wall R2D", WALL, ICE, VAR_1, TILE_SMOOTH, "--S---EE" },
{ "smooth ice wall R2U", WALL, ICE, VAR_1, TILE_SMOOTH, "N-----EE" },
{ "smooth ice wall RU2", WALL, ICE, VAR_1, TILE_SMOOTH, "NN----E-" },
{ "smooth ice wall L2U", WALL, ICE, VAR_1, TILE_SMOOTH, "N---WW--" },
{ "smooth ice wall LU2", WALL, ICE, VAR_1, TILE_SMOOTH, "NN--W---" },
{ "smooth ice wall L2D", WALL, ICE, VAR_1, TILE_SMOOTH, "--S-WW--" },
{ "smooth ice wall LD2", WALL, ICE, VAR_1, TILE_SMOOTH, "--SSW---" },
{ "smooth ice wall LRUD", WALL, ICE, VAR_1, TILE_SMOOTH, "N-S-W-E-" },
{ "smooth ice wall RUD", WALL, ICE, VAR_1, TILE_SMOOTH, "N-S---E-" },
{ "smooth ice wall LRD", WALL, ICE, VAR_1, TILE_SMOOTH, "--S-W-E-" },
{ "smooth ice wall LRU", WALL, ICE, VAR_1, TILE_SMOOTH, "N---W-E-" },
{ "smooth ice wall LUD", WALL, ICE, VAR_1, TILE_SMOOTH, "N-S-W---" },
{ "smooth ice wall RD", WALL, ICE, VAR_1, TILE_SMOOTH, "--S---E-" },
// 0x1D0
{ "smooth ice wall RU", WALL, ICE, VAR_1, TILE_SMOOTH, "N-----E-" },
{ "smooth ice wall LU", WALL, ICE, VAR_1, TILE_SMOOTH, "N---W---" },
{ "smooth ice wall LD", WALL, ICE, VAR_1, TILE_SMOOTH, "--S-W---" },
{ "smooth ice wall UD", WALL, ICE, VAR_1, TILE_SMOOTH, "N-S-----" },
{ "smooth ice wall LR", WALL, ICE, VAR_1, TILE_SMOOTH, "----W-E-" },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
// 0x1E0
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 },
{ "constructed floor", FLOOR, CONSTRUCTED, VAR_1 },
{ "constructed fortification", FORTIFICATION, CONSTRUCTED, VAR_1 },
{ "constructed pillar", PILLAR, CONSTRUCTED, VAR_1 },
// 0x1F0
{ "constructed wall RD2", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "--SS--E-" },
{ "constructed wall R2D", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "--S---EE" },
{ "constructed wall R2U", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "N-----EE" },
{ "constructed wall RU2", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "NN----E-" },
{ "constructed wall L2U", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "N---WW--" },
{ "constructed wall LU2", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "NN--W---" },
{ "constructed wall L2D", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "--S-WW--" },
{ "constructed wall LD2", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "--SSW---" },
{ "constructed wall LRUD", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "N-S-W-E-" },
{ "constructed wall RUD", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "N-S---E-" },
{ "constructed wall LRD", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "--S-W-E-" },
{ "constructed wall LRU", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "N---W-E-" },
{ "constructed wall LUD", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "N-S-W---" },
{ "constructed wall RD", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "--S---E-" },
{ "constructed wall RU", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "N-----E-" },
{ "constructed wall LU", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "N---W---" },
// 0x200
{ "constructed wall LD", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "--S-W---" },
{ "constructed wall UD", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "N-S-----" },
{ "constructed wall LR", WALL, CONSTRUCTED, VAR_1, TILE_NORMAL, "----W-E-" },
{ "constructed stair up/down", STAIR_UPDOWN, CONSTRUCTED, VAR_1 },
{ "constructed stair down", STAIR_DOWN, CONSTRUCTED, VAR_1 },
{ "constructed stair up", STAIR_UP, CONSTRUCTED, VAR_1 },
{ "constructed ramp", RAMP, CONSTRUCTED, VAR_1 },
// end
{ 0, tileshape_invalid, tilematerial_invalid, VAR_1 }
};
//set tile class string lookup table (e.g. for printing to user)
#define X(name,comment) #name,
const char * TileShapeString[tileshape_count+1] = {
TILESHAPE_MACRO
0
};
#undef X
//string lookup table (e.g. for printing to user)
#define X(name,comment) #name,
const char * TileMaterialString[tilematerial_count+1] = {
TILEMATERIAL_MACRO
0
};
#undef X
//string lookup table (e.g. for printing to user)
#define X(name,comment) #name,
const char * TileSpecialString[tilespecial_count+1] = {
TILESPECIAL_MACRO
0
};
#undef X
int16_t findSimilarTileType( const int16_t sourceTileType, const TileShape tshape )
{
int16_t match=0;
int value=0, matchv=0;
const TileRow *source = &tileTypeTable[sourceTileType];
const df::tiletype_shape cur_shape = tileShape(sourceTileType);
const df::tiletype_material cur_material = tileMaterial(sourceTileType);
const df::tiletype_special cur_special = tileSpecial(sourceTileType);
const df::tiletype_variant cur_variant = tileVariant(sourceTileType);
const TileDirection cur_direction = tileDirection(sourceTileType);
//Shortcut.
//If the current tile is already a shape match, leave.
if( tshape == source->shape ) return sourceTileType;
//Cheap pseudo-entropy, by using address of the variable on the stack.
//No need for real random numbers.
static int entropy;
entropy += (int)( (void *)(&match) );
entropy ^= ((entropy & 0xFF000000)>>24) ^ ((entropy & 0x00FF0000)>>16);
if (tshape == cur_shape)
return sourceTileType;
#ifdef assert
assert( sourceTileType >=0 && sourceTileType < TILE_TYPE_ARRAY_LENGTH );
assert(tiletype::is_valid(sourceTileType));
#endif
//Special case for smooth pillars.
//When you want a smooth wall, no need to search for best match. Just use a pillar instead.
//Choosing the right direction would require knowing neighbors.
if( WALL==tshape && (TILE_SMOOTH==source->special || CONSTRUCTED==source->material) ){
switch( source->material ){
case CONSTRUCTED: match=495; break;
case ICE: match= 83; break;
case VEIN: match= 82; break;
case FEATSTONE: match= 81; break;
case OBSIDIAN: match= 80; break;
case STONE: match= 79; break;
// Special case for smooth pillars.
// When you want a smooth wall, no need to search for best match. Just use a pillar instead.
// Choosing the right direction would require knowing neighbors.
if ((tshape == tiletype_shape::WALL) && ((cur_special == tiletype_special::SMOOTH) || (cur_material == tiletype_material::CONSTRUCTION)))
{
switch (cur_material)
{
case tiletype_material::CONSTRUCTION:
return tiletype::ConstructedPillar;
case tiletype_material::FROZEN_LIQUID:
return tiletype::FrozenPillar;
case tiletype_material::MINERAL:
return tiletype::MineralPillar;
case tiletype_material::FEATURE:
return tiletype::FeaturePillar;
case tiletype_material::LAVA_STONE:
return tiletype::LavaPillar;
case tiletype_material::STONE:
return tiletype::StonePillar;
}
if( match ) return match;
}
//Run through until perfect match found or hit end.
for(int16_t tt=0;tt<TILE_TYPE_ARRAY_LENGTH && value<(8|4|1); ++tt)
// Run through until perfect match found or hit end.
FOR_ENUM_ITEMS(tiletype, tt)
{
if( tshape == tileTypeTable[tt].shape )
if (value < (8|4|1))
break;
if (tileShape(tt) == tshape)
{
//shortcut null entries
if(!tileTypeTable[tt].name) continue;
//Special flag match is absolutely mandatory!
if( source->special != tileTypeTable[tt].special ) continue;
// Special flag match is absolutely mandatory!
if (tileSpecial(tt) != cur_special)
continue;
//Special case for constructions.
//Never turn a construction into a non-contruction.
if( CONSTRUCTED == source->material && CONSTRUCTED != tileTypeTable[tt].material ) continue;
// Special case for constructions.
// Never turn a construction into a non-contruction.
if ((cur_material == tiletype_material::CONSTRUCTION) && (tileMaterial(tt) != cur_material))
continue;
value=0;
value = 0;
//Material is high-value match
if( tileTypeTable[tt].material == source->material ) value|=8;
//Direction is medium value match
if( tileTypeTable[tt].direction.whole == source->direction.whole ) value|=4;
//Variant is low-value match
if( tileTypeTable[tt].variant == source->variant ) value|=1;
if (cur_material == tileMaterial(tt))
value |= 8;
// Direction is medium value match
if (cur_direction == tileDirection(tt))
value |= 4;
// Variant is low-value match
if (cur_variant == tileVariant(tt))
value |= 1;
//Check value against last match.
if( value>matchv )
// Check value against last match.
if (value > matchv)
{
match=tt;
matchv=value;
match = tt;
matchv = value;
}
}
}
//Post-processing for floors.
//Give raw floors variation.
//Variant matters, but does not matter for source.
//Error on the side of caution.
if( FLOOR==tshape && CONSTRUCTED!=source->material && !source->special )
// If the selected tile has a variant, then pick a random one
match = findRandomVariant(match);
if (match)
return match;
return sourceTileType;
}
df::tiletype findRandomVariant (const df::tiletype tile)
{
if (tileVariant(tile) == tiletype_variant::NONE)
return tile;
std::vector<df::tiletype> matches;
FOR_ENUM_ITEMS(tiletype, tt)
{
//Trying to make a floor type with variants, so randomize the variant.
//Very picky, only handle known safe tile types.
//Some floors have 4 variants, some have 3, so the order of these matters.
switch( match ){
case 261:
//Furrowed soil got chosen by accident. Fix that.
match=352+(3&entropy);
break;
case 336: //STONE
case 340: //OBSIDIAN
case 344: //featstone
case 349: //grass
case 352: //soil
case 356: //wet soil
case 387: //dry grass
case 394: //dead grass
case 398: //grass B
case 441: //vein
match += 3&entropy;
break;
case 242: //ASHES
case 258: //ICE
match += (1&entropy) + (2&entropy);
break;
}
if (tileShape(tt) == tileShape(tile) &&
tileMaterial(tt) == tileMaterial(tile) &&
tileSpecial(tt) == tileSpecial(tile))
matches.push_back(tt);
}
if( match ) return match;
return sourceTileType;
return matches[rand() % matches.size()];
}
}

@ -29,118 +29,11 @@ distribution.
#include "Pragma.h"
#include "Export.h"
#include "DataDefs.h"
#include "df/tiletype.h"
namespace DFHack
{
// tile class -- determines the general shape of the tile
// enum and lookup table for string names created using X macros
#define TILESHAPE_MACRO \
X(EMPTY, "") \
X(WALL, "") \
X(PILLAR, "") \
X(BROOK_BED, "mineable, water-passable rock on the bottom of brook") \
X(FORTIFICATION, "") \
X(STAIR_UP, "") \
X(STAIR_DOWN, "") \
X(STAIR_UPDOWN, "") \
X(RAMP, "ramps have no direction" ) \
X(RAMP_TOP, "used for pathing?" ) \
X(FLOOR, "") \
X(BROOK_TOP, "water-passable floor on top of BROOK_BED tiles") \
X(RIVER_BED, "It's a riverbed. Basically a floor that doesn't get muddy.") \
X(POOL, "A pool. Gathers water while it's raining.'") \
X(TREE_DEAD, "") \
X(TREE_OK, "") \
X(SAPLING_DEAD, "") \
X(SAPLING_OK, "") \
X(SHRUB_DEAD, "") \
X(SHRUB_OK, "") \
X(BOULDER, "") \
X(PEBBLES, "") \
X(ENDLESS_PIT, "a fake endless pit")
//end TILESHAPE_MACRO
//define tile class enum
#define X(name,comment) name,
enum TileShape {
tileshape_invalid=-1,
TILESHAPE_MACRO
tileshape_count,
};
#undef X
DFHACK_EXPORT extern const char *TileShapeString[];
#define TILEMATERIAL_MACRO \
X(AIR, "empty" ) \
X(SOIL, "ordinary soil. material depends on geology" ) \
X(STONE, "ordinary layer stone. material depends on geology" ) \
X(FEATSTONE, "map special stone. used for things like hell, the hell temple or adamantine tubes. material depends on local/global special" ) \
X(OBSIDIAN, "lava stone created by mixing magma and water" ) \
X(VEIN, "vein stone. material depends on mineral veins present" ) \
X(ICE, "frozen water... not much to say. you can determine what was on the tile before it froze by looking into the 'ice vein' objects" ) \
X(GRASS, "light grass (has 4 variants)" ) \
X(GRASS2, "dark grass (has 4 variants)" ) \
X(GRASS_DEAD, "dead grass (has 4 variants)" ) \
X(GRASS_DRY, "dry grass (has 4 variants)" ) \
X(DRIFTWOOD, "driftwood. normally shows up on beaches" ) \
X(HFS, "the stuff demon pits are made of - this makes them different from ordinary pits." ) \
X(MAGMA, "material for semi-molten rock and 'magma flow' tiles" ) \
X(CAMPFIRE, "human armies make them when they siege. The original tile may be lost?" ) \
X(FIRE, "burning grass" ) \
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
// material enum
#define X(name,comment) name,
enum TileMaterial {
tilematerial_invalid=-1,
TILEMATERIAL_MACRO
tilematerial_count,
};
#undef X
DFHACK_EXPORT extern const char *TileMaterialString[];
// 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(RIVER_SOURCE, "River Source, when it exists on a map" ) \
X(WATERFALL, "Waterfall from Nowhere, used by cave rivers back in 40d" ) \
X(CRACKED, "Partially (75%) mined walls" ) \
X(DAMAGED, "Partially (50%) mined walls" ) \
X(WORN, "Partially (25%) mined walls" ) \
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
DFHACK_EXPORT extern const char *TileSpecialString[];
// 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.
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;
@ -162,6 +55,18 @@ namespace DFHack
{
whole = whole_bits;
}
bool operator== (const TileDirection &other) const
{
return whole == other.whole;
}
bool operator!= (const TileDirection &other) const
{
return whole != other.whole;
}
operator bool() const
{
return whole != 0;
}
TileDirection( unsigned char North, unsigned char South, unsigned char West, unsigned char East )
{
north=North; south=South; east=East; west=West;
@ -235,148 +140,94 @@ namespace DFHack
#undef DIRECTION
return str;
}
};
struct TileRow
{
const char * name;
TileShape shape;
TileMaterial material;
TileVariant variant;
TileSpecial special;
TileDirection direction;
};
#define TILE_TYPE_ARRAY_LENGTH 520
extern DFHACK_EXPORT const TileRow tileTypeTable[];
using namespace df::enums;
// tile is missing a floor
inline
bool LowPassable(int16_t tiletype)
bool LowPassable(df::tiletype tiletype)
{
switch(DFHack::tileTypeTable[tiletype].shape)
{
case DFHack::EMPTY:
case DFHack::STAIR_DOWN:
case DFHack::STAIR_UPDOWN:
case DFHack::RAMP_TOP:
return true;
default:
return false;
}
};
return tiletype_shape::get_passable_low(tiletype::get_shape(tiletype));
}
// tile is missing a roof
inline
bool HighPassable(int16_t tiletype)
{
switch(DFHack::tileTypeTable[tiletype].shape)
{
case DFHack::EMPTY:
case DFHack::STAIR_DOWN:
case DFHack::STAIR_UPDOWN:
case DFHack::STAIR_UP:
case DFHack::RAMP:
case DFHack::RAMP_TOP:
case DFHack::FLOOR:
case DFHack::SAPLING_DEAD:
case DFHack::SAPLING_OK:
case DFHack::SHRUB_DEAD:
case DFHack::SHRUB_OK:
case DFHack::BOULDER:
case DFHack::PEBBLES:
case DFHack::RIVER_BED:
case DFHack::POOL:
case DFHack::ENDLESS_PIT:
case DFHack::BROOK_TOP:
return true;
default:
return false;
}
};
inline
bool FlowPassable(int16_t tiletype)
bool HighPassable(df::tiletype tiletype)
{
TileShape tc = tileTypeTable[tiletype].shape;
return tc != WALL && tc != PILLAR && tc != TREE_DEAD && tc != TREE_OK;
};
return tiletype_shape::get_passable_flow(tiletype::get_shape(tiletype));
}
inline
bool isWallTerrain(int16_t tiletype)
bool FlowPassable(df::tiletype tiletype)
{
return tileTypeTable[tiletype].shape >= WALL && tileTypeTable[tiletype].shape <= FORTIFICATION ;
return tiletype_shape::get_passable_high(tiletype::get_shape(tiletype));
}
inline
bool isFloorTerrain(int16_t tiletype)
bool isWallTerrain(df::tiletype tiletype)
{
return tileTypeTable[tiletype].shape >= FLOOR && tileTypeTable[tiletype].shape <= PEBBLES;
return tiletype_shape::get_basic_shape(tiletype::get_shape(tiletype)) == tiletype_shape_basic::Wall;
}
inline
bool isRampTerrain(int16_t tiletype)
bool isFloorTerrain(df::tiletype tiletype)
{
return tileTypeTable[tiletype].shape == RAMP;
return tiletype_shape::get_basic_shape(tiletype::get_shape(tiletype)) == tiletype_shape_basic::Floor;
}
inline
bool isStairTerrain(int16_t tiletype)
bool isRampTerrain(df::tiletype tiletype)
{
return tileTypeTable[tiletype].shape >= STAIR_UP && tileTypeTable[tiletype].shape <= STAIR_UPDOWN;
return tiletype_shape::get_basic_shape(tiletype::get_shape(tiletype)) == tiletype_shape_basic::Ramp;
}
inline
bool isOpenTerrain(int16_t tiletype)
bool isOpenTerrain(df::tiletype tiletype)
{
return tileTypeTable[tiletype].shape == EMPTY;
return tiletype_shape::get_basic_shape(tiletype::get_shape(tiletype)) == tiletype_shape_basic::Open;
}
inline
const char * tileName(int16_t tiletype)
bool isStairTerrain(df::tiletype tiletype)
{
return tileTypeTable[tiletype].name;
return tiletype_shape::get_basic_shape(tiletype::get_shape(tiletype)) == tiletype_shape_basic::Stair;
}
inline
TileShape tileShape(int16_t tiletype)
const char * tileName(df::tiletype tiletype)
{
return tileTypeTable[tiletype].shape;
return tiletype::get_caption(tiletype);
}
inline
TileSpecial tileSpecial(int16_t tiletype)
df::tiletype_shape tileShape(df::tiletype tiletype)
{
return tileTypeTable[tiletype].special;
return tiletype::get_shape(tiletype);
}
inline
TileVariant tileVariant(int16_t tiletype)
df::tiletype_special tileSpecial(df::tiletype tiletype)
{
return tileTypeTable[tiletype].variant;
return tiletype::get_special(tiletype);
}
inline
TileMaterial tileMaterial(int16_t tiletype)
df::tiletype_variant tileVariant(df::tiletype tiletype)
{
return tileTypeTable[tiletype].material;
return tiletype::get_variant(tiletype);
}
inline
TileDirection tileDirection(int16_t tiletype)
df::tiletype_material tileMaterial(df::tiletype tiletype)
{
return tileTypeTable[tiletype].direction;
return tiletype::get_material(tiletype);
}
/// Safely access the tile type array.
inline const
TileRow * getTileRow(int16_t tiletype)
inline
TileDirection tileDirection(df::tiletype tiletype)
{
if( tiletype<0 || tiletype>=TILE_TYPE_ARRAY_LENGTH ) return 0;
return ( const TileRow * ) &tileTypeTable[tiletype];
return TileDirection(tiletype::get_direction(tiletype));
}
/**
@ -384,23 +235,22 @@ namespace DFHack
* 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.
* @return matching index in tileTypeTable, or -1 if none found.
* @return matching index in tileTypeTable, or 0 if none found.
*/
inline
int16_t findTileType( const TileShape tshape, const TileMaterial tmat, const TileVariant tvar, const TileSpecial tspecial, const TileDirection tdir )
df::tiletype findTileType( const df::tiletype_shape tshape, const df::tiletype_material tmat, const df::tiletype_variant tvar, const df::tiletype_special tspecial, const TileDirection tdir )
{
int16_t tt;
for(tt=0;tt<TILE_TYPE_ARRAY_LENGTH; ++tt)
FOR_ENUM_ITEMS(tiletype, tt)
{
if( tshape>-1 && tshape != tileTypeTable[tt].shape ) continue;
if( tmat>-1 && tmat != tileTypeTable[tt].material ) continue;
if( tvar>-1 && tvar != tileTypeTable[tt].variant ) continue;
if( tspecial>-1 && tspecial != tileTypeTable[tt].special ) continue;
if( tdir.whole && tdir.whole != tileTypeTable[tt].direction.whole ) continue;
//Match!
if (tshape != tiletype_shape::NONE && tshape != tileShape(tt)) continue;
if (tmat != tiletype_material::NONE && tmat != tileMaterial(tt)) continue;
if (tvar != tiletype_variant::NONE && tvar != tileVariant(tt)) continue;
if (tspecial != tiletype_special::NONE && tspecial != tileSpecial(tt)) continue;
if (tdir && tdir != tileDirection(tt)) continue;
// Match!
return tt;
}
return -1;
return tiletype::Void;
}
/**
@ -410,9 +260,13 @@ namespace DFHack
*
* @todo Definitely needs improvement for wall directions, etc.
*/
DFHACK_EXPORT int16_t findSimilarTileType( const int16_t sourceTileType, const TileShape tshape );
}
DFHACK_EXPORT df::tiletype findSimilarTileType( const df::tiletype sourceTileType, const df::tiletype_shape tshape );
/**
* Finds a random variant of the selected tile
* If there are no variants, returns the same tile
*/
DFHACK_EXPORT df::tiletype findRandomVariant(const df::tiletype tile);
}
#endif // TILETYPES_H_INCLUDED

@ -47,8 +47,8 @@ void SquashVeins (DFCoord bcoord, mapblock40d & mb, t_blockmaterials & materials
//iterate through columns
for (uint32_t k = 0; k< 16;k++)
{
int16_t tt = mb.tiletypes[k][j];
if(DFHack::tileMaterial(tt) == DFHack::VEIN)
df::tiletype tt = mb.tiletypes[k][j];
if(DFHack::tileMaterial(tt) == tiletype_material::MINERAL)
{
for(int i = (int) veins.size() - 1; i >= 0;i--)
{
@ -123,11 +123,11 @@ class Block
veinmats[p.x][p.y] = -1;
}
uint16_t TileTypeAt(df::coord2d p)
df::tiletype TileTypeAt(df::coord2d p)
{
return raw.tiletypes[p.x][p.y];
}
bool setTiletypeAt(df::coord2d p, uint16_t tiletype)
bool setTiletypeAt(df::coord2d p, df::tiletype tiletype)
{
if(!valid) return false;
dirty_tiletypes = true;
@ -291,16 +291,16 @@ class MapCache
return 0;
}
}
uint16_t tiletypeAt (DFHack::DFCoord tilecoord)
df::tiletype tiletypeAt (DFHack::DFCoord tilecoord)
{
Block * b= BlockAt(tilecoord / 16);
if(b && b->valid)
{
return b->TileTypeAt(tilecoord % 16);
}
return 0;
return tiletype::Void;
}
bool setTiletypeAt(DFHack::DFCoord tilecoord, uint16_t tiletype)
bool setTiletypeAt(DFHack::DFCoord tilecoord, df::tiletype tiletype)
{
Block * b= BlockAt(tilecoord / 16);
if(b && b->valid)

@ -134,7 +134,7 @@ union t_blockflags
* 16x16 array of tile types
* \ingroup grp_maps
*/
typedef int16_t tiletypes40d [16][16];
typedef df::tiletype tiletypes40d [16][16];
/**
* 16x16 array used for squashed block materials
* \ingroup grp_maps

@ -144,7 +144,7 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
c->con.printerr("Cursor is in an invalid/uninitialized area. Place it over a floor.\n");
return CR_FAILURE;
}
uint16_t ttype = MC.tiletypeAt(pos_cursor);
df::tiletype ttype = MC.tiletypeAt(pos_cursor);
if(!DFHack::isFloorTerrain(ttype))
{
c->con.printerr("Cursor should be placed over a floor.\n");

@ -43,13 +43,13 @@ DFhackCExport command_result df_deramp (Core * c, vector <string> & parameters)
{
for (int y = 0; y < 16; y++)
{
int16_t oldT = block->tiletype[x][y];
if ((tileShape(oldT) == RAMP) &&
df::tiletype oldT = block->tiletype[x][y];
if ((tileShape(oldT) == tiletype_shape::RAMP) &&
(block->designation[x][y].bits.dig == tile_dig_designation::Default))
{
// Current tile is a ramp.
// Set current tile, as accurately as can be expected
int16_t newT = findSimilarTileType(oldT, FLOOR);
df::tiletype newT = findSimilarTileType(oldT, tiletype_shape::FLOOR);
// If no change, skip it (couldn't find a good tile type)
if (oldT == newT)
@ -59,15 +59,15 @@ DFhackCExport command_result df_deramp (Core * c, vector <string> & parameters)
block->designation[x][y].bits.dig = tile_dig_designation::No;
// Check the tile above this one, in case a downward slope needs to be removed.
if ((above) && (tileShape(above->tiletype[x][y]) == RAMP_TOP))
above->tiletype[x][y] = 32; // open space
if ((above) && (tileShape(above->tiletype[x][y]) == tiletype_shape::RAMP_TOP))
above->tiletype[x][y] = tiletype::OpenSpace; // open space
count++;
}
// ramp fixer
else if ((tileShape(oldT) != RAMP)
&& (above) && (tileShape(above->tiletype[x][y]) == RAMP_TOP))
else if ((tileShape(oldT) != tiletype_shape::RAMP)
&& (above) && (tileShape(above->tiletype[x][y]) == tiletype_shape::RAMP_TOP))
{
above->tiletype[x][y] = 32; // open space
above->tiletype[x][y] = tiletype::OpenSpace; // open space
countbad++;
}
}

@ -141,7 +141,7 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
MapExtras::MapCache MCache;
df::tile_designation des = MCache.designationAt(xy);
int16_t tt = MCache.tiletypeAt(xy);
df::tiletype tt = MCache.tiletypeAt(xy);
df::tile_occupancy oc;
if (checkbuilding)

@ -22,10 +22,10 @@ using namespace df::enums;
using df::global::world;
bool setTileMaterial(int16_t &tile, const TileMaterial mat)
bool setTileMaterial(df::tiletype &tile, const df::tiletype_material mat)
{
int16_t newTile = findTileType(tileShape(tile), mat, tileVariant(tile), tileSpecial(tile), tileDirection(tile));
if (newTile == -1)
df::tiletype newTile = findTileType(tileShape(tile), mat, tileVariant(tile), tileSpecial(tile), tileDirection(tile));
if (newTile == tiletype::Void)
return false;
if (newTile != tile)
{
@ -77,16 +77,16 @@ DFhackCExport command_result df_fixveins (Core * c, vector <string> & parameters
bool has_vein = has_mineral[y] & (1 << x);
if (has_feature)
has_vein = false;
int16_t oldT = block->tiletype[x][y];
TileMaterial mat = tileMaterial(oldT);
if ((mat == VEIN) && !has_vein)
mineral_removed += setTileMaterial(block->tiletype[x][y], STONE);
if ((mat == STONE) && has_vein)
mineral_added += setTileMaterial(block->tiletype[x][y], VEIN);
if ((mat == FEATSTONE) && !has_feature)
feature_removed += setTileMaterial(block->tiletype[x][y], STONE);
if ((mat == STONE) && has_feature)
feature_added += setTileMaterial(block->tiletype[x][y], FEATSTONE);
df::tiletype oldT = block->tiletype[x][y];
df::tiletype_material mat = tileMaterial(oldT);
if ((mat == tiletype_material::MINERAL) && !has_vein)
mineral_removed += setTileMaterial(block->tiletype[x][y], tiletype_material::STONE);
if ((mat == tiletype_material::STONE) && has_vein)
mineral_added += setTileMaterial(block->tiletype[x][y], tiletype_material::MINERAL);
if ((mat == tiletype_material::FEATURE) && !has_feature)
feature_removed += setTileMaterial(block->tiletype[x][y], tiletype_material::STONE);
if ((mat == tiletype_material::STONE) && has_feature)
feature_added += setTileMaterial(block->tiletype[x][y], tiletype_material::FEATURE);
}
}
}

@ -105,10 +105,11 @@ DFhackCExport command_result df_getplants (Core * c, vector <string> & parameter
if (!exclude)
continue;
}
TileShape shape = tileShape(cur->tiletype[x][y]);
if (plant->flags.bits.is_shrub && (treesonly || shape != SHRUB_OK))
df::tiletype_shape shape = tileShape(cur->tiletype[x][y]);
df::tiletype_special special = tileSpecial(cur->tiletype[x][y]);
if (plant->flags.bits.is_shrub && (treesonly || (shape != tiletype_shape::SHRUB && special != tiletype_special::DEAD)))
continue;
if (!plant->flags.bits.is_shrub && (shrubsonly || (shape != TREE_OK && shape != TREE_DEAD)))
if (!plant->flags.bits.is_shrub && (shrubsonly || shape != tiletype_shape::TREE))
continue;
if (cur->designation[x][y].bits.hidden)
continue;

@ -129,7 +129,7 @@ public:
bool juststarted = true;
while (mc.testCoord(start))
{
uint16_t tt = mc.tiletypeAt(start);
df::tiletype tt = mc.tiletypeAt(start);
if(DFHack::LowPassable(tt) || juststarted && DFHack::HighPassable(tt))
{
v.push_back(start);
@ -177,7 +177,7 @@ public:
maybeFlood(DFCoord(xy.x, xy.y - 1, xy.z), to_flood, mc);
maybeFlood(DFCoord(xy.x, xy.y + 1, xy.z), to_flood, mc);
uint16_t tt = mc.tiletypeAt(xy);
df::tiletype tt = mc.tiletypeAt(xy);
if (LowPassable(tt))
{
maybeFlood(DFCoord(xy.x, xy.y, xy.z - 1), to_flood, mc);
@ -455,7 +455,7 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
coord_vec::iterator iter = all_tiles.begin();
while (iter != all_tiles.end())
{
mcache.setTiletypeAt(*iter, 331);
mcache.setTiletypeAt(*iter, tiletype::LavaWall);
mcache.setTemp1At(*iter,10015);
mcache.setTemp2At(*iter,10015);
df::tile_designation des = mcache.designationAt(*iter);
@ -469,7 +469,7 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
coord_vec::iterator iter = all_tiles.begin();
while (iter != all_tiles.end())
{
mcache.setTiletypeAt(*iter, 340);
mcache.setTiletypeAt(*iter, findRandomVariant(tiletype::LavaFloor1));
iter ++;
}
}
@ -478,7 +478,7 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
coord_vec::iterator iter = all_tiles.begin();
while (iter != all_tiles.end())
{
mcache.setTiletypeAt(*iter, 90);
mcache.setTiletypeAt(*iter, tiletype::RiverSource);
df::tile_designation a = mcache.designationAt(*iter);
a.bits.liquid_type = tile_liquid::Water;
@ -525,7 +525,7 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
continue;
}
df::tile_designation des = mcache.designationAt(current);
uint16_t tt = mcache.tiletypeAt(current);
df::tiletype tt = mcache.tiletypeAt(current);
// don't put liquids into places where they don't belong...
if(!DFHack::FlowPassable(tt))
{

@ -206,15 +206,14 @@ DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & pa
prototile->set_flow_size(des.bits.flow_size);
}
uint16_t type = b->TileTypeAt(coord);
const DFHack::TileRow *info = DFHack::getTileRow(type);
prototile->set_type((dfproto::Tile::TileType)info->shape);
df::tiletype type = b->TileTypeAt(coord);
prototile->set_type((dfproto::Tile::TileType)tileShape(type));
prototile->set_material_type((dfproto::Tile::MaterialType)info->material);
prototile->set_material_type((dfproto::Tile::MaterialType)tileMaterial(type));
df::coord map_pos = df::coord(b_x*16+x,b_y*16+y,z);
switch (info->material)
switch (tileMaterial(type))
{
case DFHack::SOIL:
case DFHack::STONE:

@ -105,7 +105,7 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre
c->con.printerr("Map is not available!\n");
return CR_FAILURE;
}
DFHack::Gui * Gui = c->getGui();
Gui * Gui = c->getGui();
uint32_t x_max, y_max, z_max;
Maps::getSize(x_max, y_max, z_max);
MapExtras::MapCache map;
@ -208,7 +208,7 @@ DFhackCExport command_result df_grow (Core * c, vector <string> & parameters)
return CR_FAILURE;
}
MapExtras::MapCache map;
DFHack::Gui *Gui = c->getGui();
Gui *Gui = c->getGui();
int32_t x,y,z;
if(Gui->getCursorCoords(x,y,z))
{
@ -220,7 +220,8 @@ DFhackCExport command_result df_grow (Core * c, vector <string> & parameters)
df::plant * tree = alltrees->at(i);
if(tree->pos.x == x && tree->pos.y == y && tree->pos.z == z)
{
if(DFHack::tileShape(map.tiletypeAt(DFHack::DFCoord(x,y,z))) == DFHack::SAPLING_OK)
if(tileShape(map.tiletypeAt(DFCoord(x,y,z))) == tiletype_shape::SAPLING &&
tileSpecial(map.tiletypeAt(DFCoord(x,y,z))) != tiletype_special::DEAD)
{
tree->grow_counter = Vegetation::sapling_to_tree_threshold;
}
@ -235,8 +236,8 @@ DFhackCExport command_result df_grow (Core * c, vector <string> & parameters)
for(size_t i = 0 ; i < world->plants.all.size(); i++)
{
df::plant *p = world->plants.all[i];
uint16_t ttype = map.tiletypeAt(df::coord(p->pos.x,p->pos.y,p->pos.z));
if(!p->flags.bits.is_shrub && DFHack::tileShape(ttype) == DFHack::SAPLING_OK)
df::tiletype ttype = map.tiletypeAt(df::coord(p->pos.x,p->pos.y,p->pos.z));
if(!p->flags.bits.is_shrub && tileShape(ttype) == tiletype_shape::SAPLING && tileSpecial(ttype) != tiletype_special::DEAD)
{
p->grow_counter = Vegetation::sapling_to_tree_threshold;
}

@ -143,7 +143,7 @@ DFhackCExport command_result df_probe (Core * c, vector <string> & parameters)
con.print("\n\n");
}
*/
int16_t tiletype = mc.tiletypeAt(cursor);
df::tiletype tiletype = mc.tiletypeAt(cursor);
df::tile_designation &des = block.designation[tileX][tileY];
/*
if(showDesig)
@ -169,15 +169,15 @@ DFhackCExport command_result df_probe (Core * c, vector <string> & parameters)
con.print(" = %s",tileName(tiletype));
con.print("\n");
DFHack::TileShape shape = tileShape(tiletype);
DFHack::TileMaterial material = tileMaterial(tiletype);
DFHack::TileSpecial special = tileSpecial(tiletype);
df::tiletype_shape shape = tileShape(tiletype);
df::tiletype_material material = tileMaterial(tiletype);
df::tiletype_special special = tileSpecial(tiletype);
con.print("%-10s: %4d %s\n","Class" ,shape,
TileShapeString[ shape ]);
tiletype_shape::get_key(shape));
con.print("%-10s: %4d %s\n","Material" ,
material,TileMaterialString[ material ]);
material, tiletype_material::get_key(material));
con.print("%-10s: %4d %s\n","Special" ,
special, TileSpecialString[ special ]);
special, tiletype_special::get_key(special));
con.print("%-10s: %4d\n" ,"Variant" ,
tileVariant(tiletype));
con.print("%-10s: %s\n" ,"Direction",

@ -471,27 +471,21 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
liquidWater.add(global_z);
}
uint16_t type = b->TileTypeAt(coord);
const DFHack::TileRow *info = DFHack::getTileRow(type);
if (!info)
{
con << "Bad type: " << type << std::endl;
continue;
}
df::tiletype type = b->TileTypeAt(coord);
df::tiletype_shape tileshape = tileShape(type);
df::tiletype_material tilemat = tileMaterial(type);
// We only care about these types
switch (info->shape)
switch (tileshape)
{
case DFHack::WALL:
case DFHack::PILLAR:
case DFHack::FORTIFICATION:
case tiletype_shape::WALL:
case tiletype_shape::FORTIFICATION:
break;
case DFHack::EMPTY:
case tiletype_shape::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 &&
if (tilemat == tiletype_material::AIR &&
des.bits.feature_local && des.bits.hidden &&
blockFeatureLocal.type == feature_type::deep_special_tube)
{
@ -502,19 +496,19 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
}
// Count the material type
baseMats[info->material].add(global_z);
baseMats[tilemat].add(global_z);
// Find the type of the tile
switch (info->material)
switch (tilemat)
{
case DFHack::SOIL:
case DFHack::STONE:
case tiletype_material::SOIL:
case tiletype_material::STONE:
layerMats[b->baseMaterialAt(coord)].add(global_z);
break;
case DFHack::VEIN:
case tiletype_material::MINERAL:
veinMats[b->veinMaterialAt(coord)].add(global_z);
break;
case DFHack::FEATSTONE:
case tiletype_material::FEATURE:
if (blockFeatureLocal.type != -1 && des.bits.feature_local)
{
if (blockFeatureLocal.type == feature_type::deep_special_tube
@ -536,7 +530,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
layerMats[blockFeatureGlobal.sub_material].add(global_z);
}
break;
case DFHack::OBSIDIAN:
case tiletype_material::LAVA_STONE:
// TODO ?
break;
}
@ -578,7 +572,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
con << "Base materials:" << std::endl;
for (it = baseMats.begin(); it != baseMats.end(); ++it)
{
con << std::setw(25) << DFHack::TileMaterialString[it->first] << " : " << it->second.count << std::endl;
con << std::setw(25) << tiletype_material::get_key((df::tiletype_material)it->first) << " : " << it->second.count << std::endl;
}
if (liquidWater.count || liquidMagma.count)

@ -61,10 +61,10 @@ int toint(const std::string &str, int failValue = 0)
struct TileType
{
DFHack::TileShape shape;
DFHack::TileMaterial material;
DFHack::TileSpecial special;
DFHack::TileVariant variant;
df::tiletype_shape shape;
df::tiletype_material material;
df::tiletype_special special;
df::tiletype_variant variant;
int dig;
int hidden;
int light;
@ -73,10 +73,10 @@ struct TileType
TileType()
{
shape = DFHack::tileshape_invalid;
material = DFHack::tilematerial_invalid;
special = DFHack::tilespecial_invalid;
variant = DFHack::tilevariant_invalid;
shape = tiletype_shape::NONE;
material = tiletype_material::NONE;
special = tiletype_special::NONE;
variant = tiletype_variant::NONE;
dig = -1;
hidden = -1;
light = -1;
@ -258,18 +258,18 @@ bool processTileType(TileType &paint, const std::string &option, const std::stri
}
else if (option == "material" || option == "mat" || option == "m")
{
if (valInt >= -1 && valInt < DFHack::tilematerial_count)
if (tiletype_material::is_valid((df::tiletype_material)valInt))
{
paint.material = (DFHack::TileMaterial) valInt;
paint.material = (df::tiletype_material)valInt;
found = true;
}
else
{
for (int i = 0; i < DFHack::tilematerial_count; i++)
FOR_ENUM_ITEMS(tiletype_material, i)
{
if (val == DFHack::TileMaterialString[i])
if (val == tiletype_material::get_key(i))
{
paint.material = (DFHack::TileMaterial) i;
paint.material = i;
found = true;
break;
}
@ -777,37 +777,37 @@ DFhackCExport command_result df_tiletypes (Core * c, vector <string> & parameter
for (coord_vec::iterator iter = all_tiles.begin(); iter != all_tiles.end(); ++iter)
{
const DFHack::TileRow *source = DFHack::getTileRow(map.tiletypeAt(*iter));
const df::tiletype source = map.tiletypeAt(*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)
if ((filter.shape > -1 && filter.shape != tileShape(source))
|| (filter.material > -1 && filter.material != tileMaterial(source))
|| (filter.special > -1 && filter.special != tileSpecial(source))
|| (filter.variant > -1 && filter.variant != tileVariant(source))
|| (filter.dig > -1 && (filter.dig != 0) != (des.bits.dig != tile_dig_designation::No))
)
{
continue;
}
DFHack::TileShape shape = paint.shape;
if (shape < 0)
df::tiletype_shape shape = paint.shape;
if (shape == tiletype_shape::NONE)
{
shape = source->shape;
shape = tileShape(source);
}
DFHack::TileMaterial material = paint.material;
if (material < 0)
df::tiletype_material material = paint.material;
if (material == tiletype_material::NONE)
{
material = source->material;
material = tileMaterial(source);
}
DFHack::TileSpecial special = paint.special;
if (special < 0)
df::tiletype_special special = paint.special;
if (special == tiletype_special::NONE)
{
special = source->special;
special = tileSpecial(source);
}
DFHack::TileVariant variant = paint.variant;
df::tiletype_variant variant = paint.variant;
/*
* FIXME: variant should be:
* 1. If user variant:
@ -826,24 +826,24 @@ DFhackCExport command_result df_tiletypes (Core * c, vector <string> & parameter
* the usefullness of the tool.
*/
/*
if (variant < 0)
if (variant == tiletype_variant::NONE)
{
variant = source->variant;
variant = tileVariant(source);
}
*/
// Remove direction from directionless tiles
DFHack::TileDirection direction = source->direction;
if (!(shape == DFHack::RIVER_BED || shape == DFHack::BROOK_BED || shape == DFHack::WALL && (material == DFHack::CONSTRUCTED || special == DFHack::TILE_SMOOTH))) {
DFHack::TileDirection direction = tileDirection(source);
if (!(shape == tiletype_shape::RIVER_BED || shape == tiletype_shape::BROOK_BED || shape == tiletype_shape::WALL && (material == tiletype_material::CONSTRUCTION || special == tiletype_special::SMOOTH))) {
direction.whole = 0;
}
int32_t type = DFHack::findTileType(shape, material, variant, special, direction);
df::tiletype type = DFHack::findTileType(shape, material, variant, special, direction);
// hack for empty space
if (shape == DFHack::EMPTY && material == DFHack::AIR && variant == DFHack::VAR_1 && special == DFHack::TILE_NORMAL && direction.whole == 0) {
type = 32;
if (shape == tiletype_shape::EMPTY && material == tiletype_material::AIR && variant == tiletype_variant::VAR_1 && special == tiletype_special::NORMAL && direction.whole == 0) {
type = tiletype::OpenSpace;
}
// make sure it's not invalid
if(type != -1)
if(type != tiletype::Void)
map.setTiletypeAt(*iter, type);
if (paint.hidden > -1)

@ -79,7 +79,7 @@ DFhackCExport command_result tubefill(DFHack::Core * c, std::vector<std::string>
continue;
// Is the tile already a wall?
if (tileShape(block->tiletype[x][y]) == WALL)
if (tileShape(block->tiletype[x][y]) == tiletype_shape::WALL)
continue;
// Does the tile contain liquid?
@ -92,16 +92,16 @@ DFhackCExport command_result tubefill(DFHack::Core * c, std::vector<std::string>
// 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))
if ((tileShape(above->tiletype[x][y]) == tiletype_shape::EMPTY) || (tileShape(above->tiletype[x][y]) == tiletype_shape::RAMP_TOP))
{
// 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());
above->tiletype[x][y] = findRandomVariant(tiletype::FeatureFloor1);
}
}
block->tiletype[x][y] = findTileType(WALL, FEATSTONE, tilevariant_invalid, TILE_NORMAL, TileDirection());
block->tiletype[x][y] = tiletype::FeatureWall;
++count;
}
}

@ -90,33 +90,33 @@ bool dig (MapExtras::MapCache & MCache,
//c->con.print("not digging map border\n");
return false;
}
uint16_t tt = MCache.tiletypeAt(at);
df::tiletype tt = MCache.tiletypeAt(at);
df::tile_designation des = MCache.designationAt(at);
// could be potentially used to locate hidden constructions?
if(tileMaterial(tt) == CONSTRUCTED && !des.bits.hidden)
if(tileMaterial(tt) == df::tiletype_material::CONSTRUCTION && !des.bits.hidden)
return false;
TileShape ts = tileShape(tt);
if(ts == EMPTY)
df::tiletype_shape ts = tileShape(tt);
if (ts == tiletype_shape::EMPTY)
return false;
if(!des.bits.hidden)
{
do
{
if(isWallTerrain(tt))
df::tiletype_shape_basic tsb = tiletype_shape::get_basic_shape(ts);
if(tsb == tiletype_shape_basic::Wall)
{
std::cerr << "allowing tt" << tt << ", is wall\n";
std::cerr << "allowing tt" << (int)tt << ", is wall\n";
break;
}
if(isFloorTerrain(tt)
if (tsb == tiletype_shape_basic::Floor
&& (type == tile_dig_designation::DownStair || type == tile_dig_designation::Channel)
&& ts != TREE_OK
&& ts != TREE_DEAD
&& ts != tiletype_shape::TREE
)
{
std::cerr << "allowing tt" << tt << ", is floor\n";
std::cerr << "allowing tt" << (int)tt << ", is floor\n";
break;
}
if(isStairTerrain(tt) && type == tile_dig_designation::Channel )
if (tsb == tiletype_shape_basic::Stair && type == tile_dig_designation::Channel )
break;
return false;
}
@ -147,7 +147,7 @@ bool dig (MapExtras::MapCache & MCache,
}
break;
}
std::cerr << "allowing tt" << tt << "\n";
std::cerr << "allowing tt" << (int)tt << "\n";
MCache.setDesignationAt(at,des);
return true;
};
@ -747,9 +747,9 @@ bool stamp_pattern (uint32_t bx, uint32_t by, int z_level,
for(; y < my; y++)
{
df::tile_designation & des = bl->designation[x][y];
short unsigned int tt = bl->tiletype[x][y];
df::tiletype tt = bl->tiletype[x][y];
// could be potentially used to locate hidden constructions?
if(tileMaterial(tt) == CONSTRUCTED && !des.bits.hidden)
if(tileMaterial(tt) == tiletype_material::CONSTRUCTION && !des.bits.hidden)
continue;
if(!isWallTerrain(tt) && !des.bits.hidden)
continue;
@ -927,11 +927,11 @@ DFhackCExport command_result expdig (Core * c, vector <string> & parameters)
for(int y = 0; y < 16; y++)
{
DFCoord pos(xmid+x,ymid+y,z_level);
short unsigned int tt = mx.tiletypeAt(pos);
if(tt == 0)
df::tiletype tt = mx.tiletypeAt(pos);
if(tt == tiletype::Void)
continue;
df::tile_designation des = mx.designationAt(pos);
if(tileMaterial(tt) == CONSTRUCTED && !des.bits.hidden)
if(tileMaterial(tt) == tiletype_material::CONSTRUCTION && !des.bits.hidden)
continue;
if(!isWallTerrain(tt) && !des.bits.hidden)
continue;
@ -1002,7 +1002,7 @@ DFhackCExport command_result vdig (Core * c, vector <string> & parameters)
}
MapExtras::MapCache * MCache = new MapExtras::MapCache;
df::tile_designation des = MCache->designationAt(xy);
int16_t tt = MCache->tiletypeAt(xy);
df::tiletype tt = MCache->tiletypeAt(xy);
int16_t veinmat = MCache->veinMaterialAt(xy);
if( veinmat == -1 )
{