summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/acr.cc55
-rw-r--r--crawl-ref/source/direct.cc11
-rw-r--r--crawl-ref/source/monstuff.cc9
-rw-r--r--crawl-ref/source/terrain.cc31
-rw-r--r--crawl-ref/source/terrain.h4
5 files changed, 69 insertions, 41 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index b52b08b403..950925d330 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -3440,9 +3440,16 @@ static void open_door(int move_x, int move_y, bool check_confused)
dx = you.x_pos + door_move.dx;
dy = you.y_pos + door_move.dy;
- if (!in_bounds(dx, dy) || grd[dx][dy] != DNGN_CLOSED_DOOR)
+ const dungeon_feature_type feat =
+ in_bounds(dx, dy) ? grd[dx][dy] : DNGN_UNSEEN;
+ if (feat != DNGN_CLOSED_DOOR)
{
- mpr( "There's no door there." );
+ switch (feat) {
+ case DNGN_OPEN_DOOR:
+ mpr("It's already open!"); break;
+ default:
+ mpr("There isn't anything that you can open there!"); break;
+ }
// Don't lose a turn.
return;
}
@@ -3451,31 +3458,34 @@ static void open_door(int move_x, int move_y, bool check_confused)
if (grd[dx][dy] == DNGN_CLOSED_DOOR)
{
std::set<coord_def> all_door;
- _find_connected_identical(coord_def(dx,dy), grd[dx][dy], all_door);
- const char* noun = get_door_noun(all_door.size()).c_str();
+ find_connected_identical(coord_def(dx,dy), grd[dx][dy], all_door);
+ const char *adj, *noun;
+ get_door_description(all_door.size(), &adj, &noun);
int skill = you.dex + (you.skills[SK_TRAPS_DOORS] + you.skills[SK_STEALTH]) / 2;
if (you.duration[DUR_BERSERKER])
{
+ // XXX: better flavor for larger doors?
if (silenced(you.x_pos, you.y_pos))
- mprf("The %s flies open!", noun);
+ {
+ mprf("The %s%s flies open!", adj, noun);
+ }
else
{
- // XXX: better flavor for gateways?
- mprf("The %s flies open with a bang!", noun);
+ mprf("The %s%s flies open with a bang!", adj, noun);
noisy( 15, you.x_pos, you.y_pos );
}
}
else if (one_chance_in(skill) && !silenced(you.x_pos, you.y_pos))
{
- mprf( "As you open the %s, it creaks loudly!", noun );
+ mprf( "As you open the %s%s, it creaks loudly!", adj, noun );
noisy( 10, you.x_pos, you.y_pos );
}
else
{
const char* verb = player_is_airborne() ? "reach down and open" : "open";
- mprf( "You %s the %s.", verb, noun );
+ mprf( "You %s the %s%s.", verb, adj, noun );
}
for (std::set<coord_def>::iterator i = all_door.begin();
@@ -3524,11 +3534,14 @@ static void close_door(int door_x, int door_y)
dx = you.x_pos + door_move.dx;
dy = you.y_pos + door_move.dy;
- if (grd[dx][dy] == DNGN_OPEN_DOOR)
+ const dungeon_feature_type feat =
+ in_bounds(dx, dy) ? grd[dx][dy] : DNGN_UNSEEN;
+ if (feat == DNGN_OPEN_DOOR)
{
std::set<coord_def> all_door;
- _find_connected_identical(coord_def(dx,dy), grd[dx][dy], all_door);
- const char* noun = get_door_noun(all_door.size()).c_str();
+ find_connected_identical(coord_def(dx,dy), grd[dx][dy], all_door);
+ const char *adj, *noun;
+ get_door_description(all_door.size(), &adj, &noun);
const coord_def you_coord(you.x_pos, you.y_pos);
for (std::set<coord_def>::iterator i = all_door.begin();
@@ -3565,22 +3578,24 @@ static void close_door(int door_x, int door_y)
if (you.duration[DUR_BERSERKER])
{
if (silenced(you.x_pos, you.y_pos))
- mprf("You slam the %s shut!", noun);
+ {
+ mprf("You slam the %s%s shut!", adj, noun);
+ }
else
{
- mprf("You slam the %s shut with an echoing bang!", noun);
+ mprf("You slam the %s%s shut with an echoing bang!", adj, noun);
noisy( 25, you.x_pos, you.y_pos );
}
}
else if (one_chance_in(skill) && !silenced(you.x_pos, you.y_pos))
{
- mprf("As you close the %s, it creaks loudly!", noun);
+ mprf("As you close the %s%s, it creaks loudly!", adj, noun);
noisy( 10, you.x_pos, you.y_pos );
}
else
{
const char* verb = player_is_airborne() ? "reach down and close" : "close";
- mprf( "You %s the %s.", verb, noun );
+ mprf( "You %s the %s%s.", verb, adj, noun );
}
for (std::set<coord_def>::iterator i = all_door.begin();
@@ -3593,7 +3608,13 @@ static void close_door(int door_x, int door_y)
}
else
{
- mpr("There isn't anything that you can close there!");
+ switch (feat)
+ {
+ case DNGN_CLOSED_DOOR:
+ mpr("It's already closed!"); break;
+ default:
+ mpr("There isn't anything that you can close there!"); break;
+ }
}
} // end open_door()
diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc
index 73c204f1b6..76b6fc40dd 100644
--- a/crawl-ref/source/direct.cc
+++ b/crawl-ref/source/direct.cc
@@ -1815,11 +1815,14 @@ std::string feature_description(int mx, int my, bool bloody,
if ( grid == DNGN_OPEN_DOOR || grid == DNGN_CLOSED_DOOR )
{
- std::string desc = (grid == DNGN_OPEN_DOOR) ? "open " : "closed ";
-
std::set<coord_def> all_door;
- _find_connected_identical(coord_def(mx, my), grd[mx][my], all_door);
- desc += get_door_noun(all_door.size()).c_str();
+ find_connected_identical(coord_def(mx, my), grd[mx][my], all_door);
+ const char *adj, *noun;
+ get_door_description(all_door.size(), &adj, &noun);
+
+ std::string desc = adj;
+ desc += (grid == DNGN_OPEN_DOOR) ? "open " : "closed ";
+ desc += noun;
if (bloody)
desc += ", spattered with blood";
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 11306b9c81..0af9e58596 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -5277,7 +5277,8 @@ static bool is_trap_safe(const monsters *monster, const int trap_x,
static void mons_open_door(monsters* monster, const coord_def &pos)
{
dungeon_feature_type grid = grd(pos);
- std::string noun = "door";
+ const char *adj, *noun="door";
+
bool was_secret = false;
if (grid == DNGN_SECRET_DOOR)
@@ -5292,8 +5293,8 @@ static void mons_open_door(monsters* monster, const coord_def &pos)
else // maybe several connected doors -> gate
{
std::set<coord_def> all_door;
- _find_connected_identical(pos, grd(pos), all_door);
- noun = get_door_noun(all_door.size()).c_str();
+ find_connected_identical(pos, grd(pos), all_door);
+ get_door_description(all_door.size(), &adj, &noun);
for (std::set<coord_def>::iterator i = all_door.begin();
i != all_door.end(); ++i)
@@ -5316,7 +5317,7 @@ static void mons_open_door(monsters* monster, const coord_def &pos)
if (!you.can_see(monster))
{
- mprf("Something unseen opens the %s.", noun.c_str());
+ mprf("Something unseen opens the %s%s.", adj, noun);
interrupt_activity(AI_FORCE_INTERRUPT);
}
}
diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc
index 4294d75d77..6dc4224162 100644
--- a/crawl-ref/source/terrain.cc
+++ b/crawl-ref/source/terrain.cc
@@ -237,29 +237,32 @@ bool grid_is_branch_stairs( dungeon_feature_type grid )
}
// Find all connected cells containing ft, starting at d.
-void _find_connected_identical(coord_def d, dungeon_feature_type ft,
+void find_connected_identical(coord_def d, dungeon_feature_type ft,
std::set<coord_def>& out)
{
if (grd[d.x][d.y] != ft) return;
if (out.insert(d).second)
{
- _find_connected_identical(coord_def(d.x+1, d.y), ft, out);
- _find_connected_identical(coord_def(d.x-1, d.y), ft, out);
- _find_connected_identical(coord_def(d.x, d.y+1), ft, out);
- _find_connected_identical(coord_def(d.x, d.y-1), ft, out);
+ find_connected_identical(coord_def(d.x+1, d.y), ft, out);
+ find_connected_identical(coord_def(d.x-1, d.y), ft, out);
+ find_connected_identical(coord_def(d.x, d.y+1), ft, out);
+ find_connected_identical(coord_def(d.x, d.y-1), ft, out);
}
}
-std::string get_door_noun(int door_count)
+void get_door_description(int door_size, const char** adjective, const char** noun)
{
- switch (door_count)
- {
- case 0: return "buggy opening";
- case 1: return "door";
- case 2: return "large door";
- case 3: return "gate";
- default: return "huge gate";
- }
+ const char* descriptions[] = {
+ "miniscule " , "buggy door",
+ "" , "door",
+ "large " , "door",
+ "" , "gate",
+ "huge " , "gate",
+ };
+
+ const unsigned int idx = MIN((unsigned int)door_size*2, ARRAYSIZE(descriptions)-2);
+ *adjective = descriptions[idx];
+ *noun = descriptions[idx+1];
}
dungeon_feature_type grid_secret_door_appearance( int gx, int gy )
diff --git a/crawl-ref/source/terrain.h b/crawl-ref/source/terrain.h
index 973c25413c..590303ab45 100644
--- a/crawl-ref/source/terrain.h
+++ b/crawl-ref/source/terrain.h
@@ -44,9 +44,9 @@ bool grid_is_watery(dungeon_feature_type grid);
god_type grid_altar_god( dungeon_feature_type grid );
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,
+void find_connected_identical(coord_def d, dungeon_feature_type ft,
std::set<coord_def>& out);
-std::string get_door_noun(int door_count);
+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 );