Skip to content

Commit

Permalink
Finish conversion, fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
quietust committed Feb 14, 2012
1 parent d0a8c2e commit d15d38d
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 132 deletions.
60 changes: 30 additions & 30 deletions library/include/TileTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
14 changes: 7 additions & 7 deletions plugins/mapexport/mapexport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,34 +215,34 @@ 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);
prototile->set_material(blockFeatureGlobal.sub_material);
}
}
break;
case DFHack::CONSTRUCTED:
case tiletype_material::CONSTRUCTION:
if (constructionMaterials.find(map_pos) != constructionMaterials.end())
{
prototile->set_material_index(constructionMaterials[map_pos].first);
Expand Down
11 changes: 6 additions & 5 deletions plugins/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion plugins/prospector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 3 additions & 15 deletions plugins/regrass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
}
Expand Down
80 changes: 34 additions & 46 deletions plugins/reveal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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)
{
Expand Down
Loading

0 comments on commit d15d38d

Please sign in to comment.