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; using namespace df::enums;
// tile is missing a floor
inline 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 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 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 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 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 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 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 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 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 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 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 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 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 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)) switch (tileMaterial(type))
{ {
case DFHack::SOIL: case tiletype_material::SOIL:
case DFHack::STONE: case tiletype_material::STONE:
prototile->set_material_index(0); prototile->set_material_index(0);
prototile->set_material(b->baseMaterialAt(coord)); prototile->set_material(b->baseMaterialAt(coord));
break; break;
case DFHack::VEIN: case tiletype_material::MINERAL:
prototile->set_material_index(0); prototile->set_material_index(0);
prototile->set_material(b->veinMaterialAt(coord)); prototile->set_material(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_index(0); prototile->set_material_index(0);
prototile->set_material(blockFeatureLocal.sub_material); prototile->set_material(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_index(0); prototile->set_material_index(0);
@ -242,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);

@ -172,14 +172,15 @@ DFhackCExport command_result df_probe (Core * c, vector <string> & parameters)
df::tiletype_shape shape = tileShape(tiletype); df::tiletype_shape shape = tileShape(tiletype);
df::tiletype_material material = tileMaterial(tiletype); df::tiletype_material material = tileMaterial(tiletype);
df::tiletype_special 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,
tiletype_shape::get_key(shape)); ENUM_KEY_STR(tiletype_shape, shape));
con.print("%-10s: %4d %s\n","Material" , 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" , con.print("%-10s: %4d %s\n","Special" ,
special, tiletype_special::get_key(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");

@ -572,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) << 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) 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++) 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++;
} }
} }

@ -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;

@ -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;
} }
@ -267,7 +267,7 @@ bool processTileType(TileType &paint, const std::string &option, const std::stri
{ {
FOR_ENUM_ITEMS(tiletype_material, i) FOR_ENUM_ITEMS(tiletype_material, i)
{ {
if (val == tiletype_material::get_key(i)) if (val == ENUM_KEY_STR(tiletype_material,i))
{ {
paint.material = i; paint.material = i;
found = true; found = true;
@ -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;

@ -102,7 +102,7 @@ bool dig (MapExtras::MapCache & MCache,
{ {
do 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) if(tsb == tiletype_shape_basic::Wall)
{ {
std::cerr << "allowing tt" << (int)tt << ", is wall\n"; std::cerr << "allowing tt" << (int)tt << ", is wall\n";