summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-17 11:40:33 +0000
committerpauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-17 11:40:33 +0000
commit54945881c3da9d5610da4e29a62c2ab0c788d60b (patch)
tree7b0d0c29113834437a2d0a96cf73aa65a8b27824
parenteda11ccd07fd9869b193d33490d456a56649b4de (diff)
downloadcrawl-ref-54945881c3da9d5610da4e29a62c2ab0c788d60b.tar.gz
crawl-ref-54945881c3da9d5610da4e29a62c2ab0c788d60b.zip
More fixes so 1916515 doesn't happen again.
Add BRANCH_FIRST_HELL and BRANCH_LAST_HELL and check vs those in player_in_hell() rather than hard-coding the enums. Whoever did that is naughty; they should have at least stuck a comment in the branch enum. Also added some compile-checks in player_in_hell to draw attention in case the hell branches are touched. Also added some startup code that verifies the branches[] array (whose name should be changed to Branches!) is in the same order as the branches enum. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3690 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/acr.cc7
-rw-r--r--crawl-ref/source/enum.h2
-rw-r--r--crawl-ref/source/player.cc9
3 files changed, 16 insertions, 2 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index a681d16089..39657a0e58 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -4399,4 +4399,11 @@ void compile_time_asserts()
//jmf: NEW ASSERTS: we ought to do a *lot* of these
COMPILE_CHECK(NUM_SPELLS < SPELL_NO_SPELL , c7);
COMPILE_CHECK(NUM_JOBS < JOB_UNKNOWN , c8);
+
+ // Also some runtime stuff; I don't know if the order of branches[]
+ // needs to match the enum, but it currently does.
+ for (int i=0; i<NUM_BRANCHES; i++)
+ {
+ ASSERT(branches[i].id == i);
+ }
}
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index 04a0002c65..78476d2940 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -329,11 +329,13 @@ enum branch_type // you.where_are_you
BRANCH_TOMB,
BRANCH_VESTIBULE_OF_HELL,
BRANCH_DIS,
+ BRANCH_FIRST_HELL = BRANCH_DIS,
BRANCH_GEHENNA,
BRANCH_COCYTUS,
BRANCH_TARTARUS,
BRANCH_INFERNO, // unimplemented
BRANCH_THE_PIT, // unimplemented
+ BRANCH_LAST_HELL = BRANCH_THE_PIT,
BRANCH_HALL_OF_ZOT,
BRANCH_CAVERNS, // unimplemented
NUM_BRANCHES
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 28aa2d51a5..5c59b42fcc 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -372,9 +372,14 @@ bool player_in_branch( int branch )
bool player_in_hell( void )
{
+ // No real reason except to draw someone's attention here if they
+ // mess with the branch enum.
+ COMPILE_CHECK(BRANCH_FIRST_HELL == BRANCH_DIS, a);
+ COMPILE_CHECK(BRANCH_LAST_HELL == BRANCH_THE_PIT, b);
+
return (you.level_type == LEVEL_DUNGEON
- && (you.where_are_you >= BRANCH_DIS
- && you.where_are_you <= BRANCH_THE_PIT)
+ && ( you.where_are_you >= BRANCH_FIRST_HELL
+ && you.where_are_you <= BRANCH_LAST_HELL)
&& you.where_are_you != BRANCH_VESTIBULE_OF_HELL);
}