Move terrain blockage check into cTerrain class

This commit is contained in:
2017-04-14 01:12:56 -04:00
parent 4baac518e9
commit 936a848166
7 changed files with 12 additions and 11 deletions

View File

@@ -2346,7 +2346,7 @@ void increase_age() {
if(univ.party.status[ePartyStatus::FLIGHT] == 2)
add_string_to_buf("You are starting to descend.");
if(univ.party.status[ePartyStatus::FLIGHT] == 1) {
if(blocksMove(univ.scenario.ter_types[univ.out[univ.party.out_loc.x][univ.party.out_loc.y]].blockage)) {
if(univ.scenario.ter_types[univ.out[univ.party.out_loc.x][univ.party.out_loc.y]].blocksMove()) {
add_string_to_buf(" You plummet to your deaths.");
slay_party(eMainStatus::DEAD);
print_buf();

View File

@@ -947,7 +947,7 @@ void draw_terrain(short mode) {
static ter_num_t get_ground_for_shore(ter_num_t ter){
if(univ.scenario.ter_types[ter].block_horse) return current_ground;
else if(blocksMove(univ.scenario.ter_types[ter].blockage)) return current_ground;
else if(univ.scenario.ter_types[ter].blocksMove()) return current_ground;
else return ter;
}

View File

@@ -208,7 +208,7 @@ short sight_obscurity(short x,short y) {
}
short combat_obscurity(short x, short y) {
if(blocksMove(univ.scenario.ter_types[coord_to_ter(x,y)].blockage)) return 5;
if(univ.scenario.ter_types[coord_to_ter(x,y)].blocksMove()) return 5;
if(is_lava(x,y)) return 5;
return sight_obscurity(x,y);
}
@@ -440,7 +440,7 @@ bool outd_is_special(location to_check) {
}
bool impassable(ter_num_t terrain_to_check) {
if(blocksMove(univ.scenario.ter_types[terrain_to_check].blockage))
if(univ.scenario.ter_types[terrain_to_check].blocksMove())
return true;
else return false;
}

View File

@@ -297,7 +297,7 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,
play_sound(-1 * ter_flag2);
}
give_help(47,65);
if(blocksMove(univ.scenario.ter_types[ter].blockage))
if(univ.scenario.ter_types[ter].blocksMove())
can_enter = false;
break;
case eTerSpec::DAMAGING:
@@ -1018,7 +1018,7 @@ void use_item(short pc,short item) {
case ePartyStatus::DETECT_LIFE: ASB(" Your vision of life becomes blurry."); break;
case ePartyStatus::FLIGHT:
if(i <= str) {
if(blocksMove(univ.scenario.ter_types[univ.out[univ.party.out_loc.x][univ.party.out_loc.y]].blockage)) {
if(univ.scenario.ter_types[univ.out[univ.party.out_loc.x][univ.party.out_loc.y]].blocksMove()) {
add_string_to_buf(" You plummet to your deaths.");
slay_party(eMainStatus::DEAD);
print_buf();

View File

@@ -408,3 +408,8 @@ void cTerrain::import_legacy(legacy::terrain_type_type& old){
else if(i == 37)
frill_for = 36, frill_chance = 25;
}
bool cTerrain::blocksMove() const {
int code = (int) blockage;
return code > 2;
}

View File

@@ -45,6 +45,7 @@ public:
pic_num_t map_pic = -1;
unsigned short i; // for temporary use in porting
bool blocksMove() const;
void import_legacy(legacy::terrain_type_type& old);
void writeTo(std::ostream& file) const;
};

View File

@@ -79,11 +79,6 @@ enum class eTerObstruct {
BLOCK_MOVE_AND_SIGHT = 5,
};
inline bool blocksMove(eTerObstruct block) {
int code = (int) block;
return code > 2;
}
enum class eStepSnd {STEP, SQUISH, CRUNCH, NONE, SPLASH};
std::ostream& operator << (std::ostream& out, eTerSpec e);