Made invalid tile types really invalid, license and unused depends cleanup.

develop
Petr Mrázek 2011-11-25 18:54:50 +01:00
parent 370681848d
commit 57b5ed8fa7
9 changed files with 293 additions and 1095 deletions

@ -25,7 +25,7 @@ set(DF_VERSION_MINOR "31")
set(DF_VERSION_PATCH "25") set(DF_VERSION_PATCH "25")
set(DF_VERSION "${DF_VERSION_MAJOR}.${DF_VERSION_MINOR}.${DF_VERSION_PATCH}") set(DF_VERSION "${DF_VERSION_MAJOR}.${DF_VERSION_MINOR}.${DF_VERSION_PATCH}")
set(DFHACK_RELEASE "8") set(DFHACK_RELEASE "9")
## where to install things (after the build is done, classic 'make install' or package structure) ## where to install things (after the build is done, classic 'make install' or package structure)
# the dfhack libraries will be installed here: # the dfhack libraries will be installed here:

@ -24,42 +24,6 @@ must not be misrepresented as being the original software.
distribution. distribution.
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
License of "RSA Data Security, Inc. MD5 Message-Digest Algorithm"
Used to identify DF binaries.
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
-----------------------------------------------------------------
License of the "RSA Data Security, Inc. MD5 Message-Digest Algorithm" C++ wrapper:
This is my wrapper-class to create
a MD5 Hash from a string and a file.
This code is completly free, you
can copy it, modify it, or do
what ever you want with it.
Feb. 2005
Benjamin Grüdelbach
------------------------------------------------------------------
License of the used XML reader library License of the used XML reader library
www.sourceforge.net/projects/tinyxml www.sourceforge.net/projects/tinyxml
@ -83,39 +47,6 @@ must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
------------------------------------------------------------------
Free Getopt
Copyright (c)2002-2003 Mark K. Kim
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the original author of this software nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
------------------------------------------------------------------ ------------------------------------------------------------------
* dirent.h - dirent API for Microsoft Visual Studio * dirent.h - dirent API for Microsoft Visual Studio

@ -31,46 +31,46 @@ namespace DFHack
const TileRow tileTypeTable[TILE_TYPE_ARRAY_LENGTH] = const TileRow tileTypeTable[TILE_TYPE_ARRAY_LENGTH] =
{ {
// 0 // 0
{"void",EMPTY, AIR, VAR_1}, {"void",tileshape_invalid, tilematerial_invalid, VAR_1},
{"ramp top",RAMP_TOP, AIR, VAR_1}, {"ramp top",RAMP_TOP, AIR, VAR_1},
{"pool",POOL, SOIL, VAR_1}, {"pool",POOL, SOIL, VAR_1},
{0, EMPTY, AIR, VAR_1}, {0, tileshape_invalid, tilematerial_invalid, VAR_1},
{0, EMPTY, AIR, VAR_1}, {0, tileshape_invalid, tilematerial_invalid, VAR_1},
{0, EMPTY, AIR, VAR_1}, {0, tileshape_invalid, tilematerial_invalid, VAR_1},
{0, EMPTY, AIR, VAR_1}, {0, tileshape_invalid, tilematerial_invalid, VAR_1},
{0, EMPTY, AIR, VAR_1}, {0, tileshape_invalid, tilematerial_invalid, VAR_1},
{0, EMPTY, AIR, VAR_1}, {0, tileshape_invalid, tilematerial_invalid, VAR_1},
{0, EMPTY, AIR, VAR_1}, {0, tileshape_invalid, tilematerial_invalid, VAR_1},
// 10 // 10
{0, EMPTY, AIR, VAR_1}, {0, tileshape_invalid, tilematerial_invalid, VAR_1},
{0, EMPTY, AIR, VAR_1}, {0, tileshape_invalid, tilematerial_invalid, VAR_1},
{0, EMPTY, AIR, VAR_1}, {0, tileshape_invalid, tilematerial_invalid, VAR_1},
{0, EMPTY, AIR, VAR_1}, {0, tileshape_invalid, tilematerial_invalid, VAR_1},
{0, EMPTY, AIR, VAR_1}, {0, tileshape_invalid, tilematerial_invalid, VAR_1},
{0, EMPTY, AIR, VAR_1}, {0, tileshape_invalid, tilematerial_invalid, VAR_1},
{0, EMPTY, AIR, VAR_1}, {0, tileshape_invalid, tilematerial_invalid, VAR_1},
{0, EMPTY, AIR, VAR_1}, {0, tileshape_invalid, tilematerial_invalid, VAR_1},
{0, EMPTY, AIR, VAR_1}, {0, tileshape_invalid, tilematerial_invalid, VAR_1},
{"driftwood stack",FLOOR, DRIFTWOOD, VAR_1}, {"driftwood stack",FLOOR, DRIFTWOOD, VAR_1},
// 20 // 20
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{"tree",TREE_OK, SOIL, VAR_1}, {"tree",TREE_OK, SOIL, VAR_1},
{"ice stair up/down",STAIR_UPDOWN, ICE, VAR_1}, {"ice stair up/down",STAIR_UPDOWN, ICE, VAR_1},
{"ice stair down",STAIR_DOWN, ICE, VAR_1}, {"ice stair down",STAIR_DOWN, ICE, VAR_1},
{"ice stair up",STAIR_UP, ICE, VAR_1}, {"ice stair up",STAIR_UP, ICE, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 30 // 30
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{"empty space",EMPTY, AIR, VAR_1}, {"empty space",EMPTY, AIR, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{"shrub",SHRUB_OK, SOIL, VAR_1}, {"shrub",SHRUB_OK, SOIL, VAR_1},
{"chasm",ENDLESS_PIT, AIR, VAR_1}, {"chasm",ENDLESS_PIT, AIR, VAR_1},
{"obsidian stair up/down",STAIR_UPDOWN, OBSIDIAN, VAR_1}, {"obsidian stair up/down",STAIR_UPDOWN, OBSIDIAN, VAR_1},
@ -87,7 +87,7 @@ namespace DFHack
{"smooth featstone? floor",FLOOR, FEATSTONE, VAR_1 , TILE_SMOOTH }, {"smooth featstone? floor",FLOOR, FEATSTONE, VAR_1 , TILE_SMOOTH },
{"smooth vein floor",FLOOR, VEIN, VAR_1 , TILE_SMOOTH }, {"smooth vein floor",FLOOR, VEIN, VAR_1 , TILE_SMOOTH },
{"smooth ice floor",FLOOR, ICE, VAR_1 , TILE_SMOOTH }, {"smooth ice floor",FLOOR, ICE, VAR_1 , TILE_SMOOTH },
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{"grass stair up/down",STAIR_UPDOWN, GRASS, VAR_1}, {"grass stair up/down",STAIR_UPDOWN, GRASS, VAR_1},
// 50 // 50
@ -107,23 +107,23 @@ namespace DFHack
{"featstone? stair up/down",STAIR_UPDOWN, FEATSTONE, VAR_1}, {"featstone? stair up/down",STAIR_UPDOWN, FEATSTONE, VAR_1},
{"featstone? stair down",STAIR_DOWN, FEATSTONE, VAR_1}, {"featstone? stair down",STAIR_DOWN, FEATSTONE, VAR_1},
{"featstone? stair up",STAIR_UP, FEATSTONE, VAR_1}, {"featstone? stair up",STAIR_UP, FEATSTONE, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{"stone fortification",FORTIFICATION, STONE, VAR_1}, {"stone fortification",FORTIFICATION, STONE, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{"campfire",FLOOR, CAMPFIRE, VAR_1}, {"campfire",FLOOR, CAMPFIRE, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 70 // 70
{"fire",FLOOR, FIRE, VAR_1}, {"fire",FLOOR, FIRE, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{"stone pillar",PILLAR, STONE, VAR_1}, {"stone pillar",PILLAR, STONE, VAR_1},
//80 //80
@ -131,185 +131,185 @@ namespace DFHack
{"featstone? pillar",PILLAR, FEATSTONE, VAR_1,TILE_SMOOTH}, {"featstone? pillar",PILLAR, FEATSTONE, VAR_1,TILE_SMOOTH},
{"vein pillar",PILLAR, VEIN, VAR_1,TILE_SMOOTH}, {"vein pillar",PILLAR, VEIN, VAR_1,TILE_SMOOTH},
{"ice pillar",PILLAR, ICE, VAR_1,TILE_SMOOTH}, {"ice pillar",PILLAR, ICE, VAR_1,TILE_SMOOTH},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{"waterfall landing",FLOOR, SOIL, VAR_1, TILE_WATERFALL }, // verify material {"waterfall landing",FLOOR, SOIL, VAR_1, TILE_WATERFALL }, // verify material
// 90 // 90
{"river source",FLOOR, SOIL, VAR_1, TILE_RIVER_SOURCE }, // verify material {"river source",FLOOR, SOIL, VAR_1, TILE_RIVER_SOURCE }, // verify material
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 100 // 100
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 110 // 110
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 120 // 120
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 130 // 130
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 140 // 140
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 150 // 150
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 160 // 160
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 170 // 170
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{"cracked stone wall" ,WALL, STONE, VAR_1, TILE_CRACKED }, {"cracked stone wall" ,WALL, STONE, VAR_1, TILE_CRACKED },
{"damaged stone wall" ,WALL, STONE, VAR_1, TILE_DAMAGED }, {"damaged stone wall" ,WALL, STONE, VAR_1, TILE_DAMAGED },
{"worn stone wall" ,WALL, STONE, VAR_1, TILE_WORN }, {"worn stone wall" ,WALL, STONE, VAR_1, TILE_WORN },
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 180 // 180
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 190 // 190
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 200 // 200
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 210 // 210
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{"stone wall" ,WALL, STONE, VAR_1}, {"stone wall" ,WALL, STONE, VAR_1},
// 220 // 220
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 230 // 230
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{"sapling" ,SAPLING_OK, SOIL, VAR_1}, {"sapling" ,SAPLING_OK, SOIL, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{"dry grass ramp" ,RAMP, GRASS_DRY, VAR_1}, {"dry grass ramp" ,RAMP, GRASS_DRY, VAR_1},
{"dead grass ramp" ,RAMP, GRASS_DEAD, VAR_1}, {"dead grass ramp" ,RAMP, GRASS_DEAD, VAR_1},
{"grass ramp" ,RAMP, GRASS, VAR_1}, {"grass ramp" ,RAMP, GRASS, VAR_1},
@ -325,20 +325,20 @@ namespace DFHack
{"ashes" ,FLOOR, ASHES, VAR_2}, {"ashes" ,FLOOR, ASHES, VAR_2},
{"ashes" ,FLOOR, ASHES, VAR_3}, {"ashes" ,FLOOR, ASHES, VAR_3},
{"ice ramp" ,RAMP, ICE, VAR_1}, {"ice ramp" ,RAMP, ICE, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 250 // 250
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{"ice floor" ,FLOOR, ICE, VAR_2}, {"ice floor" ,FLOOR, ICE, VAR_2},
{"ice floor" ,FLOOR, ICE, VAR_3}, {"ice floor" ,FLOOR, ICE, VAR_3},
@ -351,7 +351,7 @@ namespace DFHack
{"soil wall" ,WALL, SOIL, VAR_1}, {"soil wall" ,WALL, SOIL, VAR_1},
{"glowing barrier" ,WALL, CYAN_GLOW, VAR_1}, {"glowing barrier" ,WALL, CYAN_GLOW, VAR_1},
{"glowing floor" ,FLOOR, CYAN_GLOW, VAR_1}, {"glowing floor" ,FLOOR, CYAN_GLOW, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{"smooth obsidian wall RD2",WALL,OBSIDIAN,VAR_1 , TILE_SMOOTH , "--SS--E-" }, {"smooth obsidian wall RD2",WALL,OBSIDIAN,VAR_1 , TILE_SMOOTH , "--SS--E-" },
// 270 // 270
@ -489,11 +489,11 @@ namespace DFHack
// 380 // 380
{"brook bed SE",BROOK_BED,SOIL,VAR_1, TILE_NORMAL, "SE" }, {"brook bed SE",BROOK_BED,SOIL,VAR_1, TILE_NORMAL, "SE" },
{"brook top",BROOK_TOP,SOIL,VAR_1 }, {"brook top",BROOK_TOP,SOIL,VAR_1 },
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{"dry grass 1",FLOOR,GRASS_DRY,VAR_1}, {"dry grass 1",FLOOR,GRASS_DRY,VAR_1},
{"dry grass 2",FLOOR,GRASS_DRY,VAR_2}, {"dry grass 2",FLOOR,GRASS_DRY,VAR_2},
{"dry grass 3",FLOOR,GRASS_DRY,VAR_3}, {"dry grass 3",FLOOR,GRASS_DRY,VAR_3},
@ -592,36 +592,36 @@ namespace DFHack
{"smooth ice wall",WALL,ICE,VAR_1 , TILE_SMOOTH , "--S-W---" }, {"smooth ice wall",WALL,ICE,VAR_1 , TILE_SMOOTH , "--S-W---" },
{"smooth ice wall",WALL,ICE,VAR_1 , TILE_SMOOTH , "N-S-----" }, {"smooth ice wall",WALL,ICE,VAR_1 , TILE_SMOOTH , "N-S-----" },
{"smooth ice wall",WALL,ICE,VAR_1 , TILE_SMOOTH , "----W-E-"}, {"smooth ice wall",WALL,ICE,VAR_1 , TILE_SMOOTH , "----W-E-"},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 470 // 470
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 480 // 480
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
// 490 // 490
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{0 ,EMPTY, AIR, VAR_1}, {0 ,tileshape_invalid, tilematerial_invalid, VAR_1},
{"constructed floor",FLOOR,CONSTRUCTED, VAR_1}, {"constructed floor",FLOOR,CONSTRUCTED, VAR_1},
{"constructed fortification",FORTIFICATION,CONSTRUCTED, VAR_1}, {"constructed fortification",FORTIFICATION,CONSTRUCTED, VAR_1},
{"constructed pillar",PILLAR,CONSTRUCTED, VAR_1}, {"constructed pillar",PILLAR,CONSTRUCTED, VAR_1},
@ -652,7 +652,7 @@ namespace DFHack
{"constructed stair down",STAIR_DOWN,CONSTRUCTED, VAR_1}, {"constructed stair down",STAIR_DOWN,CONSTRUCTED, VAR_1},
{"constructed stair up",STAIR_UP,CONSTRUCTED, VAR_1}, {"constructed stair up",STAIR_UP,CONSTRUCTED, VAR_1},
{"constructed ramp",RAMP,CONSTRUCTED, VAR_1}, {"constructed ramp",RAMP,CONSTRUCTED, VAR_1},
{0 ,EMPTY, AIR, VAR_1} // end {0 ,tileshape_invalid, tilematerial_invalid, VAR_1} // end
}; };
//set tile class string lookup table (e.g. for printing to user) //set tile class string lookup table (e.g. for printing to user)
@ -685,39 +685,37 @@ namespace DFHack
int value=0, matchv=0; int value=0, matchv=0;
const TileRow *source = &tileTypeTable[sourceTileType]; const TileRow *source = &tileTypeTable[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 == source->shape ) return sourceTileType;
//Cheap pseudo-entropy, by using address of the variable on the stack.
//Cheap pseudo-entropy, by using address of the variable on the stack. //No need for real random numbers.
//No need for real random numbers. static int entropy;
static int entropy; entropy += (int)( (void *)(&match) );
entropy += (int)( (void *)(&match) ); entropy ^= ((entropy & 0xFF000000)>>24) ^ ((entropy & 0x00FF0000)>>16);
entropy ^= ((entropy & 0xFF000000)>>24) ^ ((entropy & 0x00FF0000)>>16);
#ifdef assert #ifdef assert
assert( sourceTileType >=0 && sourceTileType < TILE_TYPE_ARRAY_LENGTH ); assert( sourceTileType >=0 && sourceTileType < TILE_TYPE_ARRAY_LENGTH );
#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) ){ if( WALL==tshape && (TILE_SMOOTH==source->special || CONSTRUCTED==source->material) ){
switch( source->material ){ switch( source->material ){
case CONSTRUCTED: match=495; break; case CONSTRUCTED: match=495; break;
case ICE: match= 83; break; case ICE: match= 83; break;
case VEIN: match= 82; break; case VEIN: match= 82; break;
case FEATSTONE: match= 81; break; case FEATSTONE: match= 81; break;
case OBSIDIAN: match= 80; break; case OBSIDIAN: match= 80; break;
case STONE: match= 79; break; case STONE: match= 79; break;
} }
if( match ) return match; if( match ) return match;
} }
//Run through until perfect match found or hit end.
//Run through until perfect match found or hit end.
for(int32_t tt=0;tt<TILE_TYPE_ARRAY_LENGTH && value<(8|4|1); ++tt) for(int32_t tt=0;tt<TILE_TYPE_ARRAY_LENGTH && value<(8|4|1); ++tt)
{ {
if( tshape == tileTypeTable[tt].shape ) if( tshape == tileTypeTable[tt].shape )
@ -728,9 +726,9 @@ namespace DFHack
//Special flag match is absolutely mandatory! //Special flag match is absolutely mandatory!
if( source->special != tileTypeTable[tt].special ) continue; 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( CONSTRUCTED == source->material && CONSTRUCTED != tileTypeTable[tt].material ) continue;
value=0; value=0;
//Material is high-value match //Material is high-value match
@ -749,39 +747,38 @@ namespace DFHack
} }
} }
//Post-processing for floors. //Post-processing for floors.
//Give raw floors variation. //Give raw floors variation.
//Variant matters, but does not matter for source. //Variant matters, but does not matter for source.
//Error on the side of caution. //Error on the side of caution.
if( FLOOR==tshape && CONSTRUCTED!=source->material && !source->special ) if( FLOOR==tshape && CONSTRUCTED!=source->material && !source->special )
{ {
//Trying to make a floor type with variants, so randomize the variant. //Trying to make a floor type with variants, so randomize the variant.
//Very picky, only handle known safe tile types. //Very picky, only handle known safe tile types.
//Some floors have 4 variants, some have 3, so the order of these matters. //Some floors have 4 variants, some have 3, so the order of these matters.
switch( match ){ switch( match ){
case 261: case 261:
//Furrowed soil got chosen by accident. Fix that. //Furrowed soil got chosen by accident. Fix that.
match=352+(3&entropy); match=352+(3&entropy);
break; break;
case 336: //STONE case 336: //STONE
case 340: //OBSIDIAN case 340: //OBSIDIAN
case 344: //featstone case 344: //featstone
case 349: //grass case 349: //grass
case 352: //soil case 352: //soil
case 356: //wet soil case 356: //wet soil
case 387: //dry grass case 387: //dry grass
case 394: //dead grass case 394: //dead grass
case 398: //grass B case 398: //grass B
case 441: //vein case 441: //vein
match += 3&entropy; match += 3&entropy;
break; break;
case 242: //ASHES case 242: //ASHES
case 258: //ICE case 258: //ICE
match += (1&entropy) + (2&entropy); match += (1&entropy) + (2&entropy);
break; break;
} }
} }
if( match ) return match; if( match ) return match;
return sourceTileType; return sourceTileType;
} }

@ -1,293 +0,0 @@
/*****************************************************************************
* getopt.c - competent and free getopt library.
* $Header: /cvsroot/freegetopt/freegetopt/getopt.c,v 1.2 2003/10/26 03:10:20 vindaci Exp $
*
* Copyright (c)2002-2003 Mark K. Kim
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the original author of this software nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <string>
#include <malloc.h>
#include <iostream>
class xgetopt
{
public:
xgetopt(std::vector<std::string> & params, const char* optstr_ )
{
allocd_argv = (char **) malloc((params.size() + 2) * sizeof(char*));
int index = 0;
allocd_argv[0] = strdup("foo");
while(index < params.size())
{
allocd_argv[index+1] = strdup( params[index].c_str() );
index++;
}
allocd_argv[index+1] = 0;
optarg = NULL;
optind = 0;
opterr = 1;
optopt = '?';
argv_index = 1;
argv_index2 = 1;
opt_offset = 1;
dashdash = 0;
nonopt = 0;
argc = index;
argv = allocd_argv;
optstr = optstr_;
prev_argv = argv;
prev_argc = argc;
}
xgetopt(int argc_, char** argv_, const char* optstr_)
{
allocd_argv = NULL;
optarg = NULL;
optind = 0;
opterr = 1;
optopt = '?';
argv_index = 1;
argv_index2 = 1;
opt_offset = 1;
dashdash = 0;
nonopt = 0;
argc = argc_;
argv = argv_;
optstr = optstr_;
prev_argv = argv;
prev_argc = argc;
}
~xgetopt()
{
if (allocd_argv)
{
int idx = 0;
while (char * tmp = allocd_argv[idx])
{
free(tmp);
}
free(allocd_argv);
}
}
int optind;
int opterr;
int optopt;
int operator()()
{
int c = 0;
/* Jump point in case we want to ignore the current argv_index */
getopt_top:
/* Misc. initializations */
optarg = NULL;
/* Dash-dash check */
if(argv[argv_index] && !strcmp(argv[argv_index], "--"))
{
dashdash = 1;
increment_index();
}
/* If we're at the end of argv, that's it. */
if(argv[argv_index] == NULL)
{
c = -1;
}
/* Are we looking at a string? Single dash is also a string */
else if(dashdash || argv[argv_index][0] != '-' || !strcmp(argv[argv_index], "-"))
{
/* If we want a string... */
if(optstr[0] == '-')
{
c = 1;
optarg = argv[argv_index];
increment_index();
}
/* If we really don't want it (we're in POSIX mode), we're done */
else if(optstr[0] == '+' || getenv("POSIXLY_CORRECT"))
{
c = -1;
/* Everything else is a non-opt argument */
nonopt = argc - argv_index;
}
/* If we mildly don't want it, then move it back */
else
{
if(!permute_argv_once()) goto getopt_top;
else c = -1;
}
}
/* Otherwise we're looking at an option */
else
{
const char* opt_ptr = NULL;
/* Grab the option */
c = argv[argv_index][opt_offset++];
/* Is the option in the optstr? */
if(optstr[0] == '-') opt_ptr = strchr(optstr+1, c);
else opt_ptr = strchr(optstr, c);
/* Invalid argument */
if(!opt_ptr)
{
if(opterr)
{
fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
}
optopt = c;
c = '?';
/* Move onto the next option */
increment_index();
}
/* Option takes argument */
else if(opt_ptr[1] == ':')
{
/* ie, -oARGUMENT, -xxxoARGUMENT, etc. */
if(argv[argv_index][opt_offset] != '\0')
{
optarg = &argv[argv_index][opt_offset];
increment_index();
}
/* ie, -o ARGUMENT (only if it's a required argument) */
else if(opt_ptr[2] != ':')
{
/* One of those "you're not expected to understand this" moment */
if(argv_index2 < argv_index) argv_index2 = argv_index;
while(argv[++argv_index2] && argv[argv_index2][0] == '-');
optarg = argv[argv_index2];
/* Don't cross into the non-option argument list */
if(argv_index2 + nonopt >= prev_argc) optarg = NULL;
/* Move onto the next option */
increment_index();
}
else
{
/* Move onto the next option */
increment_index();
}
/* In case we got no argument for an option with required argument */
if(optarg == NULL && opt_ptr[2] != ':')
{
optopt = c;
c = '?';
if(opterr)
{
fprintf(stderr,"%s: option requires an argument -- %c\n",
argv[0], optopt);
}
}
}
/* Option does not take argument */
else
{
/* Next argv_index */
if(argv[argv_index][opt_offset] == '\0')
{
increment_index();
}
}
}
/* Calculate optind */
if(c == -1)
{
optind = argc - nonopt;
}
else
{
optind = argv_index;
}
return c;
}
private:
char** prev_argv; /* Keep a copy of argv and argc to */
int prev_argc; /* tell if getopt params change */
int argv_index; /* Option we're checking */
int argv_index2; /* Option argument we're checking */
int opt_offset; /* Index into compounded "-option" */
int dashdash; /* True if "--" option reached */
int nonopt; /* How many nonopts we've found */
int argc;
char ** argv;
const char * optstr;
char* optarg;
char** allocd_argv;
void increment_index()
{
/* Move onto the next option */
if(argv_index < argv_index2)
{
while(prev_argv[++argv_index] && prev_argv[argv_index][0] != '-'
&& argv_index < argv_index2+1);
}
else argv_index++;
opt_offset = 1;
}
/*
* Permutes argv[] so that the argument currently being processed is moved
* to the end.
*/
int permute_argv_once()
{
/* Movability check */
if(argv_index + nonopt >= prev_argc) return 1;
/* Move the current option to the end, bring the others to front */
else
{
char* tmp = prev_argv[argv_index];
/* Move the data */
memmove(&prev_argv[argv_index], &prev_argv[argv_index+1],
sizeof(char**) * (prev_argc - argv_index - 1));
prev_argv[prev_argc - 1] = tmp;
nonopt++;
return 0;
}
}
};

@ -38,7 +38,7 @@ namespace DFHack
{ {
class VersionInfo; class VersionInfo;
class Process; class Process;
class Window; //class Window;
class DFVector; class DFVector;
class VersionInfoFactory; class VersionInfoFactory;
class PlatformSpecific; class PlatformSpecific;

@ -390,12 +390,13 @@ namespace DFHack
int32_t findTileType( const TileShape tshape, const TileMaterial tmat, const TileVariant tvar, const TileSpecial tspecial, const TileDirection tdir ) int32_t findTileType( const TileShape tshape, const TileMaterial tmat, const TileVariant tvar, const TileSpecial tspecial, const TileDirection tdir )
{ {
int32_t tt; int32_t tt;
for(tt=0;tt<TILE_TYPE_ARRAY_LENGTH; ++tt){ for(tt=0;tt<TILE_TYPE_ARRAY_LENGTH; ++tt)
if( tshape>-1 ) if( tshape != tileTypeTable[tt].shape ) continue; {
if( tmat>-1 ) if( tmat != tileTypeTable[tt].material ) continue; if( tshape>-1 && tshape != tileTypeTable[tt].shape ) continue;
if( tvar>-1 ) if( tvar != tileTypeTable[tt].variant ) continue; if( tmat>-1 && tmat != tileTypeTable[tt].material ) continue;
if( tspecial>-1 ) if( tspecial != tileTypeTable[tt].special ) continue; if( tvar>-1 && tvar != tileTypeTable[tt].variant ) continue;
if( tdir.whole ) if( tdir.whole != tileTypeTable[tt].direction.whole ) continue; if( tspecial>-1 && tspecial != tileTypeTable[tt].special ) continue;
if( tdir.whole && tdir.whole != tileTypeTable[tt].direction.whole ) continue;
//Match! //Match!
return tt; return tt;
} }

@ -21,7 +21,6 @@ using namespace std;
#include <dfhack/modules/Materials.h> #include <dfhack/modules/Materials.h>
#include <dfhack/extra/MapExtras.h> #include <dfhack/extra/MapExtras.h>
#include <dfhack/MiscUtils.h> #include <dfhack/MiscUtils.h>
#include <xgetopt.h>
using std::vector; using std::vector;
using std::string; using std::string;

@ -1 +1 @@
Subproject commit b274d22da0613f38188209efae065603cb442b41 Subproject commit 71d28909ec397d0a772e6135a822cc1c4a5fd3a7

@ -1,437 +0,0 @@
// Produces a list of materials available on the map.
// Options:
// -a : show unrevealed tiles
// -p : don't show plants
// -s : don't show slade
// -t : don't show demon temple
//#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;
#include <DFHack.h>
#include <dfhack/extra/MapExtras.h>
#include <xgetopt.h>
#include <dfhack/extra/termutil.h>
typedef std::map<int16_t, unsigned int> MatMap;
typedef std::map<int16_t, int> LevelMap;
typedef std::vector< pair<int16_t, unsigned int> > MatSorter;
typedef std::vector<DFHack::t_feature> FeatureList;
typedef std::vector<DFHack::t_feature*> FeatureListPointer;
typedef std::map<DFHack::DFCoord, FeatureListPointer> FeatureMap;
typedef std::vector<DFHack::dfh_plant> PlantList;
bool parseOptions(int argc, char **argv, bool &showHidden, bool &showPlants,
bool &showSlade, bool &showTemple, bool &showLevels)
{
char c;
xgetopt opt(argc, argv, "apstz");
opt.opterr = 0;
while ((c = opt()) != -1)
{
switch (c)
{
case 'a':
showHidden = true;
break;
case 'p':
showPlants = false;
break;
case 's':
showSlade = false;
break;
case 't':
showTemple = false;
break;
case 'z':
showLevels = true;
break;
case '?':
switch (opt.optopt)
{
// For when we take arguments
default:
if (isprint(opt.optopt))
std::cerr << "Unknown option -" << opt.optopt << "!"
<< std::endl;
else
std::cerr << "Unknown option character " << (int) opt.optopt << "!"
<< std::endl;
}
default:
// Um.....
return false;
}
}
return true;
}
template<template <typename> class P = std::greater >
struct compare_pair_second
{
template<class T1, class T2>
bool operator()(const std::pair<T1, T2>& left, const std::pair<T1, T2>& right)
{
return P<T2>()(left.second, right.second);
}
};
inline void countMat(MatMap &mat, LevelMap &low, LevelMap &high, int16_t id, int z)
{
mat[id]++;
if (!low.count(id))
low[id] = z;
high[id] = z;
}
void printLevels(LevelMap &low, LevelMap &high, int16_t id, int z_base)
{
int lowv = low[id];
int highv = high[id];
std::cout << " (" << (z_base+low[id]) << ".." << (z_base+high[id]) << ")";
}
void printMats(MatMap &mat, std::vector<DFHack::t_matgloss> &materials, bool showLevels, LevelMap &low, LevelMap &high, int z_base)
{
unsigned int total = 0;
MatSorter sorting_vector;
for (MatMap::const_iterator it = mat.begin(); it != mat.end(); ++it)
{
sorting_vector.push_back(*it);
}
std::sort(sorting_vector.begin(), sorting_vector.end(), compare_pair_second<>());
for (MatSorter::const_iterator it = sorting_vector.begin(); it != sorting_vector.end(); ++it)
{
if(it->first >= materials.size())
{
cerr << "Bad index: " << it->first << " out of " << materials.size() << endl;
continue;
}
DFHack::t_matgloss mat = materials[it->first];
std::cout << std::setw(25) << mat.id << " : " << it->second;
if (showLevels)
printLevels(low, high, it->first, z_base);
std::cout << std::endl;
total += it->second;
}
std::cout << ">>> TOTAL = " << total << std::endl << std::endl;
}
int main(int argc, char *argv[])
{
bool temporary_terminal = TemporaryTerminal();
bool showHidden = false;
bool showPlants = true;
bool showSlade = true;
bool showTemple = true;
bool showLevels = false;
if (!parseOptions(argc, argv, showHidden, showPlants, showSlade, showTemple, showLevels))
{
return -1;
}
uint32_t x_max = 0, y_max = 0, z_max = 0;
int32_t x_base = 0, y_base = 0, z_base = 0;
DFHack::ContextManager manager("Memory.xml");
DFHack::Context *context = manager.getSingleContext();
if (!context->Attach())
{
std::cerr << "Unable to attach to DF!" << std::endl;
if(temporary_terminal)
std::cin.ignore();
return 1;
}
DFHack::Maps *maps = context->getMaps();
if (!maps->Start())
{
std::cerr << "Cannot get map info!" << std::endl;
context->Detach();
if(temporary_terminal)
std::cin.ignore();
return 1;
}
maps->getSize(x_max, y_max, z_max);
maps->getPosition(x_base, y_base, z_base);
MapExtras::MapCache map(maps);
DFHack::Materials *mats = context->getMaterials();
if (!mats->ReadInorganicMaterials())
{
std::cerr << "Unable to read inorganic material definitons!" << std::endl;
context->Detach();
if(temporary_terminal)
std::cin.ignore();
return 1;
}
if (showPlants && !mats->ReadOrganicMaterials())
{
std::cerr << "Unable to read organic material definitons; plants won't be listed!" << std::endl;
showPlants = false;
}
FeatureList globalFeatures;
FeatureMap localFeatures;
DFHack::t_feature *blockFeatureGlobal = 0;
DFHack::t_feature *blockFeatureLocal = 0;
bool hasAquifer = false;
bool hasDemonTemple = false;
bool hasLair = false;
int topMagmaLevel = -1;
MatMap baseMats;
LevelMap baseMatLow, baseMatHigh;
MatMap layerMats;
LevelMap layerMatLow, layerMatHigh;
MatMap veinMats;
LevelMap veinMatLow, veinMatHigh;
MatMap plantMats;
MatMap treeMats;
LevelMap plantMatLow, plantMatHigh;
if (!(showSlade && maps->ReadGlobalFeatures(globalFeatures)))
{
std::cerr << "Unable to read global features; slade won't be listed!" << std::endl;
}
if (!maps->ReadLocalFeatures(localFeatures))
{
std::cerr << "Unable to read local features; adamantine "
<< (showTemple ? "and demon temples " : "")
<< "won't be listed!" << std::endl;
}
uint32_t vegCount = 0;
DFHack::Vegetation *veg = context->getVegetation();
if (showPlants && !veg->Start(vegCount))
{
std::cerr << "Unable to read vegetation; plants won't be listed!" << std::endl;
}
for(uint32_t z = 0; z < z_max; z++)
{
for(uint32_t b_y = 0; b_y < y_max; b_y++)
{
for(uint32_t b_x = 0; b_x < x_max; b_x++)
{
// Get the map block
DFHack::DFCoord blockCoord(b_x, b_y);
MapExtras::Block *b = map.BlockAt(DFHack::DFCoord(b_x, b_y, z));
if (!b || !b->valid)
{
continue;
}
{ // Find features
uint16_t index = b->raw.global_feature;
if (index != -1 && index < globalFeatures.size())
{
blockFeatureGlobal = &globalFeatures[index];
}
index = b->raw.local_feature;
FeatureMap::const_iterator it = localFeatures.find(blockCoord);
if (it != localFeatures.end())
{
FeatureListPointer features = it->second;
if (index != -1 && index < features.size())
{
blockFeatureLocal = features[index];
}
}
}
// Iterate over all the tiles in the block
for(uint32_t y = 0; y < 16; y++)
{
for(uint32_t x = 0; x < 16; x++)
{
DFHack::DFCoord coord(x, y);
DFHack::t_designation des = b->DesignationAt(coord);
DFHack::t_occupancy occ = b->OccupancyAt(coord);
// Skip hidden tiles
if (!showHidden && des.bits.hidden)
{
continue;
}
// Check for aquifer
if (des.bits.water_table)
{
hasAquifer = true;
}
// Check for lairs
if (occ.bits.monster_lair)
{
hasLair = true;
}
// Remember magma
if (des.bits.flow_size && des.bits.liquid_type == 1)
{
topMagmaLevel = z;
}
uint16_t type = b->TileTypeAt(coord);
const DFHack::TileRow *info = DFHack::getTileRow(type);
if (!info)
{
std::cerr << "Bad type: " << type << std::endl;
continue;
}
// We only care about these types
switch (info->shape)
{
case DFHack::WALL:
case DFHack::PILLAR:
case DFHack::FORTIFICATION:
break;
default:
continue;
}
// Count the material type
countMat(baseMats, baseMatLow, baseMatHigh, info->material, z);
// Find the type of the tile
switch (info->material)
{
case DFHack::SOIL:
case DFHack::STONE:
countMat(layerMats, layerMatLow, layerMatHigh, b->baseMaterialAt(coord), z);
break;
case DFHack::VEIN:
countMat(veinMats, veinMatLow, veinMatHigh, b->veinMaterialAt(coord), z);
break;
case DFHack::FEATSTONE:
if (blockFeatureLocal && des.bits.feature_local)
{
if (blockFeatureLocal->type == DFHack::feature_Adamantine_Tube
&& blockFeatureLocal->main_material == 0) // stone
{
countMat(veinMats, veinMatLow, veinMatHigh, blockFeatureLocal->sub_material, z);
}
else if (showTemple
&& blockFeatureLocal->type == DFHack::feature_Hell_Temple)
{
hasDemonTemple = true;
}
}
if (showSlade && blockFeatureGlobal && des.bits.feature_global
&& blockFeatureGlobal->type == DFHack::feature_Underworld
&& blockFeatureGlobal->main_material == 0) // stone
{
countMat(layerMats, layerMatLow, layerMatHigh, blockFeatureGlobal->sub_material, z);
}
break;
case DFHack::OBSIDIAN:
// TODO ?
break;
}
}
}
// Check plants this way, as the other way wasn't getting them all
// and we can check visibility more easily here
if (showPlants)
{
PlantList plants;
if (maps->ReadVegetation(b_x, b_y, z, &plants))
{
for (PlantList::const_iterator it = plants.begin(); it != plants.end(); it++)
{
const DFHack::t_plant & plant = (*it).sdata;
DFHack::DFCoord loc(plant.x, plant.y);
loc = loc % 16;
if (showHidden || !b->DesignationAt(loc).bits.hidden)
{
MatMap &mmap = (plant.is_shrub ? plantMats : treeMats);
countMat(mmap, plantMatLow, plantMatHigh, plant.material, z);
}
}
}
}
// Block end
} // block x
// Clean uneeded memory
map.trash();
} // block y
} // z
MatMap::const_iterator it;
std::cout << "Base materials:" << std::endl;
for (it = baseMats.begin(); it != baseMats.end(); ++it)
{
std::cout << std::setw(25) << DFHack::TileMaterialString[it->first] << " : " << it->second;
if (showLevels)
printLevels(baseMatLow, baseMatHigh, it->first, z_base);
std::cout << std::endl;
}
std::cout << std::endl << "Layer materials:" << std::endl;
printMats(layerMats, mats->inorganic, showLevels, layerMatLow, layerMatHigh, z_base);
std::cout << "Vein materials:" << std::endl;
printMats(veinMats, mats->inorganic, showLevels, veinMatLow, veinMatHigh, z_base);
if (showPlants)
{
std::cout << "Shrubs:" << std::endl;
printMats(plantMats, mats->organic, showLevels, plantMatLow, plantMatHigh, z_base);
std::cout << "Wood in trees:" << std::endl;
printMats(treeMats, mats->organic, showLevels, plantMatLow, plantMatHigh, z_base);
}
if (showLevels && topMagmaLevel >= 0)
{
std::cout << "Topmost magma z-level: " << (z_base + topMagmaLevel) << std::endl;
}
if (hasAquifer)
{
std::cout << "Has aquifer" << std::endl;
}
if (hasDemonTemple)
{
std::cout << "Has demon temple" << std::endl;
}
if (hasLair)
{
std::cout << "Has lair" << std::endl;
}
// Cleanup
if (showPlants)
{
veg->Finish();
}
mats->Finish();
maps->Finish();
context->Detach();
if(temporary_terminal)
{
std::cout << " Press any key to finish.";
std::cin.ignore();
}
std::cout << std::endl;
return 0;
}