all at once.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3448 c06c8d41-db1a-0410-9941-cceddc491573
JEWGBHOQGDSWMLT4FZTQWUKTBJJWY5CSRAQQUOWIZ7U4QBJ6ZLBQC
// Find all connected cells containing ft, starting at d.
static 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);
}
}
mpr( player_is_airborne() ? "You reach down and open the door."
: "You open the door." );
const char* verb = player_is_airborne() ? "reach down and open" : "open";
mprf( "You %s the %s.", verb, noun );
if (mgrd[dx][dy] != NON_MONSTER)
std::set<coord_def> all_door;
_find_connected_identical(coord_def(dx,dy), grd[dx][dy], all_door);
const char* noun = (all_door.size() == 1) ? "door" : "gate";
const coord_def you_coord(you.x_pos, you.y_pos);
for (std::set<coord_def>::iterator i = all_door.begin();
i != all_door.end(); ++i)
// Need to make sure that turn_is_over is set if creature is
// invisible
mpr("There's a creature in the doorway!");
door_move.dx = 0;
door_move.dy = 0;
return;
}
const coord_def& dc = *i;
if (mgrd[dc.x][dc.y] != NON_MONSTER)
{
// Need to make sure that turn_is_over is set if creature is
// invisible
mprf("There's a creature in the %sway!", noun);
door_move.dx = 0;
door_move.dy = 0;
return;
}
if (igrd[dx][dy] != NON_ITEM)
{
mpr("There's something blocking the doorway.");
door_move.dx = 0;
door_move.dy = 0;
return;
if (igrd[dc.x][dc.y] != NON_ITEM)
{
mprf("There's something blocking the %sway.", noun);
door_move.dx = 0;
door_move.dy = 0;
return;
}
if (you_coord == dc)
{
mprf("There's a thickheaded creature in the %sway!", noun);
return;
}
mpr( player_is_airborne() ? "You reach down and close the door."
: "You close the door." );
const char* verb = player_is_airborne() ? "reach down and close" : "close";
mprf( "You %s the %s.", verb, noun );