diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-22 01:22:34 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-22 01:22:34 +0000 |
commit | a6fa467deec581b1f0c1392e2658c7072c1a994d (patch) | |
tree | 7f0213abf52fb50724c2a614a5c31f0117afe1d7 /crawl-ref | |
parent | df61a8134cdf7f61511315b8e2a6b537858fc330 (diff) | |
download | crawl-ref-a6fa467deec581b1f0c1392e2658c7072c1a994d.tar.gz crawl-ref-a6fa467deec581b1f0c1392e2658c7072c1a994d.zip |
Let a level_id be directly compared to a branch type with == and != to
determine if a level_id is (not) in BRANCH_FOO; takes care of comparing
level_type to LEVEL_DUNGEON.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6034 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/misc.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/monplace.cc | 9 | ||||
-rw-r--r-- | crawl-ref/source/overmap.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/traps.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/travel.h | 11 |
5 files changed, 20 insertions, 13 deletions
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index b6851642de..c975143f50 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -1699,8 +1699,8 @@ void up_stairs(dungeon_feature_type force_stair, // to Hell as shortcuts between dungeon levels, which won't work, // and will confuse the dickens out of the player (well, it confused // the dickens out of me when it happened). - if (new_level_id.branch == BRANCH_MAIN_DUNGEON - && old_level_id.branch == BRANCH_VESTIBULE_OF_HELL) + if (new_level_id == BRANCH_MAIN_DUNGEON + && old_level_id == BRANCH_VESTIBULE_OF_HELL) { lp.id.depth = -1; lp.pos.x = lp.pos.y = -1; @@ -1713,7 +1713,7 @@ void up_stairs(dungeon_feature_type force_stair, // and that we can descend that downstair and get back to where we // came from. This assumption is guaranteed false when climbing out // of one of the branches of Hell. - if (new_level_id.branch != BRANCH_VESTIBULE_OF_HELL) + if (new_level_id != BRANCH_VESTIBULE_OF_HELL) { // Set the new level's stair, assuming arbitrarily that going // downstairs will land you on the same upstairs you took to diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index 01eb5d962c..7bbe489f2d 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -272,13 +272,13 @@ monster_type pick_random_monster(const level_id &place, lev_mons = power; - if (place.branch == BRANCH_MAIN_DUNGEON + if (place == BRANCH_MAIN_DUNGEON && lev_mons != 51 && one_chance_in(4)) { lev_mons = random2(power); } - if (place.branch == BRANCH_MAIN_DUNGEON + if (place == BRANCH_MAIN_DUNGEON && lev_mons < 28) { // If on D:1, allow moderately out-of-depth monsters only after @@ -485,11 +485,8 @@ static monster_type _resolve_monster_type(monster_type mon_type, } } // end proximity check - if (place.branch == BRANCH_HALL_OF_BLADES - && place.level_type == LEVEL_DUNGEON) - { + if (place == BRANCH_HALL_OF_BLADES) mon_type = MONS_DANCING_WEAPON; - } else { // Now pick a monster of the given branch and level. diff --git a/crawl-ref/source/overmap.cc b/crawl-ref/source/overmap.cc index b7968ea31f..deda426c5e 100644 --- a/crawl-ref/source/overmap.cc +++ b/crawl-ref/source/overmap.cc @@ -151,7 +151,7 @@ static altar_map_type get_notable_altars(const altar_map_type &altars) for ( altar_map_type::const_iterator na_iter = altars.begin(); na_iter != altars.end(); ++na_iter ) { - if (na_iter->first.id.branch != BRANCH_ECUMENICAL_TEMPLE) + if (na_iter->first.id != BRANCH_ECUMENICAL_TEMPLE) notable_altars[na_iter->first] = na_iter->second; } return (notable_altars); diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index f2e2144a7a..e28d838b0b 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -1003,7 +1003,7 @@ bool is_valid_shaft_level(const level_id &place) return (false); // Disallow shafts on the first two levels. - if (place.branch == BRANCH_MAIN_DUNGEON + if (place == BRANCH_MAIN_DUNGEON && you.your_level < 2) { return (false); @@ -1196,8 +1196,7 @@ static trap_type random_trap_default(int level_number, const level_id &place) type = TRAP_BLADE; if (random2(1 + level_number) > 14 && one_chance_in(3) - || (place.branch == BRANCH_HALL_OF_ZOT - && place.level_type == LEVEL_DUNGEON && coinflip())) + || (place == BRANCH_HALL_OF_ZOT && coinflip())) { type = TRAP_ZOT; } diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h index d657cbb21a..8f42f83cac 100644 --- a/crawl-ref/source/travel.h +++ b/crawl-ref/source/travel.h @@ -258,6 +258,17 @@ public: return (branch < id.branch) || (branch==id.branch && depth < id.depth); } + bool operator == ( const branch_type _branch ) const + { + return (branch == _branch && level_type == LEVEL_DUNGEON); + } + + bool operator != ( const branch_type _branch ) const + { + return !operator == (_branch); + } + + int absdepth() const; void save(writer&) const; |