summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-17 14:16:52 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-17 14:16:52 +0000
commita9a5ce7479fc6358f96aadad9654d35f2a573782 (patch)
treec1c30d02f940fc10fd80f729ce712fe0fee8fc07 /crawl-ref/source
parent3893b36195d2345f1a24a42fd5ed31cd72a8f501 (diff)
downloadcrawl-ref-a9a5ce7479fc6358f96aadad9654d35f2a573782.tar.gz
crawl-ref-a9a5ce7479fc6358f96aadad9654d35f2a573782.zip
x on the level-map changes travel exclusion radius. Radius steps are 1, 4 and
8. Travel cache version also changes. [1738213] describe_floor() now uses feature_description instead of rolling its own. This does produce redundant messages when stepping into shallow water, but I think we can live with that. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1591 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/command.cc1
-rw-r--r--crawl-ref/source/direct.cc48
-rw-r--r--crawl-ref/source/direct.h2
-rw-r--r--crawl-ref/source/items.cc191
-rw-r--r--crawl-ref/source/travel.cc152
-rw-r--r--crawl-ref/source/travel.h25
-rw-r--r--crawl-ref/source/view.cc52
-rw-r--r--crawl-ref/source/view.h1
8 files changed, 194 insertions, 278 deletions
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index 97701a0d71..2ed5176f77 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -529,6 +529,7 @@ static const char *level_map_help =
"<w>^</w> : cycle through traps\n"
"<w>Tab</w> : cycle through shops and portals\n"
"<w>X</w> : cycle through travel eXclusions\n"
+ "<w>x</w> : change the radius of a travel exclusion\n"
"<w>W</w> : cycle through waypoints\n"
"<w>*</w> : cycle forward through stashes\n"
"<w>/</w> : cycle backward through stashes\n"
diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc
index 16aa831cf4..62a445b2fa 100644
--- a/crawl-ref/source/direct.cc
+++ b/crawl-ref/source/direct.cc
@@ -1207,6 +1207,39 @@ std::vector<dungeon_feature_type> features_by_desc(const text_pattern &pattern)
return (features);
}
+void describe_floor()
+{
+ const int grid = grd(you.pos());
+
+ std::string prefix = "There is ";
+ std::string feat;
+ std::string suffix = " here.";
+ switch (grid)
+ {
+ case DNGN_FLOOR:
+ return;
+
+ case DNGN_ENTER_SHOP:
+ prefix = "There is an entrance to ";
+ break;
+
+ default:
+ break;
+ }
+
+ feat = feature_description(you.x_pos, you.y_pos);
+ if (feat.empty())
+ return;
+ if (grid != DNGN_ENTER_SHOP)
+ feat[0] = tolower(feat[0]);
+ if (ends_with(feat, "."))
+ feat = feat.substr(0, feat.length() - 1);
+
+ mpr((prefix + feat + suffix).c_str());
+ if (grid == DNGN_ENTER_LABYRINTH)
+ mpr("Beware, for starvation awaits!");
+}
+
std::string feature_description(int grid)
{
switch (grid)
@@ -1285,7 +1318,7 @@ std::string feature_description(int grid)
case DNGN_ENTER_TARTARUS:
return ("A gateway to the decaying netherworld of Tartarus.");
case DNGN_ENTER_ABYSS:
- return ("A gateway to the infinite Abyss.");
+ return ("A one-way gate to the infinite horrors of the Abyss.");
case DNGN_EXIT_ABYSS:
return ("A gateway leading out of the Abyss.");
case DNGN_STONE_ARCH:
@@ -1390,15 +1423,14 @@ std::string feature_description(int grid)
std::string feature_description(int mx, int my)
{
- int trf; // used for trap type??
-
const int grid = grd[mx][my];
- std::string desc = feature_description(grid);
switch (grid)
{
case DNGN_TRAP_MECHANICAL:
case DNGN_TRAP_MAGICAL:
case DNGN_TRAP_III:
+ {
+ int trf;
for (trf = 0; trf < MAX_TRAPS; trf++)
{
if (env.trap[trf].x == mx
@@ -1438,17 +1470,15 @@ std::string feature_description(int mx, int my)
case TRAP_NEEDLE:
return ("A needle trap.");
default:
- mpr("An undefined trap. Huh?");
error_message_to_player();
- break;
+ return ("An undefined trap.");
}
- break;
+ }
case DNGN_ENTER_SHOP:
return (shop_name(mx, my));
default:
- break;
+ return (feature_description(grid));
}
- return (desc);
}
static void describe_mons_enchantment(const monsters &mons,
diff --git a/crawl-ref/source/direct.h b/crawl-ref/source/direct.h
index 973000e8de..c2f808d3a8 100644
--- a/crawl-ref/source/direct.h
+++ b/crawl-ref/source/direct.h
@@ -33,6 +33,8 @@ bool in_los(int x, int y);
bool in_vlos(int x, int y);
bool in_vlos(const coord_def &pos);
+void describe_floor();
+
int dos_direction_unmunge(int doskey);
std::string feature_description(int mx, int my);
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index e970be60a1..00df6398ee 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -37,6 +37,7 @@
#include "cloud.h"
#include "debug.h"
#include "delay.h"
+#include "direct.h"
#include "effects.h"
#include "hiscores.h"
#include "invent.h"
@@ -512,196 +513,6 @@ void destroy_item_stack( int x, int y )
}
}
-static void describe_floor() {
-
- const int grid = grd[you.x_pos][you.y_pos];
-
- if (grid >= DNGN_ENTER_HELL && grid <= DNGN_PERMADRY_FOUNTAIN)
- {
- if (grid >= DNGN_STONE_STAIRS_DOWN_I && grid <= DNGN_ROCK_STAIRS_DOWN)
- {
- mprf("There is a %s staircase leading down here.",
- (grid == DNGN_ROCK_STAIRS_DOWN) ? "rock" : "stone" );
- }
- else if (grid >= DNGN_STONE_STAIRS_UP_I && grid <= DNGN_ROCK_STAIRS_UP)
- {
- mprf("There is a %s staircase leading upwards here.",
- (grid == DNGN_ROCK_STAIRS_UP) ? "rock" : "stone" );
- }
- else
- {
- switch (grid)
- {
- case DNGN_ENTER_HELL:
- mpr("There is a gateway to Hell here.");
- break;
- case DNGN_ENTER_GEHENNA:
- mpr("There is a gateway to Gehenna here.");
- break;
- case DNGN_ENTER_COCYTUS:
- mpr("There is a gateway to the frozen wastes of Cocytus here.");
- break;
- case DNGN_ENTER_TARTARUS:
- mpr("There is a gateway to Tartarus here.");
- break;
- case DNGN_ENTER_DIS:
- mpr("There is a gateway to the Iron City of Dis here.");
- break;
- case DNGN_ENTER_SHOP:
- mprf("There is an entrance to %s here.",
- shop_name(you.x_pos, you.y_pos));
- break;
- case DNGN_ENTER_LABYRINTH:
- mpr("There is an entrance to a labyrinth here.");
- mpr("Beware, for starvation awaits!");
- break;
- case DNGN_ENTER_ABYSS:
- mpr("There is a one-way gate to the infinite horrors of the Abyss here.");
- break;
- case DNGN_STONE_ARCH:
- mpr("There is an empty stone archway here.");
- break;
- case DNGN_EXIT_ABYSS:
- mpr("There is a gateway leading out of the Abyss here.");
- break;
- case DNGN_ENTER_PANDEMONIUM:
- mpr("There is a gate leading to the halls of Pandemonium here.");
- break;
- case DNGN_EXIT_PANDEMONIUM:
- mpr("There is a gate leading out of Pandemonium here.");
- break;
- case DNGN_TRANSIT_PANDEMONIUM:
- mpr("There is a gate leading to another region of Pandemonium here.");
- break;
- case DNGN_ENTER_ORCISH_MINES:
- mpr("There is a staircase to the Orcish Mines here.");
- break;
- case DNGN_ENTER_HIVE:
- mpr("There is a staircase to the Hive here.");
- break;
- case DNGN_ENTER_LAIR:
- mpr("There is a staircase to the Lair here.");
- break;
- case DNGN_ENTER_SLIME_PITS:
- mpr("There is a staircase to the Slime Pits here.");
- break;
- case DNGN_ENTER_VAULTS:
- mpr("There is a staircase to the Vaults here.");
- break;
- case DNGN_ENTER_CRYPT:
- mpr("There is a staircase to the Crypt here.");
- break;
- case DNGN_ENTER_HALL_OF_BLADES:
- mpr("There is a staircase to the Hall of Blades here.");
- break;
- case DNGN_ENTER_ZOT:
- mpr("There is a gate to the Realm of Zot here.");
- break;
- case DNGN_ENTER_TEMPLE:
- mpr("There is a staircase to the Ecumenical Temple here.");
- break;
- case DNGN_ENTER_SNAKE_PIT:
- mpr("There is a staircase to the Snake Pit here.");
- break;
- case DNGN_ENTER_ELVEN_HALLS:
- mpr("There is a staircase to the Elven Halls here.");
- break;
- case DNGN_ENTER_TOMB:
- mpr("There is a staircase to the Tomb here.");
- break;
- case DNGN_ENTER_SWAMP:
- mpr("There is a staircase to the Swamp here.");
- break;
- case DNGN_ENTER_SHOALS:
- mpr("There is a staircase to the Shoals here.");
- break;
- case DNGN_RETURN_FROM_ORCISH_MINES:
- case DNGN_RETURN_FROM_HIVE:
- case DNGN_RETURN_FROM_LAIR:
- case DNGN_RETURN_FROM_VAULTS:
- case DNGN_RETURN_FROM_TEMPLE:
- mpr("There is a staircase back to the Dungeon here.");
- break;
- case DNGN_RETURN_FROM_SLIME_PITS:
- case DNGN_RETURN_FROM_SNAKE_PIT:
- case DNGN_RETURN_FROM_SWAMP:
- case DNGN_RETURN_FROM_SHOALS:
- mpr("There is a staircase back to the Lair here.");
- break;
- case DNGN_RETURN_FROM_CRYPT:
- case DNGN_RETURN_FROM_HALL_OF_BLADES:
- mpr("There is a staircase back to the Vaults here.");
- break;
- case DNGN_RETURN_FROM_TOMB:
- mpr("There is a staircase back to the Crypt here.");
- break;
- case DNGN_RETURN_FROM_ELVEN_HALLS:
- mpr("There is a staircase back to the Mines here.");
- break;
- case DNGN_RETURN_FROM_ZOT:
- mpr("There is a gate leading back out of this place here.");
- break;
- case DNGN_ALTAR_ZIN:
- mpr("There is a glowing white marble altar of Zin here.");
- break;
- case DNGN_ALTAR_SHINING_ONE:
- mpr("There is a glowing golden altar of the Shining One here.");
- break;
- case DNGN_ALTAR_KIKUBAAQUDGHA:
- mpr("There is an ancient bone altar of Kikubaaqudgha here.");
- break;
- case DNGN_ALTAR_YREDELEMNUL:
- mpr("There is a basalt altar of Yredelemnul here.");
- break;
- case DNGN_ALTAR_XOM:
- mpr("There is a shimmering altar of Xom here.");
- break;
- case DNGN_ALTAR_VEHUMET:
- mpr("There is a shining altar of Vehumet here.");
- break;
- case DNGN_ALTAR_OKAWARU:
- mpr("There is an iron altar of Okawaru here.");
- break;
- case DNGN_ALTAR_MAKHLEB:
- mpr("There is a burning altar of Makhleb here.");
- break;
- case DNGN_ALTAR_SIF_MUNA:
- mpr("There is a deep blue altar of Sif Muna here.");
- break;
- case DNGN_ALTAR_TROG:
- mpr("There is a bloodstained altar of Trog here.");
- break;
- case DNGN_ALTAR_NEMELEX_XOBEH:
- mpr("There is a sparkling altar of Nemelex Xobeh here.");
- break;
- case DNGN_ALTAR_ELYVILON:
- mpr("There is a silver altar of Elyvilon here.");
- break;
- case DNGN_ALTAR_LUGONU:
- mpr("There is a corrupted altar of Lugonu here.");
- break;
- case DNGN_ALTAR_BEOGH:
- mpr("There is a roughly hewn altar of Beogh here.");
- break;
- case DNGN_BLUE_FOUNTAIN:
- mpr("There is a fountain here (q to drink).");
- break;
- case DNGN_SPARKLING_FOUNTAIN:
- mpr("There is a sparkling fountain here (q to drink).");
- break;
- case DNGN_DRY_FOUNTAIN_I:
- case DNGN_DRY_FOUNTAIN_II:
- case DNGN_DRY_FOUNTAIN_IV:
- case DNGN_DRY_FOUNTAIN_VI:
- case DNGN_DRY_FOUNTAIN_VIII:
- case DNGN_PERMADRY_FOUNTAIN:
- mpr("There is a dry fountain here.");
- break;
- }
- }
- }
-}
-
static bool invisible_to_player( const item_def& item ) {
return strstr(item.inscription.c_str(), "=k") != 0;
}
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index 196d897c61..3b5e5ac569 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -42,7 +42,7 @@
#endif
#define TC_MAJOR_VERSION ((unsigned char) 4)
-#define TC_MINOR_VERSION ((unsigned char) 6)
+#define TC_MINOR_VERSION ((unsigned char) 7)
enum IntertravelDestination
{
@@ -66,7 +66,7 @@ TravelCache travel_cache;
static std::vector<stair_info> curr_stairs;
// Squares that are not safe to travel to on the current level.
-static std::vector<coord_def> curr_excludes;
+static std::vector<travel_exclude> curr_excludes;
// This is where we last tried to take a stair during interlevel travel.
// Note that last_stair.depth should be set to -1 before initiating interlevel
@@ -185,44 +185,40 @@ static const char *trap_name(int x, int y)
/*
* Returns true if the character can cross this dungeon feature.
*/
-inline bool is_traversable(unsigned char grid)
+inline bool is_traversable(int grid)
{
- return traversable_terrain[(int) grid] == TRAVERSABLE;
+ return traversable_terrain[grid] == TRAVERSABLE;
}
-static bool is_excluded(int x, int y, const std::vector<coord_def> &exc)
+static bool is_excluded(const coord_def &p,
+ const std::vector<travel_exclude> &exc)
{
for (int i = 0, count = exc.size(); i < count; ++i)
{
- const coord_def &c = exc[i];
- int dx = c.x - x,
- dy = c.y - y;
- if (dx * dx + dy * dy <= Options.travel_exclude_radius2)
- return true;
+ if ((exc[i].pos - p).abs() < exc[i].radius_sq())
+ return (true);
}
- return false;
-}
-
-inline static bool is_excluded(const coord_def &c,
- const std::vector<coord_def> &exc)
-{
- return is_excluded(c.x, c.y, exc);
+ return (false);
}
-inline static bool is_excluded(int x, int y)
+inline static bool is_excluded(const coord_def &p)
{
- return is_excluded(x, y, curr_excludes);
+ return is_excluded(p, curr_excludes);
}
-static bool is_exclude_root(int x, int y)
+static travel_exclude *find_exclude_root(const coord_def &p)
{
for (int i = 0, count = curr_excludes.size(); i < count; ++i)
{
- const coord_def &c = curr_excludes[i];
- if (c.x == x && c.y == y)
- return true;
+ if (curr_excludes[i].pos == p)
+ return (&curr_excludes[i]);
}
- return false;
+ return (NULL);
+}
+
+bool is_exclude_root(const coord_def &p)
+{
+ return (find_exclude_root(p));
}
const char *run_mode_name(int runmode)
@@ -266,34 +262,70 @@ void clear_excludes()
}
}
-void toggle_exclude(int x, int y)
+void cycle_exclude_radius(const coord_def &p)
{
- // Sanity checks
+ if (travel_exclude *exc = find_exclude_root(p))
+ {
+ int &curr_radius = exc->radius;
+
+ switch (curr_radius)
+ {
+ case LOS_RADIUS: curr_radius = 1; break;
+ case 1 : curr_radius = 4; break;
+ case 4 : curr_radius = LOS_RADIUS; break;
+ }
+
+ if (can_travel_interlevel())
+ {
+ LevelInfo &li = travel_cache.get_level_info(level_id::current());
+ li.update();
+ }
+ }
+}
+
+void toggle_exclude(const coord_def &p)
+{
+ if (is_exclude_root(p))
+ set_exclude(p, 0);
+ else
+ set_exclude(p, LOS_RADIUS);
+}
+
+void set_exclude(const coord_def &p, int radius)
+{
+ // Sanity checks; excludes can be set in Pan and regular dungeon
+ // levels only.
if (you.level_type == LEVEL_LABYRINTH || you.level_type == LEVEL_ABYSS)
return;
- if (!in_bounds(x, y))
+ if (!in_bounds(p))
return;
- if (!is_terrain_known(x, y))
+ if (!is_terrain_known(p))
return;
-
- if (is_exclude_root(x, y))
+
+ if (is_exclude_root(p))
{
for (int i = 0, count = curr_excludes.size(); i < count; ++i)
{
- const coord_def &c = curr_excludes[i];
- if (c.x == x && c.y == y)
+ if (curr_excludes[i].pos == p)
{
- curr_excludes.erase( curr_excludes.begin() + i );
- break ;
+ if (!radius)
+ {
+ curr_excludes.erase( curr_excludes.begin() + i );
+ break ;
+ }
+ else
+ {
+ curr_excludes[i].radius = radius;
+ return;
+ }
}
}
}
else
{
- const coord_def c(x, y);
- curr_excludes.push_back(c);
+ curr_excludes.push_back(travel_exclude(p, radius));
}
if (can_travel_interlevel())
@@ -325,7 +357,7 @@ static bool is_monster_blocked(int x, int y)
*/
static bool is_reseedable(int x, int y)
{
- if (is_excluded(x, y))
+ if (is_excluded(coord_def(x, y)))
return (true);
int grid = grd[x][y];
return (grid == DNGN_DEEP_WATER || grid == DNGN_SHALLOW_WATER ||
@@ -373,7 +405,7 @@ bool is_travelsafe_square(int x, int y, bool ignore_hostile,
"s", trap_name(x, y)))
#endif
)
- && !is_excluded(x, y);
+ && !is_excluded(coord_def(x, y));
}
// Returns true if the location at (x,y) is monster-free and contains no clouds.
@@ -1040,12 +1072,10 @@ command_type direction_to_command( char x, char y )
return CMD_NO_CMD;
}
-static void fill_exclude_radius(const coord_def &c)
+static void fill_exclude_radius(const travel_exclude &exc)
{
- int radius = 0;
- while (radius * radius < Options.travel_exclude_radius2)
- radius++;
-
+ const int radius = exc.radius;
+ const coord_def &c = exc.pos;
for (int y = c.y - radius; y <= c.y + radius; ++y)
{
for (int x = c.x - radius; x <= c.x + radius; ++x)
@@ -1054,9 +1084,11 @@ static void fill_exclude_radius(const coord_def &c)
|| travel_point_distance[x][y])
continue;
- if (is_exclude_root(x, y))
+ const coord_def p(x, y);
+
+ if (is_exclude_root(p))
travel_point_distance[x][y] = PD_EXCLUDED;
- else if (is_excluded(x, y))
+ else if (is_excluded(p))
travel_point_distance[x][y] = PD_EXCLUDED_RADIUS;
}
}
@@ -1301,11 +1333,11 @@ const coord_def travel_pathfind::pathfind(run_mode_type rmode)
{
for (int i = 0, size = curr_excludes.size(); i < size; ++i)
{
- const coord_def &exc = curr_excludes[i];
+ const travel_exclude &exc = curr_excludes[i];
// An exclude - wherever it is - is always a feature.
- if (std::find(features->begin(), features->end(), exc)
+ if (std::find(features->begin(), features->end(), exc.pos)
== features->end())
- features->push_back(exc);
+ features->push_back(exc.pos);
fill_exclude_radius(exc);
}
@@ -1414,7 +1446,7 @@ bool travel_pathfind::path_flood(const coord_def &c, const coord_def &dc)
&& dc != start)
{
if (features &&
- (is_trap(dc.x, dc.y) || is_exclude_root(dc.x, dc.y)))
+ (is_trap(dc.x, dc.y) || is_exclude_root(dc)))
{
features->push_back(dc);
}
@@ -1425,8 +1457,8 @@ bool travel_pathfind::path_flood(const coord_def &c, const coord_def &dc)
// Appropriate mystic number. Nobody else should check
// this number, since this square is unsafe for travel.
point_distance[dc.x][dc.y] =
- is_exclude_root(dc.x, dc.y)? PD_EXCLUDED :
- is_excluded(dc.x, dc.y) ? PD_EXCLUDED_RADIUS :
+ is_exclude_root(dc) ? PD_EXCLUDED :
+ is_excluded(dc) ? PD_EXCLUDED_RADIUS :
PD_TRAP;
}
return (false);
@@ -1451,9 +1483,9 @@ bool travel_pathfind::path_flood(const coord_def &c, const coord_def &dc)
if (ignore_hostile)
{
point_distance[dc.x][dc.y] = -point_distance[dc.x][dc.y];
- if (is_exclude_root(dc.x, dc.y))
+ if (is_exclude_root(dc))
point_distance[dc.x][dc.y] = PD_EXCLUDED;
- else if (is_excluded(dc.x, dc.y))
+ else if (is_excluded(dc))
point_distance[dc.x][dc.y] = PD_EXCLUDED_RADIUS;
}
@@ -1473,7 +1505,7 @@ bool travel_pathfind::path_flood(const coord_def &c, const coord_def &dc)
}
}
- if (features && dc != start && is_exclude_root(dc.x, dc.y))
+ if (features && dc != start && is_exclude_root(dc))
features->push_back(dc);
}
@@ -2386,7 +2418,7 @@ static bool loadlev_populate_stair_distances(const level_pos &target)
return false;
}
- std::vector<coord_def> old_excludes = curr_excludes;
+ std::vector<travel_exclude> old_excludes = curr_excludes;
curr_excludes.clear();
LevelInfo &li = travel_cache.get_level_info(target.id);
@@ -2946,8 +2978,8 @@ void LevelInfo::save(FILE *file) const
{
for (int i = 0, count = excludes.size(); i < count; ++i)
{
- writeShort(file, excludes[i].x);
- writeShort(file, excludes[i].y);
+ writeCoord(file, excludes[i].pos);
+ writeShort(file, excludes[i].radius);
}
}
}
@@ -2984,9 +3016,9 @@ void LevelInfo::load(FILE *file)
for (int i = 0; i < nexcludes; ++i)
{
coord_def c;
- c.x = readShort(file);
- c.y = readShort(file);
- excludes.push_back(c);
+ readCoord(file, c);
+ const int radius = readShort(file);
+ excludes.push_back(travel_exclude(c, radius));
}
}
}
diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h
index d6fb9c62f1..8fad985664 100644
--- a/crawl-ref/source/travel.h
+++ b/crawl-ref/source/travel.h
@@ -25,10 +25,13 @@
void initialise_travel();
void stop_running(void);
void travel_init_new_level();
-void toggle_exclude(int x, int y);
+void cycle_exclude_radius(const coord_def &p);
+void toggle_exclude(const coord_def &p);
+void set_exclude(const coord_def &p, int radius2);
void clear_excludes();
unsigned char is_waypoint(int x, int y);
void update_excludes();
+bool is_exclude_root(const coord_def &p);
bool is_stair(unsigned gridc);
bool is_travelable_stair(unsigned gridc);
command_type stair_direction(int stair_feat);
@@ -319,6 +322,22 @@ struct stair_info
void load(FILE *);
};
+struct travel_exclude
+{
+ coord_def pos;
+ int radius;
+
+ travel_exclude(const coord_def &p, int r = LOS_RADIUS)
+ : pos(p), radius(r)
+ {
+ }
+
+ int radius_sq() const
+ {
+ return (radius * radius * 17 / 16);
+ }
+};
+
// Information on a level that interlevel travel needs.
struct LevelInfo
{
@@ -341,7 +360,7 @@ struct LevelInfo
void reset_distances();
void set_level_excludes();
- const std::vector<coord_def> &get_excludes() const
+ const std::vector<travel_exclude> &get_excludes() const
{
return excludes;
}
@@ -375,7 +394,7 @@ private:
std::vector<stair_info> stairs;
// Squares that are not safe to travel to.
- std::vector<coord_def> excludes;
+ std::vector<travel_exclude> excludes;
std::vector<short> stair_distances; // Dist between stairs
level_id id;
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index acb938359a..9a0044dfea 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -190,8 +190,12 @@ int get_envmap_col(int x, int y)
bool is_terrain_known( int x, int y )
{
- return (env.map[x][y].flags
- & (MAP_MAGIC_MAPPED_FLAG | MAP_SEEN_FLAG));
+ return (env.map[x][y].known());
+}
+
+bool is_terrain_known(const coord_def &p)
+{
+ return (env.map(p).known());
}
bool is_terrain_seen( int x, int y )
@@ -2493,6 +2497,15 @@ static void draw_level_map(int start_x, int start_y, bool travel_mode)
update_screen();
}
+static void reset_travel_colours(std::vector<coord_def> &features)
+{
+ // We now need to redo travel colours
+ features.clear();
+ find_travel_pos(you.x_pos, you.y_pos, NULL, NULL, &features);
+ // Sort features into the order the player is likely to prefer.
+ arrange_features(features);
+}
+
// show_map() now centers the known map along x or y. This prevents
// the player from getting "artificial" location clues by using the
// map to see how close to the end they are. They'll need to explore
@@ -2616,24 +2629,31 @@ void show_map( FixedVector<int, 2> &spec_place, bool travel_mode )
arrange_features(features);
move_x = move_y = 0;
break;
+
+ // Cycle the radius of an exclude.
+ case 'x':
+ {
+ const coord_def p(start_x + curs_x - 1, start_y + curs_y - 1);
+ if (is_exclude_root(p))
+ cycle_exclude_radius(p);
+ reset_travel_colours(features);
+ move_x = move_y = 0;
+ break;
+ }
+
case CONTROL('E'):
case CONTROL('X'):
- {
- int x = start_x + curs_x - 1, y = start_y + curs_y - 1;
- if (getty == CONTROL('X'))
- toggle_exclude(x, y);
- else
- clear_excludes();
-
- // We now need to redo travel colours
- features.clear();
- find_travel_pos(you.x_pos, you.y_pos, NULL, NULL, &features);
- // Sort features into the order the player is likely to prefer.
- arrange_features(features);
+ {
+ int x = start_x + curs_x - 1, y = start_y + curs_y - 1;
+ if (getty == CONTROL('X'))
+ toggle_exclude(coord_def(x, y));
+ else
+ clear_excludes();
- move_x = move_y = 0;
- }
+ reset_travel_colours(features);
+ move_x = move_y = 0;
break;
+ }
case 'b':
case '1':
diff --git a/crawl-ref/source/view.h b/crawl-ref/source/view.h
index 8bf9e79237..3a47f8adac 100644
--- a/crawl-ref/source/view.h
+++ b/crawl-ref/source/view.h
@@ -139,6 +139,7 @@ void set_terrain_seen( int x, int y );
bool is_terrain_known( int x, int y );
bool is_terrain_seen( int x, int y );
bool is_terrain_changed( int x, int y );
+bool is_terrain_known(const coord_def &p);
inline bool is_terrain_seen(const coord_def &c)
{