Conflicts:
	plugins/mapexport/mapexport.cpp
develop
Petr Mrázek 2012-02-14 09:59:33 +01:00
commit 448e270421
44 changed files with 587 additions and 1412 deletions

@ -28,710 +28,77 @@ distribution.
namespace DFHack namespace DFHack
{ {
const TileRow tileTypeTable[TILE_TYPE_ARRAY_LENGTH] = df::tiletype findSimilarTileType (const df::tiletype sourceTileType, const df::tiletype_shape tshape)
{ {
// 0x000 df::tiletype match = tiletype::Void;
{ "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 },
{ 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; 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. //Shortcut.
//If the current tile is already a shape match, leave. //If the current tile is already a shape match, leave.
if( tshape == source->shape ) return sourceTileType; if (tshape == cur_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);
#ifdef assert #ifdef assert
assert( sourceTileType >=0 && sourceTileType < TILE_TYPE_ARRAY_LENGTH ); assert(tiletype::is_valid(sourceTileType));
#endif #endif
// Special case for smooth pillars. // Special case for smooth pillars.
// When you want a smooth wall, no need to search for best match. Just use a pillar instead. // 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. // Choosing the right direction would require knowing neighbors.
if( WALL==tshape && (TILE_SMOOTH==source->special || CONSTRUCTED==source->material) ){
switch( source->material ){ if ((tshape == tiletype_shape::WALL) && ((cur_special == tiletype_special::SMOOTH) || (cur_material == tiletype_material::CONSTRUCTION)))
case CONSTRUCTED: match=495; break; {
case ICE: match= 83; break; switch (cur_material)
case VEIN: match= 82; break; {
case FEATSTONE: match= 81; break; case tiletype_material::CONSTRUCTION:
case OBSIDIAN: match= 80; break; return tiletype::ConstructedPillar;
case STONE: match= 79; break; 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. // Run through until perfect match found or hit end.
for(int16_t tt=0;tt<TILE_TYPE_ARRAY_LENGTH && value<(8|4|1); ++tt) FOR_ENUM_ITEMS(tiletype, tt)
{ {
if( tshape == tileTypeTable[tt].shape ) if (value == (8|4|1))
break;
if (tileShape(tt) == tshape)
{ {
//shortcut null entries // Special flag match is mandatory, but only if it might possibly make a difference
if(!tileTypeTable[tt].name) continue; if (tileSpecial(tt) != tiletype_special::NONE && cur_special != tiletype_special::NONE && tileSpecial(tt) != cur_special)
continue;
//Special flag match is absolutely mandatory!
if( source->special != tileTypeTable[tt].special ) continue;
// Special case for constructions. // Special case for constructions.
// Never turn a construction into a non-contruction. // Never turn a construction into a non-contruction.
if( CONSTRUCTED == source->material && CONSTRUCTED != tileTypeTable[tt].material ) continue; if ((cur_material == tiletype_material::CONSTRUCTION) && (tileMaterial(tt) != cur_material))
continue;
value = 0; value = 0;
//Material is high-value match //Material is high-value match
if( tileTypeTable[tt].material == source->material ) value|=8; if (cur_material == tileMaterial(tt))
value |= 8;
// Direction is medium value match // Direction is medium value match
if( tileTypeTable[tt].direction.whole == source->direction.whole ) value|=4; if (cur_direction == tileDirection(tt))
value |= 4;
// Variant is low-value match // Variant is low-value match
if( tileTypeTable[tt].variant == source->variant ) value|=1; if (cur_variant == tileVariant(tt))
value |= 1;
// Check value against last match. // Check value against last match.
if (value > matchv) if (value > matchv)
@ -742,39 +109,24 @@ namespace DFHack
} }
} }
//Post-processing for floors. // If the selected tile has a variant, then pick a random one
//Give raw floors variation. match = findRandomVariant(match);
//Variant matters, but does not matter for source. if (match)
//Error on the side of caution. return match;
if( FLOOR==tshape && CONSTRUCTED!=source->material && !source->special ) return sourceTileType;
{
//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;
} }
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)
{
if (tileShape(tt) == tileShape(tile) &&
tileMaterial(tt) == tileMaterial(tile) &&
tileSpecial(tt) == tileSpecial(tile))
matches.push_back(tt);
} }
if( match ) return match; return matches[rand() % matches.size()];
return sourceTileType;
} }
} }

@ -29,118 +29,11 @@ distribution.
#include "Pragma.h" #include "Pragma.h"
#include "Export.h" #include "Export.h"
#include "DataDefs.h"
#include "df/tiletype.h"
namespace DFHack 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 //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;
@ -162,6 +55,18 @@ namespace DFHack
{ {
whole = whole_bits; 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 ) 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;
@ -235,172 +140,124 @@ namespace DFHack
#undef DIRECTION #undef DIRECTION
return str; return str;
} }
}; };
struct TileRow using namespace df::enums;
{
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[];
// tile is missing a floor
inline inline
bool LowPassable(int16_t tiletype) const char * tileName(df::tiletype tiletype)
{
switch(DFHack::tileTypeTable[tiletype].shape)
{ {
case DFHack::EMPTY: return ENUM_ATTR(tiletype, caption, tiletype);
case DFHack::STAIR_DOWN:
case DFHack::STAIR_UPDOWN:
case DFHack::RAMP_TOP:
return true;
default:
return false;
} }
};
// tile is missing a roof
inline inline
bool HighPassable(int16_t tiletype) df::tiletype_shape tileShape(df::tiletype tiletype)
{
switch(DFHack::tileTypeTable[tiletype].shape)
{ {
case DFHack::EMPTY: return ENUM_ATTR(tiletype, shape, tiletype);
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)
{
TileShape tc = tileTypeTable[tiletype].shape;
return tc != WALL && tc != PILLAR && tc != TREE_DEAD && tc != TREE_OK;
};
inline inline
bool isWallTerrain(int16_t tiletype) df::tiletype_special tileSpecial(df::tiletype tiletype)
{ {
return tileTypeTable[tiletype].shape >= WALL && tileTypeTable[tiletype].shape <= FORTIFICATION ; return ENUM_ATTR(tiletype, special, tiletype);
} }
inline inline
bool isFloorTerrain(int16_t tiletype) df::tiletype_variant tileVariant(df::tiletype tiletype)
{ {
return tileTypeTable[tiletype].shape >= FLOOR && tileTypeTable[tiletype].shape <= PEBBLES; return ENUM_ATTR(tiletype, variant, tiletype);
} }
inline inline
bool isRampTerrain(int16_t tiletype) df::tiletype_material tileMaterial(df::tiletype tiletype)
{ {
return tileTypeTable[tiletype].shape == RAMP; return ENUM_ATTR(tiletype, material, tiletype);
} }
inline inline
bool isStairTerrain(int16_t tiletype) TileDirection tileDirection(df::tiletype tiletype)
{ {
return tileTypeTable[tiletype].shape >= STAIR_UP && tileTypeTable[tiletype].shape <= STAIR_UPDOWN; return TileDirection(ENUM_ATTR(tiletype, direction, tiletype));
} }
// tile is missing a floor
inline inline
bool isOpenTerrain(int16_t tiletype) bool LowPassable(df::tiletype tiletype)
{ {
return tileTypeTable[tiletype].shape == EMPTY; return ENUM_ATTR(tiletype_shape, passable_low, tileShape(tiletype));
} }
// tile is missing a roof
inline inline
const char * tileName(int16_t tiletype) bool HighPassable(df::tiletype tiletype)
{ {
return tileTypeTable[tiletype].name; return ENUM_ATTR(tiletype_shape, passable_high, tileShape(tiletype));
} }
inline inline
TileShape tileShape(int16_t tiletype) bool FlowPassable(df::tiletype tiletype)
{ {
return tileTypeTable[tiletype].shape; return ENUM_ATTR(tiletype_shape, passable_flow, tileShape(tiletype));
} }
inline inline
TileSpecial tileSpecial(int16_t tiletype) bool isWallTerrain(df::tiletype tiletype)
{ {
return tileTypeTable[tiletype].special; return ENUM_ATTR(tiletype_shape, basic_shape, tileShape(tiletype)) == tiletype_shape_basic::Wall;
} }
inline inline
TileVariant tileVariant(int16_t tiletype) bool isFloorTerrain(df::tiletype tiletype)
{ {
return tileTypeTable[tiletype].variant; return ENUM_ATTR(tiletype_shape, basic_shape, tileShape(tiletype)) == tiletype_shape_basic::Floor;
} }
inline inline
TileMaterial tileMaterial(int16_t tiletype) bool isRampTerrain(df::tiletype tiletype)
{ {
return tileTypeTable[tiletype].material; return ENUM_ATTR(tiletype_shape, basic_shape, tileShape(tiletype)) == tiletype_shape_basic::Ramp;
} }
inline inline
TileDirection tileDirection(int16_t tiletype) bool isOpenTerrain(df::tiletype tiletype)
{ {
return tileTypeTable[tiletype].direction; return ENUM_ATTR(tiletype_shape, basic_shape, tileShape(tiletype)) == tiletype_shape_basic::Open;
} }
/// Safely access the tile type array. inline
inline const bool isStairTerrain(df::tiletype tiletype)
TileRow * getTileRow(int16_t tiletype)
{ {
if( tiletype<0 || tiletype>=TILE_TYPE_ARRAY_LENGTH ) return 0; return ENUM_ATTR(tiletype_shape, basic_shape, tileShape(tiletype)) == tiletype_shape_basic::Stair;
return ( const TileRow * ) &tileTypeTable[tiletype];
} }
/** /**
* 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, specify NONE for that type
* For tile directions, pass NULL to omit. * 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 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_ENUM_ITEMS(tiletype, tt)
for(tt=0;tt<TILE_TYPE_ARRAY_LENGTH; ++tt) {
{ if (tshape != tiletype_shape::NONE && tshape != tileShape(tt))
if( tshape>-1 && tshape != tileTypeTable[tt].shape ) continue; continue;
if( tmat>-1 && tmat != tileTypeTable[tt].material ) continue; if (tmat != tiletype_material::NONE && tmat != tileMaterial(tt))
if( tvar>-1 && tvar != tileTypeTable[tt].variant ) continue; continue;
if( tspecial>-1 && tspecial != tileTypeTable[tt].special ) continue; // Don't require variant to match if the destination tile doesn't even have one
if( tdir.whole && tdir.whole != tileTypeTable[tt].direction.whole ) continue; if (tvar != tiletype_variant::NONE && tvar != tileVariant(tt) && tileVariant(tt) != tiletype_variant::NONE)
continue;
// Same for special
if (tspecial != tiletype_special::NONE && tspecial != tileSpecial(tt) && tileSpecial(tt) != tiletype_special::NONE)
continue;
if (tdir && tdir != tileDirection(tt))
continue;
// Match! // Match!
return tt; return tt;
} }
return -1; return tiletype::Void;
} }
/** /**
@ -410,9 +267,13 @@ namespace DFHack
* *
* @todo Definitely needs improvement for wall directions, etc. * @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 #endif // TILETYPES_H_INCLUDED

@ -42,38 +42,6 @@ namespace DFHack
uint8_t data[SIZE]; uint8_t data[SIZE];
}; };
// DF effects, by darius from the bay12 forum
enum EFFECT_TYPE
{
EFF_MIASMA=0,
EFF_WATER,
EFF_WATER2,
EFF_BLOOD,
EFF_DUST,
EFF_MAGMA,
EFF_SMOKE,
EFF_DRAGONFIRE,
EFF_FIRE,
EFF_WEBING,
EFF_BOILING, // uses matgloss
EFF_OCEANWAVE
};
struct t_effect_df40d //size 40
{
uint16_t type;
t_matglossPair material;
int16_t lifetime;
uint16_t x;
uint16_t y;
uint16_t z; //14
int16_t x_direction;
int16_t y_direction;
junk_fill <12> unk4;
uint8_t canCreateNew;//??
uint8_t isHidden;
};
struct t_name struct t_name
{ {
char first_name[128]; char first_name[128];

@ -47,8 +47,8 @@ void SquashVeins (DFCoord bcoord, mapblock40d & mb, t_blockmaterials & materials
//iterate through columns //iterate through columns
for (uint32_t k = 0; k< 16;k++) for (uint32_t k = 0; k< 16;k++)
{ {
int16_t tt = mb.tiletypes[k][j]; df::tiletype tt = mb.tiletypes[k][j];
if(DFHack::tileMaterial(tt) == DFHack::VEIN) if(DFHack::tileMaterial(tt) == tiletype_material::MINERAL)
{ {
for(int i = (int) veins.size() - 1; i >= 0;i--) for(int i = (int) veins.size() - 1; i >= 0;i--)
{ {
@ -76,6 +76,11 @@ void SquashRocks ( std::vector< std::vector <uint16_t> > * layerassign, DFHack::
materials[xx][yy] = -1; materials[xx][yy] = -1;
continue; continue;
} }
if (mb.biome_indices[test] >= layerassign->size())
{
materials[xx][yy] = -1;
continue;
}
materials[xx][yy] = materials[xx][yy] =
layerassign->at(mb.biome_indices[test])[mb.designation[xx][yy].bits.geolayer_index]; layerassign->at(mb.biome_indices[test])[mb.designation[xx][yy].bits.geolayer_index];
} }
@ -118,11 +123,11 @@ class Block
veinmats[p.x][p.y] = -1; 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]; 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; if(!valid) return false;
dirty_tiletypes = true; dirty_tiletypes = true;
@ -286,16 +291,16 @@ class MapCache
return 0; return 0;
} }
} }
uint16_t tiletypeAt (DFHack::DFCoord tilecoord) df::tiletype tiletypeAt (DFHack::DFCoord tilecoord)
{ {
Block * b= BlockAt(tilecoord / 16); Block * b= BlockAt(tilecoord / 16);
if(b && b->valid) if(b && b->valid)
{ {
return b->TileTypeAt(tilecoord % 16); 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); Block * b= BlockAt(tilecoord / 16);
if(b && b->valid) if(b && b->valid)

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

@ -1 +1 @@
Subproject commit 03a791f0fff6789ec4bb931b2abd7bf91403a2b5 Subproject commit 6696efc85f55a6cc32161a247d5a1ca6c15344d2

@ -28,8 +28,8 @@ static tthread::mutex* mymutex=0;
static tthread::thread* thread_dfusion=0; static tthread::thread* thread_dfusion=0;
uint64_t timeLast=0; uint64_t timeLast=0;
DFhackCExport command_result dfusion (Core * c, vector <string> & parameters); command_result dfusion (Core * c, vector <string> & parameters);
DFhackCExport command_result lua_run (Core * c, vector <string> & parameters); command_result lua_run (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -126,7 +126,7 @@ void InterpreterLoop(Core* c)
} }
s.settop(0); s.settop(0);
} }
DFhackCExport command_result lua_run (Core * c, vector <string> & parameters) command_result lua_run (Core * c, vector <string> & parameters)
{ {
Console &con=c->con; Console &con=c->con;
mymutex->lock(); mymutex->lock();
@ -172,7 +172,7 @@ void RunDfusion(void *p)
s.settop(0);// clean up s.settop(0);// clean up
mymutex->unlock(); mymutex->unlock();
} }
DFhackCExport command_result dfusion (Core * c, vector <string> & parameters) command_result dfusion (Core * c, vector <string> & parameters)
{ {
if(parameters[0]=="init") if(parameters[0]=="init")
{ {

@ -32,9 +32,9 @@ using MapExtras::Block;
using MapExtras::MapCache; using MapExtras::MapCache;
using df::global::world; using df::global::world;
DFhackCExport command_result df_autodump(Core * c, vector <string> & parameters); command_result df_autodump(Core * c, vector <string> & parameters);
DFhackCExport command_result df_autodump_destroy_here(Core * c, vector <string> & parameters); command_result df_autodump_destroy_here(Core * c, vector <string> & parameters);
DFhackCExport command_result df_autodump_destroy_item(Core * c, vector <string> & parameters); command_result df_autodump_destroy_item(Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -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"); c->con.printerr("Cursor is in an invalid/uninitialized area. Place it over a floor.\n");
return CR_FAILURE; return CR_FAILURE;
} }
uint16_t ttype = MC.tiletypeAt(pos_cursor); df::tiletype ttype = MC.tiletypeAt(pos_cursor);
if(!DFHack::isFloorTerrain(ttype)) if(!DFHack::isFloorTerrain(ttype))
{ {
c->con.printerr("Cursor should be placed over a floor.\n"); c->con.printerr("Cursor should be placed over a floor.\n");
@ -283,14 +283,14 @@ static command_result autodump_main(Core * c, vector <string> & parameters)
return CR_OK; return CR_OK;
} }
DFhackCExport command_result df_autodump(Core * c, vector <string> & parameters) command_result df_autodump(Core * c, vector <string> & parameters)
{ {
CoreSuspender suspend(c); CoreSuspender suspend(c);
return autodump_main(c, parameters); return autodump_main(c, parameters);
} }
DFhackCExport command_result df_autodump_destroy_here(Core * c, vector <string> & parameters) command_result df_autodump_destroy_here(Core * c, vector <string> & parameters)
{ {
// HOTKEY COMMAND; CORE ALREADY SUSPENDED // HOTKEY COMMAND; CORE ALREADY SUSPENDED
if (!parameters.empty()) if (!parameters.empty())
@ -305,7 +305,7 @@ DFhackCExport command_result df_autodump_destroy_here(Core * c, vector <string>
static map<int, df::item_flags> pending_destroy; static map<int, df::item_flags> pending_destroy;
static int last_frame = 0; static int last_frame = 0;
DFhackCExport command_result df_autodump_destroy_item(Core * c, vector <string> & parameters) command_result df_autodump_destroy_item(Core * c, vector <string> & parameters)
{ {
// HOTKEY COMMAND; CORE ALREADY SUSPENDED // HOTKEY COMMAND; CORE ALREADY SUSPENDED
if (!parameters.empty()) if (!parameters.empty())

@ -113,7 +113,7 @@ command_result cleanunits (Core * c)
return CR_OK; return CR_OK;
} }
DFhackCExport command_result spotclean (Core * c, vector <string> & parameters) command_result spotclean (Core * c, vector <string> & parameters)
{ {
// HOTKEY COMMAND: CORE ALREADY SUSPENDED // HOTKEY COMMAND: CORE ALREADY SUSPENDED
if (cursor->x == -30000) if (cursor->x == -30000)
@ -145,7 +145,7 @@ DFhackCExport command_result spotclean (Core * c, vector <string> & parameters)
return CR_OK; return CR_OK;
} }
DFhackCExport command_result clean (Core * c, vector <string> & parameters) command_result clean (Core * c, vector <string> & parameters)
{ {
bool map = false; bool map = false;
bool snow = false; bool snow = false;

@ -26,7 +26,7 @@ using namespace df::enums;
using df::global::world; using df::global::world;
DFhackCExport command_result df_cleanowned (Core * c, vector <string> & parameters); command_result df_cleanowned (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -61,7 +61,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result df_cleanowned (Core * c, vector <string> & parameters) command_result df_cleanowned (Core * c, vector <string> & parameters)
{ {
bool dump_scattered = false; bool dump_scattered = false;
bool confiscate_all = false; bool confiscate_all = false;

@ -12,7 +12,7 @@ using std::string;
using namespace DFHack; using namespace DFHack;
using namespace DFHack::Simple; using namespace DFHack::Simple;
DFhackCExport command_result colonies (Core * c, vector <string> & parameters); command_result colonies (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -42,7 +42,7 @@ void destroyColonies();
void convertColonies(Materials *Materials); void convertColonies(Materials *Materials);
void showColonies(Core *c, Materials *Materials); void showColonies(Core *c, Materials *Materials);
DFhackCExport command_result colonies (Core * c, vector <string> & parameters) command_result colonies (Core * c, vector <string> & parameters)
{ {
bool destroy = false; bool destroy = false;
bool convert = false; bool convert = false;

@ -17,7 +17,7 @@ using namespace df::enums;
using df::global::world; using df::global::world;
DFhackCExport command_result df_deramp (Core * c, vector <string> & parameters) command_result df_deramp (Core * c, vector <string> & parameters)
{ {
if (!parameters.empty()) if (!parameters.empty())
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
@ -43,13 +43,13 @@ DFhackCExport command_result df_deramp (Core * c, vector <string> & parameters)
{ {
for (int y = 0; y < 16; y++) for (int y = 0; y < 16; y++)
{ {
int16_t oldT = block->tiletype[x][y]; df::tiletype oldT = block->tiletype[x][y];
if ((tileShape(oldT) == RAMP) && if ((tileShape(oldT) == tiletype_shape::RAMP) &&
(block->designation[x][y].bits.dig == tile_dig_designation::Default)) (block->designation[x][y].bits.dig == tile_dig_designation::Default))
{ {
// Current tile is a ramp. // Current tile is a ramp.
// Set current tile, as accurately as can be expected // 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 no change, skip it (couldn't find a good tile type)
if (oldT == newT) 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; 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. // Check the tile above this one, in case a downward slope needs to be removed.
if ((above) && (tileShape(above->tiletype[x][y]) == RAMP_TOP)) if ((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
count++; count++;
} }
// ramp fixer // ramp fixer
else if ((tileShape(oldT) != RAMP) else if ((tileShape(oldT) != tiletype_shape::RAMP)
&& (above) && (tileShape(above->tiletype[x][y]) == RAMP_TOP)) && (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++; countbad++;
} }
} }

@ -18,15 +18,15 @@ using std::string;
using std::stack; using std::stack;
using namespace DFHack; using namespace DFHack;
DFhackCExport DFHack::command_result readFlag (Core * c, vector <string> & parameters); command_result readFlag (Core * c, vector <string> & parameters);
DFhackCExport DFHack::command_result writeFlag (Core * c, vector <string> & parameters); command_result writeFlag (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
return "buildprobe"; return "buildprobe";
} }
DFhackCExport DFHack::command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{ {
commands.clear(); commands.clear();
commands.push_back(PluginCommand("bshow","Output building occupancy value",readFlag)); commands.push_back(PluginCommand("bshow","Output building occupancy value",readFlag));
@ -34,16 +34,16 @@ DFhackCExport DFHack::command_result plugin_init ( Core * c, std::vector <Plugin
return CR_OK; return CR_OK;
} }
DFhackCExport DFHack::command_result plugin_shutdown ( Core * c ) DFhackCExport command_result plugin_shutdown ( Core * c )
{ {
return CR_OK; return CR_OK;
} }
DFhackCExport DFHack::command_result readFlag (Core * c, vector <string> & parameters) command_result readFlag (Core * c, vector <string> & parameters)
{ {
c->Suspend(); c->Suspend();
DFHack::Gui * Gui = c->getGui(); Gui * Gui = c->getGui();
// init the map // init the map
if(!Maps::IsValid()) if(!Maps::IsValid())
{ {
@ -61,10 +61,10 @@ DFhackCExport DFHack::command_result readFlag (Core * c, vector <string> & param
return CR_FAILURE; return CR_FAILURE;
} }
DFHack::DFCoord cursor = DFHack::DFCoord(cx,cy,cz); DFCoord cursor = DFCoord(cx,cy,cz);
MapExtras::MapCache * MCache = new MapExtras::MapCache(); MapExtras::MapCache * MCache = new MapExtras::MapCache();
DFHack::t_occupancy oc = MCache->occupancyAt(cursor); t_occupancy oc = MCache->occupancyAt(cursor);
c->con.print("Current Value: %d\n", oc.bits.building); c->con.print("Current Value: %d\n", oc.bits.building);
@ -72,7 +72,7 @@ DFhackCExport DFHack::command_result readFlag (Core * c, vector <string> & param
return CR_OK; return CR_OK;
} }
DFhackCExport DFHack::command_result writeFlag (Core * c, vector <string> & parameters) command_result writeFlag (Core * c, vector <string> & parameters)
{ {
if (parameters.size() == 0) if (parameters.size() == 0)
{ {
@ -110,7 +110,7 @@ DFhackCExport DFHack::command_result writeFlag (Core * c, vector <string> & para
c->Suspend(); c->Suspend();
DFHack::Gui * Gui = c->getGui(); Gui * Gui = c->getGui();
// init the map // init the map
if(!Maps::IsValid()) if(!Maps::IsValid())
{ {
@ -128,10 +128,10 @@ DFhackCExport DFHack::command_result writeFlag (Core * c, vector <string> & para
return CR_FAILURE; return CR_FAILURE;
} }
DFHack::DFCoord cursor = DFHack::DFCoord(cx,cy,cz); DFCoord cursor = DFCoord(cx,cy,cz);
MapExtras::MapCache * MCache = new MapExtras::MapCache(); MapExtras::MapCache * MCache = new MapExtras::MapCache();
DFHack::t_occupancy oc = MCache->occupancyAt(cursor); t_occupancy oc = MCache->occupancyAt(cursor);
oc.bits.building = value; oc.bits.building = value;
MCache->setOccupancyAt(cursor, oc); MCache->setOccupancyAt(cursor, oc);

@ -145,7 +145,7 @@ protected:
// END item choosers // END item choosers
////////////////////// //////////////////////
DFhackCExport command_result df_dumpitems (Core * c, vector <string> & parameters); command_result df_dumpitems (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -169,7 +169,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result df_dumpitems (Core * c, vector <string> & parameters) command_result df_dumpitems (Core * c, vector <string> & parameters)
{ {
c->Suspend(); c->Suspend();
DFHack::Materials * Materials = c->getMaterials(); DFHack::Materials * Materials = c->getMaterials();

@ -27,11 +27,11 @@ int32_t last_mouse[2] = {-1, -1};
uint32_t last_menu = 0; uint32_t last_menu = 0;
uint64_t timeLast = 0; uint64_t timeLast = 0;
DFhackCExport command_result kittens (Core * c, vector <string> & parameters); command_result kittens (Core * c, vector <string> & parameters);
DFhackCExport command_result ktimer (Core * c, vector <string> & parameters); command_result ktimer (Core * c, vector <string> & parameters);
DFhackCExport command_result trackmenu (Core * c, vector <string> & parameters); command_result trackmenu (Core * c, vector <string> & parameters);
DFhackCExport command_result trackpos (Core * c, vector <string> & parameters); command_result trackpos (Core * c, vector <string> & parameters);
DFhackCExport command_result colormods (Core * c, vector <string> & parameters); command_result colormods (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -104,7 +104,7 @@ DFhackCExport command_result plugin_onupdate ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result trackmenu (Core * c, vector <string> & parameters) command_result trackmenu (Core * c, vector <string> & parameters)
{ {
if(trackmenu_flg) if(trackmenu_flg)
{ {
@ -128,13 +128,13 @@ DFhackCExport command_result trackmenu (Core * c, vector <string> & parameters)
} }
} }
} }
DFhackCExport command_result trackpos (Core * c, vector <string> & parameters) command_result trackpos (Core * c, vector <string> & parameters)
{ {
trackpos_flg = !trackpos_flg; trackpos_flg = !trackpos_flg;
return CR_OK; return CR_OK;
} }
DFhackCExport command_result colormods (Core * c, vector <string> & parameters) command_result colormods (Core * c, vector <string> & parameters)
{ {
c->Suspend(); c->Suspend();
auto & vec = df::global::world->raws.creatures.alphabetic; auto & vec = df::global::world->raws.creatures.alphabetic;
@ -152,7 +152,7 @@ DFhackCExport command_result colormods (Core * c, vector <string> & parameters)
return CR_OK; return CR_OK;
} }
DFhackCExport command_result ktimer (Core * c, vector <string> & parameters) command_result ktimer (Core * c, vector <string> & parameters)
{ {
if(timering) if(timering)
{ {
@ -170,7 +170,7 @@ DFhackCExport command_result ktimer (Core * c, vector <string> & parameters)
return CR_OK; return CR_OK;
} }
DFhackCExport command_result kittens (Core * c, vector <string> & parameters) command_result kittens (Core * c, vector <string> & parameters)
{ {
final_flag = false; final_flag = false;
Console & con = c->con; Console & con = c->con;

@ -28,7 +28,7 @@ enum HEXVIEW_STATES
{ {
STATE_OFF,STATE_ON STATE_OFF,STATE_ON
}; };
DFhackCExport command_result memview (Core * c, vector <string> & parameters); command_result memview (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -139,7 +139,7 @@ DFhackCExport command_result plugin_onupdate ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result memview (Core * c, vector <string> & parameters) command_result memview (Core * c, vector <string> & parameters)
{ {
mymutex->lock(); mymutex->lock();
c->p->getMemRanges(memdata.ranges); c->p->getMemRanges(memdata.ranges);

@ -10,7 +10,7 @@ using std::vector;
using std::string; using std::string;
using namespace DFHack; using namespace DFHack;
DFhackCExport command_result df_notes (Core * c, vector <string> & parameters); command_result df_notes (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -31,7 +31,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result df_notes (Core * c, vector <string> & parameters) command_result df_notes (Core * c, vector <string> & parameters)
{ {
Console & con = c->con; Console & con = c->con;
c->Suspend(); c->Suspend();

@ -16,8 +16,8 @@ bool final_flag = true;
bool timering = false; bool timering = false;
uint64_t timeLast = 0; uint64_t timeLast = 0;
DFhackCExport command_result rawdump_i (Core * c, vector <string> & parameters); command_result rawdump_i (Core * c, vector <string> & parameters);
DFhackCExport command_result rawdump_p (Core * c, vector <string> & parameters); command_result rawdump_p (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -37,7 +37,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result rawdump_i (Core * c, vector <string> & parameters) command_result rawdump_i (Core * c, vector <string> & parameters)
{ {
int index = -1; int index = -1;
Console & con = c->con; Console & con = c->con;
@ -81,7 +81,7 @@ DFhackCExport command_result rawdump_i (Core * c, vector <string> & parameters)
return CR_OK; return CR_OK;
} }
DFhackCExport command_result rawdump_p (Core * c, vector <string> & parameters) command_result rawdump_p (Core * c, vector <string> & parameters)
{ {
int index = -1; int index = -1;
Console & con = c->con; Console & con = c->con;

@ -162,8 +162,8 @@ public:
}; };
}; };
DFhackCExport command_result df_tiles (Core * c, vector <string> & parameters); command_result df_tiles (Core * c, vector <string> & parameters);
DFhackCExport command_result df_paint (Core * c, vector <string> & parameters); command_result df_paint (Core * c, vector <string> & parameters);
struct Settings struct Settings
{ {
@ -217,7 +217,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result df_tiles (Core * c, vector <string> & parameters) command_result df_tiles (Core * c, vector <string> & parameters)
{ {
int32_t x,y,z; int32_t x,y,z;
uint32_t x_max,y_max,z_max; uint32_t x_max,y_max,z_max;

@ -24,9 +24,9 @@ struct t_vecTriplet
void * alloc_end; void * alloc_end;
}; };
DFhackCExport command_result df_vectors (Core * c, command_result df_vectors (Core * c,
vector <string> & parameters); vector <string> & parameters);
DFhackCExport command_result df_clearvec (Core * c, command_result df_clearvec (Core * c,
vector <string> & parameters); vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
@ -148,7 +148,7 @@ static void printVec(Console &con, const char* msg, t_vecTriplet *vec,
msg, offset, pos, vec->start, length); msg, offset, pos, vec->start, length);
} }
DFhackCExport command_result df_vectors (Core * c, vector <string> & parameters) command_result df_vectors (Core * c, vector <string> & parameters)
{ {
Console & con = c->con; Console & con = c->con;
@ -270,7 +270,7 @@ static void clearUsage(Console &con)
<< std::endl; << std::endl;
} }
DFhackCExport command_result df_clearvec (Core * c, vector <string> & parameters) command_result df_clearvec (Core * c, vector <string> & parameters)
{ {
Console & con = c->con; Console & con = c->con;

@ -17,7 +17,7 @@ using namespace df::enums;
using df::global::world; using df::global::world;
DFhackCExport command_result df_drybuckets (Core * c, vector <string> & parameters) command_result df_drybuckets (Core * c, vector <string> & parameters)
{ {
if (!parameters.empty()) if (!parameters.empty())
return CR_WRONG_USAGE; return CR_WRONG_USAGE;

@ -33,7 +33,7 @@ using df::global::world;
// Here go all the command declarations... // Here go all the command declarations...
// mostly to allow having the mandatory stuff on top of the file and commands on the bottom // mostly to allow having the mandatory stuff on top of the file and commands on the bottom
DFhackCExport command_result export_dwarves (Core * c, std::vector <std::string> & parameters); command_result export_dwarves (Core * c, std::vector <std::string> & parameters);
// A plugins must be able to return its name. This must correspond to the filename - export.plug.so or export.plug.dll // A plugins must be able to return its name. This must correspond to the filename - export.plug.so or export.plug.dll
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
@ -155,7 +155,7 @@ static void export_dwarf(Core* c, df::unit* cre, ostream& out) {
out << " </Creature>" << endl; out << " </Creature>" << endl;
} }
DFhackCExport command_result export_dwarves (Core * c, std::vector <std::string> & parameters) command_result export_dwarves (Core * c, std::vector <std::string> & parameters)
{ {
string filename; string filename;
if (parameters.size() == 1) { if (parameters.size() == 1) {

@ -18,21 +18,21 @@ using namespace DFHack;
using namespace df::enums; using namespace df::enums;
//Function pointer type for whole-map tile checks. //Function pointer type for whole-map tile checks.
typedef void (*checkTile)(DFHack::DFCoord, MapExtras::MapCache &); typedef void (*checkTile)(DFCoord, MapExtras::MapCache &);
//Forward Declarations for Commands //Forward Declarations for Commands
DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::string> & params); command_result filltraffic(Core * c, std::vector<std::string> & params);
DFhackCExport command_result alltraffic(DFHack::Core * c, std::vector<std::string> & params); command_result alltraffic(Core * c, std::vector<std::string> & params);
//Forward Declarations for Utility Functions //Forward Declarations for Utility Functions
DFhackCExport command_result setAllMatching(DFHack::Core * c, checkTile checkProc, command_result setAllMatching(Core * c, checkTile checkProc,
DFHack::DFCoord minCoord = DFHack::DFCoord(0, 0, 0), DFCoord minCoord = DFCoord(0, 0, 0),
DFHack::DFCoord maxCoord = DFHack::DFCoord(0xFFFF, 0xFFFF, 0xFFFF)); DFCoord maxCoord = DFCoord(0xFFFF, 0xFFFF, 0xFFFF));
void allHigh(DFHack::DFCoord coord, MapExtras::MapCache & map); void allHigh(DFCoord coord, MapExtras::MapCache & map);
void allNormal(DFHack::DFCoord coord, MapExtras::MapCache & map); void allNormal(DFCoord coord, MapExtras::MapCache & map);
void allLow(DFHack::DFCoord coord, MapExtras::MapCache & map); void allLow(DFCoord coord, MapExtras::MapCache & map);
void allRestricted(DFHack::DFCoord coord, MapExtras::MapCache & map); void allRestricted(DFCoord coord, MapExtras::MapCache & map);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -78,7 +78,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::string> & params) command_result filltraffic(Core * c, std::vector<std::string> & params)
{ {
// HOTKEY COMMAND; CORE ALREADY SUSPENDED // HOTKEY COMMAND; CORE ALREADY SUSPENDED
@ -119,7 +119,7 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
} }
} }
DFHack::Gui * Gui = c->getGui(); Gui * Gui = c->getGui();
if (!Maps::IsValid()) if (!Maps::IsValid())
{ {
c->con.printerr("Map is not available!\n"); c->con.printerr("Map is not available!\n");
@ -137,11 +137,11 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
return CR_FAILURE; return CR_FAILURE;
} }
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz); DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
MapExtras::MapCache MCache; MapExtras::MapCache MCache;
df::tile_designation des = MCache.designationAt(xy); df::tile_designation des = MCache.designationAt(xy);
int16_t tt = MCache.tiletypeAt(xy); df::tiletype tt = MCache.tiletypeAt(xy);
df::tile_occupancy oc; df::tile_occupancy oc;
if (checkbuilding) if (checkbuilding)
@ -154,13 +154,13 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
return CR_FAILURE; return CR_FAILURE;
} }
if(DFHack::isWallTerrain(tt)) if(isWallTerrain(tt))
{ {
c->con.printerr("This tile is a wall. Please select a passable tile.\n"); c->con.printerr("This tile is a wall. Please select a passable tile.\n");
return CR_FAILURE; return CR_FAILURE;
} }
if(checkpit && DFHack::isOpenTerrain(tt)) if(checkpit && isOpenTerrain(tt))
{ {
c->con.printerr("This tile is a hole. Please select a passable tile.\n"); c->con.printerr("This tile is a hole. Please select a passable tile.\n");
return CR_FAILURE; return CR_FAILURE;
@ -175,7 +175,7 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
c->con.print("%d/%d/%d ... FILLING!\n", cx,cy,cz); c->con.print("%d/%d/%d ... FILLING!\n", cx,cy,cz);
//Naive four-way or six-way flood fill with possible tiles on a stack. //Naive four-way or six-way flood fill with possible tiles on a stack.
stack <DFHack::DFCoord> flood; stack <DFCoord> flood;
flood.push(xy); flood.push(xy);
while(!flood.empty()) while(!flood.empty())
@ -188,8 +188,8 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
tt = MCache.tiletypeAt(xy); tt = MCache.tiletypeAt(xy);
if(DFHack::isWallTerrain(tt)) continue; if(isWallTerrain(tt)) continue;
if(checkpit && DFHack::isOpenTerrain(tt)) continue; if(checkpit && isOpenTerrain(tt)) continue;
if (checkbuilding) if (checkbuilding)
{ {
@ -205,30 +205,30 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
if (xy.x > 0) if (xy.x > 0)
{ {
flood.push(DFHack::DFCoord(xy.x - 1, xy.y, xy.z)); flood.push(DFCoord(xy.x - 1, xy.y, xy.z));
} }
if (xy.x < tx_max - 1) if (xy.x < tx_max - 1)
{ {
flood.push(DFHack::DFCoord(xy.x + 1, xy.y, xy.z)); flood.push(DFCoord(xy.x + 1, xy.y, xy.z));
} }
if (xy.y > 0) if (xy.y > 0)
{ {
flood.push(DFHack::DFCoord(xy.x, xy.y - 1, xy.z)); flood.push(DFCoord(xy.x, xy.y - 1, xy.z));
} }
if (xy.y < ty_max - 1) if (xy.y < ty_max - 1)
{ {
flood.push(DFHack::DFCoord(xy.x, xy.y + 1, xy.z)); flood.push(DFCoord(xy.x, xy.y + 1, xy.z));
} }
if (updown) if (updown)
{ {
if (xy.z > 0 && DFHack::LowPassable(tt)) if (xy.z > 0 && LowPassable(tt))
{ {
flood.push(DFHack::DFCoord(xy.x, xy.y, xy.z - 1)); flood.push(DFCoord(xy.x, xy.y, xy.z - 1));
} }
if (xy.z < z_max && DFHack::HighPassable(tt)) if (xy.z < z_max && HighPassable(tt))
{ {
flood.push(DFHack::DFCoord(xy.x, xy.y, xy.z + 1)); flood.push(DFCoord(xy.x, xy.y, xy.z + 1));
} }
} }
@ -241,9 +241,9 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
enum e_checktype {no_check, check_equal, check_nequal}; enum e_checktype {no_check, check_equal, check_nequal};
DFhackCExport command_result alltraffic(DFHack::Core * c, std::vector<std::string> & params) command_result alltraffic(Core * c, std::vector<std::string> & params)
{ {
void (*proc)(DFHack::DFCoord, MapExtras::MapCache &) = allNormal; void (*proc)(DFCoord, MapExtras::MapCache &) = allNormal;
//Loop through parameters //Loop through parameters
for(size_t i = 0; i < params.size();i++) for(size_t i = 0; i < params.size();i++)
@ -274,13 +274,13 @@ DFhackCExport command_result alltraffic(DFHack::Core * c, std::vector<std::strin
//newTraffic is the traffic designation to set. //newTraffic is the traffic designation to set.
//check takes a coordinate and the map cache as arguments, and returns true if the criteria is met. //check takes a coordinate and the map cache as arguments, and returns true if the criteria is met.
//minCoord and maxCoord can be used to specify a bounding cube. //minCoord and maxCoord can be used to specify a bounding cube.
DFhackCExport command_result setAllMatching(DFHack::Core * c, checkTile checkProc, command_result setAllMatching(Core * c, checkTile checkProc,
DFHack::DFCoord minCoord, DFHack::DFCoord maxCoord) DFCoord minCoord, DFCoord maxCoord)
{ {
//Initialization. //Initialization.
CoreSuspender suspend(c); CoreSuspender suspend(c);
DFHack::Gui * Gui = c->getGui(); Gui * Gui = c->getGui();
if (!Maps::IsValid()) if (!Maps::IsValid())
{ {
c->con.printerr("Map is not available!\n"); c->con.printerr("Map is not available!\n");
@ -326,7 +326,7 @@ DFhackCExport command_result setAllMatching(DFHack::Core * c, checkTile checkPro
{ {
for(uint32_t z = minCoord.z; z <= maxCoord.z; z++) for(uint32_t z = minCoord.z; z <= maxCoord.z; z++)
{ {
DFHack::DFCoord tile = DFHack::DFCoord(x, y, z); DFCoord tile = DFCoord(x, y, z);
checkProc(tile, MCache); checkProc(tile, MCache);
} }
} }
@ -338,25 +338,25 @@ DFhackCExport command_result setAllMatching(DFHack::Core * c, checkTile checkPro
} }
//Unconditionally set map to target traffic type //Unconditionally set map to target traffic type
void allHigh(DFHack::DFCoord coord, MapExtras::MapCache &map) void allHigh(DFCoord coord, MapExtras::MapCache &map)
{ {
df::tile_designation des = map.designationAt(coord); df::tile_designation des = map.designationAt(coord);
des.bits.traffic = tile_traffic::High; des.bits.traffic = tile_traffic::High;
map.setDesignationAt(coord, des); map.setDesignationAt(coord, des);
} }
void allNormal(DFHack::DFCoord coord, MapExtras::MapCache &map) void allNormal(DFCoord coord, MapExtras::MapCache &map)
{ {
df::tile_designation des = map.designationAt(coord); df::tile_designation des = map.designationAt(coord);
des.bits.traffic = tile_traffic::Normal; des.bits.traffic = tile_traffic::Normal;
map.setDesignationAt(coord, des); map.setDesignationAt(coord, des);
} }
void allLow(DFHack::DFCoord coord, MapExtras::MapCache &map) void allLow(DFCoord coord, MapExtras::MapCache &map)
{ {
df::tile_designation des = map.designationAt(coord); df::tile_designation des = map.designationAt(coord);
des.bits.traffic = tile_traffic::Low; des.bits.traffic = tile_traffic::Low;
map.setDesignationAt(coord, des); map.setDesignationAt(coord, des);
} }
void allRestricted(DFHack::DFCoord coord, MapExtras::MapCache &map) void allRestricted(DFCoord coord, MapExtras::MapCache &map)
{ {
df::tile_designation des = map.designationAt(coord); df::tile_designation des = map.designationAt(coord);
des.bits.traffic = tile_traffic::Restricted; des.bits.traffic = tile_traffic::Restricted;

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

@ -17,7 +17,7 @@ using namespace df::enums;
using df::global::world; using df::global::world;
DFhackCExport command_result df_flows (Core * c, vector <string> & parameters) command_result df_flows (Core * c, vector <string> & parameters)
{ {
CoreSuspender suspend(c); CoreSuspender suspend(c);

@ -23,7 +23,7 @@ using namespace df::enums;
using df::global::world; using df::global::world;
DFhackCExport command_result df_getplants (Core * c, vector <string> & parameters) command_result df_getplants (Core * c, vector <string> & parameters)
{ {
string plantMatStr = ""; string plantMatStr = "";
set<int> plantIDs; set<int> plantIDs;
@ -105,10 +105,11 @@ DFhackCExport command_result df_getplants (Core * c, vector <string> & parameter
if (!exclude) if (!exclude)
continue; continue;
} }
TileShape shape = tileShape(cur->tiletype[x][y]); df::tiletype_shape shape = tileShape(cur->tiletype[x][y]);
if (plant->flags.bits.is_shrub && (treesonly || shape != SHRUB_OK)) 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; 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; continue;
if (cur->designation[x][y].bits.hidden) if (cur->designation[x][y].bits.hidden)
continue; continue;

@ -14,8 +14,8 @@ using namespace df::enums;
using df::global::d_init; using df::global::d_init;
DFhackCExport command_result twaterlvl(Core * c, vector <string> & parameters); command_result twaterlvl(Core * c, vector <string> & parameters);
DFhackCExport command_result tidlers(Core * c, vector <string> & parameters); command_result tidlers(Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -40,7 +40,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result twaterlvl(Core * c, vector <string> & parameters) command_result twaterlvl(Core * c, vector <string> & parameters)
{ {
// HOTKEY COMMAND: CORE ALREADY SUSPENDED // HOTKEY COMMAND: CORE ALREADY SUSPENDED
d_init->flags1.toggle(d_init_flags1::SHOW_FLOW_AMOUNTS); d_init->flags1.toggle(d_init_flags1::SHOW_FLOW_AMOUNTS);
@ -48,7 +48,7 @@ DFhackCExport command_result twaterlvl(Core * c, vector <string> & parameters)
return CR_OK; return CR_OK;
} }
DFhackCExport command_result tidlers(Core * c, vector <string> & parameters) command_result tidlers(Core * c, vector <string> & parameters)
{ {
// HOTKEY COMMAND: CORE ALREADY SUSPENDED // HOTKEY COMMAND: CORE ALREADY SUSPENDED
d_init->idlers = ENUM_NEXT_ITEM(d_init_idlers, d_init->idlers); d_init->idlers = ENUM_NEXT_ITEM(d_init_idlers, d_init->idlers);

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

@ -23,7 +23,7 @@ using df::global::world;
typedef std::vector<df::plant *> PlantList; typedef std::vector<df::plant *> PlantList;
DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & parameters); command_result mapexport (Core * c, std::vector <std::string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -44,7 +44,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & parameters) command_result mapexport (Core * c, std::vector <std::string> & parameters)
{ {
bool showHidden = false; bool showHidden = false;
@ -206,36 +206,35 @@ DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & pa
prototile->set_flow_size(des.bits.flow_size); prototile->set_flow_size(des.bits.flow_size);
} }
uint16_t type = b->TileTypeAt(coord); df::tiletype type = b->TileTypeAt(coord);
const DFHack::TileRow *info = DFHack::getTileRow(type); prototile->set_type((dfproto::Tile::TileType)tileShape(type));
prototile->set_type((dfproto::Tile::TileType)info->shape);
prototile->set_tile_material((dfproto::Tile::TileMaterialType)info->material); prototile->set_material_type((dfproto::Tile::TileMaterialType)tileMaterial(type));
df::coord map_pos = df::coord(b_x*16+x,b_y*16+y,z); 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 tiletype_material::SOIL:
case DFHack::STONE: case tiletype_material::STONE:
prototile->set_material_type(0); prototile->set_material_type(0);
prototile->set_material_index(b->baseMaterialAt(coord)); prototile->set_material_index(b->baseMaterialAt(coord));
break; break;
case DFHack::VEIN: case tiletype_material::MINERAL:
prototile->set_material_type(0); prototile->set_material_type(0);
prototile->set_material_index(b->veinMaterialAt(coord)); prototile->set_material_index(b->veinMaterialAt(coord));
break; break;
case DFHack::FEATSTONE: case tiletype_material::FEATURE:
if (blockFeatureLocal.type != -1 && des.bits.feature_local) if (blockFeatureLocal.type != -1 && des.bits.feature_local)
{ {
if (blockFeatureLocal.type == df::feature_type::deep_special_tube if (blockFeatureLocal.type == feature_type::deep_special_tube
&& blockFeatureLocal.main_material == 0) // stone && blockFeatureLocal.main_material == 0) // stone
{ {
prototile->set_material_type(0); prototile->set_material_type(0);
prototile->set_material_index(blockFeatureLocal.sub_material); prototile->set_material_index(blockFeatureLocal.sub_material);
} }
if (blockFeatureGlobal.type != -1 && des.bits.feature_global if (blockFeatureGlobal.type != -1 && des.bits.feature_global
&& blockFeatureGlobal.type == df::feature_type::feature_underworld_from_layer && blockFeatureGlobal.type == feature_type::feature_underworld_from_layer
&& blockFeatureGlobal.main_material == 0) // stone && blockFeatureGlobal.main_material == 0) // stone
{ {
prototile->set_material_type(0); prototile->set_material_type(0);
@ -243,7 +242,7 @@ DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & pa
} }
} }
break; break;
case DFHack::CONSTRUCTED: case tiletype_material::CONSTRUCTION:
if (constructionMaterials.find(map_pos) != constructionMaterials.end()) if (constructionMaterials.find(map_pos) != constructionMaterials.end())
{ {
prototile->set_material_index(constructionMaterials[map_pos].first); prototile->set_material_index(constructionMaterials[map_pos].first);

@ -12,7 +12,7 @@ using namespace std;
using namespace DFHack; using namespace DFHack;
DFhackCExport command_result mode (Core * c, vector <string> & parameters); command_result mode (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -91,7 +91,7 @@ void printCurrentModes(t_gamemodes gm, Console & con)
} }
} }
DFhackCExport command_result mode (Core * c, vector <string> & parameters) command_result mode (Core * c, vector <string> & parameters)
{ {
string command = ""; string command = "";
bool set = false; bool set = false;

@ -20,9 +20,9 @@ using std::string;
using namespace DFHack; using namespace DFHack;
using df::global::world; using df::global::world;
DFhackCExport command_result df_grow (Core * c, vector <string> & parameters); command_result df_grow (Core * c, vector <string> & parameters);
DFhackCExport command_result df_immolate (Core * c, vector <string> & parameters); command_result df_immolate (Core * c, vector <string> & parameters);
DFhackCExport command_result df_extirpate (Core * c, vector <string> & parameters); command_result df_extirpate (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -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"); c->con.printerr("Map is not available!\n");
return CR_FAILURE; return CR_FAILURE;
} }
DFHack::Gui * Gui = c->getGui(); Gui * Gui = c->getGui();
uint32_t x_max, y_max, z_max; uint32_t x_max, y_max, z_max;
Maps::getSize(x_max, y_max, z_max); Maps::getSize(x_max, y_max, z_max);
MapExtras::MapCache map; MapExtras::MapCache map;
@ -162,7 +162,7 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre
return CR_OK; return CR_OK;
} }
DFhackCExport command_result df_immolate (Core * c, vector <string> & parameters) command_result df_immolate (Core * c, vector <string> & parameters)
{ {
bool shrubs = false, trees = false, help = false; bool shrubs = false, trees = false, help = false;
if(getoptions(parameters,shrubs,trees,help)) if(getoptions(parameters,shrubs,trees,help))
@ -176,7 +176,7 @@ DFhackCExport command_result df_immolate (Core * c, vector <string> & parameters
} }
} }
DFhackCExport command_result df_extirpate (Core * c, vector <string> & parameters) command_result df_extirpate (Core * c, vector <string> & parameters)
{ {
bool shrubs = false, trees = false, help = false; bool shrubs = false, trees = false, help = false;
if(getoptions(parameters,shrubs,trees, help)) if(getoptions(parameters,shrubs,trees, help))
@ -190,7 +190,7 @@ DFhackCExport command_result df_extirpate (Core * c, vector <string> & parameter
} }
} }
DFhackCExport command_result df_grow (Core * c, vector <string> & parameters) command_result df_grow (Core * c, vector <string> & parameters)
{ {
for(size_t i = 0; i < parameters.size();i++) for(size_t i = 0; i < parameters.size();i++)
{ {
@ -208,7 +208,7 @@ DFhackCExport command_result df_grow (Core * c, vector <string> & parameters)
return CR_FAILURE; return CR_FAILURE;
} }
MapExtras::MapCache map; MapExtras::MapCache map;
DFHack::Gui *Gui = c->getGui(); Gui *Gui = c->getGui();
int32_t x,y,z; int32_t x,y,z;
if(Gui->getCursorCoords(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); df::plant * tree = alltrees->at(i);
if(tree->pos.x == x && tree->pos.y == y && tree->pos.z == z) 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; 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++) for(size_t i = 0 ; i < world->plants.all.size(); i++)
{ {
df::plant *p = world->plants.all[i]; df::plant *p = world->plants.all[i];
uint16_t ttype = map.tiletypeAt(df::coord(p->pos.x,p->pos.y,p->pos.z)); df::tiletype 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) if(!p->flags.bits.is_shrub && tileShape(ttype) == tiletype_shape::SAPLING && tileSpecial(ttype) != tiletype_special::DEAD)
{ {
p->grow_counter = Vegetation::sapling_to_tree_threshold; p->grow_counter = Vegetation::sapling_to_tree_threshold;
} }

@ -31,8 +31,8 @@ using namespace DFHack::Simple;
using namespace df::enums; using namespace df::enums;
using df::global::world; using df::global::world;
DFhackCExport command_result df_probe (Core * c, vector <string> & parameters); command_result df_probe (Core * c, vector <string> & parameters);
DFhackCExport command_result df_cprobe (Core * c, vector <string> & parameters); command_result df_cprobe (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -56,7 +56,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result df_cprobe (Core * c, vector <string> & parameters) command_result df_cprobe (Core * c, vector <string> & parameters)
{ {
Console & con = c->con; Console & con = c->con;
CoreSuspender suspend(c); CoreSuspender suspend(c);
@ -82,7 +82,7 @@ DFhackCExport command_result df_cprobe (Core * c, vector <string> & parameters)
return CR_OK; return CR_OK;
} }
DFhackCExport command_result df_probe (Core * c, vector <string> & parameters) command_result df_probe (Core * c, vector <string> & parameters)
{ {
//bool showBlock, showDesig, showOccup, showTile, showMisc; //bool showBlock, showDesig, showOccup, showTile, showMisc;
Console & con = c->con; Console & con = c->con;
@ -143,7 +143,7 @@ DFhackCExport command_result df_probe (Core * c, vector <string> & parameters)
con.print("\n\n"); con.print("\n\n");
} }
*/ */
int16_t tiletype = mc.tiletypeAt(cursor); df::tiletype tiletype = mc.tiletypeAt(cursor);
df::tile_designation &des = block.designation[tileX][tileY]; df::tile_designation &des = block.designation[tileX][tileY];
/* /*
if(showDesig) if(showDesig)
@ -169,17 +169,18 @@ DFhackCExport command_result df_probe (Core * c, vector <string> & parameters)
con.print(" = %s",tileName(tiletype)); con.print(" = %s",tileName(tiletype));
con.print("\n"); con.print("\n");
DFHack::TileShape shape = tileShape(tiletype); df::tiletype_shape shape = tileShape(tiletype);
DFHack::TileMaterial material = tileMaterial(tiletype); df::tiletype_material material = tileMaterial(tiletype);
DFHack::TileSpecial special = tileSpecial(tiletype); df::tiletype_special special = tileSpecial(tiletype);
df::tiletype_variant variant = tileVariant(tiletype);
con.print("%-10s: %4d %s\n","Class" ,shape, con.print("%-10s: %4d %s\n","Class" ,shape,
TileShapeString[ shape ]); ENUM_KEY_STR(tiletype_shape, shape));
con.print("%-10s: %4d %s\n","Material" , con.print("%-10s: %4d %s\n","Material" ,
material,TileMaterialString[ material ]); material, ENUM_KEY_STR(tiletype_material, material));
con.print("%-10s: %4d %s\n","Special" , con.print("%-10s: %4d %s\n","Special" ,
special, TileSpecialString[ special ]); special, ENUM_KEY_STR(tiletype_special, special));
con.print("%-10s: %4d\n" ,"Variant" , con.print("%-10s: %4d %s\n" ,"Variant" ,
tileVariant(tiletype)); variant, ENUM_KEY_STR(tiletype_variant, variant));
con.print("%-10s: %s\n" ,"Direction", con.print("%-10s: %s\n" ,"Direction",
tileDirection(tiletype).getStr()); tileDirection(tiletype).getStr());
con.print("\n"); con.print("\n");

@ -177,7 +177,7 @@ void printVeins(DFHack::Console & con, MatMap &mat_map,
printMats(con, rest, world->raws.inorganics, show_value); printMats(con, rest, world->raws.inorganics, show_value);
} }
DFhackCExport command_result prospector (Core * c, vector <string> & parameters); command_result prospector (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -345,7 +345,7 @@ static command_result embark_prospector(DFHack::Core *c, df::viewscreen_choose_s
return CR_OK; return CR_OK;
} }
DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & parameters) command_result prospector (DFHack::Core * c, vector <string> & parameters)
{ {
bool showHidden = false; bool showHidden = false;
bool showPlants = true; bool showPlants = true;
@ -471,27 +471,21 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
liquidWater.add(global_z); liquidWater.add(global_z);
} }
uint16_t type = b->TileTypeAt(coord); df::tiletype type = b->TileTypeAt(coord);
const DFHack::TileRow *info = DFHack::getTileRow(type); df::tiletype_shape tileshape = tileShape(type);
df::tiletype_material tilemat = tileMaterial(type);
if (!info)
{
con << "Bad type: " << type << std::endl;
continue;
}
// We only care about these types // We only care about these types
switch (info->shape) switch (tileshape)
{ {
case DFHack::WALL: case tiletype_shape::WALL:
case DFHack::PILLAR: case tiletype_shape::FORTIFICATION:
case DFHack::FORTIFICATION:
break; break;
case DFHack::EMPTY: case tiletype_shape::EMPTY:
/* A heuristic: tubes inside adamantine have EMPTY:AIR tiles which /* A heuristic: tubes inside adamantine have EMPTY:AIR tiles which
still have feature_local set. Also check the unrevealed status, still have feature_local set. Also check the unrevealed status,
so as to exclude any holes mined by the player. */ 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 && des.bits.feature_local && des.bits.hidden &&
blockFeatureLocal.type == feature_type::deep_special_tube) 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 // Count the material type
baseMats[info->material].add(global_z); baseMats[tilemat].add(global_z);
// Find the type of the tile // Find the type of the tile
switch (info->material) switch (tilemat)
{ {
case DFHack::SOIL: case tiletype_material::SOIL:
case DFHack::STONE: case tiletype_material::STONE:
layerMats[b->baseMaterialAt(coord)].add(global_z); layerMats[b->baseMaterialAt(coord)].add(global_z);
break; break;
case DFHack::VEIN: case tiletype_material::MINERAL:
veinMats[b->veinMaterialAt(coord)].add(global_z); veinMats[b->veinMaterialAt(coord)].add(global_z);
break; break;
case DFHack::FEATSTONE: case tiletype_material::FEATURE:
if (blockFeatureLocal.type != -1 && des.bits.feature_local) if (blockFeatureLocal.type != -1 && des.bits.feature_local)
{ {
if (blockFeatureLocal.type == feature_type::deep_special_tube 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); layerMats[blockFeatureGlobal.sub_material].add(global_z);
} }
break; break;
case DFHack::OBSIDIAN: case tiletype_material::LAVA_STONE:
// TODO ? // TODO ?
break; break;
} }
@ -578,7 +572,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
con << "Base materials:" << std::endl; con << "Base materials:" << std::endl;
for (it = baseMats.begin(); it != baseMats.end(); ++it) 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) << ENUM_KEY_STR(tiletype_material,(df::tiletype_material)it->first) << " : " << it->second.count << std::endl;
} }
if (liquidWater.count || liquidMagma.count) if (liquidWater.count || liquidMagma.count)

@ -23,7 +23,7 @@ static tthread::mutex * instance_mutex = 0;
static bool running = false; static bool running = false;
static tthread::thread * QTThread; static tthread::thread * QTThread;
DFhackCExport command_result runqt (Core * c, vector <string> & parameters); command_result runqt (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -43,7 +43,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_FAILURE; return CR_FAILURE;
} }
DFhackCExport command_result runqt (Core * c, vector <string> & parameters) command_result runqt (Core * c, vector <string> & parameters)
{ {
instance_mutex->lock(); instance_mutex->lock();
if(!running) if(!running)

@ -17,7 +17,7 @@ using namespace DFHack;
using df::global::world; using df::global::world;
DFhackCExport command_result df_regrass (Core * c, vector <string> & parameters) command_result df_regrass (Core * c, vector <string> & parameters)
{ {
if (!parameters.empty()) if (!parameters.empty())
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
@ -32,28 +32,16 @@ DFhackCExport command_result df_regrass (Core * c, vector <string> & parameters)
{ {
for (int y = 0; y < 16; y++) for (int y = 0; y < 16; y++)
{ {
if (DFHack::tileShape(cur->tiletype[x][y]) != DFHack::FLOOR) if (tileShape(cur->tiletype[x][y]) != tiletype_shape::FLOOR)
continue; continue;
if (DFHack::tileMaterial(cur->tiletype[x][y]) != DFHack::SOIL) if (tileMaterial(cur->tiletype[x][y]) != tiletype_material::SOIL)
continue; continue;
if (cur->designation[x][y].bits.subterranean) if (cur->designation[x][y].bits.subterranean)
continue; continue;
if (cur->occupancy[x][y].bits.building) if (cur->occupancy[x][y].bits.building)
continue; continue;
switch (rand() % 8) cur->tiletype[x][y] = findRandomVariant((rand() & 1) ? tiletype::GrassLightFloor1 : tiletype::GrassDarkFloor1);
{
// light grass
case 0: cur->tiletype[x][y] = 0x015C; break;
case 1: cur->tiletype[x][y] = 0x015D; break;
case 2: cur->tiletype[x][y] = 0x015E; break;
case 3: cur->tiletype[x][y] = 0x015F; break;
// dark grass
case 4: cur->tiletype[x][y] = 0x018E; break;
case 5: cur->tiletype[x][y] = 0x018F; break;
case 6: cur->tiletype[x][y] = 0x0190; break;
case 7: cur->tiletype[x][y] = 0x0191; break;
}
count++; count++;
} }
} }

@ -58,11 +58,11 @@ enum revealstate
revealstate revealed = NOT_REVEALED; revealstate revealed = NOT_REVEALED;
DFhackCExport command_result reveal(DFHack::Core * c, std::vector<std::string> & params); command_result reveal(DFHack::Core * c, std::vector<std::string> & params);
DFhackCExport command_result unreveal(DFHack::Core * c, std::vector<std::string> & params); command_result unreveal(DFHack::Core * c, std::vector<std::string> & params);
DFhackCExport command_result revtoggle(DFHack::Core * c, std::vector<std::string> & params); command_result revtoggle(DFHack::Core * c, std::vector<std::string> & params);
DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string> & params); command_result revflood(DFHack::Core * c, std::vector<std::string> & params);
DFhackCExport command_result nopause(DFHack::Core * c, std::vector<std::string> & params); command_result nopause(DFHack::Core * c, std::vector<std::string> & params);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -124,7 +124,7 @@ command_result nopause (Core * c, std::vector <std::string> & parameters)
} }
DFhackCExport command_result reveal(DFHack::Core * c, std::vector<std::string> & params) command_result reveal(DFHack::Core * c, std::vector<std::string> & params)
{ {
bool no_hell = true; bool no_hell = true;
bool pause = true; bool pause = true;
@ -215,7 +215,7 @@ DFhackCExport command_result reveal(DFHack::Core * c, std::vector<std::string> &
return CR_OK; return CR_OK;
} }
DFhackCExport command_result unreveal(DFHack::Core * c, std::vector<std::string> & params) command_result unreveal(DFHack::Core * c, std::vector<std::string> & params)
{ {
Console & con = c->con; Console & con = c->con;
for(size_t i = 0; i < params.size();i++) for(size_t i = 0; i < params.size();i++)
@ -272,7 +272,7 @@ DFhackCExport command_result unreveal(DFHack::Core * c, std::vector<std::string>
return CR_OK; return CR_OK;
} }
DFhackCExport command_result revtoggle (DFHack::Core * c, std::vector<std::string> & params) command_result revtoggle (DFHack::Core * c, std::vector<std::string> & params)
{ {
for(size_t i = 0; i < params.size();i++) for(size_t i = 0; i < params.size();i++)
{ {
@ -292,7 +292,7 @@ DFhackCExport command_result revtoggle (DFHack::Core * c, std::vector<std::strin
} }
} }
DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string> & params) command_result revflood(DFHack::Core * c, std::vector<std::string> & params)
{ {
for(size_t i = 0; i < params.size();i++) for(size_t i = 0; i < params.size();i++)
{ {
@ -338,7 +338,7 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string>
} }
DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz); DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
MapCache * MCache = new MapCache; MapCache * MCache = new MapCache;
int16_t tt = MCache->tiletypeAt(xy); df::tiletype tt = MCache->tiletypeAt(xy);
if(isWallTerrain(tt)) if(isWallTerrain(tt))
{ {
c->con.printerr("Point the cursor at some empty space you want to be unhidden.\n"); c->con.printerr("Point the cursor at some empty space you want to be unhidden.\n");
@ -372,58 +372,46 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string>
if(!MCache->testCoord(current)) if(!MCache->testCoord(current))
continue; continue;
int16_t tt = MCache->tiletypeAt(current); df::tiletype tt = MCache->tiletypeAt(current);
df::tile_designation des = MCache->designationAt(current); df::tile_designation des = MCache->designationAt(current);
if(!des.bits.hidden) if(!des.bits.hidden)
{ {
continue; continue;
} }
const TileRow * r = getTileRow(tt);
/*
if(!r)
{
cerr << "unknown tiletype! " << dec << tt << endl;
continue;
}
*/
bool below = 0; bool below = 0;
bool above = 0; bool above = 0;
bool sides = 0; bool sides = 0;
bool unhide = 1; bool unhide = 1;
// by tile shape, determine behavior and action // by tile shape, determine behavior and action
switch (r->shape) switch (tileShape(tt))
{ {
// walls: // walls:
case WALL: case tiletype_shape::WALL:
case PILLAR:
if(from_below) if(from_below)
unhide = 0; unhide = 0;
break; break;
// air/free space // air/free space
case EMPTY: case tiletype_shape::EMPTY:
case RAMP_TOP: case tiletype_shape::RAMP_TOP:
case STAIR_UPDOWN: case tiletype_shape::STAIR_UPDOWN:
case STAIR_DOWN: case tiletype_shape::STAIR_DOWN:
case BROOK_TOP: case tiletype_shape::BROOK_TOP:
above = below = sides = true; above = below = sides = true;
break; break;
// has floor // has floor
case FORTIFICATION: case tiletype_shape::FORTIFICATION:
case STAIR_UP: case tiletype_shape::STAIR_UP:
case RAMP: case tiletype_shape::RAMP:
case FLOOR: case tiletype_shape::FLOOR:
case TREE_DEAD: case tiletype_shape::TREE:
case TREE_OK: case tiletype_shape::SAPLING:
case SAPLING_DEAD: case tiletype_shape::SHRUB:
case SAPLING_OK: case tiletype_shape::BOULDER:
case SHRUB_DEAD: case tiletype_shape::PEBBLES:
case SHRUB_OK: case tiletype_shape::BROOK_BED:
case BOULDER: case tiletype_shape::RIVER_BED:
case PEBBLES: case tiletype_shape::ENDLESS_PIT:
case BROOK_BED: case tiletype_shape::POOL:
case RIVER_BED:
case ENDLESS_PIT:
case POOL:
if(from_below) if(from_below)
unhide = 0; unhide = 0;
above = sides = true; above = sides = true;

@ -97,7 +97,7 @@ string searchAbbreviations(string in)
} }
}; };
DFhackCExport command_result df_seedwatch(Core* pCore, vector<string>& parameters) command_result df_seedwatch(Core* pCore, vector<string>& parameters)
{ {
Core& core = *pCore; Core& core = *pCore;
if(!core.isValid()) if(!core.isValid())

@ -10,7 +10,7 @@ using namespace DFHack;
// Here go all the command declarations... // Here go all the command declarations...
// mostly to allow having the mandatory stuff on top of the file and commands on the bottom // mostly to allow having the mandatory stuff on top of the file and commands on the bottom
DFhackCExport command_result server (Core * c, std::vector <std::string> & parameters); command_result server (Core * c, std::vector <std::string> & parameters);
// A plugins must be able to return its name. This must correspond to the filename - skeleton.plug.so or skeleton.plug.dll // A plugins must be able to return its name. This must correspond to the filename - skeleton.plug.so or skeleton.plug.dll
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
@ -39,7 +39,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
} }
// This is WRONG and STUPID. Never use this as an example! // This is WRONG and STUPID. Never use this as an example!
DFhackCExport command_result server (Core * c, std::vector <std::string> & parameters) command_result server (Core * c, std::vector <std::string> & parameters)
{ {
// It's nice to provide a 'help' option for your command. // It's nice to provide a 'help' option for your command.
// It's also nice to print the same help if you get invalid options from the user instead of just acting strange // It's also nice to print the same help if you get invalid options from the user instead of just acting strange

@ -27,7 +27,7 @@ using namespace df::enums;
using df::global::world; using df::global::world;
DFhackCExport command_result df_showmood (Core * c, vector <string> & parameters) command_result df_showmood (Core * c, vector <string> & parameters)
{ {
if (!parameters.empty()) if (!parameters.empty())
return CR_WRONG_USAGE; return CR_WRONG_USAGE;

@ -61,10 +61,10 @@ int toint(const std::string &str, int failValue = 0)
struct TileType struct TileType
{ {
DFHack::TileShape shape; df::tiletype_shape shape;
DFHack::TileMaterial material; df::tiletype_material material;
DFHack::TileSpecial special; df::tiletype_special special;
DFHack::TileVariant variant; df::tiletype_variant variant;
int dig; int dig;
int hidden; int hidden;
int light; int light;
@ -73,10 +73,10 @@ struct TileType
TileType() TileType()
{ {
shape = DFHack::tileshape_invalid; shape = tiletype_shape::NONE;
material = DFHack::tilematerial_invalid; material = tiletype_material::NONE;
special = DFHack::tilespecial_invalid; special = tiletype_special::NONE;
variant = DFHack::tilevariant_invalid; variant = tiletype_variant::NONE;
dig = -1; dig = -1;
hidden = -1; hidden = -1;
light = -1; light = -1;
@ -99,7 +99,7 @@ std::ostream &operator<<(std::ostream &stream, const TileType &paint)
if (paint.special >= 0) if (paint.special >= 0)
{ {
stream << DFHack::TileSpecialString[paint.special]; stream << ENUM_KEY_STR(tiletype_special,paint.special);
used = true; used = true;
needSpace = true; needSpace = true;
} }
@ -112,7 +112,7 @@ std::ostream &operator<<(std::ostream &stream, const TileType &paint)
needSpace = false; needSpace = false;
} }
stream << DFHack::TileMaterialString[paint.material]; stream << ENUM_KEY_STR(tiletype_material,paint.material);
used = true; used = true;
needSpace = true; needSpace = true;
} }
@ -125,7 +125,7 @@ std::ostream &operator<<(std::ostream &stream, const TileType &paint)
needSpace = false; needSpace = false;
} }
stream << DFHack::TileShapeString[paint.shape]; stream << ENUM_KEY_STR(tiletype_shape,paint.shape);
used = true; used = true;
needSpace = true; needSpace = true;
} }
@ -138,7 +138,7 @@ std::ostream &operator<<(std::ostream &stream, const TileType &paint)
needSpace = false; needSpace = false;
} }
stream << "VAR_" << (paint.variant + 1); stream << ENUM_KEY_STR(tiletype_variant,paint.variant);
used = true; used = true;
needSpace = true; needSpace = true;
} }
@ -233,18 +233,18 @@ bool processTileType(TileType &paint, const std::string &option, const std::stri
if (option == "shape" || option == "sh" || option == "s") if (option == "shape" || option == "sh" || option == "s")
{ {
if (valInt >= -1 && valInt < DFHack::tileshape_count) if (tiletype_shape::is_valid((df::tiletype_shape)valInt))
{ {
paint.shape = (DFHack::TileShape) valInt; paint.shape = (df::tiletype_shape)valInt;
found = true; found = true;
} }
else else
{ {
for (int i = 0; i < DFHack::tileshape_count; i++) FOR_ENUM_ITEMS(tiletype_shape,i)
{ {
if (val == DFHack::TileShapeString[i]) if (val == ENUM_KEY_STR(tiletype_shape,i))
{ {
paint.shape = (DFHack::TileShape) i; paint.shape = i;
found = true; found = true;
break; break;
} }
@ -258,18 +258,18 @@ bool processTileType(TileType &paint, const std::string &option, const std::stri
} }
else if (option == "material" || option == "mat" || option == "m") 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; found = true;
} }
else else
{ {
for (int i = 0; i < DFHack::tilematerial_count; i++) FOR_ENUM_ITEMS(tiletype_material, i)
{ {
if (val == DFHack::TileMaterialString[i]) if (val == ENUM_KEY_STR(tiletype_material,i))
{ {
paint.material = (DFHack::TileMaterial) i; paint.material = i;
found = true; found = true;
break; break;
} }
@ -283,18 +283,18 @@ bool processTileType(TileType &paint, const std::string &option, const std::stri
} }
else if (option == "special" || option == "sp") else if (option == "special" || option == "sp")
{ {
if (valInt >= -1 && valInt < DFHack::tilespecial_count) if (tiletype_special::is_valid((df::tiletype_special)valInt))
{ {
paint.special = (DFHack::TileSpecial) valInt; paint.special = (df::tiletype_special)valInt;
found = true; found = true;
} }
else else
{ {
for (int i = 0; i < DFHack::tilespecial_count; i++) FOR_ENUM_ITEMS(tiletype_special, i)
{ {
if (val == DFHack::TileSpecialString[i]) if (val == ENUM_KEY_STR(tiletype_special,i))
{ {
paint.special = (DFHack::TileSpecial) i; paint.special = i;
found = true; found = true;
break; break;
} }
@ -308,16 +308,29 @@ bool processTileType(TileType &paint, const std::string &option, const std::stri
} }
else if (option == "variant" || option == "var" || option == "v") else if (option == "variant" || option == "var" || option == "v")
{ {
if (valInt >= -1 && valInt <= DFHack::VAR_4) if (tiletype_variant::is_valid((df::tiletype_variant)valInt))
{ {
paint.variant = (DFHack::TileVariant) valInt; paint.variant = (df::tiletype_variant)valInt;
found = true; found = true;
} }
else else
{
FOR_ENUM_ITEMS(tiletype_variant, i)
{
if (val == ENUM_KEY_STR(tiletype_variant,i))
{
paint.variant = i;
found = true;
break;
}
}
if (!found)
{ {
std::cout << "Unknown tile variant: " << value << std::endl; std::cout << "Unknown tile variant: " << value << std::endl;
} }
} }
}
else if (option == "designated" || option == "d") else if (option == "designated" || option == "d")
{ {
if (valInt >= -1 && valInt < 2) if (valInt >= -1 && valInt < 2)
@ -415,33 +428,37 @@ void help( std::ostream & out, const std::string &option)
{ {
out << "Available shapes:" << std::endl out << "Available shapes:" << std::endl
<< " ANY" << std::endl; << " ANY" << std::endl;
for (int i = 0; i < DFHack::tileshape_count; i++) FOR_ENUM_ITEMS(tiletype_shape,i)
{ {
out << " " << DFHack::TileShapeString[i] << std::endl; out << " " << ENUM_KEY_STR(tiletype_shape,i) << std::endl;
} }
} }
else if (option == "material"|| option == "mat" ||option == "m") else if (option == "material"|| option == "mat" ||option == "m")
{ {
out << "Available materials:" << std::endl out << "Available materials:" << std::endl
<< " ANY" << std::endl; << " ANY" << std::endl;
for (int i = 0; i < DFHack::tilematerial_count; i++) FOR_ENUM_ITEMS(tiletype_material,i)
{ {
out << " " << DFHack::TileMaterialString[i] << std::endl; out << " " << ENUM_KEY_STR(tiletype_material,i) << std::endl;
} }
} }
else if (option == "special" || option == "sp") else if (option == "special" || option == "sp")
{ {
out << "Available specials:" << std::endl out << "Available specials:" << std::endl
<< " ANY" << std::endl; << " ANY" << std::endl;
for (int i = 0; i < DFHack::tilespecial_count; i++) FOR_ENUM_ITEMS(tiletype_special,i)
{ {
out << " " << DFHack::TileSpecialString[i] << std::endl; out << " " << ENUM_KEY_STR(tiletype_special,i) << std::endl;
} }
} }
else if (option == "variant" || option == "var" || option == "v") else if (option == "variant" || option == "var" || option == "v")
{ {
out << "Available variants:" << std::endl out << "Available variants:" << std::endl
<< " ANY, 0 - " << DFHack::VAR_4 << std::endl; << " ANY" << std::endl;
FOR_ENUM_ITEMS(tiletype_variant,i)
{
out << " " << ENUM_KEY_STR(tiletype_variant,i) << std::endl;
}
} }
else if (option == "designated" || option == "d") else if (option == "designated" || option == "d")
{ {
@ -601,8 +618,8 @@ public:
bool juststarted = true; bool juststarted = true;
while (mc.testCoord(start)) while (mc.testCoord(start))
{ {
uint16_t tt = mc.tiletypeAt(start); df::tiletype tt = mc.tiletypeAt(start);
if(DFHack::LowPassable(tt) || juststarted && DFHack::HighPassable(tt)) if(LowPassable(tt) || juststarted && HighPassable(tt))
{ {
v.push_back(start); v.push_back(start);
juststarted = false; juststarted = false;
@ -616,7 +633,7 @@ public:
CommandHistory tiletypes_hist; CommandHistory tiletypes_hist;
DFhackCExport command_result df_tiletypes (Core * c, vector <string> & parameters); command_result df_tiletypes (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -637,7 +654,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result df_tiletypes (Core * c, vector <string> & parameters) command_result df_tiletypes (Core * c, vector <string> & parameters)
{ {
uint32_t x_max = 0, y_max = 0, z_max = 0; uint32_t x_max = 0, y_max = 0, z_max = 0;
int32_t x = 0, y = 0, z = 0; int32_t x = 0, y = 0, z = 0;
@ -777,37 +794,37 @@ DFhackCExport command_result df_tiletypes (Core * c, vector <string> & parameter
for (coord_vec::iterator iter = all_tiles.begin(); iter != all_tiles.end(); ++iter) 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); df::tile_designation des = map.designationAt(*iter);
if ((filter.shape > -1 && filter.shape != source->shape) if ((filter.shape > -1 && filter.shape != tileShape(source))
|| (filter.material > -1 && filter.material != source->material) || (filter.material > -1 && filter.material != tileMaterial(source))
|| (filter.special > -1 && filter.special != source->special) || (filter.special > -1 && filter.special != tileSpecial(source))
|| (filter.variant > -1 && filter.variant != source->variant) || (filter.variant > -1 && filter.variant != tileVariant(source))
|| (filter.dig > -1 && (filter.dig != 0) != (des.bits.dig != tile_dig_designation::No)) || (filter.dig > -1 && (filter.dig != 0) != (des.bits.dig != tile_dig_designation::No))
) )
{ {
continue; continue;
} }
DFHack::TileShape shape = paint.shape; df::tiletype_shape shape = paint.shape;
if (shape < 0) if (shape == tiletype_shape::NONE)
{ {
shape = source->shape; shape = tileShape(source);
} }
DFHack::TileMaterial material = paint.material; df::tiletype_material material = paint.material;
if (material < 0) if (material == tiletype_material::NONE)
{ {
material = source->material; material = tileMaterial(source);
} }
DFHack::TileSpecial special = paint.special; df::tiletype_special special = paint.special;
if (special < 0) 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: * FIXME: variant should be:
* 1. If user variant: * 1. If user variant:
@ -826,24 +843,24 @@ DFhackCExport command_result df_tiletypes (Core * c, vector <string> & parameter
* the usefullness of the tool. * the usefullness of the tool.
*/ */
/* /*
if (variant < 0) if (variant == tiletype_variant::NONE)
{ {
variant = source->variant; variant = tileVariant(source);
} }
*/ */
// Remove direction from directionless tiles // Remove direction from directionless tiles
DFHack::TileDirection direction = source->direction; DFHack::TileDirection direction = tileDirection(source);
if (!(shape == DFHack::RIVER_BED || shape == DFHack::BROOK_BED || shape == DFHack::WALL && (material == DFHack::CONSTRUCTED || special == DFHack::TILE_SMOOTH))) { 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; 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 // hack for empty space
if (shape == DFHack::EMPTY && material == DFHack::AIR && variant == DFHack::VAR_1 && special == DFHack::TILE_NORMAL && direction.whole == 0) { if (shape == tiletype_shape::EMPTY && material == tiletype_material::AIR && variant == tiletype_variant::VAR_1 && special == tiletype_special::NORMAL && direction.whole == 0) {
type = 32; type = tiletype::OpenSpace;
} }
// make sure it's not invalid // make sure it's not invalid
if(type != -1) if(type != tiletype::Void)
map.setTiletypeAt(*iter, type); map.setTiletypeAt(*iter, type);
if (paint.hidden > -1) if (paint.hidden > -1)

@ -18,7 +18,7 @@ using namespace DFHack::Simple;
using namespace df::enums; using namespace df::enums;
using df::global::world; using df::global::world;
DFhackCExport command_result tubefill(DFHack::Core * c, std::vector<std::string> & params); command_result tubefill(DFHack::Core * c, std::vector<std::string> & params);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -37,7 +37,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result tubefill(DFHack::Core * c, std::vector<std::string> & params) command_result tubefill(DFHack::Core * c, std::vector<std::string> & params)
{ {
uint64_t count = 0; uint64_t count = 0;
@ -79,7 +79,7 @@ DFhackCExport command_result tubefill(DFHack::Core * c, std::vector<std::string>
continue; continue;
// Is the tile already a wall? // Is the tile already a wall?
if (tileShape(block->tiletype[x][y]) == WALL) if (tileShape(block->tiletype[x][y]) == tiletype_shape::WALL)
continue; continue;
// Does the tile contain liquid? // 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 // Check the tile above this one, in case we need to add a floor
if (above) 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 // 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 // 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) if (!above->designation[x][y].bits.feature_local)
continue; 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; ++count;
} }
} }

@ -16,11 +16,11 @@ using std::stack;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
DFhackCExport command_result vdig (Core * c, vector <string> & parameters); command_result vdig (Core * c, vector <string> & parameters);
DFhackCExport command_result vdigx (Core * c, vector <string> & parameters); command_result vdigx (Core * c, vector <string> & parameters);
DFhackCExport command_result autodig (Core * c, vector <string> & parameters); command_result autodig (Core * c, vector <string> & parameters);
DFhackCExport command_result expdig (Core * c, vector <string> & parameters); command_result expdig (Core * c, vector <string> & parameters);
DFhackCExport command_result digcircle (Core *c, vector <string> & parameters); command_result digcircle (Core *c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
@ -90,33 +90,33 @@ bool dig (MapExtras::MapCache & MCache,
//c->con.print("not digging map border\n"); //c->con.print("not digging map border\n");
return false; return false;
} }
uint16_t tt = MCache.tiletypeAt(at); df::tiletype tt = MCache.tiletypeAt(at);
df::tile_designation des = MCache.designationAt(at); df::tile_designation des = MCache.designationAt(at);
// could be potentially used to locate hidden constructions? // 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; return false;
TileShape ts = tileShape(tt); df::tiletype_shape ts = tileShape(tt);
if(ts == EMPTY) if (ts == tiletype_shape::EMPTY)
return false; return false;
if(!des.bits.hidden) if(!des.bits.hidden)
{ {
do do
{ {
if(isWallTerrain(tt)) df::tiletype_shape_basic tsb = ENUM_ATTR(tiletype_shape, 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; break;
} }
if(isFloorTerrain(tt) if (tsb == tiletype_shape_basic::Floor
&& (type == tile_dig_designation::DownStair || type == tile_dig_designation::Channel) && (type == tile_dig_designation::DownStair || type == tile_dig_designation::Channel)
&& ts != TREE_OK && ts != tiletype_shape::TREE
&& ts != TREE_DEAD
) )
{ {
std::cerr << "allowing tt" << tt << ", is floor\n"; std::cerr << "allowing tt" << (int)tt << ", is floor\n";
break; break;
} }
if(isStairTerrain(tt) && type == tile_dig_designation::Channel ) if (tsb == tiletype_shape_basic::Stair && type == tile_dig_designation::Channel )
break; break;
return false; return false;
} }
@ -147,7 +147,7 @@ bool dig (MapExtras::MapCache & MCache,
} }
break; break;
} }
std::cerr << "allowing tt" << tt << "\n"; std::cerr << "allowing tt" << (int)tt << "\n";
MCache.setDesignationAt(at,des); MCache.setDesignationAt(at,des);
return true; return true;
}; };
@ -180,7 +180,7 @@ bool lineY (MapExtras::MapCache & MCache,
return true; return true;
}; };
DFhackCExport command_result digcircle (Core * c, vector <string> & parameters) command_result digcircle (Core * c, vector <string> & parameters)
{ {
static bool filled = false; static bool filled = false;
static circle_what what = circle_set; static circle_what what = circle_set;
@ -747,9 +747,9 @@ bool stamp_pattern (uint32_t bx, uint32_t by, int z_level,
for(; y < my; y++) for(; y < my; y++)
{ {
df::tile_designation & des = bl->designation[x][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? // 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; continue;
if(!isWallTerrain(tt) && !des.bits.hidden) if(!isWallTerrain(tt) && !des.bits.hidden)
continue; continue;
@ -777,7 +777,7 @@ bool stamp_pattern (uint32_t bx, uint32_t by, int z_level,
return true; return true;
}; };
DFhackCExport command_result expdig (Core * c, vector <string> & parameters) command_result expdig (Core * c, vector <string> & parameters)
{ {
bool force_help = false; bool force_help = false;
static explo_how how = EXPLO_NOTHING; static explo_how how = EXPLO_NOTHING;
@ -927,11 +927,11 @@ DFhackCExport command_result expdig (Core * c, vector <string> & parameters)
for(int y = 0; y < 16; y++) for(int y = 0; y < 16; y++)
{ {
DFCoord pos(xmid+x,ymid+y,z_level); DFCoord pos(xmid+x,ymid+y,z_level);
short unsigned int tt = mx.tiletypeAt(pos); df::tiletype tt = mx.tiletypeAt(pos);
if(tt == 0) if(tt == tiletype::Void)
continue; continue;
df::tile_designation des = mx.designationAt(pos); df::tile_designation des = mx.designationAt(pos);
if(tileMaterial(tt) == CONSTRUCTED && !des.bits.hidden) if(tileMaterial(tt) == tiletype_material::CONSTRUCTION && !des.bits.hidden)
continue; continue;
if(!isWallTerrain(tt) && !des.bits.hidden) if(!isWallTerrain(tt) && !des.bits.hidden)
continue; continue;
@ -954,7 +954,7 @@ DFhackCExport command_result expdig (Core * c, vector <string> & parameters)
return CR_OK; return CR_OK;
} }
DFhackCExport command_result vdigx (Core * c, vector <string> & parameters) command_result vdigx (Core * c, vector <string> & parameters)
{ {
// HOTKEY COMMAND: CORE ALREADY SUSPENDED // HOTKEY COMMAND: CORE ALREADY SUSPENDED
vector <string> lol; vector <string> lol;
@ -962,7 +962,7 @@ DFhackCExport command_result vdigx (Core * c, vector <string> & parameters)
return vdig(c,lol); return vdig(c,lol);
} }
DFhackCExport command_result vdig (Core * c, vector <string> & parameters) command_result vdig (Core * c, vector <string> & parameters)
{ {
// HOTKEY COMMAND: CORE ALREADY SUSPENDED // HOTKEY COMMAND: CORE ALREADY SUSPENDED
uint32_t x_max,y_max,z_max; uint32_t x_max,y_max,z_max;
@ -1002,7 +1002,7 @@ DFhackCExport command_result vdig (Core * c, vector <string> & parameters)
} }
MapExtras::MapCache * MCache = new MapExtras::MapCache; MapExtras::MapCache * MCache = new MapExtras::MapCache;
df::tile_designation des = MCache->designationAt(xy); 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); int16_t veinmat = MCache->veinMaterialAt(xy);
if( veinmat == -1 ) if( veinmat == -1 )
{ {
@ -1120,7 +1120,7 @@ DFhackCExport command_result vdig (Core * c, vector <string> & parameters)
return CR_OK; return CR_OK;
} }
DFhackCExport command_result autodig (Core * c, vector <string> & parameters) command_result autodig (Core * c, vector <string> & parameters)
{ {
return CR_NOT_IMPLEMENTED; return CR_NOT_IMPLEMENTED;
} }

@ -15,7 +15,7 @@ using namespace std;
#include "modules/Gui.h" #include "modules/Gui.h"
using namespace DFHack; using namespace DFHack;
DFhackCExport command_result df_versionosd (Core * c, vector <string> & parameters); command_result df_versionosd (Core * c, vector <string> & parameters);
static DFSDL_Surface* (*_IMG_LoadPNG_RW)(void* src) = 0; static DFSDL_Surface* (*_IMG_LoadPNG_RW)(void* src) = 0;
static vPtr (*_SDL_RWFromFile)(const char* file, const char *mode) = 0; static vPtr (*_SDL_RWFromFile)(const char* file, const char *mode) = 0;
static int (*_SDL_SetAlpha)(vPtr surface, uint32_t flag, uint8_t alpha) = 0; static int (*_SDL_SetAlpha)(vPtr surface, uint32_t flag, uint8_t alpha) = 0;
@ -117,7 +117,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result df_versionosd (Core * c, vector <string> & parameters) command_result df_versionosd (Core * c, vector <string> & parameters)
{ {
On = !On; On = !On;
c->Suspend(); c->Suspend();

@ -13,7 +13,7 @@ using namespace DFHack;
bool locked = false; bool locked = false;
unsigned char locked_data[25]; unsigned char locked_data[25];
DFhackCExport command_result weather (Core * c, vector <string> & parameters); command_result weather (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -40,7 +40,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK; return CR_OK;
} }
DFhackCExport command_result weather (Core * c, vector <string> & parameters) command_result weather (Core * c, vector <string> & parameters)
{ {
Console & con = c->con; Console & con = c->con;
bool lock = false; bool lock = false;