Finish conversion, fix compile errors

develop
Quietust 2012-02-13 19:17:38 -06:00
parent d0a8c2edd8
commit d15d38d536
8 changed files with 126 additions and 132 deletions

@ -144,90 +144,90 @@ namespace DFHack
using namespace df::enums;
// tile is missing a floor
inline
bool LowPassable(df::tiletype tiletype)
const char * tileName(df::tiletype tiletype)
{
return tiletype_shape::get_passable_low(tiletype::get_shape(tiletype));
return ENUM_ATTR(tiletype, caption, tiletype);
}
// tile is missing a roof
inline
bool HighPassable(df::tiletype tiletype)
df::tiletype_shape tileShape(df::tiletype tiletype)
{
return tiletype_shape::get_passable_flow(tiletype::get_shape(tiletype));
return ENUM_ATTR(tiletype, shape, tiletype);
}
inline
bool FlowPassable(df::tiletype tiletype)
df::tiletype_special tileSpecial(df::tiletype tiletype)
{
return tiletype_shape::get_passable_high(tiletype::get_shape(tiletype));
return ENUM_ATTR(tiletype, special, tiletype);
}
inline
bool isWallTerrain(df::tiletype tiletype)
df::tiletype_variant tileVariant(df::tiletype tiletype)
{
return tiletype_shape::get_basic_shape(tiletype::get_shape(tiletype)) == tiletype_shape_basic::Wall;
return ENUM_ATTR(tiletype, variant, tiletype);
}
inline
bool isFloorTerrain(df::tiletype tiletype)
df::tiletype_material tileMaterial(df::tiletype tiletype)
{
return tiletype_shape::get_basic_shape(tiletype::get_shape(tiletype)) == tiletype_shape_basic::Floor;
return ENUM_ATTR(tiletype, material, tiletype);
}
inline
bool isRampTerrain(df::tiletype tiletype)
TileDirection tileDirection(df::tiletype tiletype)
{
return tiletype_shape::get_basic_shape(tiletype::get_shape(tiletype)) == tiletype_shape_basic::Ramp;
return TileDirection(ENUM_ATTR(tiletype, direction, tiletype));
}
// tile is missing a floor
inline
bool isOpenTerrain(df::tiletype tiletype)
bool LowPassable(df::tiletype tiletype)
{
return tiletype_shape::get_basic_shape(tiletype::get_shape(tiletype)) == tiletype_shape_basic::Open;
return ENUM_ATTR(tiletype_shape, passable_low, tileShape(tiletype));
}
// tile is missing a roof
inline
bool isStairTerrain(df::tiletype tiletype)
bool HighPassable(df::tiletype tiletype)
{
return tiletype_shape::get_basic_shape(tiletype::get_shape(tiletype)) == tiletype_shape_basic::Stair;
return ENUM_ATTR(tiletype_shape, passable_high, tileShape(tiletype));
}
inline
const char * tileName(df::tiletype tiletype)
bool FlowPassable(df::tiletype tiletype)
{
return tiletype::get_caption(tiletype);
return ENUM_ATTR(tiletype_shape, passable_flow, tileShape(tiletype));
}
inline
df::tiletype_shape tileShape(df::tiletype tiletype)
bool isWallTerrain(df::tiletype tiletype)
{
return tiletype::get_shape(tiletype);
return ENUM_ATTR(tiletype_shape, basic_shape, tileShape(tiletype)) == tiletype_shape_basic::Wall;
}
inline
df::tiletype_special tileSpecial(df::tiletype tiletype)
bool isFloorTerrain(df::tiletype tiletype)
{
return tiletype::get_special(tiletype);
return ENUM_ATTR(tiletype_shape, basic_shape, tileShape(tiletype)) == tiletype_shape_basic::Floor;
}
inline
df::tiletype_variant tileVariant(df::tiletype tiletype)
bool isRampTerrain(df::tiletype tiletype)
{
return tiletype::get_variant(tiletype);
return ENUM_ATTR(tiletype_shape, basic_shape, tileShape(tiletype)) == tiletype_shape_basic::Ramp;
}
inline
df::tiletype_material tileMaterial(df::tiletype tiletype)
bool isOpenTerrain(df::tiletype tiletype)
{
return tiletype::get_material(tiletype);
return ENUM_ATTR(tiletype_shape, basic_shape, tileShape(tiletype)) == tiletype_shape_basic::Open;
}
inline
TileDirection tileDirection(df::tiletype tiletype)
bool isStairTerrain(df::tiletype tiletype)
{
return TileDirection(tiletype::get_direction(tiletype));
return ENUM_ATTR(tiletype_shape, basic_shape, tileShape(tiletype)) == tiletype_shape_basic::Stair;
}
/**

@ -215,26 +215,26 @@ DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & pa
switch (tileMaterial(type))
{
case DFHack::SOIL:
case DFHack::STONE:
case tiletype_material::SOIL:
case tiletype_material::STONE:
prototile->set_material_index(0);
prototile->set_material(b->baseMaterialAt(coord));
break;
case DFHack::VEIN:
case tiletype_material::MINERAL:
prototile->set_material_index(0);
prototile->set_material(b->veinMaterialAt(coord));
break;
case DFHack::FEATSTONE:
case tiletype_material::FEATURE:
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
{
prototile->set_material_index(0);
prototile->set_material(blockFeatureLocal.sub_material);
}
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
{
prototile->set_material_index(0);
@ -242,7 +242,7 @@ DFhackCExport command_result mapexport (Core * c, std::vector <std::string> & pa
}
}
break;
case DFHack::CONSTRUCTED:
case tiletype_material::CONSTRUCTION:
if (constructionMaterials.find(map_pos) != constructionMaterials.end())
{
prototile->set_material_index(constructionMaterials[map_pos].first);

@ -172,14 +172,15 @@ DFhackCExport command_result df_probe (Core * c, vector <string> & parameters)
df::tiletype_shape shape = tileShape(tiletype);
df::tiletype_material material = tileMaterial(tiletype);
df::tiletype_special special = tileSpecial(tiletype);
df::tiletype_variant variant = tileVariant(tiletype);
con.print("%-10s: %4d %s\n","Class" ,shape,
tiletype_shape::get_key(shape));
ENUM_KEY_STR(tiletype_shape, shape));
con.print("%-10s: %4d %s\n","Material" ,
material, tiletype_material::get_key(material));
material, ENUM_KEY_STR(tiletype_material, material));
con.print("%-10s: %4d %s\n","Special" ,
special, tiletype_special::get_key(special));
con.print("%-10s: %4d\n" ,"Variant" ,
tileVariant(tiletype));
special, ENUM_KEY_STR(tiletype_special, special));
con.print("%-10s: %4d %s\n" ,"Variant" ,
variant, ENUM_KEY_STR(tiletype_variant, variant));
con.print("%-10s: %s\n" ,"Direction",
tileDirection(tiletype).getStr());
con.print("\n");

@ -572,7 +572,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
con << "Base materials:" << std::endl;
for (it = baseMats.begin(); it != baseMats.end(); ++it)
{
con << std::setw(25) << tiletype_material::get_key((df::tiletype_material)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)

@ -32,28 +32,16 @@ DFhackCExport command_result df_regrass (Core * c, vector <string> & parameters)
{
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;
if (DFHack::tileMaterial(cur->tiletype[x][y]) != DFHack::SOIL)
if (tileMaterial(cur->tiletype[x][y]) != tiletype_material::SOIL)
continue;
if (cur->designation[x][y].bits.subterranean)
continue;
if (cur->occupancy[x][y].bits.building)
continue;
switch (rand() % 8)
{
// 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;
}
cur->tiletype[x][y] = findRandomVariant((rand() & 1) ? tiletype::GrassLightFloor1 : tiletype::GrassDarkFloor1);
count++;
}
}

@ -338,7 +338,7 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string>
}
DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
MapCache * MCache = new MapCache;
int16_t tt = MCache->tiletypeAt(xy);
df::tiletype tt = MCache->tiletypeAt(xy);
if(isWallTerrain(tt))
{
c->con.printerr("Point the cursor at some empty space you want to be unhidden.\n");
@ -372,62 +372,50 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string>
if(!MCache->testCoord(current))
continue;
int16_t tt = MCache->tiletypeAt(current);
df::tiletype tt = MCache->tiletypeAt(current);
df::tile_designation des = MCache->designationAt(current);
if(!des.bits.hidden)
{
continue;
}
const TileRow * r = getTileRow(tt);
/*
if(!r)
{
cerr << "unknown tiletype! " << dec << tt << endl;
continue;
}
*/
bool below = 0;
bool above = 0;
bool sides = 0;
bool unhide = 1;
// by tile shape, determine behavior and action
switch (r->shape)
switch (tileShape(tt))
{
// walls:
case WALL:
case PILLAR:
if(from_below)
unhide = 0;
break;
// air/free space
case EMPTY:
case RAMP_TOP:
case STAIR_UPDOWN:
case STAIR_DOWN:
case BROOK_TOP:
above = below = sides = true;
break;
// has floor
case FORTIFICATION:
case STAIR_UP:
case RAMP:
case FLOOR:
case TREE_DEAD:
case TREE_OK:
case SAPLING_DEAD:
case SAPLING_OK:
case SHRUB_DEAD:
case SHRUB_OK:
case BOULDER:
case PEBBLES:
case BROOK_BED:
case RIVER_BED:
case ENDLESS_PIT:
case POOL:
if(from_below)
unhide = 0;
above = sides = true;
break;
// walls:
case tiletype_shape::WALL:
if(from_below)
unhide = 0;
break;
// air/free space
case tiletype_shape::EMPTY:
case tiletype_shape::RAMP_TOP:
case tiletype_shape::STAIR_UPDOWN:
case tiletype_shape::STAIR_DOWN:
case tiletype_shape::BROOK_TOP:
above = below = sides = true;
break;
// has floor
case tiletype_shape::FORTIFICATION:
case tiletype_shape::STAIR_UP:
case tiletype_shape::RAMP:
case tiletype_shape::FLOOR:
case tiletype_shape::TREE:
case tiletype_shape::SAPLING:
case tiletype_shape::SHRUB:
case tiletype_shape::BOULDER:
case tiletype_shape::PEBBLES:
case tiletype_shape::BROOK_BED:
case tiletype_shape::RIVER_BED:
case tiletype_shape::ENDLESS_PIT:
case tiletype_shape::POOL:
if(from_below)
unhide = 0;
above = sides = true;
break;
}
if(unhide)
{

@ -99,7 +99,7 @@ std::ostream &operator<<(std::ostream &stream, const TileType &paint)
if (paint.special >= 0)
{
stream << DFHack::TileSpecialString[paint.special];
stream << ENUM_KEY_STR(tiletype_special,paint.special);
used = true;
needSpace = true;
}
@ -112,7 +112,7 @@ std::ostream &operator<<(std::ostream &stream, const TileType &paint)
needSpace = false;
}
stream << DFHack::TileMaterialString[paint.material];
stream << ENUM_KEY_STR(tiletype_material,paint.material);
used = true;
needSpace = true;
}
@ -125,7 +125,7 @@ std::ostream &operator<<(std::ostream &stream, const TileType &paint)
needSpace = false;
}
stream << DFHack::TileShapeString[paint.shape];
stream << ENUM_KEY_STR(tiletype_shape,paint.shape);
used = true;
needSpace = true;
}
@ -138,7 +138,7 @@ std::ostream &operator<<(std::ostream &stream, const TileType &paint)
needSpace = false;
}
stream << "VAR_" << (paint.variant + 1);
stream << ENUM_KEY_STR(tiletype_variant,paint.variant);
used = 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 (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;
}
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;
break;
}
@ -267,7 +267,7 @@ bool processTileType(TileType &paint, const std::string &option, const std::stri
{
FOR_ENUM_ITEMS(tiletype_material, i)
{
if (val == tiletype_material::get_key(i))
if (val == ENUM_KEY_STR(tiletype_material,i))
{
paint.material = i;
found = true;
@ -283,18 +283,18 @@ bool processTileType(TileType &paint, const std::string &option, const std::stri
}
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;
}
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;
break;
}
@ -308,14 +308,27 @@ bool processTileType(TileType &paint, const std::string &option, const std::stri
}
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;
}
else
{
std::cout << "Unknown tile variant: " << value << std::endl;
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;
}
}
}
else if (option == "designated" || option == "d")
@ -415,33 +428,37 @@ void help( std::ostream & out, const std::string &option)
{
out << "Available shapes:" << 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")
{
out << "Available materials:" << 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")
{
out << "Available specials:" << 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")
{
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")
{
@ -601,8 +618,8 @@ public:
bool juststarted = true;
while (mc.testCoord(start))
{
uint16_t tt = mc.tiletypeAt(start);
if(DFHack::LowPassable(tt) || juststarted && DFHack::HighPassable(tt))
df::tiletype tt = mc.tiletypeAt(start);
if(LowPassable(tt) || juststarted && HighPassable(tt))
{
v.push_back(start);
juststarted = false;

@ -102,7 +102,7 @@ bool dig (MapExtras::MapCache & MCache,
{
do
{
df::tiletype_shape_basic tsb = tiletype_shape::get_basic_shape(ts);
df::tiletype_shape_basic tsb = ENUM_ATTR(tiletype_shape, basic_shape, ts);
if(tsb == tiletype_shape_basic::Wall)
{
std::cerr << "allowing tt" << (int)tt << ", is wall\n";