Enumify terrain blockage and generalize the line of sight function

This should probably be two separate commits, but they're tangled together and I don't want to spend the effort to disentangle them.
This commit is contained in:
2014-12-01 19:50:19 -05:00
parent afd45b3774
commit d900c7edef
19 changed files with 150 additions and 300 deletions

View File

@@ -240,6 +240,20 @@ enum eTrimType {
TRIM_CITY = 18, // the game will join roads up to this space but not draw roads on the space
};
/* terrain type blockage */
enum class eTerObstruct {
CLEAR = 0,
BLOCK_SIGHT = 1,
BLOCK_MONSTERS = 2,
BLOCK_MOVE = 3,
BLOCK_MOVE_AND_SHOOT = 4,
BLOCK_MOVE_AND_SIGHT = 5,
};
inline bool blocksMove(eTerObstruct block) {
int code = (int) block;
return code > 2;
}
/* items[i].type a.k.a type of weapon */
enum class eWeapType {

View File

@@ -95,7 +95,7 @@ cTerrain& cTerrain::operator = (legacy::terrain_type_type& old){
99,99,99,99,99,2, 99,99,99,99, 99,99,99,99,
};
picture = old.picture;
blockage = old.blockage;
blockage = (eTerObstruct) old.blockage;
if(picture < 260){
combat_arena = arenas[picture];
ground_type = ground[picture];
@@ -365,3 +365,16 @@ std::istream& operator >> (std::istream& in, eTerSpec& e){
else e = TER_SPEC_NONE;
return in;
}
std::ostream& operator << (std::ostream& out, eTerObstruct& e){
return out << (int) e;
}
std::istream& operator >> (std::istream& in, eTerObstruct& e){
int i;
in >> i;
if(i > 0 && i < 6)
e = (eTerObstruct) i;
else e = eTerObstruct::CLEAR;
return in;
}

View File

@@ -24,7 +24,7 @@ class cTerrain {
public:
std::string name;
pic_num_t picture;
unsigned char blockage;
eTerObstruct blockage;
ter_flag_t flag1;
ter_flag_t flag2;
ter_flag_t flag3; // new additional flag for special properties
@@ -52,5 +52,7 @@ public:
std::ostream& operator << (std::ostream& out, eTerSpec& e);
std::istream& operator >> (std::istream& in, eTerSpec& e);
std::ostream& operator << (std::ostream& out, eTerObstruct& e);
std::istream& operator >> (std::istream& in, eTerObstruct& e);
#endif