From 6d752d6fba7259fcb9dcca0566cbc1826d14d218 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Thu, 12 Jun 2008 03:03:37 +0000 Subject: Include secret doors in door-clustering (gates) when opening doors. In otherwords, if there's a line of secret doors with just one non-secret closed door among them and the non-secret door is opened, open up all the secret doors. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5744 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 15 +++++++++++++-- crawl-ref/source/terrain.cc | 15 +++++++++++++++ crawl-ref/source/terrain.h | 3 +++ 3 files changed, 31 insertions(+), 2 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index ca0a727c6a..8017232801 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -3684,7 +3684,8 @@ static void _open_door(int move_x, int move_y, bool check_confused) if (grd[dx][dy] == DNGN_CLOSED_DOOR) { std::set all_door; - find_connected_identical(coord_def(dx,dy), grd[dx][dy], all_door); + find_connected_range(coord_def(dx,dy), DNGN_CLOSED_DOOR, + DNGN_SECRET_DOOR, all_door); const char *adj, *noun; get_door_description(all_door.size(), &adj, &noun); @@ -3714,11 +3715,11 @@ static void _open_door(int move_x, int move_y, bool check_confused) mprf( "You %s the %s%s.", verb, adj, noun ); } + bool seen_secret = false; for (std::set::iterator i = all_door.begin(); i != all_door.end(); ++i) { const coord_def& dc = *i; - grd[dc.x][dc.y] = DNGN_OPEN_DOOR; // Even if some of the door is out of LOS, we want the entire // door to be updated. Hitting this case requires a really big // door! @@ -3728,7 +3729,17 @@ static void _open_door(int move_x, int move_y, bool check_confused) #ifdef USE_TILE tile_place_tile_bk(dc.x, dc.y, TILE_DNGN_OPEN_DOOR); #endif + if (!seen_secret && grd[dc.x][dc.y] == DNGN_SECRET_DOOR) + { + seen_secret = true; + dungeon_feature_type secret + = grid_secret_door_appearance(dc.x, dc.y); + mprf("That %s was a secret door!", + feature_description(secret, NUM_TRAPS, false, + DESC_PLAIN, false).c_str()); + } } + grd[dc.x][dc.y] = DNGN_OPEN_DOOR; } you.turn_is_over = true; } diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc index 2ae8d1c2d6..fd4a204617 100644 --- a/crawl-ref/source/terrain.cc +++ b/crawl-ref/source/terrain.cc @@ -244,6 +244,21 @@ void find_connected_identical(coord_def d, dungeon_feature_type ft, } } +// Find all connected cells containing ft_min to ft_max, starting at d. +void find_connected_range(coord_def d, dungeon_feature_type ft_min, + dungeon_feature_type ft_max, + std::set& out) +{ + if (grd[d.x][d.y] < ft_min || grd[d.x][d.y] > ft_max) return; + if (out.insert(d).second) + { + find_connected_range(coord_def(d.x+1, d.y), ft_min, ft_max, out); + find_connected_range(coord_def(d.x-1, d.y), ft_min, ft_max, out); + find_connected_range(coord_def(d.x, d.y+1), ft_min, ft_max, out); + find_connected_range(coord_def(d.x, d.y-1), ft_min, ft_max, out); + } +} + void get_door_description(int door_size, const char** adjective, const char** noun) { const char* descriptions[] = { diff --git a/crawl-ref/source/terrain.h b/crawl-ref/source/terrain.h index 5ab9eb8a18..b7cbf4313f 100644 --- a/crawl-ref/source/terrain.h +++ b/crawl-ref/source/terrain.h @@ -46,6 +46,9 @@ dungeon_feature_type altar_for_god( god_type god ); bool grid_is_branch_stairs( dungeon_feature_type grid ); void find_connected_identical(coord_def d, dungeon_feature_type ft, std::set& out); +void find_connected_range(coord_def d, dungeon_feature_type ft_min, + dungeon_feature_type ft_max, + std::set& out); void get_door_description(int door_size, const char** adjective, const char** noun); dungeon_feature_type grid_secret_door_appearance( int gx, int gy ); bool grid_destroys_items( dungeon_feature_type grid ); -- cgit v1.2.3-54-g00ecf