summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/abyss.cc2
-rw-r--r--crawl-ref/source/acr.cc4
-rw-r--r--crawl-ref/source/decks.cc6
-rw-r--r--crawl-ref/source/dungeon.cc2
-rw-r--r--crawl-ref/source/dungeon.h4
-rw-r--r--crawl-ref/source/misc.cc20
-rw-r--r--crawl-ref/source/player.cc5
-rw-r--r--crawl-ref/source/stuff.cc2
-rw-r--r--crawl-ref/source/terrain.cc36
-rw-r--r--crawl-ref/source/tilesdl.cc8
-rw-r--r--crawl-ref/source/travel.cc12
11 files changed, 48 insertions, 53 deletions
diff --git a/crawl-ref/source/abyss.cc b/crawl-ref/source/abyss.cc
index b5eaa2ecbb..9c51074f42 100644
--- a/crawl-ref/source/abyss.cc
+++ b/crawl-ref/source/abyss.cc
@@ -683,7 +683,7 @@ static bool _spawn_corrupted_servant_near(const coord_def &pos)
{
const coord_def p( pos.x + random2avg(4, 3) + random2(3),
pos.y + random2avg(4, 3) + random2(3) );
- if (!in_bounds(p) || p == you.pos() || mgrd(p) != NON_MONSTER
+ if (!in_bounds(p) || actor_at(p)
|| !grid_compatible(DNGN_FLOOR, grd(p)))
{
continue;
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 6d14d14ce4..4913357d35 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -3068,7 +3068,7 @@ static void _open_door(coord_def move, bool check_confused)
{
set_envmap_obj(dc, DNGN_OPEN_DOOR);
#ifdef USE_TILE
- env.tile_bk_bg[dc.x][dc.y] = TILE_DNGN_OPEN_DOOR;
+ env.tile_bk_bg(dc) = TILE_DNGN_OPEN_DOOR;
#endif
if (!seen_secret && grd(dc) == DNGN_SECRET_DOOR)
{
@@ -3234,7 +3234,7 @@ static void _close_door(coord_def move)
{
set_envmap_obj(dc, DNGN_CLOSED_DOOR);
#ifdef USE_TILE
- env.tile_bk_bg[dc.x][dc.y] = TILE_DNGN_CLOSED_DOOR;
+ env.tile_bk_bg(dc) = TILE_DNGN_CLOSED_DOOR;
#endif
}
}
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index 063d5e6122..f3a1e29f0c 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -2375,13 +2375,13 @@ static void _deepen_water(const coord_def& center, int radius)
const coord_def p = *ri;
if (grd(p) == DNGN_SHALLOW_WATER
&& p != you.pos()
- && x_chance_in_y(1+count_neighbours(p.x, p.y, DNGN_DEEP_WATER), 8))
+ && x_chance_in_y(1+count_neighbours(p, DNGN_DEEP_WATER), 8))
{
dungeon_terrain_changed(p, DNGN_DEEP_WATER);
}
if (grd(p) == DNGN_FLOOR
- && random2(3) < random2(count_neighbours(p.x,p.y,DNGN_DEEP_WATER)
- + count_neighbours(p.x,p.y,DNGN_SHALLOW_WATER)))
+ && random2(3) < random2(count_neighbours(p, DNGN_DEEP_WATER)
+ + count_neighbours(p, DNGN_SHALLOW_WATER)))
{
dungeon_terrain_changed(p, DNGN_SHALLOW_WATER);
}
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index b6218e6b6b..8bef417413 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -5061,7 +5061,7 @@ static void _replace_area( const coord_def& p1, const coord_def& p2,
{
set_envmap_obj(*ri, feature);
#ifdef USE_TILE
- env.tile_bk_bg[ri->x][ri->y] = feature;
+ env.tile_bk_bg(*ri) = feature;
#endif
}
}
diff --git a/crawl-ref/source/dungeon.h b/crawl-ref/source/dungeon.h
index e73eff36a9..00d24662b6 100644
--- a/crawl-ref/source/dungeon.h
+++ b/crawl-ref/source/dungeon.h
@@ -417,6 +417,10 @@ inline int count_feature_in_box( const coord_def& p1, const coord_def& p2,
int count_antifeature_in_box(int x0, int y0, int x1, int y1,
dungeon_feature_type feat);
int count_neighbours(int x, int y, dungeon_feature_type feat);
+inline int count_neighbours(const coord_def& p, dungeon_feature_type feat)
+{
+ return count_neighbours(p.x, p.y, feat);
+}
void remember_vault_placement(std::string key, vault_placement &place);
#endif
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index a3c77d2036..c5650baf26 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -306,32 +306,30 @@ void maybe_coagulate_blood_potions_floor(int obj)
// Now that coagulating is necessary, check square for
// !coagulated blood.
ASSERT(blood.pos.x >= 0 && blood.pos.y >= 0);
- for (int o = igrd[blood.pos.x][blood.pos.y]; o != NON_ITEM;
- o = mitm[o].link)
+ for (stack_iterator si(blood.pos); si; ++si)
{
- if (mitm[o].base_type == OBJ_POTIONS
- && mitm[o].sub_type == POT_BLOOD_COAGULATED)
+ if (si->base_type == OBJ_POTIONS
+ && si->sub_type == POT_BLOOD_COAGULATED)
{
// Merge with existing stack.
- CrawlHashTable &props2 = mitm[o].props;
+ CrawlHashTable &props2 = si->props;
if (!props2.exists("timer"))
- init_stack_blood_potions(mitm[o], mitm[o].special);
+ init_stack_blood_potions(*si, si->special);
ASSERT(props2.exists("timer"));
CrawlVector &timer2 = props2["timer"].get_vector();
- ASSERT(timer2.size() == mitm[o].quantity);
+ ASSERT(timer2.size() == si->quantity);
// Update timer -> push(pop).
- long val;
while (!age_timer.empty())
{
- val = age_timer[age_timer.size() - 1];
+ const long val = age_timer.back();
age_timer.pop_back();
timer2.push_back(val);
}
_long_sort(timer2);
- inc_mitm_item_quantity(o, coag_count);
- ASSERT(timer2.size() == mitm[o].quantity);
+ inc_mitm_item_quantity(si.link(), coag_count);
+ ASSERT(timer2.size() == si->quantity);
dec_mitm_item_quantity(obj, rot_count + coag_count);
return;
}
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 6250c86c09..146b32d571 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -2947,9 +2947,8 @@ void forget_map(unsigned char chance_forgotten, bool force)
#ifdef USE_TILE
set_envmap_obj(*ri, DNGN_UNSEEN);
tiles.update_minimap(ri->x, ri->y);
- env.tile_bk_fg[ri->x][ri->y] = 0;
- env.tile_bk_bg[ri->x][ri->y]
- = tileidx_feature(DNGN_UNSEEN, ri->x, ri->y);
+ env.tile_bk_fg(*ri) = 0;
+ env.tile_bk_bg(*ri) = tileidx_feature(DNGN_UNSEEN, ri->x, ri->y);
#endif
}
}
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index 22726b562f..a89e46192d 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -1690,7 +1690,7 @@ void zap_los_monsters()
// coord_def
int coord_def::distance_from(const coord_def &other) const
{
- return (grid_distance(x, y, other.x, other.y));
+ return (grid_distance(*this, other));
}
int integer_sqrt(int value)
diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc
index 11821e1e75..a893869834 100644
--- a/crawl-ref/source/terrain.cc
+++ b/crawl-ref/source/terrain.cc
@@ -262,16 +262,16 @@ bool grid_is_branch_stairs(dungeon_feature_type grid)
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 (grd(d) != ft)
+ return;
- std::string prop = env.markers.property_at(d, MAT_ANY,
- "connected_exclude");
+ std::string prop = env.markers.property_at(d, MAT_ANY, "connected_exclude");
if (!prop.empty())
{
// Even if this square is excluded from being a part of connected
// cells, add it if it's the starting square.
- if (out.size() == 0)
+ if (out.empty())
out.insert(d);
return;
}
@@ -290,16 +290,16 @@ void find_connected_range(coord_def d, dungeon_feature_type ft_min,
dungeon_feature_type ft_max,
std::set<coord_def>& out)
{
- if (grd[d.x][d.y] < ft_min || grd[d.x][d.y] > ft_max) return;
+ if (grd(d) < ft_min || grd(d) > ft_max)
+ return;
- std::string prop = env.markers.property_at(d, MAT_ANY,
- "connected_exclude");
+ std::string prop = env.markers.property_at(d, MAT_ANY, "connected_exclude");
if (!prop.empty())
{
// Even if this square is excluded from being a part of connected
// cells, add it if it's the starting square.
- if (out.size() == 0)
+ if (out.empty())
out.insert(d);
return;
}
@@ -603,9 +603,9 @@ void dungeon_terrain_changed(const coord_def &pos,
static void _announce_swap_real(coord_def orig_pos, coord_def dest_pos)
{
- dungeon_feature_type orig_feat = grd(dest_pos);
+ const dungeon_feature_type orig_feat = grd(dest_pos);
- std::string orig_name =
+ const std::string orig_name =
feature_description(dest_pos, false,
see_grid(orig_pos) ? DESC_CAP_THE : DESC_CAP_A,
false);
@@ -615,22 +615,18 @@ static void _announce_swap_real(coord_def orig_pos, coord_def dest_pos)
std::string orig_actor, dest_actor;
if (orig_pos == you.pos())
orig_actor = "you";
- else if (mgrd(orig_pos) != NON_MONSTER)
+ else if (const monsters *m = monster_at(orig_pos))
{
- monsters &mon(menv[mgrd(orig_pos)]);
-
- if (you.can_see(&mon))
- orig_actor = mon.name(DESC_NOCAP_THE);
+ if (you.can_see(m))
+ orig_actor = m->name(DESC_NOCAP_THE);
}
if (dest_pos == you.pos())
dest_actor = "you";
- else if (mgrd(dest_pos) != NON_MONSTER)
+ else if (const monsters *m = monster_at(dest_pos))
{
- monsters &mon(menv[mgrd(dest_pos)]);
-
- if (you.can_see(&mon))
- dest_actor = mon.name(DESC_NOCAP_THE);
+ if (you.can_see(m))
+ dest_actor = m->name(DESC_NOCAP_THE);
}
std::ostringstream str;
diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc
index b73a783b49..9a58228668 100644
--- a/crawl-ref/source/tilesdl.cc
+++ b/crawl-ref/source/tilesdl.cc
@@ -406,10 +406,10 @@ void TilesFramework::load_dungeon(const coord_def &cen)
}
else if (!crawl_view.in_grid_los(gc) || !env.show(ep))
{
- fg = env.tile_bk_fg[gc.x][gc.y];
- bg = env.tile_bk_bg[gc.x][gc.y];
+ fg = env.tile_bk_fg(gc);
+ bg = env.tile_bk_bg(gc);
if (!fg && !bg)
- tileidx_unseen(fg, bg, get_envmap_char(gc.x, gc.y), gc);
+ tileidx_unseen(fg, bg, get_envmap_char(gc), gc);
bg |= tile_unseen_flag(gc);
}
else
@@ -418,7 +418,7 @@ void TilesFramework::load_dungeon(const coord_def &cen)
bg = env.tile_bg[ep.x-1][ep.y-1];
}
- if (gc.x == cen.x && gc.y == cen.y)
+ if (gc == cen)
bg |= TILE_FLAG_CURSOR1;
tb[count++] = fg;
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index 6452eaf2c4..6f981823da 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -224,7 +224,7 @@ bool is_altar(dungeon_feature_type grid)
bool is_altar(const coord_def &c)
{
- return is_altar(grd[c.x][c.y]);
+ return is_altar(grd(c));
}
inline bool is_player_altar(dungeon_feature_type grid)
@@ -236,7 +236,7 @@ inline bool is_player_altar(dungeon_feature_type grid)
inline bool is_player_altar(const coord_def &c)
{
- return is_player_altar(grd[c.x][c.y]);
+ return is_player_altar(grd(c));
}
#ifdef CLUA_BINDINGS
@@ -1031,10 +1031,8 @@ static void _explore_find_target_square()
// Auto-explore is only zigzagging if the prefered
// target (whereto) and the anti-zigzag target are
// close together.
- if (grid_distance(target.x, target.y,
- whereto.x, whereto.y) <= 5
- && distance(target.x, target.y,
- whereto.x, whereto.y) <= 34)
+ if (grid_distance(target, whereto) <= 5
+ && distance(target, whereto) <= 34)
{
_set_target_square(target);
return;
@@ -3064,7 +3062,7 @@ int level_id::absdepth() const
level_id level_id::get_next_level_id(const coord_def &pos)
{
- int gridc = grd[pos.x][pos.y];
+ int gridc = grd(pos);
level_id id = current();
for ( int i = 0; i < NUM_BRANCHES; ++i )