Strictify the terrain trim enum

This commit is contained in:
2014-12-01 20:04:30 -05:00
parent d900c7edef
commit e86362d294
9 changed files with 56 additions and 55 deletions

View File

@@ -937,7 +937,7 @@ void draw_terrain(short mode)
eTrimType trim = scenario.ter_types[spec_terrain].trim_type;
// Finally, draw this terrain spot
if(trim == TRIM_WALKWAY){
if(trim == eTrimType::WALKWAY){
int trim = -1;
unsigned char ground_t = scenario.ter_types[spec_terrain].trim_ter;
ter_num_t ground_ter = get_ter_from_ground(ground_t);
@@ -970,10 +970,10 @@ void draw_terrain(short mode)
draw_one_terrain_spot(q,r,trim < 0 ? spec_terrain : ground_ter);
if(trim >= 0)
draw_trim(q,r,trim + 50,spec_terrain);
}else if(trim == TRIM_ROAD || trim == TRIM_N || trim == TRIM_S ||
trim == TRIM_W || trim == TRIM_E) {
}else if(trim == eTrimType::ROAD || trim == eTrimType::N || trim == eTrimType::S ||
trim == eTrimType::W || trim == eTrimType::E) {
draw_one_terrain_spot(q,r,spec_terrain);
place_road(q,r,where_draw,trim == TRIM_ROAD);
place_road(q,r,where_draw,trim == eTrimType::ROAD);
}else if(spec_terrain == 65535) {
draw_one_terrain_spot(q,r,-1);
}else{
@@ -1285,11 +1285,11 @@ bool extend_road_terrain(ter_num_t ter)
eTrimType trim = scenario.ter_types[ter].trim_type;
eTerSpec spec = scenario.ter_types[ter].special;
ter_num_t flag = scenario.ter_types[ter].flag1.u;
if(trim == TRIM_ROAD || trim == TRIM_CITY || trim == TRIM_WALKWAY)
if(trim == eTrimType::ROAD || trim == eTrimType::CITY || trim == eTrimType::WALKWAY)
return true;
if(spec == TER_SPEC_BRIDGE)
return true;
if(spec == TER_SPEC_TOWN_ENTRANCE && trim != TRIM_NONE)
if(spec == TER_SPEC_TOWN_ENTRANCE && trim != eTrimType::NONE)
return true; // cave entrance, most likely
if(spec == TER_SPEC_UNLOCKABLE || spec == TER_SPEC_CHANGE_WHEN_STEP_ON)
return true; // closed door, possibly locked; or closed portcullis
@@ -1310,27 +1310,27 @@ static bool superextend_road_terrain(int x, int y) {
// Connect road to trim?
ter_num_t ter = coord_to_ter(x,y);
eTrimType trim = scenario.ter_types[ter].trim_type;
if(trim == TRIM_N || trim == TRIM_S) {
if(trim == eTrimType::N || trim == eTrimType::S) {
ter_num_t up = coord_to_ter(x,y-1);
ter_num_t down = coord_to_ter(x,y+1);
eTrimType trimUp = scenario.ter_types[up].trim_type;
eTrimType trimDn = scenario.ter_types[down].trim_type;
if((trimUp == TRIM_ROAD || trimUp == TRIM_CITY) && (trimDn == TRIM_ROAD || trimDn == TRIM_CITY))
if((trimUp == eTrimType::ROAD || trimUp == eTrimType::CITY) && (trimDn == eTrimType::ROAD || trimDn == eTrimType::CITY))
return can_build_roads_on(ter);
if((trimUp == TRIM_ROAD || trimUp == TRIM_CITY) && trim == TRIM_N && trimDn == TRIM_S)
if((trimUp == eTrimType::ROAD || trimUp == eTrimType::CITY) && trim == eTrimType::N && trimDn == eTrimType::S)
return can_build_roads_on(ter);
if((trimDn == TRIM_ROAD || trimDn == TRIM_CITY) && trim == TRIM_S && trimUp == TRIM_N)
if((trimDn == eTrimType::ROAD || trimDn == eTrimType::CITY) && trim == eTrimType::S && trimUp == eTrimType::N)
return can_build_roads_on(ter);
} else if(trim == TRIM_E || trim == TRIM_W) {
} else if(trim == eTrimType::E || trim == eTrimType::W) {
ter_num_t left = coord_to_ter(x-1,y);
ter_num_t right = coord_to_ter(x+1,y);
eTrimType trimLeft = scenario.ter_types[left].trim_type;
eTrimType trimRight = scenario.ter_types[right].trim_type;
if((trimLeft == TRIM_ROAD || trimLeft == TRIM_CITY) && (trimRight == TRIM_ROAD || trimRight == TRIM_CITY))
if((trimLeft == eTrimType::ROAD || trimLeft == eTrimType::CITY) && (trimRight == eTrimType::ROAD || trimRight == eTrimType::CITY))
return can_build_roads_on(ter);
if((trimLeft == TRIM_ROAD || trimLeft == TRIM_CITY) && trim == TRIM_W && trimRight == TRIM_E)
if((trimLeft == eTrimType::ROAD || trimLeft == eTrimType::CITY) && trim == eTrimType::W && trimRight == eTrimType::E)
return can_build_roads_on(ter);
if((trimRight == TRIM_ROAD || trimRight == TRIM_CITY) && trim == TRIM_E && trimLeft == TRIM_W)
if((trimRight == eTrimType::ROAD || trimRight == eTrimType::CITY) && trim == eTrimType::E && trimLeft == eTrimType::W)
return can_build_roads_on(ter);
}
return false;
@@ -1339,9 +1339,9 @@ static bool superextend_road_terrain(int x, int y) {
static bool connect_roads(ter_num_t ter){
eTrimType trim = scenario.ter_types[ter].trim_type;
eTerSpec spec = scenario.ter_types[ter].special;
if(trim == TRIM_ROAD || trim == TRIM_CITY)
if(trim == eTrimType::ROAD || trim == eTrimType::CITY)
return true;
if(spec == TER_SPEC_TOWN_ENTRANCE && trim != TRIM_NONE)
if(spec == TER_SPEC_TOWN_ENTRANCE && trim != eTrimType::NONE)
return true; // cave entrance, most likely
return false;
}
@@ -1416,7 +1416,7 @@ void place_road(short q,short r,location where, bool here)
eTrimType vertTrim = scenario.ter_types[ter].trim_type;
if ((where.y == 0) || connect_roads(ter))
vert = can_build_roads_on(ref);
else if((vertTrim == TRIM_S && trim == TRIM_N) || (vertTrim == TRIM_N && trim == TRIM_S))
else if((vertTrim == eTrimType::S && trim == eTrimType::N) || (vertTrim == eTrimType::N && trim == eTrimType::S))
vert = can_build_roads_on(ref);
if (((is_out()) && (where.x < 96)) || (!(is_out()) && (where.x < univ.town->max_dim() - 1)))
@@ -1425,7 +1425,7 @@ void place_road(short q,short r,location where, bool here)
if (((is_out()) && (where.x == 96)) || (!(is_out()) && (where.x == univ.town->max_dim() - 1))
|| connect_roads(ter))
horz = can_build_roads_on(ref);
else if((horzTrim == TRIM_W && trim == TRIM_E) || (horzTrim == TRIM_E && trim == TRIM_W))
else if((horzTrim == eTrimType::W && trim == eTrimType::E) || (horzTrim == eTrimType::E && trim == eTrimType::W))
horz = can_build_roads_on(ref);
if(vert){
@@ -1435,7 +1435,7 @@ void place_road(short q,short r,location where, bool here)
if (((is_out()) && (where.y == 96)) || (!(is_out()) && (where.y == univ.town->max_dim() - 1))
|| connect_roads(ter))
vert = can_build_roads_on(ref);
else if((vertTrim == TRIM_S && trim == TRIM_N) || (vertTrim == TRIM_N && trim == TRIM_S))
else if((vertTrim == eTrimType::S && trim == eTrimType::N) || (vertTrim == eTrimType::N && trim == eTrimType::S))
vert = can_build_roads_on(ref);
else vert = false;
}
@@ -1446,7 +1446,7 @@ void place_road(short q,short r,location where, bool here)
eTrimType horzTrim = scenario.ter_types[ter].trim_type;
if ((where.x == 0) || connect_roads(ter))
horz = can_build_roads_on(ref);
else if((horzTrim == TRIM_W && trim == TRIM_E) || (horzTrim == TRIM_E && trim == TRIM_W))
else if((horzTrim == eTrimType::W && trim == eTrimType::E) || (horzTrim == eTrimType::E && trim == eTrimType::W))
horz = can_build_roads_on(ref);
else horz = false;
}

View File

@@ -653,7 +653,7 @@ bool is_fluid(ter_num_t ter_type)////
// if (((ter_type >= 71) && (ter_type <= 76)) || (ter_type == 90))
// return true;
// return false;
return scenario.ter_types[ter_type].trim_type == TRIM_FRILLS;
return scenario.ter_types[ter_type].trim_type == eTrimType::FRILLS;
}
// Is this a beach that gets shore plopped down next to it?
@@ -661,7 +661,7 @@ bool is_shore(ter_num_t ter_type)////
{
if (is_fluid(ter_type) == true)
return false;
if(scenario.ter_types[ter_type].trim_type == TRIM_WATERFALL)
if(scenario.ter_types[ter_type].trim_type == eTrimType::WATERFALL)
return false;
// if (ter_type == 77)
// return false;
@@ -679,7 +679,7 @@ bool is_shore(ter_num_t ter_type)////
// These two functions used to determine wall round-cornering
bool is_wall(ter_num_t ter_type)////
{
return scenario.ter_types[ter_type].trim_type == TRIM_WALL;
return scenario.ter_types[ter_type].trim_type == eTrimType::WALL;
// short pic;
//
// pic = scenario.ter_types[ter_type].picture;
@@ -691,11 +691,11 @@ bool is_wall(ter_num_t ter_type)////
}
bool is_ground(ter_num_t ter_type)
{
if(scenario.ter_types[ter_type].trim_type == TRIM_WALL)
if(scenario.ter_types[ter_type].trim_type == eTrimType::WALL)
return false;
if(scenario.ter_types[ter_type].block_horse)
return false;
// if(scenario.ter_types[ter_type].trim_type == TRIM_WALKWAY)
// if(scenario.ter_types[ter_type].trim_type == eTrimType::WALKWAY)
// return false;
return true;
}

View File

@@ -288,8 +288,8 @@ bool is_blocked(location to_check)
// Keep away from marked specials during combat
if ((is_combat()) && univ.town.is_spot(to_check.x, to_check.y))
return true;
if ((is_combat()) && (scenario.ter_types[coord_to_ter(to_check.x,to_check.y)].trim_type == TRIM_CITY))
return true; // TODO: Maybe replace TRIM_CITY with a blockage == clear/special && is_special() check
if ((is_combat()) && (scenario.ter_types[coord_to_ter(to_check.x,to_check.y)].trim_type == eTrimType::CITY))
return true; // TODO: Maybe replace eTrimType::CITY with a blockage == clear/special && is_special() check
// Party there?
if (is_town())

View File

@@ -210,9 +210,9 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short
}
if ((is_combat()) && (univ.town.is_spot(where_check.x, where_check.y) ||
(scenario.ter_types[coord_to_ter(where_check.x, where_check.y)].trim_type == TRIM_CITY))) {
(scenario.ter_types[coord_to_ter(where_check.x, where_check.y)].trim_type == eTrimType::CITY))) {
ASB("Move: Can't trigger this special in combat.");
return false; // TODO: Maybe replace TRIM_CITY check with a blockage == clear/special && is_special() check?
return false; // TODO: Maybe replace eTrimType::CITY check with a blockage == clear/special && is_special() check?
}
if (((mode == 1) || ((mode == 2) && (which_combat_type == 1)))

View File

@@ -35,19 +35,19 @@ cOutdoors& cOutdoors::operator = (legacy::outdoor_record_type& old){
if(old.terrain[i][j] == 81 && i > 0 && i < 47 && j > 0 && j < 47) {
if(old.terrain[i+1][j] == 81) {
ter_num_t connect = old.terrain[i-1][j];
if(connect == 80 || scenario.ter_types[connect].trim_type == TRIM_CITY)
if(connect == 80 || scenario.ter_types[connect].trim_type == eTrimType::CITY)
terrain[i][j] = 44;
} else if(old.terrain[i-1][j] == 81) {
ter_num_t connect = old.terrain[i+1][j];
if(connect == 80 || scenario.ter_types[connect].trim_type == TRIM_CITY)
if(connect == 80 || scenario.ter_types[connect].trim_type == eTrimType::CITY)
terrain[i][j] = 40;
} else if(old.terrain[i][j+1] == 81) {
ter_num_t connect = old.terrain[i][j-1];
if(connect == 80 || scenario.ter_types[connect].trim_type == TRIM_CITY)
if(connect == 80 || scenario.ter_types[connect].trim_type == eTrimType::CITY)
terrain[i][j] = 42;
} else if(old.terrain[i][j-1] == 81) {
ter_num_t connect = old.terrain[i][j+1];
if(connect == 80 || scenario.ter_types[connect].trim_type == TRIM_CITY)
if(connect == 80 || scenario.ter_types[connect].trim_type == eTrimType::CITY)
terrain[i][j] = 38;
}
}

View File

@@ -228,16 +228,16 @@ enum eTerSpec {
// 24. Bridge - if the party boats over it, they get the option to land. (Unused, Unused, Unused)
};
enum eTrimType {
TRIM_NONE = 0,
TRIM_WALL = 1, // not a trim, but trims will conform to it as if it's the same ground type (eg stone wall)
TRIM_S, TRIM_SE, TRIM_E, TRIM_NE, TRIM_N, TRIM_NW, TRIM_W, TRIM_SW,
TRIM_NE_INNER, TRIM_SE_INNER, TRIM_SW_INNER, TRIM_NW_INNER,
TRIM_FRILLS = 14, // like on lava and underground water; no trim_ter required
TRIM_ROAD = 15, // the game will treat it like a road space and draw roads; no trim_ter required
TRIM_WALKWAY = 16, // the game will draw walkway corners; trim_ter is base terrain to draw on
TRIM_WATERFALL = 17, // special case for waterfalls
TRIM_CITY = 18, // the game will join roads up to this space but not draw roads on the space
enum class eTrimType {
NONE = 0,
WALL = 1, // not a trim, but trims will conform to it as if it's the same ground type (eg stone wall)
S, SE, E, NE, N, NW, W, SW,
NE_INNER, SE_INNER, SW_INNER, NW_INNER,
FRILLS = 14, // like on lava and underground water; no trim_ter required
ROAD = 15, // the game will treat it like a road space and draw roads; no trim_ter required
WALKWAY = 16, // the game will draw walkway corners; trim_ter is base terrain to draw on
WATERFALL = 17, // special case for waterfalls
CITY = 18, // the game will join roads up to this space but not draw roads on the space
};
/* terrain type blockage */

View File

@@ -109,7 +109,7 @@ cTerrain& cTerrain::operator = (legacy::terrain_type_type& old){
}else{
combat_arena = 1;
ground_type = 255;
trim_type = TRIM_NONE;
trim_type = eTrimType::NONE;
trim_ter = 0;
}
if(trim_ter == 99) trim_ter = 0;

View File

@@ -1795,18 +1795,18 @@ bool terrain_matches(unsigned char x, unsigned char y, ter_num_t ter){
if(ter2 == ter) return true;
if(scenario.ter_types[ter2].ground_type != scenario.ter_types[ter].ground_type)
return false;
if(scenario.ter_types[ter].trim_type == TRIM_NONE &&
scenario.ter_types[ter2].trim_type >= TRIM_S &&
scenario.ter_types[ter2].trim_type <= TRIM_NW_INNER)
if(scenario.ter_types[ter].trim_type == eTrimType::NONE &&
scenario.ter_types[ter2].trim_type >= eTrimType::S &&
scenario.ter_types[ter2].trim_type <= eTrimType::NW_INNER)
return ter == get_ground_from_ter(ter);
if(scenario.ter_types[ter2].trim_type == TRIM_NONE &&
scenario.ter_types[ter].trim_type >= TRIM_S &&
scenario.ter_types[ter].trim_type <= TRIM_NW_INNER)
if(scenario.ter_types[ter2].trim_type == eTrimType::NONE &&
scenario.ter_types[ter].trim_type >= eTrimType::S &&
scenario.ter_types[ter].trim_type <= eTrimType::NW_INNER)
return ter2 == get_ground_from_ter(ter2);
if(scenario.ter_types[ter2].trim_type >= TRIM_S &&
scenario.ter_types[ter2].trim_type <= TRIM_NW_INNER &&
scenario.ter_types[ter].trim_type >= TRIM_S &&
scenario.ter_types[ter].trim_type <= TRIM_NW_INNER)
if(scenario.ter_types[ter2].trim_type >= eTrimType::S &&
scenario.ter_types[ter2].trim_type <= eTrimType::NW_INNER &&
scenario.ter_types[ter].trim_type >= eTrimType::S &&
scenario.ter_types[ter].trim_type <= eTrimType::NW_INNER)
return true;
return false;
}

View File

@@ -328,7 +328,8 @@ void fill_ter_info(cDialog& me, short ter){
me["trans"].setTextToNum(ter_type.trans_to_what);
me["ground"].setTextToNum(ter_type.ground_type);
me["trimter"].setTextToNum(ter_type.trim_ter);
me["trim"].setTextToNum(ter_type.trim_type);
// TODO: Replace edit text box for trim with a framed name and Select button
me["trim"].setTextToNum((int)ter_type.trim_type);
std::string propid = "prop" + std::to_string(ter_type.special);
dynamic_cast<cLedGroup&>(me["prop"]).setSelected(propid);
fill_ter_flag_info(me, "prop", false);