diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-10-17 08:59:19 +0200 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-10-17 09:09:43 +0200 |
commit | 91480fa09bfd0c7e937cdf0b29360c9e10413f62 (patch) | |
tree | 8de9cb01752af154a93f3060e8163f08cefb1a0c /crawl-ref/source | |
parent | dcc94e4df24a1111124d87532aaa263f55edf58d (diff) | |
download | crawl-ref-91480fa09bfd0c7e937cdf0b29360c9e10413f62.tar.gz crawl-ref-91480fa09bfd0c7e937cdf0b29360c9e10413f62.zip |
More renaming and reorganization of feature checks.
There were a couple of functions is_something(dgn_feature_type feat)
defined in travel.cc that were otherwise independent of travel. For
consistency, move these to terrain.cc and rename to feat_is_something.
One might also consider renaming the various feat_is_whatever functions
to just is_whatever.
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/abyss.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/debug.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/directn.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/dungeon.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/dungeon.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/menu.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 10 | ||||
-rw-r--r-- | crawl-ref/source/monplace.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/monstuff.cc | 20 | ||||
-rw-r--r-- | crawl-ref/source/overmap.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/stuff.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/terrain.cc | 139 | ||||
-rw-r--r-- | crawl-ref/source/terrain.h | 12 | ||||
-rw-r--r-- | crawl-ref/source/tilepick.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/tilereg.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/travel.cc | 156 | ||||
-rw-r--r-- | crawl-ref/source/travel.h | 7 | ||||
-rw-r--r-- | crawl-ref/source/tutorial.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/view.cc | 12 |
19 files changed, 202 insertions, 199 deletions
diff --git a/crawl-ref/source/abyss.cc b/crawl-ref/source/abyss.cc index 13bc428e2c..5d93e77e67 100644 --- a/crawl-ref/source/abyss.cc +++ b/crawl-ref/source/abyss.cc @@ -788,7 +788,7 @@ static bool _is_crowded_square(const coord_def &c) continue; const coord_def n(c.x + xi, c.y + yi); - if (!in_bounds(n) || !is_traversable(grd(n))) + if (!in_bounds(n) || !feat_is_traversable(grd(n))) continue; if (++neighbours > 4) @@ -829,13 +829,13 @@ static void _corrupt_square(const crawl_environment &oenv, const coord_def &c) return; } - if (is_traversable(grd(c)) && !is_traversable(feat) + if (feat_is_traversable(grd(c)) && !feat_is_traversable(feat) && _is_crowded_square(c)) { return; } - if (!is_traversable(grd(c)) && is_traversable(feat) && _is_sealed_square(c)) + if (!feat_is_traversable(grd(c)) && feat_is_traversable(feat) && _is_sealed_square(c)) return; // What's this supposed to achieve? (jpeg) diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 440a38e90c..451b00f500 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -6909,7 +6909,7 @@ static bool _mg_region_flood(const coord_def &c, int region, bool flag) } const dungeon_feature_type ft = grd(c); - if (is_travelable_stair(ft)) + if (feat_is_travelable_stair(ft)) found_exit = true; for (int yi = -1; yi <= 1; ++yi) diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index ed8b044461..f2a9ca64e9 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -473,7 +473,7 @@ void full_describe_view() for (radius_iterator ri(you.pos(), LOS_RADIUS); ri; ++ri) { if (feat_stair_direction(grd(*ri)) != CMD_NO_CMD - || is_altar(grd(*ri))) + || feat_is_altar(grd(*ri))) { list_features.push_back(*ri); } @@ -693,7 +693,7 @@ void full_describe_view() desc += "</" + colour_str +">) "; #endif desc += feature_description(c); - if (is_travelable_stair(grd(c)) && !travel_cache.know_stair(c)) + if (feat_is_travelable_stair(grd(c)) && !travel_cache.know_stair(c)) desc += " (not visited)"; FeatureMenuEntry *me = new FeatureMenuEntry(desc, c, hotkey); me->tag = "description"; @@ -3058,7 +3058,7 @@ static std::string _stair_destination_description(const coord_def &pos) const stair_info *si = linf->get_stair(pos); if (si) return (" " + si->describe()); - else if (is_stair(grd(pos))) + else if (feat_is_stair(grd(pos))) return (" (unknown stair)"); } return (""); diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 3cd7471f5c..5893121c55 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -5243,10 +5243,10 @@ bool join_the_dots(const coord_def &from, const coord_def &to, join_count++; const dungeon_feature_type feat = grd(at); - if (early_exit && at != from && is_traversable(feat)) + if (early_exit && at != from && feat_is_traversable(feat)) return (true); - if (unforbidden(at, MMT_VAULT) && !is_traversable(feat)) + if (unforbidden(at, MMT_VAULT) && !feat_is_traversable(feat)) grd(at) = DNGN_FLOOR; if (join_count > 10000) // just insurance @@ -7698,7 +7698,7 @@ struct nearest_point inline static bool _dgn_square_travel_ok(const coord_def &c) { const dungeon_feature_type feat = grd(c); - return (is_traversable(feat) || feat_is_trap(feat) + return (feat_is_traversable(feat) || feat_is_trap(feat) || feat == DNGN_SECRET_DOOR); } diff --git a/crawl-ref/source/dungeon.h b/crawl-ref/source/dungeon.h index c730d26ec5..75f5d641c5 100644 --- a/crawl-ref/source/dungeon.h +++ b/crawl-ref/source/dungeon.h @@ -308,7 +308,7 @@ bool flood_find<fgrd, bound_check>::path_flood( return (true); } - if (!is_traversable(feat) + if (!feat_is_traversable(feat) && feat != DNGN_SECRET_DOOR && !feat_is_trap(feat)) { diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc index a952dc580f..2c4c505578 100644 --- a/crawl-ref/source/menu.cc +++ b/crawl-ref/source/menu.cc @@ -21,6 +21,7 @@ REVISION("$Rev$"); #include "player.h" #ifdef USE_TILE #include "stuff.h" + #include "terrain.h" #include "tiles.h" #include "travel.h" #endif @@ -832,7 +833,7 @@ bool FeatureMenuEntry::get_tiles(std::vector<tile_def>& tileset) const tileset.push_back(tile_def(tileidx_feature(grd(pos), pos.x, pos.y), TEX_DUNGEON)); - if (is_travelable_stair(grd(pos)) && !travel_cache.know_stair(pos)) + if (feat_is_travelable_stair(grd(pos)) && !travel_cache.know_stair(pos)) tileset.push_back(tile_def(TILE_NEW_STAIR, TEX_DEFAULT)); return (true); diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index fc9cefbf0b..a43ce79974 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -1313,7 +1313,7 @@ static void climb_message(dungeon_feature_type stair, bool going_up, (player_is_airborne() ? "float" : "slide")); } } - else if (is_gate(stair)) + else if (feat_is_gate(stair)) { mprf("You %s %s through the gate.", you.flight_mode() == FL_FLY ? "fly" : @@ -1776,7 +1776,7 @@ void up_stairs(dungeon_feature_type force_stair, } if (you.burden_state == BS_OVERLOADED && !feat_is_escape_hatch(stair_find) - && !is_gate(stair_find)) + && !feat_is_gate(stair_find)) { mpr("You are carrying too much to climb upwards."); you.turn_is_over = true; @@ -1858,9 +1858,9 @@ void up_stairs(dungeon_feature_type force_stair, const dungeon_feature_type stair_taken = stair_find; - if (you.flight_mode() == FL_LEVITATE && !is_gate(stair_find)) + if (you.flight_mode() == FL_LEVITATE && !feat_is_gate(stair_find)) mpr("You float upwards... And bob straight up to the ceiling!"); - else if (you.flight_mode() == FL_FLY && !is_gate(stair_find)) + else if (you.flight_mode() == FL_FLY && !feat_is_gate(stair_find)) mpr("You fly upwards."); else climb_message(stair_find, true, old_level_type); @@ -2090,7 +2090,7 @@ void down_stairs( int old_level, dungeon_feature_type force_stair, } if (!force_stair && you.flight_mode() == FL_LEVITATE - && !is_gate(stair_find)) + && !feat_is_gate(stair_find)) { mpr("You're floating high up above the floor!"); return; diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index 173739b9a9..01306bb13b 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -669,7 +669,7 @@ static int _is_near_stairs(coord_def &p) continue; const dungeon_feature_type feat = grd(p); - if (is_stair(feat)) + if (feat_is_stair(feat)) { // Shouldn't matter for escape hatches. if (feat_is_escape_hatch(feat)) diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 9e011a1e9b..42bc6a5606 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -3429,7 +3429,7 @@ static void _mark_neighbours_target_unreachable(monsters *mon) static bool _is_level_exit(const coord_def& pos) { // All types of stairs. - if (is_stair(grd(pos))) + if (feat_is_stair(grd(pos))) return (true); // Teleportation and shaft traps. @@ -3493,21 +3493,21 @@ static int _mons_find_nearest_level_exit(const monsters *mon, // types, this should be expanded along with it. static void _mons_indicate_level_exit(const monsters *mon) { - const dungeon_feature_type gridc = grd(mon->pos()); + const dungeon_feature_type feat = grd(mon->pos()); const bool is_shaft = (get_trap_type(mon->pos()) == TRAP_SHAFT); - if (is_gate(gridc)) + if (feat_is_gate(feat)) simple_monster_message(mon, " passes through the gate."); - else if (is_travelable_stair(gridc)) + else if (feat_is_travelable_stair(feat)) { - command_type dir = feat_stair_direction(gridc); + command_type dir = feat_stair_direction(feat); simple_monster_message(mon, make_stringf(" %s the %s.", - dir == CMD_GO_UPSTAIRS ? "goes up" : - dir == CMD_GO_DOWNSTAIRS ? "goes down" - : "takes", - is_escape_hatch(gridc) ? "escape hatch" - : "stairs").c_str()); + dir == CMD_GO_UPSTAIRS ? "goes up" : + dir == CMD_GO_DOWNSTAIRS ? "goes down" + : "takes", + feat_is_escape_hatch(feat) ? "escape hatch" + : "stairs").c_str()); } else if (is_shaft) { diff --git a/crawl-ref/source/overmap.cc b/crawl-ref/source/overmap.cc index 0a7cad42b9..a56a2bcc73 100644 --- a/crawl-ref/source/overmap.cc +++ b/crawl-ref/source/overmap.cc @@ -772,7 +772,7 @@ void annotate_level() level_id li = level_id::current(); level_id li2 = level_id::current(); - if (is_stair(grd(you.pos()))) + if (feat_is_stair(grd(you.pos()))) { li2 = level_id::get_next_level_id(you.pos()); diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index 4cafaa9b08..efedacd0ea 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -1656,7 +1656,7 @@ int near_stairs(const coord_def &p, int max_dist, for (radius_iterator ri(p, max_dist, true, false); ri; ++ri) { const dungeon_feature_type feat = grd(*ri); - if (is_stair(feat)) + if (feat_is_stair(feat)) { // Shouldn't happen for escape hatches. if (feat_is_escape_hatch(feat)) diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc index 2c8518c9a6..3dba3481ec 100644 --- a/crawl-ref/source/terrain.cc +++ b/crawl-ref/source/terrain.cc @@ -93,11 +93,6 @@ bool feat_is_staircase(dungeon_feature_type feat) && feat <= DNGN_RETURN_FROM_LAST_BRANCH); } -bool feat_is_escape_hatch(dungeon_feature_type feat) -{ - return (feat == DNGN_ESCAPE_HATCH_UP || feat == DNGN_ESCAPE_HATCH_DOWN); -} - bool feat_sealable_portal(dungeon_feature_type feat) { switch (feat) @@ -121,6 +116,125 @@ bool feat_is_portal(dungeon_feature_type feat) return (feat == DNGN_ENTER_PORTAL_VAULT || feat == DNGN_EXIT_PORTAL_VAULT); } +// Returns true if the given dungeon feature is a stair, i.e., a level +// exit. +bool feat_is_stair(dungeon_feature_type gridc) +{ + return (feat_is_travelable_stair(gridc) || feat_is_gate(gridc)); +} + +// Returns true if the given dungeon feature is a travelable stair, i.e., +// it's a level exit with a consistent endpoint. +bool feat_is_travelable_stair(dungeon_feature_type feat) +{ + switch (feat) + { + case DNGN_STONE_STAIRS_DOWN_I: + case DNGN_STONE_STAIRS_DOWN_II: + case DNGN_STONE_STAIRS_DOWN_III: + case DNGN_ESCAPE_HATCH_DOWN: + case DNGN_STONE_STAIRS_UP_I: + case DNGN_STONE_STAIRS_UP_II: + case DNGN_STONE_STAIRS_UP_III: + case DNGN_ESCAPE_HATCH_UP: + case DNGN_ENTER_HELL: + case DNGN_EXIT_HELL: + case DNGN_ENTER_DIS: + case DNGN_ENTER_GEHENNA: + case DNGN_ENTER_COCYTUS: + case DNGN_ENTER_TARTARUS: + case DNGN_ENTER_ORCISH_MINES: + case DNGN_ENTER_HIVE: + case DNGN_ENTER_LAIR: + case DNGN_ENTER_SLIME_PITS: + case DNGN_ENTER_VAULTS: + case DNGN_ENTER_CRYPT: + case DNGN_ENTER_HALL_OF_BLADES: + case DNGN_ENTER_ZOT: + case DNGN_ENTER_TEMPLE: + case DNGN_ENTER_SNAKE_PIT: + case DNGN_ENTER_ELVEN_HALLS: + case DNGN_ENTER_TOMB: + case DNGN_ENTER_SWAMP: + case DNGN_ENTER_SHOALS: + case DNGN_RETURN_FROM_ORCISH_MINES: + case DNGN_RETURN_FROM_HIVE: + case DNGN_RETURN_FROM_LAIR: + case DNGN_RETURN_FROM_SLIME_PITS: + case DNGN_RETURN_FROM_VAULTS: + case DNGN_RETURN_FROM_CRYPT: + case DNGN_RETURN_FROM_HALL_OF_BLADES: + case DNGN_RETURN_FROM_ZOT: + case DNGN_RETURN_FROM_TEMPLE: + case DNGN_RETURN_FROM_SNAKE_PIT: + case DNGN_RETURN_FROM_ELVEN_HALLS: + case DNGN_RETURN_FROM_TOMB: + case DNGN_RETURN_FROM_SWAMP: + case DNGN_RETURN_FROM_SHOALS: + return (true); + default: + return (false); + } +} + +// Returns true if the given dungeon feature is an escape hatch. +bool feat_is_escape_hatch(dungeon_feature_type feat) +{ + switch (feat) + { + case DNGN_ESCAPE_HATCH_DOWN: + case DNGN_ESCAPE_HATCH_UP: + return (true); + default: + return (false); + } +} + +// Returns true if the given dungeon feature can be considered a gate. +bool feat_is_gate(dungeon_feature_type feat) +{ + // Make up staircases in hell appear as gates. + if (player_in_hell()) + { + switch (feat) + { + case DNGN_STONE_STAIRS_UP_I: + case DNGN_STONE_STAIRS_UP_II: + case DNGN_STONE_STAIRS_UP_III: + return (true); + default: + break; + } + } + + switch (feat) + { + case DNGN_ENTER_ABYSS: + case DNGN_EXIT_ABYSS: + case DNGN_ENTER_LABYRINTH: + case DNGN_ENTER_PANDEMONIUM: + case DNGN_EXIT_PANDEMONIUM: + case DNGN_TRANSIT_PANDEMONIUM: + case DNGN_ENTER_PORTAL_VAULT: + case DNGN_EXIT_PORTAL_VAULT: + case DNGN_ENTER_ZOT: + case DNGN_RETURN_FROM_ZOT: + case DNGN_ENTER_HELL: + case DNGN_EXIT_HELL: + case DNGN_ENTER_DIS: + case DNGN_ENTER_GEHENNA: + case DNGN_ENTER_COCYTUS: + case DNGN_ENTER_TARTARUS: + return (true); + default: + return (false); + } +} + + + + + command_type feat_stair_direction(dungeon_feature_type feat) { switch (feat) @@ -274,6 +388,19 @@ dungeon_feature_type altar_for_god(god_type god) return static_cast<dungeon_feature_type>(DNGN_ALTAR_FIRST_GOD + god - 1); } +// Returns true if the dungeon feature supplied is an altar. +bool feat_is_altar(dungeon_feature_type grid) +{ + return feat_altar_god(grid) != GOD_NO_GOD; +} + +bool feat_is_player_altar(dungeon_feature_type grid) +{ + // An ugly hack, but that's what religion.cc does. + return (you.religion != GOD_NO_GOD + && feat_altar_god(grid) == you.religion); +} + bool feat_is_branch_stairs(dungeon_feature_type feat) { return ((feat >= DNGN_ENTER_FIRST_BRANCH && feat <= DNGN_ENTER_LAST_BRANCH) @@ -455,7 +582,7 @@ static coord_def _dgn_find_nearest_square( static bool _item_safe_square(const coord_def &pos) { const dungeon_feature_type feat = grd(pos); - return (is_traversable(feat) && !feat_destroys_items(feat)); + return (feat_is_traversable(feat) && !feat_destroys_items(feat)); } // Moves an item on the floor to the nearest adjacent floor-space. diff --git a/crawl-ref/source/terrain.h b/crawl-ref/source/terrain.h index 35ff6603c9..1cceb40020 100644 --- a/crawl-ref/source/terrain.h +++ b/crawl-ref/source/terrain.h @@ -18,12 +18,12 @@ actor* actor_at(const coord_def& c); bool fall_into_a_pool( const coord_def& entry, bool allow_shift, unsigned char terrain ); +bool cell_is_solid(int x, int y); +bool cell_is_solid(const coord_def &c); bool feat_is_wall(dungeon_feature_type feat); bool feat_is_opaque(dungeon_feature_type feat); bool feat_is_solid(dungeon_feature_type feat); -bool cell_is_solid(int x, int y); -bool cell_is_solid(const coord_def &c); bool feat_is_closed_door(dungeon_feature_type feat); bool feat_is_secret_door(dungeon_feature_type feat); bool feat_is_rock(dungeon_feature_type feat); @@ -36,6 +36,11 @@ command_type feat_stair_direction(dungeon_feature_type feat); bool feat_sealable_portal(dungeon_feature_type feat); bool feat_is_portal(dungeon_feature_type feat); +bool feat_is_stair(dungeon_feature_type feat); +bool feat_is_travelable_stair(dungeon_feature_type feat); +bool feat_is_escape_hatch(dungeon_feature_type feat); +bool feat_is_gate(dungeon_feature_type feat); + std::string feat_preposition(dungeon_feature_type feat, bool active = false, const actor* who = NULL); std::string stair_climb_verb(dungeon_feature_type feat); @@ -44,6 +49,9 @@ bool feat_is_water(dungeon_feature_type feat); bool feat_is_watery(dungeon_feature_type feat); god_type feat_altar_god(dungeon_feature_type feat); dungeon_feature_type altar_for_god(god_type god); +bool feat_is_altar(dungeon_feature_type feat); +bool feat_is_player_altar(dungeon_feature_type grid); + bool feat_is_branch_stairs(dungeon_feature_type feat); void find_connected_identical(coord_def d, dungeon_feature_type ft, std::set<coord_def>& out); diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc index 23fbe166f4..d8e75bd287 100644 --- a/crawl-ref/source/tilepick.cc +++ b/crawl-ref/source/tilepick.cc @@ -71,7 +71,7 @@ void TileNewLevel(bool first_time) const coord_def gc(x,y); int object = grd(gc); - if (!is_travelable_stair((dungeon_feature_type)object) + if (!feat_is_travelable_stair((dungeon_feature_type)object) || travel_cache.know_stair(gc)) { env.tile_bk_bg[x][y] &= ~TILE_FLAG_NEW_STAIR; @@ -4544,7 +4544,7 @@ void tile_draw_floor() { if (object == DNGN_DETECTED_SECRET_DOOR) bg |= TILE_FLAG_WAS_SECRET; - else if (is_travelable_stair((dungeon_feature_type)object) + else if (feat_is_travelable_stair((dungeon_feature_type)object) && !travel_cache.know_stair(gc)) { bg |= TILE_FLAG_NEW_STAIR; diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc index 4c7da0c727..d84a6bd320 100644 --- a/crawl-ref/source/tilereg.cc +++ b/crawl-ref/source/tilereg.cc @@ -1222,7 +1222,7 @@ int DungeonRegion::handle_mouse(MouseEvent &event) case CMD_GO_UPSTAIRS: return ('<'); default: - if (is_altar(feat) + if (feat_is_altar(feat) && player_can_join_god(feat_altar_god(feat))) { return ('p'); @@ -1350,7 +1350,7 @@ bool DungeonRegion::update_tip_text(std::string& tip) tip += "\n[Shift-L-Click] "; if (feat == DNGN_ENTER_SHOP) tip += "enter shop"; - else if (is_gate(feat)) + else if (feat_is_gate(feat)) tip += "enter gate"; else tip += "use stairs"; @@ -1360,7 +1360,7 @@ bool DungeonRegion::update_tip_text(std::string& tip) else tip += " (<)"; } - else if (is_altar(feat) && player_can_join_god(feat_altar_god(feat))) + else if (feat_is_altar(feat) && player_can_join_god(feat_altar_god(feat))) tip += "\n[Shift-L-Click] pray on altar (p)"; // Character overview. diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 672f387dd9..60bd9e5627 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -216,27 +216,14 @@ inline int feature_traverse_cost(dungeon_feature_type feature) return 1; } -// Returns true if the dungeon feature supplied is an altar. -bool is_altar(dungeon_feature_type grid) -{ - return feat_altar_god(grid) != GOD_NO_GOD; -} - bool is_altar(const coord_def &c) { - return is_altar(grd(c)); -} - -inline bool is_player_altar(dungeon_feature_type grid) -{ - // An ugly hack, but that's what religion.cc does. - return (you.religion != GOD_NO_GOD - && feat_altar_god(grid) == you.religion); + return feat_is_altar(grd(c)); } inline bool is_player_altar(const coord_def &c) { - return is_player_altar(grd(c)); + return feat_is_player_altar(grd(c)); } #ifdef CLUA_BINDINGS @@ -271,7 +258,7 @@ const char *trap_name(const coord_def& c) #endif // Returns true if the character can cross this dungeon feature. -bool is_traversable(dungeon_feature_type grid) +bool feat_is_traversable(dungeon_feature_type grid) { return (traversable_terrain[grid] == TRAVERSABLE); } @@ -635,7 +622,7 @@ bool is_travelsafe_square(const coord_def& c, bool ignore_hostile, return (true); } - return (is_traversable(static_cast<dungeon_feature_type>(grid)) + return (feat_is_traversable(static_cast<dungeon_feature_type>(grid)) #ifdef CLUA_BINDINGS || (is_trap(c) && clua.callbooleanfn(false, "ch_cross_trap", @@ -792,121 +779,6 @@ bool is_branch_stair(const coord_def& pos) return (next.branch != curr.branch); } -// Returns true if the given dungeon feature is a stair, i.e., a level -// exit. -bool is_stair(dungeon_feature_type gridc) -{ - return (is_travelable_stair(gridc) || is_gate(gridc)); -} - -// Returns true if the given dungeon feature is a travelable stair, i.e., -// it's a level exit with a consistent endpoint. -bool is_travelable_stair(dungeon_feature_type gridc) -{ - switch (gridc) - { - case DNGN_STONE_STAIRS_DOWN_I: - case DNGN_STONE_STAIRS_DOWN_II: - case DNGN_STONE_STAIRS_DOWN_III: - case DNGN_ESCAPE_HATCH_DOWN: - case DNGN_STONE_STAIRS_UP_I: - case DNGN_STONE_STAIRS_UP_II: - case DNGN_STONE_STAIRS_UP_III: - case DNGN_ESCAPE_HATCH_UP: - case DNGN_ENTER_HELL: - case DNGN_EXIT_HELL: - case DNGN_ENTER_DIS: - case DNGN_ENTER_GEHENNA: - case DNGN_ENTER_COCYTUS: - case DNGN_ENTER_TARTARUS: - case DNGN_ENTER_ORCISH_MINES: - case DNGN_ENTER_HIVE: - case DNGN_ENTER_LAIR: - case DNGN_ENTER_SLIME_PITS: - case DNGN_ENTER_VAULTS: - case DNGN_ENTER_CRYPT: - case DNGN_ENTER_HALL_OF_BLADES: - case DNGN_ENTER_ZOT: - case DNGN_ENTER_TEMPLE: - case DNGN_ENTER_SNAKE_PIT: - case DNGN_ENTER_ELVEN_HALLS: - case DNGN_ENTER_TOMB: - case DNGN_ENTER_SWAMP: - case DNGN_ENTER_SHOALS: - case DNGN_RETURN_FROM_ORCISH_MINES: - case DNGN_RETURN_FROM_HIVE: - case DNGN_RETURN_FROM_LAIR: - case DNGN_RETURN_FROM_SLIME_PITS: - case DNGN_RETURN_FROM_VAULTS: - case DNGN_RETURN_FROM_CRYPT: - case DNGN_RETURN_FROM_HALL_OF_BLADES: - case DNGN_RETURN_FROM_ZOT: - case DNGN_RETURN_FROM_TEMPLE: - case DNGN_RETURN_FROM_SNAKE_PIT: - case DNGN_RETURN_FROM_ELVEN_HALLS: - case DNGN_RETURN_FROM_TOMB: - case DNGN_RETURN_FROM_SWAMP: - case DNGN_RETURN_FROM_SHOALS: - return (true); - default: - return (false); - } -} - -// Returns true if the given dungeon feature is an escape hatch. -bool is_escape_hatch(dungeon_feature_type gridc) -{ - switch (gridc) - { - case DNGN_ESCAPE_HATCH_DOWN: - case DNGN_ESCAPE_HATCH_UP: - return (true); - default: - return (false); - } -} - -// Returns true if the given dungeon feature can be considered a gate. -bool is_gate(dungeon_feature_type gridc) -{ - // Make up staircases in hell appear as gates. - if (player_in_hell()) - { - switch (gridc) - { - case DNGN_STONE_STAIRS_UP_I: - case DNGN_STONE_STAIRS_UP_II: - case DNGN_STONE_STAIRS_UP_III: - return (true); - default: - break; - } - } - - switch (gridc) - { - case DNGN_ENTER_ABYSS: - case DNGN_EXIT_ABYSS: - case DNGN_ENTER_LABYRINTH: - case DNGN_ENTER_PANDEMONIUM: - case DNGN_EXIT_PANDEMONIUM: - case DNGN_TRANSIT_PANDEMONIUM: - case DNGN_ENTER_PORTAL_VAULT: - case DNGN_EXIT_PORTAL_VAULT: - case DNGN_ENTER_ZOT: - case DNGN_RETURN_FROM_ZOT: - case DNGN_ENTER_HELL: - case DNGN_EXIT_HELL: - case DNGN_ENTER_DIS: - case DNGN_ENTER_GEHENNA: - case DNGN_ENTER_COCYTUS: - case DNGN_ENTER_TARTARUS: - return (true); - default: - return (false); - } -} - // Prompts the user to stop explore if necessary for the given // explore-stop condition, returns true if explore should be stopped. bool prompt_stop_explore(int es_why) @@ -1112,7 +984,7 @@ static void _explore_find_target_square() feature = grd(target); } while (is_travelsafe_square(target) - && is_traversable(feature) + && feat_is_traversable(feature) && feature_traverse_cost(feature) == 1); target -= delta; @@ -2013,7 +1885,7 @@ void find_travel_pos(const coord_def& youpos, // happen by manual movement, so I don't think we need to worry // about this. (jpeg) if (!is_travelsafe_square(new_dest) - || !is_traversable(grd(new_dest))) + || !feat_is_traversable(grd(new_dest))) { new_dest = dest; } @@ -3651,11 +3523,11 @@ void LevelInfo::get_stairs(std::vector<coord_def> &st) { for (rectangle_iterator ri(1); ri; ++ri) { - const dungeon_feature_type grid = grd(*ri); + const dungeon_feature_type feat = grd(*ri); const int envc = env.map(*ri).object; if ((*ri == you.pos() || envc) - && is_travelable_stair(grid) + && feat_is_travelable_stair(feat) && (is_terrain_seen(*ri) || !is_branch_stair(*ri))) { st.push_back(*ri); @@ -4282,26 +4154,26 @@ bool explore_discoveries::merge_feature( } void explore_discoveries::found_feature(const coord_def &pos, - dungeon_feature_type grid) + dungeon_feature_type feat) { - if (grid == DNGN_ENTER_SHOP && ES_shop) + if (feat == DNGN_ENTER_SHOP && ES_shop) { - shops.push_back( named_thing<int>( shop_name(pos), grid ) ); + shops.push_back(named_thing<int>( shop_name(pos), feat)); es_flags |= ES_SHOP; } - else if (is_stair(grid) && ES_stair) + else if (feat_is_stair(feat) && ES_stair) { const named_thing<int> stair(cleaned_feature_description(pos), 1); add_stair(stair); es_flags |= ES_STAIR; } - else if (feat_is_portal(grid) && ES_portal) + else if (feat_is_portal(feat) && ES_portal) { const named_thing<int> portal(cleaned_feature_description(pos), 1); add_stair(portal); es_flags |= ES_PORTAL; } - else if (is_altar(grid) + else if (feat_is_altar(feat) && ES_altar && !player_in_branch(BRANCH_ECUMENICAL_TEMPLE)) { diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h index 8ce242e5e1..9c72237ab8 100644 --- a/crawl-ref/source/travel.h +++ b/crawl-ref/source/travel.h @@ -66,19 +66,14 @@ void clear_excludes(); unsigned char is_waypoint(const coord_def &p); bool is_exclude_root(const coord_def &p); -bool is_stair(dungeon_feature_type feat); -bool is_travelable_stair(dungeon_feature_type feat); -bool is_escape_hatch(dungeon_feature_type feat); -bool is_gate(dungeon_feature_type feat); command_type direction_to_command(char x, char y); -bool is_altar(dungeon_feature_type feat); bool is_resting(void); #ifdef CLUA_BINDINGS const char *trap_name(const coord_def &p); #endif -bool is_traversable(dungeon_feature_type feat); void explore_pickup_event(int did_pickup, int tried_pickup); bool is_excluded(const coord_def &p); +bool feat_is_traversable(dungeon_feature_type feat); void find_travel_pos(const coord_def& youpos, char *move_x, char *move_y, std::vector<coord_def>* coords = NULL); diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc index 354e81c92c..37ecb261ea 100644 --- a/crawl-ref/source/tutorial.cc +++ b/crawl-ref/source/tutorial.cc @@ -4220,7 +4220,7 @@ static void _tutorial_describe_feature(int x, int y) "<w>Shift</w>. "; #endif - if (is_travelable_stair(feat) && !travel_cache.know_stair(where)) + if (feat_is_travelable_stair(feat) && !travel_cache.know_stair(where)) { ostr << "\n\nYou have not yet passed through this particular " "set of stairs. "; @@ -4253,7 +4253,7 @@ static void _tutorial_describe_feature(int x, int y) "clicking the <w>left mouse button</w> while pressing " "<w>Shift</w> instead. "; #endif - if (is_travelable_stair(feat) + if (feat_is_travelable_stair(feat) && !travel_cache.know_stair(where)) { ostr << "\n\nYou have not yet passed through this " diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index bc34ea8ce1..6192c0a620 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -398,7 +398,7 @@ static int _view_emphasised_colour(const coord_def& where, dungeon_feature_type feat, int oldcolour, int newcolour) { - if (is_travelable_stair(feat) && !travel_cache.know_stair(where)) + if (feat_is_travelable_stair(feat) && !travel_cache.know_stair(where)) { if ((you.your_level || feat_stair_direction(feat) == CMD_GO_DOWNSTAIRS) && you.where_are_you != BRANCH_VESTIBULE_OF_HELL) @@ -1587,15 +1587,15 @@ inline static void _update_item_grid(const coord_def &gp, const coord_def &ep) const item_def &eitem = mitm[igrd(gp)]; unsigned short &ecol = env.show_col(ep); - const dungeon_feature_type grid = grd(gp); - if (Options.feature_item_brand && is_critical_feature(grid)) + const dungeon_feature_type feat = grd(gp); + if (Options.feature_item_brand && is_critical_feature(feat)) ecol |= COLFLAG_FEATURE_ITEM; - else if (Options.trap_item_brand && feat_is_trap(grid)) + else if (Options.trap_item_brand && feat_is_trap(feat)) ecol |= COLFLAG_TRAP_ITEM; else { const unsigned short gcol = env.grid_colours(gp); - ecol = (grid == DNGN_SHALLOW_WATER) ? + ecol = (feat == DNGN_SHALLOW_WATER) ? (gcol != BLACK ? gcol : CYAN) : eitem.colour; if (eitem.link != NON_ITEM && !crawl_state.arena) ecol |= COLFLAG_ITEM_HEAP; @@ -1604,7 +1604,7 @@ inline static void _update_item_grid(const coord_def &gp, const coord_def &ep) #ifdef USE_TILE int idx = igrd(gp); - if (is_stair(grid)) + if (feat_is_stair(feat)) tile_place_item_marker(ep.x, ep.y, idx); else tile_place_item(ep.x, ep.y, idx); |