From 54945881c3da9d5610da4e29a62c2ab0c788d60b Mon Sep 17 00:00:00 2001 From: pauldubois Date: Mon, 17 Mar 2008 11:40:33 +0000 Subject: 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 --- crawl-ref/source/player.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'crawl-ref/source/player.cc') 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); } -- cgit v1.2.3-54-g00ecf