Remove grd() helper macro
authorAidan Holm <aidanholm@gmail.com>
Sun, 18 Oct 2020 09:07:15 +0000 (17:07 +0800)
committerAidan Holm <aidanholm@gmail.com>
Mon, 19 Oct 2020 15:44:45 +0000 (23:44 +0800)
106 files changed:
crawl-ref/source/ability.cc
crawl-ref/source/abyss.cc
crawl-ref/source/acquire.cc
crawl-ref/source/actor.cc
crawl-ref/source/areas.cc
crawl-ref/source/arena.cc
crawl-ref/source/beam.cc
crawl-ref/source/bloodspatter.cc
crawl-ref/source/chardump.cc
crawl-ref/source/cloud.cc
crawl-ref/source/colour.cc
crawl-ref/source/dactions.cc
crawl-ref/source/dbg-maps.cc
crawl-ref/source/dbg-scan.cc
crawl-ref/source/decks.cc
crawl-ref/source/defines.h
crawl-ref/source/delay.cc
crawl-ref/source/describe.cc
crawl-ref/source/dgn-delve.cc
crawl-ref/source/dgn-layouts.cc
crawl-ref/source/dgn-overview.cc
crawl-ref/source/dgn-proclayouts.cc
crawl-ref/source/dgn-shoals.cc
crawl-ref/source/dgn-swamp.cc
crawl-ref/source/directn.cc
crawl-ref/source/dungeon-feature-type.h
crawl-ref/source/dungeon.cc
crawl-ref/source/evoke.cc
crawl-ref/source/exclude.cc
crawl-ref/source/fight.cc
crawl-ref/source/files.cc
crawl-ref/source/fprop.cc
crawl-ref/source/god-abil.cc
crawl-ref/source/god-passive.cc
crawl-ref/source/hints.cc
crawl-ref/source/item-use.cc
crawl-ref/source/items.cc
crawl-ref/source/l-dgn.cc
crawl-ref/source/l-dgngrd.cc
crawl-ref/source/l-feat.cc
crawl-ref/source/l-view.cc
crawl-ref/source/los.cc
crawl-ref/source/losparam.cc
crawl-ref/source/main.cc
crawl-ref/source/map-knowledge.cc
crawl-ref/source/mapdef.cc
crawl-ref/source/mapmark.cc
crawl-ref/source/maps.cc
crawl-ref/source/melee-attack.cc
crawl-ref/source/menu.cc
crawl-ref/source/mon-abil.cc
crawl-ref/source/mon-act.cc
crawl-ref/source/mon-behv.cc
crawl-ref/source/mon-cast.cc
crawl-ref/source/mon-clone.cc
crawl-ref/source/mon-death.cc
crawl-ref/source/mon-ench.cc
crawl-ref/source/mon-info.cc
crawl-ref/source/mon-movetarget.cc
crawl-ref/source/mon-pathfind.cc
crawl-ref/source/mon-pick.cc
crawl-ref/source/mon-place.cc
crawl-ref/source/mon-poly.cc
crawl-ref/source/mon-tentacle.cc
crawl-ref/source/mon-transit.cc
crawl-ref/source/mon-util.cc
crawl-ref/source/monster.cc
crawl-ref/source/movement.cc
crawl-ref/source/nearby-danger.cc
crawl-ref/source/player-act.cc
crawl-ref/source/player-reacts.cc
crawl-ref/source/player.cc
crawl-ref/source/religion.cc
crawl-ref/source/shopping.cc
crawl-ref/source/shout.cc
crawl-ref/source/show.cc
crawl-ref/source/showsymb.cc
crawl-ref/source/spl-clouds.cc
crawl-ref/source/spl-damage.cc
crawl-ref/source/spl-goditem.cc
crawl-ref/source/spl-other.cc
crawl-ref/source/spl-selfench.cc
crawl-ref/source/spl-summoning.cc
crawl-ref/source/spl-tornado.cc
crawl-ref/source/spl-transloc.cc
crawl-ref/source/stairs.cc
crawl-ref/source/stash.cc
crawl-ref/source/status.cc
crawl-ref/source/tags.cc
crawl-ref/source/target.cc
crawl-ref/source/teleport.cc
crawl-ref/source/terrain.cc
crawl-ref/source/throw.cc
crawl-ref/source/tilepick.cc
crawl-ref/source/tilereg-dgn.cc
crawl-ref/source/tileview.cc
crawl-ref/source/timed-effects.cc
crawl-ref/source/transform.cc
crawl-ref/source/traps.cc
crawl-ref/source/travel.cc
crawl-ref/source/util/monster/monster-main.cc
crawl-ref/source/view.cc
crawl-ref/source/viewmap.cc
crawl-ref/source/wiz-dgn.cc
crawl-ref/source/wiz-mon.cc
crawl-ref/source/xom.cc

index 05af15d..04519a5 100644 (file)
@@ -1311,7 +1311,7 @@ static bool _check_ability_possible(const ability_def& abil, bool quiet = false)
     // dangerous.)
     if (abil.ability == ABIL_STOP_FLYING)
     {
-        if (is_feat_dangerous(grd(you.pos()), false, true))
+        if (is_feat_dangerous(env.grid(you.pos()), false, true))
         {
             if (!quiet)
                 mpr("Stopping flight right now would be fatal!");
@@ -1667,7 +1667,7 @@ static bool _check_ability_possible(const ability_def& abil, bool quiet = false)
         // Is there a valid place to wall jump?
         bool has_targets = false;
         for (adjacent_iterator ai(you.pos()); ai; ++ai)
-            if (feat_can_wall_jump_against(grd(*ai)))
+            if (feat_can_wall_jump_against(env.grid(*ai)))
             {
                 has_targets = true;
                 break;
index d0a6675..08a0c21 100644 (file)
@@ -99,12 +99,12 @@ static coord_def _place_feature_near(const coord_def &centre,
         if (not_seen && cell_see_cell_nocache(cp, centre))
             continue;
 
-        if (grd(cp) == candidate)
+        if (env.grid(cp) == candidate)
         {
             dprf(DIAG_ABYSS, "Placing %s at (%d,%d)",
                  dungeon_feature_name(replacement),
                  cp.x, cp.y);
-            grd(cp) = replacement;
+            env.grid(cp) = replacement;
             return cp;
         }
     }
@@ -145,7 +145,7 @@ static void _write_abyssal_features()
                 {
                     if (abyssal_features[index] != DNGN_UNSEEN)
                     {
-                        grd(p) = abyssal_features[index];
+                        env.grid(p) = abyssal_features[index];
                         env.level_map_mask(p) = MMT_VAULT;
                         if (cell_is_solid(p))
                             delete_cloud(p);
@@ -156,7 +156,7 @@ static void _write_abyssal_features()
                 else
                 {
                     //Entombing the player is lame.
-                    grd(p) = DNGN_FLOOR;
+                    env.grid(p) = DNGN_FLOOR;
                 }
             }
 
@@ -185,13 +185,13 @@ static void _abyss_fixup_vault(const vault_placement *vp)
     for (vault_place_iterator vi(*vp); vi; ++vi)
     {
         const coord_def p(*vi);
-        const dungeon_feature_type feat(grd(p));
+        const dungeon_feature_type feat(env.grid(p));
         if (feat_is_stair(feat)
             && feat != DNGN_EXIT_ABYSS
             && feat != DNGN_ABYSSAL_STAIR
             && !feat_is_portal_entrance(feat))
         {
-            grd(p) = DNGN_FLOOR;
+            env.grid(p) = DNGN_FLOOR;
         }
 
         tile_init_flavour(p);
@@ -275,7 +275,7 @@ static bool _abyss_place_rune(const map_bitmask &abyss_genlevel_mask)
     {
         const coord_def p(*ri);
         if (abyss_genlevel_mask(p)
-            && grd(p) == DNGN_FLOOR && igrd(p) == NON_ITEM
+            && env.grid(p) == DNGN_FLOOR && igrd(p) == NON_ITEM
             && one_chance_in(++places_found))
         {
             chosen_spot = p;
@@ -301,7 +301,7 @@ static bool _abyss_square_accepts_items(const map_bitmask &abyss_genlevel_mask,
                                         coord_def p)
 {
     return abyss_genlevel_mask(p)
-           && grd(p) == DNGN_FLOOR
+           && env.grid(p) == DNGN_FLOOR
            && igrd(p) == NON_ITEM
            && !map_masked(p, MMT_VAULT);
 }
@@ -445,7 +445,7 @@ void push_features_to_abyss()
 
             p += you.pos();
 
-            dungeon_feature_type feature = map_bounds(p) ? grd(p) : DNGN_UNSEEN;
+            dungeon_feature_type feature = map_bounds(p) ? env.grid(p) : DNGN_UNSEEN;
             feature = sanitize_feature(feature);
             abyssal_features.push_back(feature);
         }
@@ -495,7 +495,7 @@ static bool _abyss_check_place_feat(coord_def p,
         else if (!abyss_genlevel_mask(p))
             return false;
         else
-            grd(p) = which_feat;
+            env.grid(p) = which_feat;
 
         if (feats_wanted)
             --*feats_wanted;
@@ -541,7 +541,7 @@ private:
         // env.map_knowledge().known() doesn't work on unmappable levels because
         // mapping flags are not set on such levels.
         for (radius_iterator ri(you.pos(), LOS_DEFAULT); ri; ++ri)
-            if (grd(*ri) == DNGN_EXIT_ABYSS && env.map_knowledge(*ri).seen())
+            if (env.grid(*ri) == DNGN_EXIT_ABYSS && env.map_knowledge(*ri).seen())
                 return true;
 
         return false;
@@ -665,11 +665,11 @@ static void _push_items()
         if (!item.defined() || !in_bounds(item.pos) || item.held_by_monster())
             continue;
 
-        if (!_pushy_feature(grd(item.pos)))
+        if (!_pushy_feature(env.grid(item.pos)))
             continue;
 
         for (distance_iterator di(item.pos); di; ++di)
-            if (!_pushy_feature(grd(*di)))
+            if (!_pushy_feature(env.grid(*di)))
             {
                 int j = i;
                 move_item_to_grid(&j, *di, true);
@@ -700,7 +700,7 @@ static void _abyss_wipe_square_at(coord_def p, bool saveMonsters=false)
     if (map_masked(p, MMT_VAULT))
         env.level_map_mask(p) &= ~MMT_VAULT;
 
-    grd(p) = DNGN_UNSEEN;
+    env.grid(p) = DNGN_UNSEEN;
 
     // Nuke items.
     if (igrd(p) != NON_ITEM)
@@ -802,7 +802,7 @@ static void _abyss_update_transporter(const coord_def &pos,
                                       const coord_def &target_centre,
                                       const map_bitmask &shift_area)
 {
-    if (grd(pos) != DNGN_TRANSPORTER)
+    if (env.grid(pos) != DNGN_TRANSPORTER)
         return;
 
     // Get the marker, since we will need to modify it.
@@ -1206,7 +1206,7 @@ static void _update_abyss_terrain(const coord_def &p,
     if (!in_bounds(rp))
         return;
 
-    const dungeon_feature_type currfeat = grd(rp);
+    const dungeon_feature_type currfeat = env.grid(rp);
 
     // Don't decay vaults.
     if (map_masked(rp, MMT_VAULT))
@@ -1255,7 +1255,7 @@ static void _update_abyss_terrain(const coord_def &p,
     // the selected grid should have been there, do nothing.
     if (feat != currfeat)
     {
-        grd(rp) = feat;
+        env.grid(rp) = feat;
         if (feat == DNGN_FLOOR && in_los_bounds_g(rp))
         {
             cloud_type cloud = _cloud_from_feat(currfeat);
@@ -1284,7 +1284,7 @@ static void _destroy_all_terrain(bool vaults)
 
 static void _ensure_player_habitable(bool dig_instead)
 {
-    dungeon_feature_type feat = grd(you.pos());
+    dungeon_feature_type feat = env.grid(you.pos());
     if (!you.can_pass_through_feat(feat) || is_feat_dangerous(feat))
     {
         bool shoved = you.shove();
@@ -1292,7 +1292,7 @@ static void _ensure_player_habitable(bool dig_instead)
         {
             // legal only if we just placed a vault
             ASSERT(dig_instead);
-            grd(you.pos()) = DNGN_FLOOR;
+            env.grid(you.pos()) = DNGN_FLOOR;
         }
     }
 }
@@ -1369,7 +1369,7 @@ static void _abyss_apply_terrain(const map_bitmask &abyss_genlevel_mask,
         dprf(DIAG_ABYSS, "Nuked %d features", ii);
     _ensure_player_habitable(false);
     for (rectangle_iterator ri(MAPGEN_BORDER); ri; ++ri)
-        ASSERT_RANGE(grd(*ri), DNGN_UNSEEN + 1, NUM_FEATURES);
+        ASSERT_RANGE(env.grid(*ri), DNGN_UNSEEN + 1, NUM_FEATURES);
 }
 
 static int _abyss_place_vaults(const map_bitmask &abyss_genlevel_mask)
@@ -1600,7 +1600,7 @@ static void _abyss_generate_new_area()
 // Check if there is a path between the abyss centre and an exit location.
 static bool _abyss_has_path(const coord_def &to)
 {
-    ASSERT(grd(to) == DNGN_EXIT_ABYSS);
+    ASSERT(env.grid(to) == DNGN_EXIT_ABYSS);
 
     monster_pathfind pf;
     return pf.init_pathfind(ABYSS_CENTRE, to);
@@ -1627,11 +1627,11 @@ retry:
     map_bitmask abyss_genlevel_mask(true);
     _abyss_apply_terrain(abyss_genlevel_mask);
 
-    grd(you.pos()) = _veto_dangerous_terrain(grd(you.pos()));
+    env.grid(you.pos()) = _veto_dangerous_terrain(env.grid(you.pos()));
     _place_displaced_monsters();
 
     for (rectangle_iterator ri(MAPGEN_BORDER); ri; ++ri)
-        ASSERT(grd(*ri) > DNGN_UNSEEN);
+        ASSERT(env.grid(*ri) > DNGN_UNSEEN);
     check_map_validity();
 
     // If we're starting out in the Abyss, make sure the starting grid is
@@ -1640,7 +1640,7 @@ retry:
     // altar near-by.
     if (player_in_starting_abyss())
     {
-        grd(ABYSS_CENTRE) = DNGN_ALTAR_LUGONU;
+        env.grid(ABYSS_CENTRE) = DNGN_ALTAR_LUGONU;
         const coord_def eloc = _place_feature_near(ABYSS_CENTRE, LOS_RADIUS + 2,
                                                    DNGN_FLOOR, DNGN_EXIT_ABYSS,
                                                    50, true);
@@ -1651,7 +1651,7 @@ retry:
     }
     else
     {
-        grd(ABYSS_CENTRE) = DNGN_FLOOR;
+        env.grid(ABYSS_CENTRE) = DNGN_FLOOR;
         if (one_chance_in(5))
         {
             _place_feature_near(ABYSS_CENTRE, LOS_RADIUS,
@@ -1732,7 +1732,7 @@ void abyss_teleport()
         " the Abyss!");
     _abyss_generate_new_area();
     _write_abyssal_features();
-    grd(you.pos()) = _veto_dangerous_terrain(grd(you.pos()));
+    env.grid(you.pos()) = _veto_dangerous_terrain(env.grid(you.pos()));
 
     stop_delay(true);
     forget_map(false);
@@ -1793,7 +1793,7 @@ static void _initialise_level_corrupt_seeds(int power)
         while (tries-- > 0)
         {
             where = dgn_random_point_from(you.pos(), aux_seed_radius, 2);
-            if (grd(where) == DNGN_FLOOR && !env.markers.find(where, MAT_ANY))
+            if (env.grid(where) == DNGN_FLOOR && !env.markers.find(where, MAT_ANY))
                 break;
             where.reset();
         }
@@ -1832,7 +1832,7 @@ static bool _spawn_corrupted_servant_near(const coord_def &pos)
 
         monster_type mons = pick_monster(level_id(BRANCH_ABYSS), _incorruptible);
         ASSERT(mons);
-        if (!monster_habitable_grid(mons, grd(p)))
+        if (!monster_habitable_grid(mons, env.grid(p)))
             continue;
         mgen_data mg(mons, BEH_NEUTRAL, p);
         mg.set_summoned(0, 5, 0).set_non_actor_summoner("Lugonu's corruption");
@@ -1881,7 +1881,7 @@ static bool _is_grid_corruptible(const coord_def &c)
     if (c == you.pos())
         return false;
 
-    const dungeon_feature_type feat = grd(c);
+    const dungeon_feature_type feat = env.grid(c);
 
     // Stairs and portals cannot be corrupted.
     if (feat_stair_direction(feat) != CMD_NO_CMD)
@@ -1924,7 +1924,7 @@ static bool _is_crowded_square(const coord_def &c)
                 continue;
 
             const coord_def n(c.x + xi, c.y + yi);
-            if (!in_bounds(n) || !feat_is_traversable(grd(n)))
+            if (!in_bounds(n) || !feat_is_traversable(env.grid(n)))
                 continue;
 
             if (++neighbours > 4)
@@ -1938,7 +1938,7 @@ static bool _is_crowded_square(const coord_def &c)
 static bool _is_sealed_square(const coord_def &c)
 {
     for (adjacent_iterator ai(c); ai; ++ai)
-        if (!feat_is_opaque(grd(*ai)))
+        if (!feat_is_opaque(env.grid(*ai)))
             return false;
 
     return true;
@@ -1946,7 +1946,7 @@ static bool _is_sealed_square(const coord_def &c)
 
 static void _corrupt_square_flavor(const corrupt_env &cenv, const coord_def &c)
 {
-    dungeon_feature_type feat = grd(c);
+    dungeon_feature_type feat = env.grid(c);
     int floor = cenv.pick_floor_colour();
 
     if (feat == DNGN_ROCK_WALL || feat == DNGN_METAL_WALL
@@ -2012,7 +2012,7 @@ static void _corrupt_square(const corrupt_env &cenv, const coord_def &c)
     // features.
     bool preserve_features = true;
     dungeon_feature_type feat = DNGN_UNSEEN;
-    if (feat_altar_god(grd(c)) != GOD_NO_GOD)
+    if (feat_altar_god(env.grid(c)) != GOD_NO_GOD)
     {
         preserve_features = false;
         if (!one_chance_in(3))
@@ -2023,19 +2023,19 @@ static void _corrupt_square(const corrupt_env &cenv, const coord_def &c)
 
     if (feat_is_trap(feat)
         || feat == DNGN_UNSEEN
-        || (feat_is_traversable(grd(c)) && !feat_is_traversable(feat)
+        || (feat_is_traversable(env.grid(c)) && !feat_is_traversable(feat)
             && coinflip()))
     {
         feat = DNGN_FLOOR;
     }
 
-    if (feat_is_traversable(grd(c)) && !feat_is_traversable(feat)
+    if (feat_is_traversable(env.grid(c)) && !feat_is_traversable(feat)
         && _is_crowded_square(c))
     {
         return;
     }
 
-    if (!feat_is_traversable(grd(c)) && feat_is_traversable(feat)
+    if (!feat_is_traversable(env.grid(c)) && feat_is_traversable(feat)
         && _is_sealed_square(c))
     {
         return;
@@ -2171,7 +2171,7 @@ void abyss_maybe_spawn_xp_exit()
         || !you.props.exists(ABYSS_STAIR_XP_KEY)
         || you.props[ABYSS_STAIR_XP_KEY].get_int() > 0
         || !in_bounds(you.pos())
-        || feat_is_critical(grd(you.pos())))
+        || feat_is_critical(env.grid(you.pos())))
     {
         return;
     }
@@ -2181,7 +2181,7 @@ void abyss_maybe_spawn_xp_exit()
                         && you.props[ABYSS_SPAWNED_XP_EXIT_KEY].get_bool();
 
     destroy_wall(you.pos()); // fires listeners etc even if it wasn't a wall
-    grd(you.pos()) = stairs ? DNGN_ABYSSAL_STAIR : DNGN_EXIT_ABYSS;
+    env.grid(you.pos()) = stairs ? DNGN_ABYSSAL_STAIR : DNGN_EXIT_ABYSS;
     big_cloud(CLOUD_TLOC_ENERGY, &you, you.pos(), 3 + random2(3), 3, 3);
     redraw_screen(); // before the force-more
     update_screen();
index f3b874a..f818f15 100644 (file)
@@ -1428,7 +1428,7 @@ int acquirement_create_item(object_class_type class_wanted,
 
     // If a god wants to give you something but the floor doesn't want it,
     // it counts as a failed acquirement - no piety, etc cost.
-    if (feat_destroys_items(grd(pos))
+    if (feat_destroys_items(env.grid(pos))
         && agent > GOD_NO_GOD
         && agent < NUM_GODS)
     {
index e75c5e5..f10860a 100644 (file)
@@ -80,17 +80,17 @@ bool actor::can_wield(const item_def* item, bool ignore_curse,
 
 bool actor::can_pass_through(int x, int y) const
 {
-    return can_pass_through_feat(grd[x][y]);
+    return can_pass_through_feat(env.grid[x][y]);
 }
 
 bool actor::can_pass_through(const coord_def &c) const
 {
-    return can_pass_through_feat(grd(c));
+    return can_pass_through_feat(env.grid(c));
 }
 
 bool actor::is_habitable(const coord_def &_pos) const
 {
-    return is_habitable_feat(grd(_pos));
+    return is_habitable_feat(env.grid(_pos));
 }
 
 bool actor::handle_trap()
@@ -583,7 +583,7 @@ bool actor::has_invalid_constrictor(bool move) const
     // Indirect constriction requires the defender not to move.
     return move
         // Indirect constriction requires reachable ground.
-        || !feat_has_solid_floor(grd(pos()))
+        || !feat_has_solid_floor(env.grid(pos()))
         // Constriction doesn't work out of LOS.
         || !ignoring_player && !attacker->see_cell(pos());
 }
@@ -683,7 +683,7 @@ bool actor::can_constrict(const actor* defender, bool direct) const
         && !defender->is_constricted()
         && defender->res_constrict() < 3
         // All current indrect forms of constriction require reachable ground.
-        && feat_has_solid_floor(grd(defender->pos()));
+        && feat_has_solid_floor(env.grid(defender->pos()));
 }
 
 #ifdef DEBUG_DIAGNOSTICS
@@ -983,7 +983,7 @@ void actor::collide(coord_def newpos, const actor *agent, int pow)
 
     if (you.can_see(*this))
     {
-        if (!can_pass_through_feat(grd(newpos)))
+        if (!can_pass_through_feat(env.grid(newpos)))
         {
             mprf("%s %s into %s!",
                  name(DESC_THE).c_str(), conj_verb("slam").c_str(),
index ba8ba6f..5b5da9b 100644 (file)
@@ -119,7 +119,7 @@ static void _actor_areas(actor *a)
 
         for (radius_iterator ri(a->pos(), r, C_SQUARE, LOS_SOLID); ri; ++ri)
         {
-            dungeon_feature_type f = grd(*ri);
+            dungeon_feature_type f = env.grid(*ri);
 
             _set_agrid_flag(*ri, areaprop::liquid);
 
@@ -620,7 +620,7 @@ bool liquefied(const coord_def& p, bool check_actual)
     if (!_agrid_valid)
         _update_agrid();
 
-    if (feat_is_water(grd(p)) || feat_is_lava(grd(p)))
+    if (feat_is_water(env.grid(p)) || feat_is_lava(env.grid(p)))
         return false;
 
     // "actually" liquefied (ie, check for movement)
index 712e7e3..433d677 100644 (file)
@@ -321,8 +321,8 @@ namespace arena
                 {
                     game_ended_with_error(
                         make_stringf(
-                            "Failed to create monster at (%d,%d) grd: %s",
-                            loc.x, loc.y, dungeon_feature_name(grd(loc))));
+                            "Failed to create monster at (%d,%d) env.grid: %s",
+                            loc.x, loc.y, dungeon_feature_name(env.grid(loc))));
                 }
                 list_eq(mon);
                 to_respawn[mon->mindex()] = i;
@@ -360,7 +360,7 @@ namespace arena
 
         for (int x = 0; x < GXM; ++x)
             for (int y = 0; y < GYM; ++y)
-                grd[x][y] = DNGN_ROCK_WALL;
+                env.grid[x][y] = DNGN_ROCK_WALL;
 
         unwind_bool gen(crawl_state.generating_level, true);
 
index 3140110..8684c5f 100644 (file)
@@ -829,7 +829,7 @@ void bolt::digging_wall_effect()
         return;
     }
 
-    const dungeon_feature_type feat = grd(pos());
+    const dungeon_feature_type feat = env.grid(pos());
     if (feat_is_diggable(feat))
     {
         destroy_wall(pos());
@@ -874,7 +874,7 @@ void bolt::digging_wall_effect()
 
 void bolt::burn_wall_effect()
 {
-    dungeon_feature_type feat = grd(pos());
+    dungeon_feature_type feat = env.grid(pos());
     // Fire only affects trees.
     if (!feat_is_tree(feat)
         || env.markers.property_at(pos(), MAT_ANY, "veto_destroy") == "veto"
@@ -935,7 +935,7 @@ void bolt::affect_wall()
             env.markers.property_at(pos(), MAT_ANY, "veto_destroy") == "veto";
 
         // XXX: should check env knowledge for feat_is_tree()
-        if (god_relevant && feat_is_tree(grd(pos())) && !vetoed
+        if (god_relevant && feat_is_tree(env.grid(pos())) && !vetoed
             && !is_targeting && YOU_KILL(thrower) && !dont_stop_trees)
         {
             const string prompt =
@@ -1134,7 +1134,7 @@ void bolt::do_fire()
             break;
         }
 
-        const dungeon_feature_type feat = grd(pos());
+        const dungeon_feature_type feat = env.grid(pos());
 
         if (in_bounds(target)
             // Starburst beams are essentially untargeted; some might even hit
@@ -2083,7 +2083,7 @@ vector<coord_def> create_feat_splash(coord_def center,
 
     for (distance_iterator di(center, true, false, radius); di && number > 0; ++di)
     {
-        const dungeon_feature_type feat = grd(*di);
+        const dungeon_feature_type feat = env.grid(*di);
         if ((feat == DNGN_FLOOR || feat == DNGN_SHALLOW_WATER)
             && cell_see_cell(center, *di, LOS_NO_TRANS))
         {
@@ -2503,7 +2503,7 @@ bool bolt::can_burn_trees() const
 
 bool bolt::can_affect_wall(const coord_def& p, bool map_knowledge) const
 {
-    dungeon_feature_type wall = grd(p);
+    dungeon_feature_type wall = env.grid(p);
 
     // digging might affect unseen squares, as far as the player knows
     if (map_knowledge && flavour == BEAM_DIGGING &&
@@ -2555,7 +2555,7 @@ void bolt::affect_place_clouds()
     }
 
     // No clouds here, free to make new ones.
-    const dungeon_feature_type feat = grd(p);
+    const dungeon_feature_type feat = env.grid(p);
 
     if (origin_spell == SPELL_POISONOUS_CLOUD)
         place_cloud(CLOUD_POISON, p, random2(5) + 3, agent());
@@ -2610,8 +2610,8 @@ void bolt::affect_place_explosion_clouds()
     const coord_def p = pos();
 
     // First check: fire/cold over water/lava.
-    if (grd(p) == DNGN_LAVA && flavour == BEAM_COLD
-        || feat_is_watery(grd(p)) && is_fiery())
+    if (env.grid(p) == DNGN_LAVA && flavour == BEAM_COLD
+        || feat_is_watery(env.grid(p)) && is_fiery())
     {
         place_cloud(CLOUD_STEAM, p, 2 + random2(5), agent());
         return;
@@ -2632,7 +2632,7 @@ void bolt::affect_place_explosion_clouds()
         place_cloud(CLOUD_FIRE, p, 2 + random2avg(5,2), agent());
 
         // XXX: affect other open spaces?
-        if (grd(p) == DNGN_FLOOR && !monster_at(p) && one_chance_in(4))
+        if (env.grid(p) == DNGN_FLOOR && !monster_at(p) && one_chance_in(4))
         {
             const god_type god =
                 (crawl_state.is_god_acting()) ? crawl_state.which_god_acting()
@@ -6025,7 +6025,7 @@ void bolt::determine_affected_cells(explosion_map& m, const coord_def& delta,
         return;
     }
 
-    const dungeon_feature_type dngn_feat = grd(loc);
+    const dungeon_feature_type dngn_feat = env.grid(loc);
 
     bool at_wall = false;
 
index 8554f92..818deb5 100644 (file)
@@ -37,18 +37,18 @@ static bool _allow_bleeding_on_square(const coord_def& where,
         return false;
 
     // No spattering into lava or water.
-    if (feat_is_lava(grd(where)) || feat_is_water(grd(where)))
+    if (feat_is_lava(env.grid(where)) || feat_is_water(env.grid(where)))
         return false;
 
     // No spattering into fountains (other than blood).
-    if (grd(where) == DNGN_FOUNTAIN_BLUE
-        || grd(where) == DNGN_FOUNTAIN_SPARKLING)
+    if (env.grid(where) == DNGN_FOUNTAIN_BLUE
+        || env.grid(where) == DNGN_FOUNTAIN_SPARKLING)
     {
         return false;
     }
 
     // The good gods like to keep their altars pristine.
-    if (is_good_god(feat_altar_god(grd(where))))
+    if (is_good_god(feat_altar_god(env.grid(where))))
         return false;
 
     return true;
index e4cf7f5..7b3dfc3 100644 (file)
@@ -1584,18 +1584,18 @@ void dump_map(FILE *fp, bool debug, bool dist)
                     fputc('@', fp);
                 else if (testbits(env.pgrid[x][y], FPROP_HIGHLIGHT))
                     fputc('?', fp);
-                else if (dist && grd[x][y] == DNGN_FLOOR
+                else if (dist && env.grid[x][y] == DNGN_FLOOR
                          && travel_point_distance[x][y] > 0
                          && travel_point_distance[x][y] < 10)
                 {
                     fputc('0' + travel_point_distance[x][y], fp);
                 }
-                else if (grd[x][y] >= NUM_FEATURES)
+                else if (env.grid[x][y] >= NUM_FEATURES)
                     fputc('!', fp);
                 else
                 {
                     fputs(OUTS(stringize_glyph(
-                               get_feature_def(grd[x][y]).symbol())), fp);
+                               get_feature_def(env.grid[x][y]).symbol())), fp);
                 }
             }
             fputc('\n', fp);
index 7c2074a..7b54ed0 100644 (file)
@@ -405,7 +405,7 @@ static int _spread_cloud(const cloud_struct &cloud)
             continue;
         }
 
-        if (cloud.type == CLOUD_INK && !feat_is_watery(grd(*ai)))
+        if (cloud.type == CLOUD_INK && !feat_is_watery(env.grid(*ai)))
             continue;
 
         int newdecay = cloud.decay / 2 + 1;
@@ -447,7 +447,7 @@ static void _spread_fire(const cloud_struct &cloud)
 
         // forest fire doesn't spread in all directions at once,
         // every neighbouring square gets a separate roll
-        if (!feat_is_tree(grd(*ai)) || is_temp_terrain(*ai)
+        if (!feat_is_tree(env.grid(*ai)) || is_temp_terrain(*ai)
             || x_chance_in_y(19, 20))
         {
             continue;
@@ -479,7 +479,7 @@ static void _cloud_interacts_with_terrain(const cloud_struct &cloud)
     {
         const coord_def p(*ai);
         if (in_bounds(p)
-            && feat_is_watery(grd(p))
+            && feat_is_watery(env.grid(p))
             && !cell_is_solid(p)
             && !cloud_at(p)
             && one_chance_in(14))
@@ -544,7 +544,7 @@ static int _cloud_dissipation_rate(const cloud_struct &cloud)
     }
 
     // Ink cloud shouldn't appear outside of water.
-    if (cloud.type == CLOUD_INK && !feat_is_watery(grd(cloud.pos)))
+    if (cloud.type == CLOUD_INK && !feat_is_watery(env.grid(cloud.pos)))
         return cloud.decay;
 
     return dissipate;
@@ -621,7 +621,7 @@ void manage_clouds()
         if (cell_is_solid(cloud.pos))
         {
             die("cloud %s in %s at (%d,%d)", cloud_type_name(cloud.type).c_str(),
-                dungeon_feature_name(grd(cloud.pos)), cloud.pos.x, cloud.pos.y);
+                dungeon_feature_name(env.grid(cloud.pos)), cloud.pos.x, cloud.pos.y);
         }
 #endif
 
@@ -661,18 +661,18 @@ static void _maybe_leave_water(const coord_def pos)
         return;
     }
 
-    dungeon_feature_type feat = grd(pos);
+    dungeon_feature_type feat = env.grid(pos);
 
-    if (grd(pos) == DNGN_FLOOR)
+    if (env.grid(pos) == DNGN_FLOOR)
         feat = DNGN_SHALLOW_WATER;
-    else if (grd(pos) == DNGN_SHALLOW_WATER && you.pos() != pos
+    else if (env.grid(pos) == DNGN_SHALLOW_WATER && you.pos() != pos
              && one_chance_in(3) && !crawl_state.game_is_sprint())
     {
         // Don't drown the player!
         feat = DNGN_DEEP_WATER;
     }
 
-    if (grd(pos) != feat)
+    if (env.grid(pos) != feat)
     {
         if (you.pos() == pos && you.ground_level())
             mpr("The rain has left you waist-deep in water!");
@@ -786,7 +786,7 @@ void place_cloud(cloud_type cl_type, const coord_def& ctarget, int cl_range,
     if (is_sanctuary(ctarget) && !is_harmless_cloud(cl_type))
         return;
 
-    if (cl_type == CLOUD_INK && !feat_is_watery(grd(ctarget)))
+    if (cl_type == CLOUD_INK && !feat_is_watery(env.grid(ctarget)))
         return;
 
     if (env.level_state & LSTATE_STILL_WINDS
@@ -1496,7 +1496,7 @@ static bool _mons_avoids_cloud(const monster* mons, const cloud_struct& cloud,
             return false;
 
         // This position could become deep water, and they might drown.
-        if (grd(cloud.pos) == DNGN_SHALLOW_WATER
+        if (env.grid(cloud.pos) == DNGN_SHALLOW_WATER
             && mons_intel(*mons) > I_BRAINLESS)
         {
             return true;
@@ -1614,7 +1614,7 @@ coord_def random_walk(coord_def start, int dist)
         {
             const coord_def new_pos   = pos + Compass[j];
 
-            if (in_bounds(new_pos) && !feat_is_solid(grd(new_pos))
+            if (in_bounds(new_pos) && !feat_is_solid(env.grid(new_pos))
                 && one_chance_in(++okay_dirs))
             {
                 dir = j;
index 5d2750b..dfb4bcb 100644 (file)
@@ -273,7 +273,7 @@ bool get_tornado_phase(const coord_def& loc)
 static int _etc_tornado(int, const coord_def& loc)
 {
     const bool phase = get_tornado_phase(loc);
-    switch (grd(loc))
+    switch (env.grid(loc))
     {
     case DNGN_LAVA:
         return phase ? LIGHTRED : RED;
index 6917b35..414dbe2 100644 (file)
@@ -293,8 +293,8 @@ static void _apply_daction(daction_type act)
     case DACT_REMOVE_JIYVA_ALTARS:
         for (rectangle_iterator ri(1); ri; ++ri)
         {
-            if (grd(*ri) == DNGN_ALTAR_JIYVA)
-                grd(*ri) = DNGN_FLOOR;
+            if (env.grid(*ri) == DNGN_ALTAR_JIYVA)
+                env.grid(*ri) = DNGN_FLOOR;
         }
         break;
     case DACT_ROT_CORPSES:
@@ -316,7 +316,7 @@ static void _apply_daction(daction_type act)
             if (feat->feat == DNGN_ABANDONED_SHOP)
             {
                 // TODO: clear shop data out?
-                grd(feat->pos) = DNGN_ABANDONED_SHOP;
+                env.grid(feat->pos) = DNGN_ABANDONED_SHOP;
                 view_update_at(feat->pos);
                 env.markers.remove(feat);
             }
index ea1453c..6afa528 100644 (file)
@@ -116,7 +116,7 @@ static bool _do_build_level()
             {
                 const coord_def pos(x, y);
 
-                objstat_record_feature(grd[x][y], map_masked(pos, MMT_VAULT));
+                objstat_record_feature(env.grid[x][y], map_masked(pos, MMT_VAULT));
 
                 monster *mons = monster_at(pos);
                 if (mons)
@@ -131,10 +131,10 @@ static bool _do_build_level()
                 }
             }
 
-            if (grd[x][y] == DNGN_RUNED_DOOR)
-                grd[x][y] = DNGN_CLOSED_DOOR;
-            else if (grd[x][y] == DNGN_RUNED_CLEAR_DOOR)
-                grd[x][y] = DNGN_CLOSED_CLEAR_DOOR;
+            if (env.grid[x][y] == DNGN_RUNED_DOOR)
+                env.grid[x][y] = DNGN_CLOSED_DOOR;
+            else if (env.grid[x][y] == DNGN_RUNED_CLEAR_DOOR)
+                env.grid[x][y] = DNGN_CLOSED_CLEAR_DOOR;
         }
 
 
index 2e8eea3..d8b0ea5 100644 (file)
@@ -375,7 +375,7 @@ void debug_mons_scan()
             }
         } // if (mgrd(m->pos()) != i)
 
-        if (feat_is_wall(grd(pos)))
+        if (feat_is_wall(env.grid(pos)))
         {
 #if defined(DEBUG_FATAL)
             // if we're going to dump, point out the culprit
@@ -383,7 +383,7 @@ void debug_mons_scan()
 #endif
             mprf(MSGCH_ERROR, "Monster %s in %s at (%d, %d)%s",
                  m->full_name(DESC_PLAIN).c_str(),
-                 dungeon_feature_name(grd(pos)),
+                 dungeon_feature_name(env.grid(pos)),
                  pos.x, pos.y,
                  _vault_desc(pos).c_str());
         }
@@ -639,7 +639,7 @@ void check_map_validity()
 
     for (rectangle_iterator ri(0); ri; ++ri)
     {
-        dungeon_feature_type feat = grd(*ri);
+        dungeon_feature_type feat = env.grid(*ri);
         if (feat <= DNGN_UNSEEN || feat >= NUM_FEATURES)
             die("invalid feature %d at (%d,%d)", feat, ri->x, ri->y);
         const char *name = dungeon_feature_name(feat);
index e96ae3e..39e4ae5 100644 (file)
@@ -1035,7 +1035,7 @@ static void _stairs_card(int /*power*/)
     you.duration[DUR_REPEL_STAIRS_MOVE]  = 0;
     you.duration[DUR_REPEL_STAIRS_CLIMB] = 0;
 
-    if (feat_stair_direction(grd(you.pos())) == CMD_NO_CMD)
+    if (feat_stair_direction(env.grid(you.pos())) == CMD_NO_CMD)
         you.duration[DUR_REPEL_STAIRS_MOVE]  = 1000;
     else
         you.duration[DUR_REPEL_STAIRS_CLIMB] =  500; // more annoying
@@ -1044,7 +1044,7 @@ static void _stairs_card(int /*power*/)
 
     for (radius_iterator ri(you.pos(), LOS_DEFAULT, true); ri; ++ri)
     {
-        dungeon_feature_type feat = grd(*ri);
+        dungeon_feature_type feat = env.grid(*ri);
         if (feat_stair_direction(feat) != CMD_NO_CMD
             && feat != DNGN_ENTER_SHOP)
         {
@@ -1443,7 +1443,7 @@ static void _cloud_card(int power)
 
         for (adjacent_iterator ai(mons->pos(), false); ai; ++ai)
         {
-            if (grd(*ai) == DNGN_FLOOR && !cloud_at(*ai))
+            if (env.grid(*ai) == DNGN_FLOOR && !cloud_at(*ai))
             {
                 const int cloud_power = 5 + random2avg(power_level * 6, 2);
                 place_cloud(cloudy, *ai, cloud_power, &you);
index bbba280..bb562d4 100644 (file)
@@ -196,7 +196,6 @@ const int AGILITY_BONUS = 5;
 #define MAX_MONSTER_HP 10000
 
 // some shortcuts:
-#define grd    env.grid
 #define mgrd   env.mgrid
 #define igrd   env.igrid
 
index 64fe16b..53cb57d 100644 (file)
@@ -721,7 +721,7 @@ void PasswallDelay::finish()
     if (dest.x == 0 || dest.y == 0)
         return;
 
-    switch (grd(dest))
+    switch (env.grid(dest))
     {
     default:
         if (!you.is_habitable(dest))
index 7dc656b..988005c 100644 (file)
@@ -2357,7 +2357,7 @@ void get_feature_desc(const coord_def &pos, describe_info &inf, bool include_ext
         env.markers.property_at(pos, MAT_ANY, "feature_description_long");
 
     // suppress this if the feature changed out of view
-    if (!marker_desc.empty() && grd(pos) == feat)
+    if (!marker_desc.empty() && env.grid(pos) == feat)
         long_desc += marker_desc;
 
     // Display branch descriptions on the entries to those branches.
index 543c46a..48873ea 100644 (file)
@@ -98,14 +98,14 @@ static bool _diggable(map_lines *map, coord_def c)
 {
     if (map)
         return (*map)(c) == 'x';
-    return grd(c) == DNGN_ROCK_WALL && !map_masked(c, MMT_VAULT);
+    return env.grid(c) == DNGN_ROCK_WALL && !map_masked(c, MMT_VAULT);
 }
 
 static bool _dug(map_lines *map, coord_def c)
 {
     if (map)
         return strchr(traversable_glyphs, (*map)(c));
-    return grd(c) == DNGN_FLOOR;
+    return env.grid(c) == DNGN_FLOOR;
 }
 
 static void _digcell(map_lines *map, store_type& store, coord_def c)
@@ -116,7 +116,7 @@ static void _digcell(map_lines *map, store_type& store, coord_def c)
     if (map)
         (*map)(c) = '.';
     else
-        grd(c) = DNGN_FLOOR;
+        env.grid(c) = DNGN_FLOOR;
 
     int order[8] = {0, 1, 2, 3, 4, 5, 6, 7};
     for (unsigned int d = 8; d > 0; d--)
index 1ef3032..0418c74 100644 (file)
@@ -64,8 +64,8 @@ void dgn_build_basic_level()
 
     if (!begin.origin() && !end.origin())
     {
-        grd(begin) = DNGN_STONE_STAIRS_DOWN_I;
-        grd(end)   = DNGN_STONE_STAIRS_UP_I;
+        env.grid(begin) = DNGN_STONE_STAIRS_DOWN_I;
+        env.grid(end)   = DNGN_STONE_STAIRS_UP_I;
         upstairs.push_back(begin);
     }
 
@@ -76,8 +76,8 @@ void dgn_build_basic_level()
 
     if (!begin.origin() && !end.origin())
     {
-        grd(begin) = DNGN_STONE_STAIRS_DOWN_II;
-        grd(end)   = DNGN_STONE_STAIRS_UP_II;
+        env.grid(begin) = DNGN_STONE_STAIRS_DOWN_II;
+        env.grid(end)   = DNGN_STONE_STAIRS_UP_II;
         upstairs.push_back(begin);
     }
 
@@ -88,8 +88,8 @@ void dgn_build_basic_level()
 
     if (!begin.origin() && !end.origin())
     {
-        grd(begin) = DNGN_STONE_STAIRS_DOWN_III;
-        grd(end)   = DNGN_STONE_STAIRS_UP_III;
+        env.grid(begin) = DNGN_STONE_STAIRS_DOWN_III;
+        env.grid(end)   = DNGN_STONE_STAIRS_UP_III;
         upstairs.push_back(begin);
     }
 
@@ -127,10 +127,10 @@ void dgn_build_basic_level()
 void dgn_build_bigger_room_level()
 {
     for (rectangle_iterator ri(10); ri; ++ri)
-        if (grd(*ri) == DNGN_ROCK_WALL
+        if (env.grid(*ri) == DNGN_ROCK_WALL
             && !map_masked(*ri, MMT_VAULT))
         {
-            grd(*ri) = DNGN_FLOOR;
+            env.grid(*ri) = DNGN_FLOOR;
         }
 
     dungeon_feature_type pool_type = DNGN_DEEP_WATER;
@@ -268,7 +268,7 @@ static int _trail_random_dir(int pos, int bound, int margin)
 
 static bool _viable_trail_start_location(const coord_def &c)
 {
-    if (grd(c) != DNGN_ROCK_WALL && grd(c) != DNGN_FLOOR
+    if (env.grid(c) != DNGN_ROCK_WALL && env.grid(c) != DNGN_FLOOR
         || map_masked(c, MMT_VAULT))
     {
         return false;
@@ -276,7 +276,7 @@ static bool _viable_trail_start_location(const coord_def &c)
     for (orth_adjacent_iterator ai(c); ai; ++ai)
     {
         if (in_bounds(*ai)
-            && grd(*ai) == DNGN_ROCK_WALL
+            && env.grid(*ai) == DNGN_ROCK_WALL
             && !map_masked(*ai, MMT_VAULT))
         {
             return true;
@@ -349,7 +349,7 @@ static void _make_trail(int xs, int xr, int ys, int yr, int corrlength,
                 break;
 
             // See if we stop due to intersection with another corridor/room.
-            if (grd(pos + dir * 2) == DNGN_FLOOR
+            if (env.grid(pos + dir * 2) == DNGN_FLOOR
                 && !one_chance_in(intersect_chance))
             {
                 break;
@@ -357,11 +357,11 @@ static void _make_trail(int xs, int xr, int ys, int yr, int corrlength,
 
             pos += dir;
 
-            if (grd(pos) == DNGN_ROCK_WALL)
-                grd(pos) = DNGN_FLOOR;
+            if (env.grid(pos) == DNGN_ROCK_WALL)
+                env.grid(pos) = DNGN_FLOOR;
         }
 
-        if (finish == no_corr - 1 && grd(pos) != DNGN_FLOOR)
+        if (finish == no_corr - 1 && env.grid(pos) != DNGN_FLOOR)
             finish -= 2;
 
         finish++;
@@ -467,13 +467,13 @@ static bool _octa_room(dgn_region& region, int oblique_max,
                 continue;
 
             if (_is_wall(x, y))
-                grd[x][y] = type_floor;
+                env.grid[x][y] = type_floor;
 
-            if (grd[x][y] == DNGN_FLOOR && type_floor == DNGN_SHALLOW_WATER)
-                grd[x][y] = DNGN_SHALLOW_WATER;
+            if (env.grid[x][y] == DNGN_FLOOR && type_floor == DNGN_SHALLOW_WATER)
+                env.grid[x][y] = DNGN_SHALLOW_WATER;
 
-            if (grd[x][y] == DNGN_CLOSED_DOOR && !feat_is_solid(type_floor))
-                grd[x][y] = DNGN_FLOOR;       // ick
+            if (env.grid[x][y] == DNGN_CLOSED_DOOR && !feat_is_solid(type_floor))
+                env.grid[x][y] = DNGN_FLOOR;       // ick
         }
 
         if (x > br.x - oblique_max)
@@ -508,23 +508,23 @@ static void _chequerboard(dgn_region& region, dungeon_feature_type target,
                            dungeon_feature_type floor2)
 {
     for (rectangle_iterator ri(region.pos, region.end()); ri; ++ri)
-        if (grd(*ri) == target && !map_masked(*ri, MMT_VAULT))
-            grd(*ri) = ((ri->x + ri->y) % 2) ? floor2 : floor1;
+        if (env.grid(*ri) == target && !map_masked(*ri, MMT_VAULT))
+            env.grid(*ri) = ((ri->x + ri->y) % 2) ? floor2 : floor1;
 }
 
 static int _box_room_door_spot(int x, int y)
 {
     // If there is a door near us embedded in rock, we have to be a door too.
-    if (grd[x-1][y] == DNGN_CLOSED_DOOR
+    if (env.grid[x-1][y] == DNGN_CLOSED_DOOR
             && _is_wall(x-1,y-1) && _is_wall(x-1,y+1)
-        || grd[x+1][y] == DNGN_CLOSED_DOOR
+        || env.grid[x+1][y] == DNGN_CLOSED_DOOR
             && _is_wall(x+1,y-1) && _is_wall(x+1,y+1)
-        || grd[x][y-1] == DNGN_CLOSED_DOOR
+        || env.grid[x][y-1] == DNGN_CLOSED_DOOR
             && _is_wall(x-1,y-1) && _is_wall(x+1,y-1)
-        || grd[x][y+1] == DNGN_CLOSED_DOOR
+        || env.grid[x][y+1] == DNGN_CLOSED_DOOR
             && _is_wall(x-1,y+1) && _is_wall(x+1,y+1))
     {
-        grd[x][y] = DNGN_CLOSED_DOOR;
+        env.grid[x][y] = DNGN_CLOSED_DOOR;
         return 2;
     }
 
@@ -599,12 +599,12 @@ static int _box_room_doors(int bx1, int bx2, int by1, int by2, int new_doors)
         {
             if (spot == j++)
             {
-                grd[i][by1] = DNGN_CLOSED_DOOR;
+                env.grid[i][by1] = DNGN_CLOSED_DOOR;
                 break;
             }
             if (spot == j++)
             {
-                grd[i][by2] = DNGN_CLOSED_DOOR;
+                env.grid[i][by2] = DNGN_CLOSED_DOOR;
                 break;
             }
         }
@@ -613,12 +613,12 @@ static int _box_room_doors(int bx1, int bx2, int by1, int by2, int new_doors)
         {
             if (spot == j++)
             {
-                grd[bx1][i] = DNGN_CLOSED_DOOR;
+                env.grid[bx1][i] = DNGN_CLOSED_DOOR;
                 break;
             }
             if (spot == j++)
             {
-                grd[bx2][i] = DNGN_CLOSED_DOOR;
+                env.grid[bx2][i] = DNGN_CLOSED_DOOR;
                 break;
             }
         }
@@ -670,7 +670,7 @@ static void _box_room(int bx1, int bx2, int by1, int by2,
 
 static bool _is_wall(int x, int y)
 {
-    return feat_is_wall(grd[x][y]);
+    return feat_is_wall(env.grid[x][y]);
 }
 
 static void _big_room(int level_number)
@@ -858,8 +858,8 @@ static void _diamond_rooms(int level_number)
 
 static int _good_door_spot(int x, int y)
 {
-    return (!feat_is_solid(grd[x][y]) || feat_is_closed_door(grd[x][y]))
-            && !feat_is_critical(grd[x][y]);
+    return (!feat_is_solid(env.grid[x][y]) || feat_is_closed_door(env.grid[x][y]))
+            && !feat_is_critical(env.grid[x][y]);
 }
 
 // Returns TRUE if a room was made successfully.
@@ -898,8 +898,8 @@ static bool _make_room(int sx,int sy,int ex,int ey,int max_doors, int doorlevel)
     for (rx = sx; rx <= ex; rx++)
         for (ry = sy; ry <= ey; ry++)
         {
-            if (!feat_has_dry_floor(grd[rx][ry]))
-                grd[rx][ry] = DNGN_FLOOR;
+            if (!feat_has_dry_floor(env.grid[rx][ry]))
+                env.grid[rx][ry] = DNGN_FLOOR;
         }
 
     // Put some doors on the sides (but not in corners),
@@ -907,21 +907,21 @@ static bool _make_room(int sx,int sy,int ex,int ey,int max_doors, int doorlevel)
     for (ry = sy + 1; ry < ey; ry++)
     {
         // left side
-        if (grd[sx-1][ry] == DNGN_FLOOR
-            && feat_is_solid(grd[sx-1][ry-1])
-            && feat_is_solid(grd[sx-1][ry+1]))
+        if (env.grid[sx-1][ry] == DNGN_FLOOR
+            && feat_is_solid(env.grid[sx-1][ry-1])
+            && feat_is_solid(env.grid[sx-1][ry+1]))
         {
             if (x_chance_in_y(doorlevel, 10))
-                grd[sx-1][ry] = DNGN_CLOSED_DOOR;
+                env.grid[sx-1][ry] = DNGN_CLOSED_DOOR;
         }
 
         // right side
-        if (grd[ex+1][ry] == DNGN_FLOOR
-            && feat_is_solid(grd[ex+1][ry-1])
-            && feat_is_solid(grd[ex+1][ry+1]))
+        if (env.grid[ex+1][ry] == DNGN_FLOOR
+            && feat_is_solid(env.grid[ex+1][ry-1])
+            && feat_is_solid(env.grid[ex+1][ry+1]))
         {
             if (x_chance_in_y(doorlevel, 10))
-                grd[ex+1][ry] = DNGN_CLOSED_DOOR;
+                env.grid[ex+1][ry] = DNGN_CLOSED_DOOR;
         }
     }
 
@@ -929,21 +929,21 @@ static bool _make_room(int sx,int sy,int ex,int ey,int max_doors, int doorlevel)
     for (rx = sx + 1; rx < ex; rx++)
     {
         // top
-        if (grd[rx][sy-1] == DNGN_FLOOR
-            && feat_is_solid(grd[rx-1][sy-1])
-            && feat_is_solid(grd[rx+1][sy-1]))
+        if (env.grid[rx][sy-1] == DNGN_FLOOR
+            && feat_is_solid(env.grid[rx-1][sy-1])
+            && feat_is_solid(env.grid[rx+1][sy-1]))
         {
             if (x_chance_in_y(doorlevel, 10))
-                grd[rx][sy-1] = DNGN_CLOSED_DOOR;
+                env.grid[rx][sy-1] = DNGN_CLOSED_DOOR;
         }
 
         // bottom
-        if (grd[rx][ey+1] == DNGN_FLOOR
-            && feat_is_solid(grd[rx-1][ey+1])
-            && feat_is_solid(grd[rx+1][ey+1]))
+        if (env.grid[rx][ey+1] == DNGN_FLOOR
+            && feat_is_solid(env.grid[rx-1][ey+1])
+            && feat_is_solid(env.grid[rx+1][ey+1]))
         {
             if (x_chance_in_y(doorlevel, 10))
-                grd[rx][ey+1] = DNGN_CLOSED_DOOR;
+                env.grid[rx][ey+1] = DNGN_CLOSED_DOOR;
         }
     }
 
@@ -1011,8 +1011,8 @@ static void _place_pool(dungeon_feature_type pool_type, uint8_t pool_x1,
     {
         for (i = pool_x1 + 1; i < pool_x2 - 1; i++)
         {
-            if (i >= left_edge && i <= right_edge && grd[i][j] == DNGN_FLOOR)
-                grd[i][j] = pool_type;
+            if (i >= left_edge && i <= right_edge && env.grid[i][j] == DNGN_FLOOR)
+                env.grid[i][j] = pool_type;
         }
 
         if (j - pool_y1 < (pool_y2 - pool_y1) / 2 || one_chance_in(4))
@@ -1080,7 +1080,7 @@ static bool _may_overwrite_pos(coord_def c)
     if (map_masked(c, MMT_VAULT))
         return false;
 
-    const dungeon_feature_type grid = grd(c);
+    const dungeon_feature_type grid = env.grid(c);
 
     // Don't overwrite any stairs or branch entrances.
     if (feat_is_stair(grid)
@@ -1133,10 +1133,10 @@ static void _build_river(dungeon_feature_type river_type) //mv
                     if (width == 2 && river_type == DNGN_DEEP_WATER
                         && coinflip())
                     {
-                        grd[i][j] = DNGN_SHALLOW_WATER;
+                        env.grid[i][j] = DNGN_SHALLOW_WATER;
                     }
                     else
-                        grd[i][j] = river_type;
+                        env.grid[i][j] = river_type;
 
                     // Override existing markers.
                     env.markers.remove_markers_at(coord_def(i, j), MAT_ANY);
@@ -1189,7 +1189,7 @@ static void _build_lake(dungeon_feature_type lake_type) //mv
                 // on lava and deep water grids. -- bwr
                 if (!one_chance_in(200) && _may_overwrite_pos(coord_def(i, j)))
                 {
-                    grd[i][j] = lake_type;
+                    env.grid[i][j] = lake_type;
 
                     // Override markers. (No underwater portals, please.)
                     env.markers.remove_markers_at(coord_def(i, j), MAT_ANY);
index 7f0715d..91fca41 100644 (file)
@@ -100,9 +100,9 @@ bool move_notable_thing(const coord_def& orig, const coord_def& dest)
     ASSERT_IN_BOUNDS(orig);
     ASSERT_IN_BOUNDS(dest);
     ASSERT(orig != dest);
-    ASSERT(!is_notable_terrain(grd(dest)));
+    ASSERT(!is_notable_terrain(env.grid(dest)));
 
-    if (!is_notable_terrain(grd(orig)))
+    if (!is_notable_terrain(env.grid(orig)))
         return false;
 
     level_pos pos1(level_id::current(), orig);
@@ -592,7 +592,7 @@ static bool _unnotice_shop(const level_pos &pos)
 
 static bool _unnotice_stair(const level_pos &pos)
 {
-    const dungeon_feature_type feat = grd(pos.pos);
+    const dungeon_feature_type feat = env.grid(pos.pos);
     if (!feat_is_branch_entrance(feat))
         return false;
 
@@ -990,7 +990,7 @@ void annotate_level()
     level_id li  = level_id::current();
     level_id li2 = level_id::current();
 
-    if (feat_is_stair(grd(you.pos())))
+    if (feat_is_stair(env.grid(you.pos())))
     {
         li2 = level_id::get_next_level_id(you.pos());
 
index 2819d16..10d50c1 100644 (file)
@@ -233,7 +233,7 @@ LevelLayout::LevelLayout(level_id id, uint32_t _seed, const ProceduralLayout &_l
     }
     level_excursion le;
     le.go_to(id);
-    grid = feature_grid(grd);
+    grid = feature_grid(env.grid);
     for (rectangle_iterator ri(0); ri; ++ri)
     {
         grid(*ri) = sanitize_feature(grid(*ri), true);
index 0263986..55b8973 100644 (file)
@@ -203,7 +203,7 @@ static void _shoals_apply_level()
 {
     for (rectangle_iterator ri(1); ri; ++ri)
         if (!map_masked(*ri, MMT_VAULT))
-            grd(*ri) = _shoals_feature_at(*ri);
+            env.grid(*ri) = _shoals_feature_at(*ri);
 }
 
 static void _shoals_postbuild_apply_level()
@@ -212,11 +212,11 @@ static void _shoals_postbuild_apply_level()
     {
         if (!map_masked(*ri, MMT_VAULT))
         {
-            const dungeon_feature_type feat = grd(*ri);
+            const dungeon_feature_type feat = env.grid(*ri);
             if (feat_is_water(feat) || feat == DNGN_ROCK_WALL
                 || feat == DNGN_STONE_WALL || feat == DNGN_FLOOR)
             {
-                grd(*ri) = _shoals_feature_at(*ri);
+                env.grid(*ri) = _shoals_feature_at(*ri);
             }
         }
     }
@@ -229,7 +229,7 @@ static vector<coord_def> _shoals_water_depth_change_points()
     for (rectangle_iterator ri(1); ri; ++ri)
     {
         coord_def c(*ri);
-        if (grd(c) == DNGN_DEEP_WATER
+        if (env.grid(c) == DNGN_DEEP_WATER
             && dgn_has_adjacent_feat(c, DNGN_SHALLOW_WATER))
         {
             points.push_back(c);
@@ -269,7 +269,7 @@ static void _shoals_deepen_water()
                 const coord_def adj(*ai);
                 if (!seen_points(adj)
                     && (adj - c).abs() == 1
-                    && grd(adj) == DNGN_DEEP_WATER)
+                    && env.grid(adj) == DNGN_DEEP_WATER)
                 {
                     npage.push_back(adj);
                     seen_points(adj) = true;
@@ -329,7 +329,7 @@ static int _shoals_contiguous_feature_flood(
             for (adjacent_iterator ai(p); ai && npoints < size_limit; ++ai)
             {
                 const coord_def adj(*ai);
-                if (in_bounds(adj) && !rmap(adj) && grd(adj) == feat
+                if (in_bounds(adj) && !rmap(adj) && env.grid(adj) == feat
                     && !map_masked(adj, MMT_VAULT))
                 {
                     rmap(adj) = nregion;
@@ -416,7 +416,7 @@ _shoals_point_feat_cluster(dungeon_feature_type feat,
     for (rectangle_iterator ri(1); ri; ++ri)
     {
         coord_def c(*ri);
-        if (!region_map(c) && grd(c) == feat
+        if (!region_map(c) && env.grid(c) == feat
             && !map_masked(c, MMT_VAULT))
         {
             const int featcount =
@@ -472,7 +472,7 @@ static void _shoals_make_plant_near(coord_def c, int radius,
             && !monster_at(plant_place)
             && !map_masked(plant_place, MMT_VAULT))
         {
-            const dungeon_feature_type feat(grd(plant_place));
+            const dungeon_feature_type feat(env.grid(plant_place));
             if (_shoals_plantworthy_feat(feat)
                 && (feat == preferred_feat || coinflip())
                 && (!verboten || !(*verboten)(plant_place)))
@@ -591,7 +591,7 @@ static vector<coord_def> _shoals_windshadows(grid_bool &windy)
     for (rectangle_iterator ri(1); ri; ++ri)
     {
         const coord_def p(*ri);
-        if (!windy(p) && grd(p) == DNGN_FLOOR
+        if (!windy(p) && env.grid(p) == DNGN_FLOOR
             && (dgn_has_adjacent_feat(p, DNGN_STONE_WALL)
                 || dgn_has_adjacent_feat(p, DNGN_ROCK_WALL)))
         {
@@ -687,7 +687,7 @@ void shoals_postprocess_level()
         if (is_tide_immune(c))
             continue;
 
-        const dungeon_feature_type feat(grd(c));
+        const dungeon_feature_type feat(env.grid(c));
         if (!_shoals_tide_susceptible_feat(feat) && !feat_is_solid(feat))
             continue;
 
@@ -843,13 +843,13 @@ static void _shoals_apply_tide_feature_at(
     coord_def c,
     dungeon_feature_type feat)
 {
-    const dungeon_feature_type current_feat = grd(c);
+    const dungeon_feature_type current_feat = env.grid(c);
 
     if (feat == current_feat)
         return;
 
     if (crawl_state.generating_level)
-        grd(c) = feat;
+        env.grid(c) = feat;
     else
         dungeon_terrain_changed(c, feat, false, true);
 }
@@ -880,7 +880,7 @@ static void _shoals_apply_tide_at(coord_def c, int tide)
         newfeat = DNGN_FLOOR;
     if (feat_is_water(newfeat))
         newfeat = DNGN_SHALLOW_WATER;
-    const dungeon_feature_type oldfeat = grd(c);
+    const dungeon_feature_type oldfeat = env.grid(c);
 
 
     if (oldfeat == newfeat
@@ -936,14 +936,14 @@ static void _shoals_apply_tide(int tide)
 
         for (const coord_def c : cpage)
         {
-            const dungeon_feature_type herefeat(grd(c));
+            const dungeon_feature_type herefeat(env.grid(c));
             const bool was_wet = (_shoals_tide_passable_feat(herefeat)
                                   && !is_temp_terrain(c));
             seen_points(c) = true;
             if (_shoals_tide_susceptible_feat(herefeat))
                 _shoals_apply_tide_at(c, _shoals_tide_at(c, tide));
 
-            const bool is_wet(feat_is_water(grd(c)));
+            const bool is_wet(feat_is_water(env.grid(c)));
 
             // Only squares that were wet (before applying tide
             // effects!) can propagate the tide onwards. If the tide is
@@ -958,7 +958,7 @@ static void _shoals_apply_tide(int tide)
                         continue;
                     if (!seen_points(adj))
                     {
-                        const dungeon_feature_type feat = grd(adj);
+                        const dungeon_feature_type feat = env.grid(adj);
                         if (_shoals_tide_passable_feat(feat)
                             || _shoals_tide_susceptible_feat(feat))
                         {
index 2eb985a..c6f5f96 100644 (file)
@@ -51,10 +51,10 @@ static void _swamp_apply_features(int margin)
             if (c.x < margin || c.y < margin || c.x >= GXM - margin
                 || c.y >= GYM - margin)
             {
-                grd(c) = DNGN_TREE;
+                env.grid(c) = DNGN_TREE;
             }
             else
-                grd(c) = _swamp_feature_for_height(dgn_height_at(c));
+                env.grid(c) = _swamp_feature_for_height(dgn_height_at(c));
         }
     }
 }
index 60b84c4..dadb50e 100644 (file)
@@ -385,7 +385,7 @@ static cglyph_t _get_ray_glyph(const coord_def& pos, int colour, int glych,
 // These should match tests in show.cc's _update_monster
 static bool _mon_exposed_in_water(const monster* mon)
 {
-    return grd(mon->pos()) == DNGN_SHALLOW_WATER && !mon->airborne()
+    return env.grid(mon->pos()) == DNGN_SHALLOW_WATER && !mon->airborne()
            && !mon->submerged() && !cloud_at(mon->pos());
 }
 
@@ -775,10 +775,10 @@ static void _get_nearby_features(vector<coord_def> &list_features,
             {
                 for (const text_pattern &pattern : filters)
                 {
-                    if (pattern.matches(feature_description(grd(*ri)))
-                        || feat_stair_direction(grd(*ri)) != CMD_NO_CMD
+                    if (pattern.matches(feature_description(env.grid(*ri)))
+                        || feat_stair_direction(env.grid(*ri)) != CMD_NO_CMD
                            && pattern.matches("stair")
-                        || feat_is_trap(grd(*ri))
+                        || feat_is_trap(env.grid(*ri))
                            && pattern.matches("trap"))
                     {
                         list_features.push_back(*ri);
@@ -1414,7 +1414,7 @@ void direction_chooser::print_target_description(bool &did_cloud) const
 
 string direction_chooser::target_interesting_terrain_description() const
 {
-    const dungeon_feature_type feature = grd(target());
+    const dungeon_feature_type feature = env.grid(target());
 
     // Only features which can make you lose the item are interesting.
     // FIXME: extract the naming logic from here and use
@@ -1564,7 +1564,7 @@ void direction_chooser::print_items_description() const
 
 void direction_chooser::print_floor_description(bool boring_too) const
 {
-    const dungeon_feature_type feat = grd(target());
+    const dungeon_feature_type feat = env.grid(target());
     if (!boring_too && feat == DNGN_FLOOR)
         return;
 
@@ -3024,7 +3024,7 @@ string feature_description(dungeon_feature_type grid, trap_type trap,
 
 string raw_feature_description(const coord_def &where)
 {
-    dungeon_feature_type feat = grd(where);
+    dungeon_feature_type feat = env.grid(where);
 
     int mapi = env.level_map_ids(where);
     if (mapi != INVALID_MAP_INDEX)
@@ -3169,7 +3169,7 @@ string feature_description_at(const coord_def& where, bool covering,
         string desc = "";
         if (env.forest_awoken_until)
             desc += "awoken ";
-        desc += grid == grd(where) ? raw_feature_description(where)
+        desc += grid == env.grid(where) ? raw_feature_description(where)
                                    : _base_feature_desc(grid, trap);
         if (is_temp_terrain(where))
             desc += " (summoned)";
@@ -3182,7 +3182,7 @@ string feature_description_at(const coord_def& where, bool covering,
             dtype = DESC_THE;
         // fallthrough
     default:
-        const string featdesc = grid == grd(where)
+        const string featdesc = grid == env.grid(where)
                               ? raw_feature_description(where)
                               : _base_feature_desc(grid, trap);
         return thing_do_grammar(dtype, featdesc + covering_description);
@@ -3253,7 +3253,7 @@ static string _stair_destination_description(const coord_def &pos)
         const stair_info *si = linf->get_stair(pos);
         if (si)
             return " " + si->describe();
-        else if (feat_is_stair(grd(pos)))
+        else if (feat_is_stair(env.grid(pos)))
             return " (unknown stair)";
     }
     return "";
@@ -3701,7 +3701,7 @@ static void _debug_describe_feature_at(const coord_def &where)
     string height_desc;
     if (env.heightmap)
         height_desc = make_stringf(" (height: %d)", (*env.heightmap)(where));
-    const dungeon_feature_type feat = grd(where);
+    const dungeon_feature_type feat = env.grid(where);
 
     string vault;
     const int map_index = env.level_map_ids(where);
@@ -3814,7 +3814,7 @@ static void _describe_cell(const coord_def& where, bool in_range)
     }
     else
     {
-        dungeon_feature_type feat = grd(where);
+        dungeon_feature_type feat = env.grid(where);
 
         if (_interesting_feature(feat))
         {
index 6bed951..f40875c 100644 (file)
@@ -228,7 +228,7 @@ enum dungeon_feature_type
 #endif
     DNGN_DRY_FOUNTAIN,
 
-    // Not meant to ever appear in grd().
+    // Not meant to ever appear in env.grid().
     DNGN_EXPLORE_HORIZON, // dummy for redefinition
 #if TAG_MAJOR_VERSION > 34
     DNGN_TRAVEL_TRAIL, // dummy for redefinition
index 1e230ef..dc26ff6 100644 (file)
@@ -424,10 +424,10 @@ static void _builder_assertions()
 #ifdef ASSERTS
     for (rectangle_iterator ri(0); ri; ++ri)
         if (!in_bounds(*ri))
-            if (!feat_is_valid_border(grd(*ri)))
+            if (!feat_is_valid_border(env.grid(*ri)))
             {
                 die("invalid map border at (%d,%d): %s", ri->x, ri->y,
-                    dungeon_feature_name(grd(*ri)));
+                    dungeon_feature_name(env.grid(*ri)));
             }
 #endif
 }
@@ -667,7 +667,7 @@ static void _dgn_load_colour_grid()
             if (env.grid_colours[x][y] != BLACK)
             {
                 dcgrid[x][y]
-                    = coloured_feature(grd[x][y], env.grid_colours[x][y]);
+                    = coloured_feature(env.grid[x][y], env.grid_colours[x][y]);
             }
 }
 
@@ -681,7 +681,7 @@ static void _dgn_map_colour_fixup()
     for (int y = Y_BOUND_1; y <= Y_BOUND_2; ++y)
         for (int x = X_BOUND_1; x <= X_BOUND_2; ++x)
             if (dcgrid[x][y].colour != BLACK
-                && grd[x][y] != dcgrid[x][y].feature
+                && env.grid[x][y] != dcgrid[x][y].feature
                 && dcgrid[x][y].feature != DNGN_FLOOR)
             {
                 env.grid_colours[x][y] = BLACK;
@@ -698,7 +698,7 @@ void dgn_set_grid_colour_at(const coord_def &c, int colour)
         if (!dgn_colour_grid)
             dgn_colour_grid.reset(new dungeon_colour_grid);
 
-        (*dgn_colour_grid)(c) = coloured_feature(grd(c), colour);
+        (*dgn_colour_grid)(c) = coloured_feature(env.grid(c), colour);
     }
 }
 
@@ -708,7 +708,7 @@ static void _set_grd(const coord_def &c, dungeon_feature_type feat)
     env.tile_flv(c).feat    = 0;
     env.tile_flv(c).special = 0;
     env.grid_colours(c) = 0;
-    grd(c) = feat;
+    env.grid(c) = feat;
 }
 
 static void _dgn_register_vault(const string &name, const unordered_set<string> &tags)
@@ -760,7 +760,7 @@ static void _dgn_unregister_vault(const map_def &map)
 
 bool dgn_square_travel_ok(const coord_def &c)
 {
-    const dungeon_feature_type feat = grd(c);
+    const dungeon_feature_type feat = env.grid(c);
     if (feat_is_trap(feat))
     {
         const trap_def * const trap = trap_at(c);
@@ -793,7 +793,7 @@ static bool _dgn_square_is_ever_passable(const coord_def &c)
 {
     if (!(env.level_map_mask(c) & MMT_OPAQUE))
     {
-        const dungeon_feature_type feat = grd(c);
+        const dungeon_feature_type feat = env.grid(c);
         if (feat == DNGN_DEEP_WATER || feat == DNGN_LAVA)
             return true;
     }
@@ -848,7 +848,7 @@ static bool _dgn_fill_zone(
 
 static bool _is_perm_down_stair(const coord_def &c)
 {
-    switch (grd(c))
+    switch (env.grid(c))
     {
     case DNGN_STONE_STAIRS_DOWN_I:
     case DNGN_STONE_STAIRS_DOWN_II:
@@ -872,13 +872,13 @@ static bool _is_upwards_exit_stair(const coord_def &c)
     if (feature_mimic_at(c))
         return false;
 
-    if (feat_is_stone_stair_up(grd(c))
-        || feat_is_branch_exit(grd(c)))
+    if (feat_is_stone_stair_up(env.grid(c))
+        || feat_is_branch_exit(env.grid(c)))
     {
         return true;
     }
 
-    switch (grd(c))
+    switch (env.grid(c))
     {
     case DNGN_EXIT_PANDEMONIUM:
     case DNGN_TRANSIT_PANDEMONIUM:
@@ -899,14 +899,14 @@ static bool _is_exit_stair(const coord_def &c)
     // Branch entries, portals, and abyss entries are not considered exit
     // stairs here, as they do not provide an exit (in a transitive sense) from
     // the current level.
-    if (feat_is_stone_stair(grd(c))
-        || feat_is_escape_hatch(grd(c))
-        || feat_is_branch_exit(grd(c)))
+    if (feat_is_stone_stair(env.grid(c))
+        || feat_is_escape_hatch(env.grid(c))
+        || feat_is_branch_exit(env.grid(c)))
     {
         return true;
     }
 
-    switch (grd(c))
+    switch (env.grid(c))
     {
     case DNGN_EXIT_PANDEMONIUM:
     case DNGN_TRANSIT_PANDEMONIUM:
@@ -1033,8 +1033,8 @@ static void _fixup_hell_stairs()
 {
     for (rectangle_iterator ri(1); ri; ++ri)
     {
-        if (feat_is_stone_stair_up(grd(*ri))
-            || grd(*ri) == DNGN_ESCAPE_HATCH_UP)
+        if (feat_is_stone_stair_up(env.grid(*ri))
+            || env.grid(*ri) == DNGN_ESCAPE_HATCH_UP)
         {
             _set_grd(*ri, DNGN_ENTER_HELL);
         }
@@ -1045,8 +1045,8 @@ static void _fixup_pandemonium_stairs()
 {
     for (rectangle_iterator ri(1); ri; ++ri)
     {
-        if (feat_is_stone_stair_up(grd(*ri))
-            || grd(*ri) == DNGN_ESCAPE_HATCH_UP)
+        if (feat_is_stone_stair_up(env.grid(*ri))
+            || env.grid(*ri) == DNGN_ESCAPE_HATCH_UP)
         {
             _set_grd(*ri, DNGN_TRANSIT_PANDEMONIUM);
         }
@@ -1200,7 +1200,7 @@ static coord_def _find_level_feature(int feat)
 {
     for (rectangle_iterator ri(1); ri; ++ri)
     {
-        if (grd(*ri) == feat)
+        if (env.grid(*ri) == feat)
             return *ri;
     }
 
@@ -1457,7 +1457,7 @@ void fixup_misplaced_items()
 
         if (in_bounds(item.pos))
         {
-            dungeon_feature_type feat = grd(item.pos);
+            dungeon_feature_type feat = env.grid(item.pos);
             if (feat_has_solid_floor(feat))
                 continue;
 
@@ -1526,17 +1526,17 @@ static void _fixup_branch_stairs()
     {
         const bool vault = map_masked(*ri, MMT_VAULT);
         const auto escape_replacement = vault ? up_hatch : DNGN_FLOOR;
-        if (bottom && (feat_is_stone_stair_down(grd(*ri))
-                       || grd(*ri) == DNGN_ESCAPE_HATCH_DOWN))
+        if (bottom && (feat_is_stone_stair_down(env.grid(*ri))
+                       || env.grid(*ri) == DNGN_ESCAPE_HATCH_DOWN))
         {
             _set_grd(*ri, escape_replacement);
         }
 
         if (top)
         {
-            if (grd(*ri) == DNGN_ESCAPE_HATCH_UP)
+            if (env.grid(*ri) == DNGN_ESCAPE_HATCH_UP)
                 _set_grd(*ri, escape_replacement);
-            else if (feat_is_stone_stair_up(grd(*ri)))
+            else if (feat_is_stone_stair_up(env.grid(*ri)))
             {
 #ifdef DEBUG_DIAGNOSTICS
                 if (count++ && !root)
@@ -1547,7 +1547,7 @@ static void _fixup_branch_stairs()
 #endif
                 if (root)
                 {
-                    env.markers.add(new map_feature_marker(*ri, grd(*ri)));
+                    env.markers.add(new map_feature_marker(*ri, env.grid(*ri)));
                     _set_grd(*ri, exit);
                 }
                 else
@@ -1572,7 +1572,7 @@ static void _fixup_branch_stairs()
         {
             shuffle_array(stairs);
             coord_def coord = *(stairs.begin());
-            env.markers.add(new map_feature_marker(coord, grd(coord)));
+            env.markers.add(new map_feature_marker(coord, env.grid(coord)));
             _set_grd(coord, exit);
             for (auto it = stairs.begin() + 1; it != stairs.end(); it++)
                 _set_grd(*it, DNGN_FLOOR);
@@ -1591,7 +1591,7 @@ static list<coord_def> _find_stone_stairs(bool up_stairs)
         if (feature_mimic_at(c))
             continue;
 
-        const dungeon_feature_type feat = grd(c);
+        const dungeon_feature_type feat = env.grid(c);
         if (feat_is_stone_stair(feat)
             && up_stairs == feat_is_stone_stair_up(feat))
         {
@@ -1628,8 +1628,8 @@ static void _cull_redundant_stairs(list<coord_def> &stairs,
     {
         const coord_def s1_loc = *iter1;
         // Ensure we don't search for the feature at s1. XXX: unwind_var?
-        const dungeon_feature_type saved_feat = grd(s1_loc);
-        grd(s1_loc) = DNGN_FLOOR;
+        const dungeon_feature_type saved_feat = env.grid(s1_loc);
+        env.grid(s1_loc) = DNGN_FLOOR;
 
         auto iter2 = iter1;
         ++iter2;
@@ -1644,7 +1644,7 @@ static void _cull_redundant_stairs(list<coord_def> &stairs,
 
             flood_find<feature_grid, coord_predicate> ff(env.grid,
                                                          in_bounds);
-            ff.add_feat(grd(s2_loc));
+            ff.add_feat(env.grid(s2_loc));
             const coord_def where =
                 ff.find_first_from(s1_loc, env.level_map_mask);
             if (!where.x) // these stairs aren't in the same zone
@@ -1652,11 +1652,11 @@ static void _cull_redundant_stairs(list<coord_def> &stairs,
 
             dprf(DIAG_DNGN,
                  "Too many stairs -- removing one of a connected pair.");
-            grd(s2_loc) = hatch_type;
+            env.grid(s2_loc) = hatch_type;
             stairs.erase(being_examined);
         }
 
-        grd(s1_loc) = saved_feat;
+        env.grid(s1_loc) = saved_feat;
     }
 }
 
@@ -1821,7 +1821,7 @@ static bool _fixup_stone_stairs(bool preserve_vault_stairs,
         ASSERT(needed_stairs == 1);
         ASSERT(stairs.size() == 1 || player_in_branch(root_branch));
         if (stairs.size() == 1)
-            grd(stairs.front()) = DNGN_STONE_STAIRS_UP_I;
+            env.grid(stairs.front()) = DNGN_STONE_STAIRS_UP_I;
 
         return true;
     }
@@ -1832,10 +1832,10 @@ static bool _fixup_stone_stairs(bool preserve_vault_stairs,
     {
         const coord_def s1_loc = stairs.front();
         const coord_def s2_loc = stairs.back();
-        if (grd(s1_loc) == grd(s2_loc))
+        if (env.grid(s1_loc) == env.grid(s2_loc))
         {
             _set_grd(s2_loc, (dungeon_feature_type)
-                     (base + (grd(s2_loc)-base+1) % needed_stairs));
+                     (base + (env.grid(s2_loc)-base+1) % needed_stairs));
         }
 
         stairs.push_back(stairs.front());
@@ -1889,7 +1889,7 @@ static bool _add_feat_if_missing(bool (*iswanted)(const coord_def &),
             bool found_feature = false;
             for (rectangle_iterator ri(0); ri; ++ri)
             {
-                if (grd(*ri) == feat
+                if (env.grid(*ri) == feat
                     && travel_point_distance[ri->x][ri->y] == nzones)
                 {
                     found_feature = true;
@@ -1906,7 +1906,7 @@ static bool _add_feat_if_missing(bool (*iswanted)(const coord_def &),
                 coord_def rnd;
                 rnd.x = random2(GXM);
                 rnd.y = random2(GYM);
-                if (grd(rnd) != DNGN_FLOOR)
+                if (env.grid(rnd) != DNGN_FLOOR)
                     continue;
 
                 if (travel_point_distance[rnd.x][rnd.y] != nzones)
@@ -1922,7 +1922,7 @@ static bool _add_feat_if_missing(bool (*iswanted)(const coord_def &),
 
             for (rectangle_iterator ri(0); ri; ++ri)
             {
-                if (grd(*ri) != DNGN_FLOOR)
+                if (env.grid(*ri) != DNGN_FLOOR)
                     continue;
 
                 if (travel_point_distance[ri->x][ri->y] != nzones)
@@ -1986,7 +1986,7 @@ static bool _branch_entrances_are_connected()
     // stone stairs.
     for (rectangle_iterator ri(0); ri; ++ri)
     {
-        if (!feat_is_branch_entrance(grd(*ri)))
+        if (!feat_is_branch_entrance(env.grid(*ri)))
             continue;
         if (!_has_connected_stone_stairs_from(*ri))
             return false;
@@ -2219,7 +2219,7 @@ struct coord_feat
 
     void set_from(const coord_def &c)
     {
-        feat = grd(c);
+        feat = env.grid(c);
         // Don't copy mimic-ness.
         mask = env.level_map_mask(c) & ~(MMT_MIMIC);
         // Only copy "static" properties.
@@ -2248,11 +2248,11 @@ static void _ruin_level(Iterator iter,
                 continue;
 
             // only try to replace wall and door tiles
-            if (!feat_is_wall(grd(*ri)) && !feat_is_door(grd(*ri)))
+            if (!feat_is_wall(env.grid(*ri)) && !feat_is_door(env.grid(*ri)))
                 continue;
 
             // don't mess with permarock
-            if (grd(*ri) == DNGN_PERMAROCK_WALL)
+            if (env.grid(*ri) == DNGN_PERMAROCK_WALL)
                 continue;
 
             // or vaults
@@ -2265,10 +2265,10 @@ static void _ruin_level(Iterator iter,
             int floor_count = 0;
             for (adjacent_iterator ai(*ri); ai; ++ai)
             {
-                if (!feat_is_wall(grd(*ai)) && !feat_is_door(grd(*ai))
-                    && !feat_is_statuelike(grd(*ai))
+                if (!feat_is_wall(env.grid(*ai)) && !feat_is_door(env.grid(*ai))
+                    && !feat_is_statuelike(env.grid(*ai))
                     // Shouldn't happen, but just in case.
-                    && grd(*ai) != DNGN_MALIGN_GATEWAY)
+                    && env.grid(*ai) != DNGN_MALIGN_GATEWAY)
                 {
                     if (one_chance_in(++floor_count))
                         replacement.set_from(*ai);
@@ -2289,7 +2289,7 @@ static void _ruin_level(Iterator iter,
             ASSERT(replacement != DNGN_UNSEEN);
 
             // Don't replace doors with impassable features.
-            if (feat_is_door(grd(p)))
+            if (feat_is_door(env.grid(p)))
             {
                 if (feat_is_water(replacement))
                     replacement = DNGN_SHALLOW_WATER;
@@ -2305,7 +2305,7 @@ static void _ruin_level(Iterator iter,
             }
 
             // only remove some doors, to preserve tactical options
-            if (feat_is_wall(grd(p)) || coinflip() && feat_is_door(grd(p)))
+            if (feat_is_wall(env.grid(p)) || coinflip() && feat_is_door(env.grid(p)))
             {
                 // Copy the mask and properties too, so that we don't make an
                 // isolated transparent or rtele_into square.
@@ -2317,12 +2317,12 @@ static void _ruin_level(Iterator iter,
             // but remove doors if we've removed all adjacent walls
             for (adjacent_iterator wai(p); wai; ++wai)
             {
-                if (feat_is_door(grd(*wai)))
+                if (feat_is_door(env.grid(*wai)))
                 {
                     bool remove = true;
                     for (adjacent_iterator dai(*wai); dai; ++dai)
                     {
-                        if (feat_is_wall(grd(*dai)))
+                        if (feat_is_wall(env.grid(*dai)))
                             remove = false;
                     }
                     // It's always safe to replace a door with floor.
@@ -2341,7 +2341,7 @@ static void _ruin_level(Iterator iter,
     {
         // replace some ruined walls with plants/fungi/bushes
         if (plant_density && one_chance_in(plant_density)
-            && feat_has_solid_floor(grd(p))
+            && feat_has_solid_floor(env.grid(p))
             && !plant_forbidden_at(p))
         {
             mgen_data mg;
@@ -2371,7 +2371,7 @@ static void _place_feature_mimics()
     for (rectangle_iterator ri(1); ri; ++ri)
     {
         const coord_def pos = *ri;
-        const dungeon_feature_type feat = grd(pos);
+        const dungeon_feature_type feat = env.grid(pos);
 
         // Vault tag prevents mimic.
         if (map_masked(pos, MMT_NO_MIMIC))
@@ -2536,7 +2536,7 @@ static void _check_doors()
 {
     for (rectangle_iterator ri(1); ri; ++ri)
     {
-        if (!feat_is_closed_door(grd(*ri)))
+        if (!feat_is_closed_door(env.grid(*ri)))
             continue;
 
         int solid_count = 0;
@@ -2557,14 +2557,14 @@ int count_feature_in_box(int x0, int y0, int x1, int y1,
     for (int i = x0; i < x1; ++i)
         for (int j = y0; j < y1; ++j)
         {
-            if (grd[i][j] == feat)
+            if (env.grid[i][j] == feat)
                 ++result;
         }
 
     return result;
 }
 
-// Count how many neighbours of grd[x][y] are the feature feat.
+// Count how many neighbours of env.grid[x][y] are the feature feat.
 int count_neighbours(int x, int y, dungeon_feature_type feat)
 {
     return count_feature_in_box(x-1, y-1, x+2, y+2, feat);
@@ -2576,12 +2576,12 @@ static void _prepare_water()
 {
     for (rectangle_iterator ri(1); ri; ++ri)
     {
-        if (map_masked(*ri, MMT_NO_POOL) || grd(*ri) != DNGN_DEEP_WATER)
+        if (map_masked(*ri, MMT_NO_POOL) || env.grid(*ri) != DNGN_DEEP_WATER)
             continue;
 
         for (adjacent_iterator ai(*ri); ai; ++ai)
         {
-            const dungeon_feature_type which_grid = grd(*ai);
+            const dungeon_feature_type which_grid = env.grid(*ai);
 
             if (which_grid == DNGN_SHALLOW_WATER && one_chance_in(20)
                 || feat_has_dry_floor(which_grid) && x_chance_in_y(2, 5))
@@ -3260,7 +3260,7 @@ static void _place_traps()
             // Don't place random traps under vault monsters; if a vault
             // wants this they have to request it specifically.
             if (in_bounds(ts.pos)
-                && grd(ts.pos) == DNGN_FLOOR
+                && env.grid(ts.pos) == DNGN_FLOOR
                 && !map_masked(ts.pos, MMT_NO_TRAP)
                 && mgrd(ts.pos) == NON_MONSTER)
             {
@@ -3285,7 +3285,7 @@ static void _place_traps()
         }
 
         ts.type = type;
-        grd(ts.pos) = ts.feature();
+        env.grid(ts.pos) = ts.feature();
         ts.prepare_ammo();
         env.trap[ts.pos] = ts;
         dprf("placed a %s trap", trap_name(type).c_str());
@@ -3336,8 +3336,8 @@ void dgn_place_stone_stairs(bool maybe_place_hatches)
     existing.init(false);
 
     for (rectangle_iterator ri(0); ri; ++ri)
-        if (grd(*ri) >= stair_start && grd(*ri) < stair_start + stair_count)
-            existing[grd(*ri) - stair_start] = true;
+        if (env.grid(*ri) >= stair_start && env.grid(*ri) < stair_start + stair_count)
+            existing[env.grid(*ri) - stair_start] = true;
 
     int pair_count = 3;
 
@@ -3363,7 +3363,7 @@ void dgn_place_stone_stairs(bool maybe_place_hatches)
 bool dgn_has_adjacent_feat(coord_def c, dungeon_feature_type feat)
 {
     for (adjacent_iterator ai(c); ai; ++ai)
-        if (grd(*ai) == feat)
+        if (env.grid(*ai) == feat)
             return true;
     return false;
 }
@@ -3382,7 +3382,7 @@ static inline bool _point_matches_feat(coord_def c,
                                        dungeon_feature_type adjacent_feat,
                                        bool monster_free)
 {
-    return grd(c) == searchfeat
+    return env.grid(c) == searchfeat
            && (!monster_free || !monster_at(c))
            && !map_masked(c, mapmask)
            && (adjacent_feat == DNGN_UNSEEN ||
@@ -3507,11 +3507,11 @@ static void _place_branch_entrances(bool use_vaults)
 
     for (rectangle_iterator ri(0); ri; ++ri)
     {
-        if (!feat_is_branch_entrance(grd(*ri)))
+        if (!feat_is_branch_entrance(env.grid(*ri)))
             continue;
 
         for (branch_iterator it; it; ++it)
-            if (it->entry_stairs == grd(*ri)
+            if (it->entry_stairs == env.grid(*ri)
                 && !feature_mimic_at(*ri))
             {
                 branch_entrance_placed[it->id] = true;
@@ -3726,7 +3726,7 @@ static void _place_aquatic_monsters()
         if (actor_at(*ri) || env.level_map_mask(*ri) & MMT_NO_MONS)
             continue;
 
-        dungeon_feature_type feat = grd(*ri);
+        dungeon_feature_type feat = env.grid(*ri);
         if (feat == DNGN_SHALLOW_WATER || feat == DNGN_DEEP_WATER)
             water.push_back(*ri);
         else if (feat == DNGN_LAVA)
@@ -3862,7 +3862,7 @@ static void _randomly_place_item(int item)
     {
         itempos = random_in_bounds();
         const monster* mon = monster_at(itempos);
-        found = grd(itempos) == DNGN_FLOOR
+        found = env.grid(itempos) == DNGN_FLOOR
                 && !map_masked(itempos, MMT_NO_ITEM)
                 // oklobs or statues are ok
                 && (!mon || !mons_is_firewood(*mon));
@@ -3931,7 +3931,7 @@ static bool _connect_vault_exit(const coord_def& exit)
 static bool _grid_needs_exit(const coord_def& c)
 {
     return !cell_is_solid(c)
-           || feat_is_closed_door(grd(c));
+           || feat_is_closed_door(env.grid(c));
 }
 
 static bool _map_feat_is_on_edge(const vault_placement &place,
@@ -3963,7 +3963,7 @@ static void _pick_float_exits(vault_placement &place, vector<coord_def> &targets
 
         // The vault is disconnected, does it have a stair inside?
         for (rectangle_iterator ri(place.pos, place.pos + place.size - 1); ri; ++ri)
-            if (feat_is_stair(grd(*ri)))
+            if (feat_is_stair(env.grid(*ri)))
                 return;
 
         mprf(MSGCH_ERROR, "Unable to find exit from %s",
@@ -4826,7 +4826,7 @@ monster* dgn_place_monster(mons_spec &mspec, coord_def where,
 
         const habitat_type habitat = mons_class_primary_habitat(montype);
 
-        if (in_bounds(where) && !monster_habitable_grid(montype, grd(where)))
+        if (in_bounds(where) && !monster_habitable_grid(montype, env.grid(where)))
             dungeon_terrain_changed(where, habitat2grid(habitat));
     }
 
@@ -5092,17 +5092,17 @@ static void _vault_grid_mapspec(vault_placement &place, const coord_def &where,
     if (f.trap)
         _place_specific_trap(where, f.trap.get(), 0);
     else if (f.feat >= 0)
-        grd(where) = static_cast<dungeon_feature_type>(f.feat);
+        env.grid(where) = static_cast<dungeon_feature_type>(f.feat);
     else if (f.glyph >= 0)
         _vault_grid_glyph(place, where, f.glyph);
     else if (f.shop)
         place_spec_shop(where, *f.shop);
     else
-        grd(where) = DNGN_FLOOR;
+        env.grid(where) = DNGN_FLOOR;
 
     if (f.mimic > 0 && one_chance_in(f.mimic))
     {
-        ASSERT(feat_is_mimicable(grd(where), false));
+        ASSERT(feat_is_mimicable(env.grid(where), false));
         env.level_map_mask(where) |= MMT_MIMIC;
     }
     else if (f.no_mimic)
@@ -5117,12 +5117,12 @@ static void _vault_grid_glyph(vault_placement &place, const coord_def& where,
 {
     // First, set base tile for grids {dlb}:
     if (vgrid != -1)
-        grd(where) = _glyph_to_feat(vgrid);
+        env.grid(where) = _glyph_to_feat(vgrid);
 
-    if (feat_is_altar(grd(where))
-        && is_unavailable_god(feat_altar_god(grd(where))))
+    if (feat_is_altar(env.grid(where))
+        && is_unavailable_god(feat_altar_god(env.grid(where))))
     {
-        grd(where) = DNGN_FLOOR;
+        env.grid(where) = DNGN_FLOOR;
     }
 
     // then, handle oddball grids {dlb}:
@@ -5141,7 +5141,7 @@ static void _vault_grid_glyph(vault_placement &place, const coord_def& where,
         place_specific_trap(where, random_vault_trap());
         break;
     case 'B':
-        grd(where) = _pick_temple_altar();
+        env.grid(where) = _pick_temple_altar();
         break;
     }
 
@@ -5292,9 +5292,9 @@ void dgn_replace_area(const coord_def& p1, const coord_def& p2,
 {
     for (rectangle_iterator ri(p1, p2); ri; ++ri)
     {
-        if (grd(*ri) == replace && !map_masked(*ri, mapmask))
+        if (env.grid(*ri) == replace && !map_masked(*ri, mapmask))
         {
-            grd(*ri) = feature;
+            env.grid(*ri) = feature;
             if (needs_update && env.map_knowledge(*ri).seen())
             {
                 env.map_knowledge(*ri).set_feature(feature, 0,
@@ -5412,10 +5412,10 @@ bool join_the_dots(const coord_def &from, const coord_def &to,
 
     for (auto c : path)
     {
-        auto feat = grd(c);
+        auto feat = env.grid(c);
         if (!map_masked(c, mapmask) && overwriteable(feat))
         {
-            grd(c) = DNGN_FLOOR;
+            env.grid(c) = DNGN_FLOOR;
             dgn_height_set_at(c);
         }
         else
@@ -5905,10 +5905,10 @@ static set<coord_def> _dgn_spotty_connect_path(const coord_def& from,
             if (map_masked(*ai, MMT_VAULT))
                 continue;
 
-            if (grd(*ai) == DNGN_FLOOR)
+            if (env.grid(*ai) == DNGN_FLOOR)
                 success = true; // Through, but let's remove the others, too.
 
-            if (!overwriteable(grd(*ai)) || flatten.count(*ai))
+            if (!overwriteable(env.grid(*ai)) || flatten.count(*ai))
                 continue;
 
             flatten.insert(*ai);
@@ -5940,7 +5940,7 @@ static bool _connect_spotty(const coord_def& from,
     {
         for (auto c : spotty_path)
         {
-            grd(c) = (player_in_branch(BRANCH_SWAMP) && one_chance_in(3))
+            env.grid(c) = (player_in_branch(BRANCH_SWAMP) && one_chance_in(3))
                    ? DNGN_SHALLOW_WATER
                    : DNGN_FLOOR;
             dgn_height_set_at(c);
@@ -5986,7 +5986,7 @@ static void _place_specific_trap(const coord_def& where, trap_spec* spec,
     trap_def t;
     t.type = spec_type;
     t.pos = where;
-    grd(where) = trap_feature(spec_type);
+    env.grid(where) = trap_feature(spec_type);
     t.prepare_ammo(charges);
     env.trap[where] = t;
     dprf("placed a %s trap", trap_name(spec_type).c_str());
@@ -6030,7 +6030,7 @@ static void _add_plant_clumps(int rarity,
         {
             for (radius_iterator rad(*ri, i, C_ROUND); rad; ++rad)
             {
-                if (grd(*rad) != DNGN_FLOOR)
+                if (env.grid(*rad) != DNGN_FLOOR)
                     continue;
 
                 // make sure the iterator stays valid
@@ -6092,7 +6092,7 @@ static coord_def _get_feat_dest(coord_def base_pos, dungeon_feature_type feat,
             {
                 dest_pos = random_in_bounds();
             }
-            while (grd(dest_pos) != DNGN_FLOOR
+            while (env.grid(dest_pos) != DNGN_FLOOR
                    || env.pgrid(dest_pos) & FPROP_NO_TELE_INTO
                    || count_adjacent_slime_walls(dest_pos) != 0);
         }
@@ -6180,14 +6180,14 @@ coord_def dgn_find_nearby_stair(dungeon_feature_type stair_to_find,
     if (stair_to_find == DNGN_STONE_ARCH)
     {
         const coord_def pos(dgn_find_feature_marker(stair_to_find));
-        if (in_bounds(pos) && grd(pos) == stair_to_find)
+        if (in_bounds(pos) && env.grid(pos) == stair_to_find)
             return pos;
     }
 
     if (stair_to_find == your_branch().exit_stairs)
     {
         const coord_def pos(dgn_find_feature_marker(DNGN_STONE_STAIRS_UP_I));
-        if (in_bounds(pos) && grd(pos) == stair_to_find)
+        if (in_bounds(pos) && env.grid(pos) == stair_to_find)
             return pos;
     }
 
@@ -6323,7 +6323,7 @@ coord_def dgn_find_nearby_stair(dungeon_feature_type stair_to_find,
     // can land in vaults, which is considered acceptable.
     for (rectangle_iterator ri(0); ri; ++ri)
     {
-        if (feat_has_dry_floor(grd(*ri)))
+        if (feat_has_dry_floor(env.grid(*ri)))
         {
             found++;
             if (one_chance_in(found))
@@ -6543,7 +6543,7 @@ static bool _fixup_interlevel_connectivity()
         if (feature_mimic_at(*ri))
             continue;
 
-        dungeon_feature_type feat = grd(*ri);
+        dungeon_feature_type feat = env.grid(*ri);
         switch (feat)
         {
         case DNGN_STONE_STAIRS_DOWN_I:
@@ -6817,7 +6817,7 @@ void vault_placement::apply_grid()
             if (feat == ' ')
                 continue;
 
-            const dungeon_feature_type oldgrid = grd(*ri);
+            const dungeon_feature_type oldgrid = env.grid(*ri);
 
             if (clear)
             {
@@ -6839,8 +6839,8 @@ void vault_placement::apply_grid()
                 // this too, but only if oldgrid != newgrid, so we
                 // make sure here.
                 tile_init_flavour(*ri);
-                const dungeon_feature_type newgrid = grd(*ri);
-                grd(*ri) = oldgrid;
+                const dungeon_feature_type newgrid = env.grid(*ri);
+                env.grid(*ri) = oldgrid;
                 dungeon_terrain_changed(*ri, newgrid, true);
                 remove_markers_and_listeners_at(*ri);
             }
@@ -7115,7 +7115,7 @@ static void _calc_density()
         // places in unmodified parts should not suddenly become explorable.
         if (!testbits(env.pgrid(*ri), FPROP_SEEN_OR_NOEXP))
             for (adjacent_iterator ai(*ri, false); ai; ++ai)
-                if (feat_has_solid_floor(grd(*ai)))
+                if (feat_has_solid_floor(env.grid(*ai)))
                 {
                     open++;
                     goto out;
@@ -7133,7 +7133,7 @@ static void _calc_density()
 static void _mark_solid_squares()
 {
     for (rectangle_iterator ri(0); ri; ++ri)
-        if (feat_is_solid(grd(*ri)))
+        if (feat_is_solid(env.grid(*ri)))
             env.pgrid(*ri) |= FPROP_NO_TELE_INTO;
 }
 
index 508628c..68fa4a7 100644 (file)
@@ -154,8 +154,8 @@ static bool _reaching_weapon_attack(const item_def& wpn)
         const coord_def first_middle(x_first_middle, y_first_middle);
         const coord_def second_middle(x_second_middle, y_second_middle);
 
-        if (!feat_is_reachable_past(grd(first_middle))
-            && !feat_is_reachable_past(grd(second_middle)))
+        if (!feat_is_reachable_past(env.grid(first_middle))
+            && !feat_is_reachable_past(env.grid(second_middle)))
         {
             canned_msg(MSG_SOMETHING_IN_WAY);
             return false;
@@ -163,8 +163,8 @@ static bool _reaching_weapon_attack(const item_def& wpn)
 
         // Choose one of the two middle squares (which might be the same).
         const coord_def middle =
-            !feat_is_reachable_past(grd(first_middle)) ? second_middle :
-            !feat_is_reachable_past(grd(second_middle)) ? first_middle :
+            !feat_is_reachable_past(env.grid(first_middle)) ? second_middle :
+            !feat_is_reachable_past(env.grid(second_middle)) ? first_middle :
         random_choose(first_middle, second_middle);
 
         bool success = true;
@@ -618,7 +618,7 @@ static bool _box_of_beasts()
 
 static bool _make_zig(item_def &zig)
 {
-    if (feat_is_critical(grd(you.pos())))
+    if (feat_is_critical(env.grid(you.pos())))
     {
         mpr("You can't place a gateway to a ziggurat here.");
         return false;
index 76cea76..2d8ce69 100644 (file)
@@ -444,7 +444,7 @@ void cycle_exclude_radius(const coord_def &p)
 {
     if (travel_exclude *exc = curr_excludes.get_exclude_root(p))
     {
-        if (feat_is_door(grd(p)) && env.map_knowledge(p).known())
+        if (feat_is_door(env.grid(p)) && env.map_knowledge(p).known())
         {
             _exclude_gate(p, exc->radius == 0);
             return;
index 317e0d8..85e8f71 100644 (file)
@@ -269,7 +269,7 @@ bool fight_melee(actor *attacker, actor *defender, bool *did_hit, bool simu)
             coord_def hopspot = mons->pos() - (foepos - mons->pos()).sgn();
 
             bool found = false;
-            if (!monster_habitable_grid(mons, grd(hopspot)) ||
+            if (!monster_habitable_grid(mons, env.grid(hopspot)) ||
                 actor_at(hopspot))
             {
                 for (adjacent_iterator ai(mons->pos()); ai; ++ai)
@@ -278,7 +278,7 @@ bool fight_melee(actor *attacker, actor *defender, bool *did_hit, bool simu)
                         continue;
                     else
                     {
-                        if (monster_habitable_grid(mons, grd(*ai))
+                        if (monster_habitable_grid(mons, env.grid(*ai))
                             && !actor_at(*ai))
                         {
                             hopspot = *ai;
index 2cee766..87cef84 100644 (file)
@@ -1364,9 +1364,9 @@ static void _place_player(dungeon_feature_type stair_taken,
 
     // Don't return the player into walls, deep water, or a trap.
     for (distance_iterator di(you.pos(), true, false); di; ++di)
-        if (you.is_habitable_feat(grd(*di))
-            && !is_feat_dangerous(grd(*di), true)
-            && !feat_is_trap(grd(*di)))
+        if (you.is_habitable_feat(env.grid(*di))
+            && !is_feat_dangerous(env.grid(*di), true)
+            && !feat_is_trap(env.grid(*di)))
         {
             if (you.pos() != *di)
                 you.moveto(*di);
@@ -1838,9 +1838,9 @@ static void _rescue_player_from_wall()
                 backup_clear_pos = *di;
             // TODO: in principle this should use env.map_forgotten if it
             // exists, but I'm not sure that is worth the trouble.
-            if (feat_is_stair(grd(*di)) && env.map_seen(*di))
+            if (feat_is_stair(env.grid(*di)) && env.map_seen(*di))
             {
-                const command_type dir = feat_stair_direction(grd(*di));
+                const command_type dir = feat_stair_direction(env.grid(*di));
                 if (dir == CMD_GO_UPSTAIRS)
                     upstairs.push_back(*di);
                 else if (dir == CMD_GO_DOWNSTAIRS)
@@ -2151,7 +2151,7 @@ bool load_level(dungeon_feature_type stair_taken, load_mode_type load_mode,
         if (you.duration[DUR_REPEL_STAIRS_MOVE]
             || you.duration[DUR_REPEL_STAIRS_CLIMB])
         {
-            dungeon_feature_type feat = grd(you.pos());
+            dungeon_feature_type feat = env.grid(you.pos());
             if (feat != DNGN_ENTER_SHOP
                 && feat_stair_direction(feat) != CMD_NO_CMD
                 && feat_stair_direction(stair_taken) != CMD_NO_CMD)
index 8059035..9a7e2a4 100644 (file)
@@ -30,7 +30,7 @@ bool is_bloodcovered(const coord_def& p)
 
 bool is_icecovered(const coord_def& p)
 {
-    return feat_is_wall(grd(p)) && testbits(env.pgrid(p), FPROP_ICY);
+    return feat_is_wall(env.grid(p)) && testbits(env.pgrid(p), FPROP_ICY);
 }
 
 bool is_tide_immune(const coord_def &p)
index 9808c29..e8d2c8f 100644 (file)
@@ -1884,7 +1884,7 @@ bool kiku_receive_corpses(int pow)
     for (radius_iterator ri(you.pos(), corpse_delivery_radius, C_SQUARE,
                             LOS_NO_TRANS, true); ri; ++ri)
     {
-        if (mons_class_can_pass(MONS_HUMAN, grd(*ri)))
+        if (mons_class_can_pass(MONS_HUMAN, env.grid(*ri)))
             spaces_for_corpses++;
     }
     // floating over lava, heavy tomb abuse, etc
@@ -1899,7 +1899,7 @@ bool kiku_receive_corpses(int pow)
     for (radius_iterator ri(you.pos(), corpse_delivery_radius, C_SQUARE,
                             LOS_NO_TRANS); ri; ++ri)
     {
-        bool square_is_walkable = mons_class_can_pass(MONS_HUMAN, grd(*ri));
+        bool square_is_walkable = mons_class_can_pass(MONS_HUMAN, env.grid(*ri));
         bool square_is_player_square = (*ri == you.pos());
         bool square_gets_corpse =
             random2(100) < percent_chance_a_square_receives_extra_corpse
@@ -2512,7 +2512,7 @@ bool dithmenos_shadow_step()
          apostrophise(victim->name(DESC_THE)).c_str());
     // Using 'stepped = true' here because it's Shadow *Step*.
     // This helps to evade splash upon landing on water.
-    moveto_location_effects(grd(old_pos), true, old_pos);
+    moveto_location_effects(env.grid(old_pos), true, old_pos);
 
     return true;
 }
@@ -2741,7 +2741,7 @@ bool gozag_setup_call_merchant(bool quiet)
             return false;
         }
     }
-    if (grd(you.pos()) != DNGN_FLOOR)
+    if (env.grid(you.pos()) != DNGN_FLOOR)
     {
         if (!quiet)
         {
@@ -2907,7 +2907,7 @@ static string _gozag_shop_spec(int index)
  */
 static void _gozag_place_shop(int index)
 {
-    ASSERT(grd(you.pos()) == DNGN_FLOOR);
+    ASSERT(env.grid(you.pos()) == DNGN_FLOOR);
     keyed_mapspec kmspec;
     kmspec.set_feat(_gozag_shop_spec(index), false);
 
@@ -3080,10 +3080,10 @@ bool gozag_check_bribe_branch(bool quiet)
     }
     branch_type branch = you.where_are_you;
     branch_type branch2 = NUM_BRANCHES;
-    if (feat_is_branch_entrance(grd(you.pos())))
+    if (feat_is_branch_entrance(env.grid(you.pos())))
     {
         for (branch_iterator it; it; ++it)
-            if (it->entry_stairs == grd(you.pos())
+            if (it->entry_stairs == env.grid(you.pos())
                 && gozag_branch_bribable(it->id))
             {
                 branch2 = it->id;
@@ -3118,10 +3118,10 @@ bool gozag_bribe_branch()
     ASSERT(you.gold >= bribe_amount);
     bool prompted = false;
     branch_type branch = gozag_fixup_branch(you.where_are_you);
-    if (feat_is_branch_entrance(grd(you.pos())))
+    if (feat_is_branch_entrance(env.grid(you.pos())))
     {
         for (branch_iterator it; it; ++it)
-            if (it->entry_stairs == grd(you.pos())
+            if (it->entry_stairs == env.grid(you.pos())
                 && gozag_branch_bribable(it->id))
             {
                 branch_type stair_branch = gozag_fixup_branch(it->id);
@@ -3215,7 +3215,7 @@ spret qazlal_upheaval(coord_def target, bool quiet, bool fail)
         if (cell_is_solid(beam.target))
         {
             mprf("There is %s there.",
-                 article_a(feat_type_name(grd(beam.target))).c_str());
+                 article_a(feat_type_name(env.grid(beam.target))).c_str());
             return spret::abort;
         }
 
@@ -3327,7 +3327,7 @@ spret qazlal_upheaval(coord_def target, bool quiet, bool fail)
         switch (beam.flavour)
         {
             case BEAM_LAVA:
-                if (grd(pos) == DNGN_FLOOR && !actor_at(pos) && coinflip())
+                if (env.grid(pos) == DNGN_FLOOR && !actor_at(pos) && coinflip())
                 {
                     temp_change_terrain(
                         pos, DNGN_LAVA,
@@ -3344,12 +3344,12 @@ spret qazlal_upheaval(coord_def target, bool quiet, bool fail)
                 }
                 break;
             case BEAM_FRAG:
-                if (((grd(pos) == DNGN_ROCK_WALL
-                     || grd(pos) == DNGN_CLEAR_ROCK_WALL
-                     || grd(pos) == DNGN_SLIMY_WALL)
+                if (((env.grid(pos) == DNGN_ROCK_WALL
+                     || env.grid(pos) == DNGN_CLEAR_ROCK_WALL
+                     || env.grid(pos) == DNGN_SLIMY_WALL)
                      && x_chance_in_y(pow / 4, 100)
-                    || feat_is_door(grd(pos))
-                    || grd(pos) == DNGN_GRATE))
+                    || feat_is_door(env.grid(pos))
+                    || env.grid(pos) == DNGN_GRATE))
                 {
                     noisy(30, pos);
                     destroy_wall(pos);
@@ -4765,13 +4765,13 @@ bool ru_power_leap()
             continue;
         }
 
-        if (grd(beam.target) == DNGN_OPEN_SEA)
+        if (env.grid(beam.target) == DNGN_OPEN_SEA)
         {
             clear_messages();
             mpr("You can't leap into the sea!");
             continue;
         }
-        else if (grd(beam.target) == DNGN_LAVA_SEA)
+        else if (env.grid(beam.target) == DNGN_LAVA_SEA)
         {
             clear_messages();
             mpr("You can't leap into the sea of lava!");
@@ -5154,13 +5154,13 @@ bool uskayaw_line_pass()
             continue;
         }
 
-        if (grd(beam.target) == DNGN_OPEN_SEA)
+        if (env.grid(beam.target) == DNGN_OPEN_SEA)
         {
             clear_messages();
             mpr("You can't line pass into the sea!");
             continue;
         }
-        else if (grd(beam.target) == DNGN_LAVA_SEA)
+        else if (env.grid(beam.target) == DNGN_LAVA_SEA)
         {
             clear_messages();
             mpr("You can't line pass into the sea of lava!");
@@ -5521,7 +5521,7 @@ spret hepliaklqana_transference(bool fail)
     if (uninhabitable && victim_visible)
     {
         mprf("%s can't be transferred into %s.",
-             victim->name(DESC_THE).c_str(), feat_type_name(grd(destination)));
+             victim->name(DESC_THE).c_str(), feat_type_name(env.grid(destination)));
         return spret::abort;
     }
 
@@ -5656,7 +5656,7 @@ void hepliaklqana_choose_identity()
 bool wu_jian_can_wall_jump_in_principle(const coord_def& target)
 {
     if (!have_passive(passive_t::wu_jian_wall_jump)
-        || !feat_can_wall_jump_against(grd(target))
+        || !feat_can_wall_jump_against(env.grid(target))
         || you.is_stationary()
         || you.digging)
     {
@@ -5675,7 +5675,7 @@ bool wu_jian_can_wall_jump(const coord_def& target, string &error_ret)
 
     if (!wu_jian_can_wall_jump_in_principle(target))
     {
-        if (!feat_can_wall_jump_against(grd(target)))
+        if (!feat_can_wall_jump_against(env.grid(target)))
         {
             error_ret = string("You cannot wall jump against ") +
                 feature_description_at(target, false, DESC_THE) + ".";
@@ -5707,7 +5707,7 @@ bool wu_jian_can_wall_jump(const coord_def& target, string &error_ret)
     }
 
     const actor* landing_actor = actor_at(wall_jump_landing_spot);
-    if (feat_is_solid(grd(you.pos() + wall_jump_direction))
+    if (feat_is_solid(env.grid(you.pos() + wall_jump_direction))
         || !in_bounds(wall_jump_landing_spot)
         || !you.is_habitable(wall_jump_landing_spot)
         || landing_actor)
index f97bb59..ab665ff 100644 (file)
@@ -880,7 +880,7 @@ static bool is_ash_portal(dungeon_feature_type feat)
 // Yay for rectangle_iterator and radius_iterator not sharing a base type
 static bool _check_portal(coord_def where)
 {
-    const dungeon_feature_type feat = grd(where);
+    const dungeon_feature_type feat = env.grid(where);
     if (feat != env.map_knowledge(where).feat() && is_ash_portal(feat))
     {
         env.map_knowledge(where).set_feature(feat);
@@ -1180,7 +1180,7 @@ void qazlal_storm_clouds()
         bool water = false;
         for (adjacent_iterator ai(candidates[i]); ai; ++ai)
         {
-            if (feat_is_watery(grd(*ai)))
+            if (feat_is_watery(env.grid(*ai)))
                 water = true;
         }
 
index a0047b4..d43410c 100644 (file)
@@ -991,7 +991,7 @@ void hints_first_item(const item_def &item)
 
 static string _describe_portal(const coord_def &gc)
 {
-    const dungeon_feature_type feat = grd(gc);
+    const dungeon_feature_type feat = env.grid(gc);
     string text;
 
     // For the sake of completeness, though it's very unlikely that a
@@ -1562,7 +1562,7 @@ void learned_something_new(hints_event_type seen_what, coord_def gc)
         {
             tiles.place_cursor(CURSOR_TUTORIAL, gc);
             string altar = "An altar to ";
-            altar += god_name(feat_altar_god(grd(gc)));
+            altar += god_name(feat_altar_god(env.grid(gc)));
             tiles.add_text_tag(TAG_TUTORIAL, altar, gc);
         }
 #endif
@@ -3374,7 +3374,7 @@ bool hints_pos_interesting(int x, int y)
 {
     return cloud_at(coord_def(x, y))
            || _water_is_disturbed(x, y)
-           || _hints_feat_interesting(grd[x][y]);
+           || _hints_feat_interesting(env.grid[x][y]);
 }
 
 static bool _hints_feat_interesting(dungeon_feature_type feat)
@@ -3403,7 +3403,7 @@ string hints_describe_pos(int x, int y)
 
 static void _hints_describe_feature(int x, int y, ostringstream& ostr)
 {
-    const dungeon_feature_type feat = grd[x][y];
+    const dungeon_feature_type feat = env.grid[x][y];
     const coord_def            where(x, y);
 
     if (!ostr.str().empty())
@@ -3676,7 +3676,7 @@ static bool _water_is_disturbed(int x, int y)
     const coord_def c(x,y);
     const monster* mon = monster_at(c);
 
-    if (!mon || grd(c) != DNGN_SHALLOW_WATER || !you.see_cell(c))
+    if (!mon || env.grid(c) != DNGN_SHALLOW_WATER || !you.see_cell(c))
         return false;
 
     return !mon->visible_to(&you) && !mon->airborne();
@@ -3819,9 +3819,9 @@ string hints_describe_monster(const monster_info& mi, bool has_stat_desc)
 
 void hints_observe_cell(const coord_def& gc)
 {
-    if (feat_is_escape_hatch(grd(gc)))
+    if (feat_is_escape_hatch(env.grid(gc)))
         learned_something_new(HINT_SEEN_ESCAPE_HATCH, gc);
-    else if (feat_is_branch_entrance(grd(gc)))
+    else if (feat_is_branch_entrance(env.grid(gc)))
         learned_something_new(HINT_SEEN_BRANCH, gc);
     else if (is_feature('>', gc))
         learned_something_new(HINT_SEEN_STAIRS, gc);
@@ -3829,13 +3829,13 @@ void hints_observe_cell(const coord_def& gc)
         learned_something_new(HINT_SEEN_ALTAR, gc);
     else if (is_feature('^', gc))
         learned_something_new(HINT_SEEN_TRAP, gc);
-    else if (feat_is_runed(grd(gc)))
+    else if (feat_is_runed(env.grid(gc)))
         learned_something_new(HINT_SEEN_RUNED_DOOR, gc);
-    else if (feat_is_door(grd(gc)))
+    else if (feat_is_door(env.grid(gc)))
         learned_something_new(HINT_SEEN_DOOR, gc);
-    else if (grd(gc) == DNGN_ENTER_SHOP)
+    else if (env.grid(gc) == DNGN_ENTER_SHOP)
         learned_something_new(HINT_SEEN_SHOP, gc);
-    else if (feat_is_portal_entrance(grd(gc)))
+    else if (feat_is_portal_entrance(env.grid(gc)))
         learned_something_new(HINT_SEEN_PORTAL, gc);
 
     const int it = you.visible_igrd(gc);
index d4eb06c..134b131 100644 (file)
@@ -1600,7 +1600,7 @@ bool safe_to_remove(const item_def &item, bool quiet)
           && !you.attribute[ATTR_FLIGHT_UNCANCELLABLE]
           && (you.evokable_flight() == 1);
 
-    const dungeon_feature_type feat = grd(you.pos());
+    const dungeon_feature_type feat = env.grid(you.pos());
 
     if (grants_flight && removing_ends_flight
         && is_feat_dangerous(feat, false, true))
@@ -3118,7 +3118,7 @@ void read_scroll(item_def& scroll)
         // Identify it early in case the player checks the '\' screen.
         set_ident_type(scroll, true);
 
-        if (feat_eliminates_items(grd(you.pos())))
+        if (feat_eliminates_items(env.grid(you.pos())))
         {
             mpr("Anything you acquired here would fall and be lost!");
             cancel_scroll = true;
index 1c48c71..cd43007 100644 (file)
@@ -1403,7 +1403,7 @@ void pickup(bool partial_quantity)
     if (o == NON_ITEM)
         mpr("There are no items here.");
     else if (you.form == transformation::ice_beast
-             && grd(you.pos()) == DNGN_DEEP_WATER)
+             && env.grid(you.pos()) == DNGN_DEEP_WATER)
     {
         mpr("You can't reach the bottom while floating on water.");
     }
@@ -2208,9 +2208,9 @@ bool move_item_to_grid(int *const obj, const coord_def& p, bool silent)
     bool move_below = item_is_stationary(item) && !item_is_stationary_net(item);
 
     if (!silenced(p) && !silent)
-        feat_splash_noise(grd(p));
+        feat_splash_noise(env.grid(p));
 
-    if (feat_destroys_items(grd(p)))
+    if (feat_destroys_items(env.grid(p)))
     {
         item_was_destroyed(item);
         destroy_item(ob);
@@ -2329,9 +2329,9 @@ bool copy_item_to_grid(item_def &item, const coord_def& p,
         return false;
 
     if (!silenced(p) && !silent)
-        feat_splash_noise(grd(p));
+        feat_splash_noise(env.grid(p));
 
-    if (feat_destroys_items(grd(p)))
+    if (feat_destroys_items(env.grid(p)))
     {
         item_was_destroyed(item);
         return true;
@@ -2545,7 +2545,7 @@ bool drop_item(int item_dropped, int quant_drop)
     // If you drop an item in as a merfolk, it is below the water line and
     // makes no noise falling.
     if (!you.swimming())
-        feat_splash_noise(grd(you.pos()));
+        feat_splash_noise(env.grid(you.pos()));
 
     dec_inv_item_quantity(item_dropped, quant_drop);
     you.turn_is_over = true;
index c83f713..659202f 100644 (file)
@@ -1046,14 +1046,14 @@ static int dgn_floor_halo(lua_State *ls)
 
     for (rectangle_iterator ri(0); ri; ++ri)
     {
-        if (grd(*ri) == target)
+        if (env.grid(*ri) == target)
         {
             for (adjacent_iterator ai(*ri, false); ai; ++ai)
             {
                 if (!map_bounds(*ai))
                     continue;
 
-                const dungeon_feature_type feat2 = grd(*ai);
+                const dungeon_feature_type feat2 = env.grid(*ai);
 
                 if (feat2 == DNGN_FLOOR)
                     env.grid_colours(*ai) = colour;
@@ -1744,7 +1744,7 @@ LUAFN(dgn_fill_grd_area)
 
     for (int y = y1; y <= y2; y++)
         for (int x = x1; x <= x2; x++)
-            grd[x][y] = feat;
+            env.grid[x][y] = feat;
 
     return 0;
 }
index 6e8be1c..fe11546 100644 (file)
@@ -108,12 +108,12 @@ static int dgn_grid(lua_State *ls)
         if (feat)
         {
             if (crawl_state.generating_level)
-                grd(c) = feat;
+                env.grid(c) = feat;
             else
                 dungeon_terrain_changed(c, feat);
         }
     }
-    PLUARET(number, grd(c));
+    PLUARET(number, env.grid(c));
 }
 
 LUAFN(dgn_distance)
index 284db29..86d192f 100644 (file)
@@ -16,7 +16,7 @@
         if (lua_gettop(ls) == 2) \
         { \
             COORDS(c, 1, 2);\
-            lua_pushboolean(ls, val(grd(c)));\
+            lua_pushboolean(ls, val(env.grid(c)));\
         } \
         else if (lua_isnumber(ls, 1)) \
              lua_pushboolean(ls, val(static_cast<dungeon_feature_type>( \
index e4b8654..8e9bd7e 100644 (file)
@@ -130,8 +130,8 @@ LUAFN(view_can_reach)
     }
     const coord_def first_middle(s.x/2,s.y/2);
     const coord_def second_middle(s.x - s.x/2, s.y - s.y/2);
-    if (!feat_is_reachable_past(grd(player2grid(first_middle)))
-        && !feat_is_reachable_past(grd(player2grid(second_middle))))
+    if (!feat_is_reachable_past(env.grid(player2grid(first_middle)))
+        && !feat_is_reachable_past(env.grid(player2grid(second_middle))))
     {
         PLUARET(boolean, false);
         return 1;
index 04bcb61..46ca6c5 100644 (file)
@@ -728,7 +728,7 @@ int num_feats_between(const coord_def& source, const coord_def& target,
     bool reached_target = false;
     while (dist++ <= max_dist)
     {
-        const dungeon_feature_type feat = grd(ray.pos());
+        const dungeon_feature_type feat = env.grid(ray.pos());
 
         if (ray.pos() == target)
             reached_target = true;
index 1638651..7d63af2 100644 (file)
@@ -25,7 +25,7 @@ const opacity_excl opc_excl = opacity_excl();
 
 opacity_type opacity_default::operator()(const coord_def& p) const
 {
-    dungeon_feature_type f = grd(p);
+    dungeon_feature_type f = env.grid(p);
     if (feat_is_opaque(f))
         return OPC_OPAQUE;
     else if (is_opaque_cloud(cloud_type_at(p)))
@@ -45,7 +45,7 @@ opacity_type opacity_fullyopaque::operator()(const coord_def& p) const
 
 opacity_type opacity_no_trans::operator()(const coord_def& p) const
 {
-    dungeon_feature_type f = grd(p);
+    dungeon_feature_type f = env.grid(p);
     if (feat_is_opaque(f) || feat_is_wall(f) || feat_is_closed_door(f))
         return OPC_OPAQUE;
     else if (is_opaque_cloud(cloud_type_at(p)))
@@ -57,7 +57,7 @@ opacity_type opacity_no_trans::operator()(const coord_def& p) const
 
 opacity_type opacity_fully_no_trans::operator()(const coord_def& p) const
 {
-    dungeon_feature_type f = grd(p);
+    dungeon_feature_type f = env.grid(p);
     if (feat_is_opaque(f) || feat_is_wall(f) || feat_is_closed_door(f))
         return OPC_OPAQUE;
     return OPC_CLEAR;
index f7c2428..bd5712e 100644 (file)
@@ -728,7 +728,7 @@ static void _start_running(int dir, int mode)
     const coord_def next_pos = you.pos() + Compass[dir];
 
     if (!have_passive(passive_t::slime_wall_immune)
-        && (dir == RDIR_REST || you.is_habitable_feat(grd(next_pos)))
+        && (dir == RDIR_REST || you.is_habitable_feat(env.grid(next_pos)))
         && count_adjacent_slime_walls(next_pos))
     {
         mprf(MSGCH_WARN, "You're about to run into a slime covered wall!");
@@ -1491,7 +1491,7 @@ static void _take_stairs(bool down)
     ASSERT(!crawl_state.game_is_arena());
     ASSERT(!crawl_state.arena_suspended);
 
-    const dungeon_feature_type ygrd = grd(you.pos());
+    const dungeon_feature_type ygrd = env.grid(you.pos());
 
     const bool shaft = (down && get_trap_type(you.pos()) == TRAP_SHAFT);
 
@@ -2096,7 +2096,7 @@ void process_command(command_type cmd, command_type prev_cmd)
         else // well, not examine, but...
             mprf(MSGCH_EXAMINE_FILTER, "Unknown command.");
 
-        if (feat_is_altar(grd(you.pos())))
+        if (feat_is_altar(env.grid(you.pos())))
         {
             string msg = "Press <w>%</w> or <w>%</w> to pray at altars.";
             insert_commands(msg, { CMD_GO_UPSTAIRS, CMD_GO_DOWNSTAIRS });
@@ -2455,7 +2455,7 @@ static void _swing_at_target(coord_def move)
     }
 
     // Don't waste a turn if feature is solid.
-    if (feat_is_solid(grd(target)) && !you.confused())
+    if (feat_is_solid(env.grid(target)) && !you.confused())
         return;
     else
     {
index 460bf70..81ff148 100644 (file)
@@ -123,7 +123,7 @@ void reautomap_level()
 
 void set_terrain_seen(const coord_def pos)
 {
-    const dungeon_feature_type feat = grd(pos);
+    const dungeon_feature_type feat = env.grid(pos);
     map_cell* cell = &env.map_knowledge(pos);
 
     // First time we've seen a notable feature.
index 0c70cf9..f83cca8 100644 (file)
@@ -676,9 +676,9 @@ void map_lines::apply_grid_overlay(const coord_def &c, bool is_layout)
                 else
                     offset = random2(tile_dngn_count(feat));
 
-                if (!has_floor && grd(gc) == DNGN_FLOOR)
+                if (!has_floor && env.grid(gc) == DNGN_FLOOR)
                     env.tile_flv(gc).floor = feat + offset;
-                else if (!has_rock && grd(gc) == DNGN_ROCK_WALL)
+                else if (!has_rock && env.grid(gc) == DNGN_ROCK_WALL)
                     env.tile_flv(gc).wall = feat + offset;
                 else
                 {
index b213d4c..9d6ea49 100644 (file)
@@ -1369,7 +1369,7 @@ map_position_marker *get_position_marker_at(const coord_def &pos,
  **/
 coord_def get_transporter_dest(const coord_def &pos)
 {
-    ASSERT(grd(pos) == DNGN_TRANSPORTER);
+    ASSERT(env.grid(pos) == DNGN_TRANSPORTER);
 
     map_position_marker *marker
         = get_position_marker_at(pos, DNGN_TRANSPORTER);
index 26c0976..edbc0a1 100644 (file)
@@ -365,7 +365,7 @@ static bool _may_overwrite_feature(const coord_def p,
     if (Vault_Placement_Mask && player_in_branch(BRANCH_ABYSS))
         return true;
 
-    const dungeon_feature_type grid = grd(p);
+    const dungeon_feature_type grid = env.grid(p);
 
     // Deep water grids may be overwritten if water_ok == true.
     if (grid == DNGN_DEEP_WATER)
@@ -447,7 +447,7 @@ static bool _map_safe_vault_place(const map_def &map,
                     return false;
             }
         }
-        else if (grd(cp) != DNGN_FLOOR || env.pgrid(cp) & FPROP_NO_TELE_INTO
+        else if (env.grid(cp) != DNGN_FLOOR || env.pgrid(cp) & FPROP_NO_TELE_INTO
                                        || _is_transporter_place(cp))
         {
             // Don't place overwrite_floor_cell vaults on anything but floor or
@@ -473,7 +473,7 @@ static bool _map_safe_vault_place(const map_def &map,
         {
             for (adjacent_iterator ai(cp); ai; ++ai)
             {
-                if (map_bounds(*ai) && feat_is_stair(grd(*ai)))
+                if (map_bounds(*ai) && feat_is_stair(env.grid(*ai)))
                     return false;
             }
         }
@@ -520,8 +520,8 @@ coord_def find_portal_place(const vault_placement *place, bool check_place)
             if ((!check_place
                   || place && map_place_valid(place->map, v1, place->size))
                 && (!place || _connected_minivault_place(v1, *place))
-                && !feat_is_gate(grd(v1))
-                && !feat_is_branch_entrance(grd(v1)))
+                && !feat_is_gate(env.grid(v1))
+                && !feat_is_branch_entrance(env.grid(v1)))
             {
                 candidates.push_back(v1);
             }
index 4bab961..048089d 100644 (file)
@@ -3215,9 +3215,9 @@ bool melee_attack::do_knockback(bool trample)
 
     if (!x_chance_in_y(size_diff + 3, 6)
         // need a valid tile
-        || !defender->is_habitable_feat(grd(new_pos))
+        || !defender->is_habitable_feat(env.grid(new_pos))
         // don't trample anywhere the attacker can't follow
-        || !attacker->is_habitable_feat(grd(old_pos))
+        || !attacker->is_habitable_feat(env.grid(old_pos))
         // don't trample into a monster - or do we want to cause a chain
         // reaction here?
         || actor_at(new_pos)
index 684d4b4..804a947 100644 (file)
@@ -1471,7 +1471,7 @@ FeatureMenuEntry::FeatureMenuEntry(const string &str, const coord_def p,
     MenuEntry(str, MEL_ITEM, 1, hotkey)
 {
     if (in_bounds(p))
-        feat = grd(p);
+        feat = env.grid(p);
     else
         feat = DNGN_UNSEEN;
     pos      = p;
index 599a5e3..795c312 100644 (file)
@@ -495,7 +495,7 @@ static bool _slime_merge(monster* thing)
         // Don't merge if there is an open square that reduces distance
         // to target, even if we found a possible slime to merge with.
         if (!actor_at(*ai)
-            && mons_class_can_pass(MONS_SLIME_CREATURE, grd(*ai)))
+            && mons_class_can_pass(MONS_SLIME_CREATURE, env.grid(*ai)))
         {
             return false;
         }
@@ -1145,7 +1145,7 @@ bool mon_special_ability(monster* mons)
         if (one_chance_in(5))
         {
             actor *foe = mons->get_foe();
-            if (foe && !feat_is_water(grd(foe->pos())))
+            if (foe && !feat_is_water(env.grid(foe->pos())))
             {
                 coord_def spot;
                 if (find_habitable_spot_near(foe->pos(), MONS_ELECTRIC_EEL, 3, false, spot)
index 896d738..543f1a6 100644 (file)
@@ -144,7 +144,7 @@ static void _monster_regenerate(monster* mons)
 
     // Non-land creatures out of their element cannot regenerate.
     if (mons_primary_habitat(*mons) != HT_LAND
-        && !monster_habitable_grid(mons, grd(mons->pos())))
+        && !monster_habitable_grid(mons, env.grid(mons->pos())))
     {
         return;
     }
@@ -277,7 +277,7 @@ static bool _do_mon_spell(monster* mons)
 
 static void _swim_or_move_energy(monster& mon)
 {
-    const dungeon_feature_type feat = grd(mon.pos());
+    const dungeon_feature_type feat = env.grid(mon.pos());
 
     // FIXME: Replace check with mons_is_swimming()?
     mon.lose_energy(((feat_is_lava(feat) || feat_is_water(feat))
@@ -369,7 +369,7 @@ static bool _allied_monster_at(monster* mon, coord_def a, coord_def b,
 // some monster types.
 static bool _mon_on_interesting_grid(monster* mon)
 {
-    const dungeon_feature_type feat = grd(mon->pos());
+    const dungeon_feature_type feat = env.grid(mon->pos());
 
     switch (feat)
     {
@@ -902,7 +902,7 @@ static bool _handle_swoop(monster& mons)
         if (tracer.path_taken[j] != target)
             continue;
 
-        if (!monster_habitable_grid(&mons, grd(tracer.path_taken[j+1]))
+        if (!monster_habitable_grid(&mons, env.grid(tracer.path_taken[j+1]))
             || actor_at(tracer.path_taken[j+1]))
         {
             continue;
@@ -966,8 +966,8 @@ static bool _handle_reaching(monster* mons)
         && delta.rdist() <= range
         // And with no dungeon furniture in the way of the reaching
         // attack;
-        && (feat_is_reachable_past(grd(first_middle))
-            || feat_is_reachable_past(grd(second_middle)))
+        && (feat_is_reachable_past(env.grid(first_middle))
+            || feat_is_reachable_past(env.grid(second_middle)))
         // The foe should be on the map (not stepped from time).
         && in_bounds(foepos))
     {
@@ -2233,10 +2233,10 @@ static void _post_monster_move(monster* mons)
     if (mons->type == MONS_WATER_NYMPH)
     {
         for (adjacent_iterator ai(mons->pos(), false); ai; ++ai)
-            if (feat_has_solid_floor(grd(*ai))
+            if (feat_has_solid_floor(env.grid(*ai))
                 && (coinflip() || *ai == mons->pos()))
             {
-                if (grd(*ai) != DNGN_SHALLOW_WATER && grd(*ai) != DNGN_FLOOR
+                if (env.grid(*ai) != DNGN_SHALLOW_WATER && env.grid(*ai) != DNGN_FLOOR
                     && you.see_cell(*ai))
                 {
                     mprf("%s watery aura covers %s.",
@@ -2584,7 +2584,7 @@ static bool _handle_pickup(monster* mons)
     // Flying over water doesn't let you pick up stuff. This is inexact, as
     // a merfolk could be flying, but that's currently impossible except for
     // being tornadoed, and with *that* low life expectancy let's not care.
-    dungeon_feature_type feat = grd(mons->pos());
+    dungeon_feature_type feat = env.grid(mons->pos());
 
     if ((feat == DNGN_LAVA || feat == DNGN_DEEP_WATER) && mons->airborne())
         return false;
@@ -2699,7 +2699,7 @@ static void _mons_open_door(monster& mons, const coord_def &pos)
 static bool _no_habitable_adjacent_grids(const monster* mon)
 {
     for (adjacent_iterator ai(mon->pos()); ai; ++ai)
-        if (monster_habitable_grid(mon, grd(*ai)))
+        if (monster_habitable_grid(mon, env.grid(*ai)))
             return false;
 
     return true;
@@ -2857,7 +2857,7 @@ bool mon_can_move_to_pos(const monster* mons, const coord_def& delta,
     if (is_sanctuary(mons->pos()) && actor_at(targ))
         return false;
 
-    const dungeon_feature_type target_grid = grd(targ);
+    const dungeon_feature_type target_grid = env.grid(targ);
     const habitat_type habitat = mons_primary_habitat(*mons);
 
     // No monster may enter the open sea.
@@ -2891,7 +2891,7 @@ bool mon_can_move_to_pos(const monster* mons, const coord_def& delta,
     {
         // If the monster somehow ended up in this habitat (and is
         // not dead by now), give it a chance to get out again.
-        if (grd(mons->pos()) == target_grid && mons->ground_level()
+        if (env.grid(mons->pos()) == target_grid && mons->ground_level()
             && _no_habitable_adjacent_grids(mons))
         {
             return true;
@@ -2965,7 +2965,7 @@ bool mon_can_move_to_pos(const monster* mons, const coord_def& delta,
     if (habitat == HT_WATER
         && targ != you.pos()
         && target_grid != DNGN_DEEP_WATER
-        && grd(mons->pos()) == DNGN_DEEP_WATER
+        && env.grid(mons->pos()) == DNGN_DEEP_WATER
         && mons->hit_points < (mons->max_hit_points * 3) / 4)
     {
         return false;
@@ -3254,11 +3254,11 @@ static bool _do_move_monster(monster& mons, const coord_def& delta)
 
     ASSERT(!cell_is_runed(f)); // should be checked in mons_can_traverse
 
-    if (feat_is_closed_door(grd(f)))
+    if (feat_is_closed_door(env.grid(f)))
     {
         if (mons_can_destroy_door(mons, f))
         {
-            grd(f) = DNGN_FLOOR;
+            env.grid(f) = DNGN_FLOOR;
             set_terrain_changed(f);
 
             if (you.see_cell(f))
@@ -3282,7 +3282,7 @@ static bool _do_move_monster(monster& mons, const coord_def& delta)
         }
         else if (mons_can_eat_door(mons, f))
         {
-            grd(f) = DNGN_FLOOR;
+            env.grid(f) = DNGN_FLOOR;
             set_terrain_changed(f);
 
             _jelly_grows(mons);
@@ -3323,7 +3323,7 @@ static bool _do_move_monster(monster& mons, const coord_def& delta)
 
     _escape_water_hold(mons);
 
-    if (grd(mons.pos()) == DNGN_DEEP_WATER && grd(f) != DNGN_DEEP_WATER
+    if (env.grid(mons.pos()) == DNGN_DEEP_WATER && env.grid(f) != DNGN_DEEP_WATER
         && !monster_habitable_grid(&mons, DNGN_DEEP_WATER))
     {
         // er, what?  Seems impossible.
@@ -3394,8 +3394,8 @@ static bool _monster_move(monster* mons)
             if (!cell_is_solid(*ai))
             {
                 adj_move.push_back(*ai);
-                if (habitat == HT_WATER && feat_is_watery(grd(*ai))
-                    || habitat == HT_LAVA && feat_is_lava(grd(*ai)))
+                if (habitat == HT_WATER && feat_is_watery(env.grid(*ai))
+                    || habitat == HT_LAVA && feat_is_lava(env.grid(*ai)))
                 {
                     adj_water.push_back(*ai);
                 }
@@ -3442,7 +3442,7 @@ static bool _monster_move(monster* mons)
                 good_move[count_x][count_y] = false;
                 continue;
             }
-            dungeon_feature_type target_grid = grd[targ_x][targ_y];
+            dungeon_feature_type target_grid = env.grid[targ_x][targ_y];
 
             if (target_grid == DNGN_DEEP_WATER)
                 deep_water_available = true;
@@ -3459,8 +3459,8 @@ static bool _monster_move(monster* mons)
     // is in good health.
     if (habitat == HT_WATER
         && deep_water_available
-        && grd(mons->pos()) != DNGN_DEEP_WATER
-        && grd(newpos) != DNGN_DEEP_WATER
+        && env.grid(mons->pos()) != DNGN_DEEP_WATER
+        && env.grid(newpos) != DNGN_DEEP_WATER
         && newpos != you.pos()
         && (one_chance_in(3)
             || mons->hit_points <= (mons->max_hit_points * 3) / 4))
@@ -3471,7 +3471,7 @@ static bool _monster_move(monster* mons)
             for (int cy = 0; cy < 3; cy++)
             {
                 if (good_move[cx][cy]
-                    && grd[mons->pos().x + cx - 1][mons->pos().y + cy - 1]
+                    && env.grid[mons->pos().x + cx - 1][mons->pos().y + cy - 1]
                             == DNGN_DEEP_WATER)
                 {
                     if (one_chance_in(++count))
@@ -3496,7 +3496,7 @@ static bool _monster_move(monster* mons)
 
     if (mons->type == MONS_SPATIAL_MAELSTROM)
     {
-        const dungeon_feature_type feat = grd(mons->pos() + mmov);
+        const dungeon_feature_type feat = env.grid(mons->pos() + mmov);
         if (!feat_is_permarock(feat) && feat_is_solid(feat))
         {
             const coord_def target(mons->pos() + mmov);
@@ -3514,7 +3514,7 @@ static bool _monster_move(monster* mons)
     // Take care of Dissolution burrowing, lerny, etc
     if (burrows || flattens_trees || digs)
     {
-        const dungeon_feature_type feat = grd(mons->pos() + mmov);
+        const dungeon_feature_type feat = env.grid(mons->pos() + mmov);
         if ((feat == DNGN_ROCK_WALL || feat == DNGN_CLEAR_ROCK_WALL)
                 && !burrows && digs
             || feat == DNGN_GRATE && digs)
index 88b0b50..45cdf24 100644 (file)
@@ -1421,7 +1421,7 @@ void shake_off_monsters(const actor* target)
 // types, this should be expanded along with it.
 static void _mons_indicate_level_exit(const monster* mon)
 {
-    const dungeon_feature_type feat = grd(mon->pos());
+    const dungeon_feature_type feat = env.grid(mon->pos());
     const bool is_shaft = (get_trap_type(mon->pos()) == TRAP_SHAFT);
 
     if (feat_is_gate(feat))
@@ -1472,7 +1472,7 @@ bool monster_can_hit_monster(monster* mons, const monster* targ)
     if (!targ->submerged() || mons->has_damage_type(DVORP_TENTACLE))
         return true;
 
-    if (grd(targ->pos()) != DNGN_SHALLOW_WATER)
+    if (env.grid(targ->pos()) != DNGN_SHALLOW_WATER)
         return false;
 
     const item_def *weapon = mons->weapon();
index 9fdd63c..d4bf742 100644 (file)
@@ -2188,7 +2188,7 @@ static void _set_door(set<coord_def> door, dungeon_feature_type feat)
 {
     for (const auto &dc : door)
     {
-        grd(dc) = feat;
+        env.grid(dc) = feat;
         set_terrain_changed(dc);
     }
 }
@@ -2217,7 +2217,7 @@ static int _tension_door_closed(set<coord_def> door,
  */
 static bool _can_force_door_shut(const coord_def& door)
 {
-    if (!feat_is_open_door(grd(door)))
+    if (!feat_is_open_door(env.grid(door)))
         return false;
 
     set<coord_def> all_door;
@@ -2282,7 +2282,7 @@ static vector<coord_def> _get_push_spaces_max_tension(const coord_def& pos,
     {
         set<coord_def> all_door;
         find_connected_identical(pos, all_door);
-        dungeon_feature_type old_feat = grd(pos);
+        dungeon_feature_type old_feat = env.grid(pos);
 
         act->move_to_pos(c);
         int new_tension = _tension_door_closed(all_door, old_feat);
@@ -2310,10 +2310,10 @@ static vector<coord_def> _get_push_spaces_max_tension(const coord_def& pos,
  */
 static bool _should_force_door_shut(const coord_def& door)
 {
-    if (!feat_is_open_door(grd(door)))
+    if (!feat_is_open_door(env.grid(door)))
         return false;
 
-    dungeon_feature_type old_feat = grd(door);
+    dungeon_feature_type old_feat = env.grid(door);
 
     set<coord_def> all_door;
     find_connected_identical(door, all_door);
@@ -2370,7 +2370,7 @@ static bool _seal_doors_and_stairs(const monster* warden,
     for (radius_iterator ri(you.pos(), LOS_RADIUS, C_SQUARE);
                  ri; ++ri)
     {
-        if (feat_is_open_door(grd(*ri)))
+        if (feat_is_open_door(env.grid(*ri)))
         {
             if (!_can_force_door_shut(*ri))
                 continue;
@@ -2418,7 +2418,7 @@ static bool _seal_doors_and_stairs(const monster* warden,
             vector<coord_def> excludes;
             for (const auto &dc : all_door)
             {
-                grd(dc) = DNGN_CLOSED_DOOR;
+                env.grid(dc) = DNGN_CLOSED_DOOR;
                 set_terrain_changed(dc);
                 dungeon_events.fire_position_event(DET_DOOR_CLOSED, dc);
 
@@ -2450,7 +2450,7 @@ static bool _seal_doors_and_stairs(const monster* warden,
         }
 
         // Try to seal the door
-        if (feat_is_closed_door(grd(*ri)) && !feat_is_sealed(grd(*ri)))
+        if (feat_is_closed_door(env.grid(*ri)) && !feat_is_sealed(env.grid(*ri)))
         {
             if (check_only)
                 return true;
@@ -2467,13 +2467,13 @@ static bool _seal_doors_and_stairs(const monster* warden,
                 had_effect = true;
             }
         }
-        else if (feat_is_travelable_stair(grd(*ri)))
+        else if (feat_is_travelable_stair(env.grid(*ri)))
         {
             if (check_only)
                 return true;
 
             dungeon_feature_type stype;
-            if (feat_stair_direction(grd(*ri)) == CMD_GO_UPSTAIRS)
+            if (feat_stair_direction(env.grid(*ri)) == CMD_GO_UPSTAIRS)
                 stype = DNGN_SEALED_STAIRS_UP;
             else
                 stype = DNGN_SEALED_STAIRS_DOWN;
@@ -2750,14 +2750,14 @@ bool mons_word_of_recall(monster* mons, int recall_target)
 
 static bool _valid_vine_spot(coord_def p)
 {
-    if (actor_at(p) || !monster_habitable_grid(MONS_PLANT, grd(p)))
+    if (actor_at(p) || !monster_habitable_grid(MONS_PLANT, env.grid(p)))
         return false;
 
     int num_trees = 0;
     bool valid_trees = false;
     for (adjacent_iterator ai(p); ai; ++ai)
     {
-        if (feat_is_tree(grd(*ai)))
+        if (feat_is_tree(env.grid(*ai)))
         {
             // Make sure this spot is not on a diagonal to its only adjacent
             // tree (so that the vines can pull back against the tree properly)
@@ -3321,7 +3321,7 @@ static coord_def _mons_awaken_earth_target(const monster &mon)
 
         // We can target solid cells, which themselves will awaken, so count
         // those as well.
-        if (_feat_is_awakenable(grd(candidate)))
+        if (_feat_is_awakenable(env.grid(candidate)))
             neighbours++;
 
         if (neighbours > 0)
@@ -3650,7 +3650,7 @@ static bool _should_cast_spell(const monster &mons, spell_type spell,
             || spell == SPELL_BLINK_ALLIES_AWAY))
     {
         for (auto ri = radius_iterator(mons.pos(), LOS_NO_TRANS); ri; ++ri)
-            if (feat_is_trap(grd(*ri)) && you.see_cell(*ri))
+            if (feat_is_trap(env.grid(*ri)) && you.see_cell(*ri))
                 return false;
     }
 
@@ -5381,7 +5381,7 @@ static void _mons_upheaval(monster& mons, actor& /*foe*/)
         switch (beam.flavour)
         {
             case BEAM_LAVA:
-                if (grd(pos) == DNGN_FLOOR && !actor_at(pos) && coinflip())
+                if (env.grid(pos) == DNGN_FLOOR && !actor_at(pos) && coinflip())
                 {
                     temp_change_terrain(
                         pos, DNGN_LAVA,
@@ -5394,12 +5394,12 @@ static void _mons_upheaval(monster& mons, actor& /*foe*/)
                     place_cloud(CLOUD_STORM, pos, random2(7), &mons);
                 break;
             case BEAM_FRAG:
-                if (((grd(pos) == DNGN_ROCK_WALL
-                     || grd(pos) == DNGN_CLEAR_ROCK_WALL
-                     || grd(pos) == DNGN_SLIMY_WALL)
+                if (((env.grid(pos) == DNGN_ROCK_WALL
+                     || env.grid(pos) == DNGN_CLEAR_ROCK_WALL
+                     || env.grid(pos) == DNGN_SLIMY_WALL)
                      && x_chance_in_y(1, 4)
-                     || feat_is_door(grd(pos))
-                     || grd(pos) == DNGN_GRATE))
+                     || feat_is_door(env.grid(pos))
+                     || env.grid(pos) == DNGN_GRATE))
                 {
                     noisy(30, pos);
                     destroy_wall(pos);
@@ -5712,7 +5712,7 @@ void mons_cast(monster* mons, bolt pbolt, spell_type spell_cast,
         return;
 
     case SPELL_INK_CLOUD:
-        if (!feat_is_watery(grd(mons->pos())))
+        if (!feat_is_watery(env.grid(mons->pos())))
             return;
 
         big_cloud(CLOUD_INK, mons, mons->pos(), 30, 30);
@@ -6098,8 +6098,8 @@ void mons_cast(monster* mons, bolt pbolt, spell_type spell_cast,
             }
 
             // Make sure we have a legitimate tile.
-            if (!safe_tiles.count(grd(*ai)) && !feat_is_trap(grd(*ai))
-                && feat_is_reachable_past(grd(*ai)))
+            if (!safe_tiles.count(env.grid(*ai)) && !feat_is_trap(env.grid(*ai))
+                && feat_is_reachable_past(env.grid(*ai)))
             {
                 sumcount++;
             }
@@ -6126,7 +6126,7 @@ void mons_cast(monster* mons, bolt pbolt, spell_type spell_cast,
             }
 
             // Make sure we have a legitimate tile.
-            if (safe_tiles.count(grd(*ai)) || feat_is_trap(grd(*ai)))
+            if (safe_tiles.count(env.grid(*ai)) || feat_is_trap(env.grid(*ai)))
             {
                 // All items are moved inside.
                 if (igrd(*ai) != NON_ITEM)
@@ -6797,9 +6797,9 @@ static void _speech_fill_target(string& targ_prep, string& target,
 
             if (targ_prep == "at")
             {
-                if (grd(pbolt.target) != DNGN_FLOOR)
+                if (env.grid(pbolt.target) != DNGN_FLOOR)
                 {
-                    target = feature_description(grd(pbolt.target),
+                    target = feature_description(env.grid(pbolt.target),
                                                  NUM_TRAPS, "", DESC_THE);
                 }
                 else
@@ -7281,7 +7281,7 @@ static void _mons_awaken_earth(monster &mon, const coord_def &target)
 
     for (fair_adjacent_iterator ai(target, false); ai; ++ai)
     {
-        if (!_feat_is_awakenable(grd(*ai))
+        if (!_feat_is_awakenable(env.grid(*ai))
             || env.markers.property_at(*ai, MAT_ANY, "veto_destroy")
                == "veto")
         {
@@ -7431,8 +7431,8 @@ static ai_action::goodness _monster_spell_goodness(monster* mon, mon_spell_slot
     case SPELL_CALL_TIDE:
         if (!player_in_branch(BRANCH_SHOALS) || mon->has_ench(ENCH_TIDE))
             return ai_action::impossible();
-        else if (!foe || (grd(mon->pos()) == DNGN_DEEP_WATER
-                     && grd(foe->pos()) == DNGN_DEEP_WATER))
+        else if (!foe || (env.grid(mon->pos()) == DNGN_DEEP_WATER
+                     && env.grid(foe->pos()) == DNGN_DEEP_WATER))
         {
             return ai_action::bad();
         }
@@ -7546,7 +7546,7 @@ static ai_action::goodness _monster_spell_goodness(monster* mon, mon_spell_slot
 
     case SPELL_WATERSTRIKE:
         ASSERT(foe);
-        return ai_action::good_or_impossible(feat_is_watery(grd(foe->pos())));
+        return ai_action::good_or_impossible(feat_is_watery(env.grid(foe->pos())));
 
     // Don't use unless our foe is close to us and there are no allies already
     // between the two of us
index 7b4ee74..fa36ef4 100644 (file)
@@ -237,7 +237,7 @@ bool mons_clonable(const monster* mon, bool needs_adjacent)
         {
             if (in_bounds(*ai)
                 && !actor_at(*ai)
-                && monster_habitable_grid(mon, grd(*ai)))
+                && monster_habitable_grid(mon, env.grid(*ai)))
             {
                 square_found = true;
                 break;
@@ -288,7 +288,7 @@ monster* clone_mons(const monster* orig, bool quiet, bool* obvious,
     {
         if (in_bounds(*ai)
             && !actor_at(*ai)
-            && monster_habitable_grid(orig, grd(*ai)))
+            && monster_habitable_grid(orig, env.grid(*ai)))
         {
             pos = *ai;
         }
index 2b2785f..4e1ca20 100644 (file)
@@ -480,7 +480,7 @@ static void _create_monster_hide(const item_def &corpse, bool silent)
 
     // Don't display this message if the scales were dropped over
     // lava/deep water, because then they are hardly intact.
-    if (you.see_cell(pos) && !silent && !feat_eliminates_items(grd(pos)))
+    if (you.see_cell(pos) && !silent && !feat_eliminates_items(env.grid(pos)))
     {
         // XXX: tweak for uniques/named monsters, somehow?
         mprf("%s %s intact enough to wear.",
@@ -544,7 +544,7 @@ item_def* place_monster_corpse(const monster& mons, bool force)
         return nullptr;
 
     // Don't attempt to place corpses within walls, either.
-    if (feat_is_solid(grd(mons.pos())) && !force)
+    if (feat_is_solid(env.grid(mons.pos())) && !force)
         return nullptr;
 
     // If we were told not to leave a corpse, don't.
@@ -561,7 +561,7 @@ item_def* place_monster_corpse(const monster& mons, bool force)
     {
         _gold_pile(corpse, mons_species(mons.type));
         // If gold would be destroyed, give it directly to the player instead.
-        if (feat_eliminates_items(grd(mons.pos())))
+        if (feat_eliminates_items(env.grid(mons.pos())))
         {
             get_gold(corpse, corpse.quantity, false);
             destroy_item(corpse, true);
@@ -2173,8 +2173,8 @@ item_def* monster_die(monster& mons, killer_type killer,
                     you.attribute[ATTR_PAKELLAS_EXTRA_MP] -= mp_heal;
 
                     if (you.attribute[ATTR_PAKELLAS_EXTRA_MP] <= 0
-                        && (feat_has_solid_floor(grd(you.pos()))
-                            || feat_is_watery(grd(you.pos()))
+                        && (feat_has_solid_floor(env.grid(you.pos()))
+                            || feat_is_watery(env.grid(you.pos()))
                                && species_likes_water(you.species)))
                     {
                         int thing_created = items(true, OBJ_POTIONS,
@@ -2812,7 +2812,7 @@ void mons_check_pool(monster* mons, const coord_def &oldpos,
     if (!mons->ground_level())
         return;
 
-    dungeon_feature_type grid = grd(mons->pos());
+    dungeon_feature_type grid = env.grid(mons->pos());
     if (grid != DNGN_LAVA && grid != DNGN_DEEP_WATER
         || monster_habitable_grid(mons, grid))
     {
@@ -2822,7 +2822,7 @@ void mons_check_pool(monster* mons, const coord_def &oldpos,
 
     // Don't worry about invisibility. You should be able to see if
     // something has fallen into the lava.
-    if (you.see_cell(mons->pos()) && (oldpos == mons->pos() || grd(oldpos) != grid))
+    if (you.see_cell(mons->pos()) && (oldpos == mons->pos() || env.grid(oldpos) != grid))
     {
          mprf("%s falls into the %s!",
              mons->name(DESC_THE).c_str(),
@@ -3326,7 +3326,7 @@ void mons_felid_revive(monster* mons)
         revive_place.x = random2(GXM);
         revive_place.y = random2(GYM);
         if (!in_bounds(revive_place)
-            || grd(revive_place) != DNGN_FLOOR
+            || env.grid(revive_place) != DNGN_FLOOR
             || cloud_at(revive_place)
             || monster_at(revive_place)
             || env.pgrid(revive_place) & FPROP_NO_TELE_INTO
index 98e5b4b..f451142 100644 (file)
@@ -420,7 +420,7 @@ static bool _prepare_del_ench(monster* mon, const mon_enchant &me)
 
     for (adjacent_iterator ai(mon->pos()); ai; ++ai)
         if (!actor_at(*ai)
-            && monster_can_submerge(mon, grd(*ai))
+            && monster_can_submerge(mon, env.grid(*ai))
             && one_chance_in(++okay_squares))
         {
             target_square = *ai;
@@ -431,7 +431,7 @@ static bool _prepare_del_ench(monster* mon, const mon_enchant &me)
 
     // No available adjacent squares from which the monster could also
     // have unsubmerged. Can it just stay submerged where it is?
-    if (monster_can_submerge(mon, grd(mon->pos())))
+    if (monster_can_submerge(mon, env.grid(mon->pos())))
         return false;
 
     // The terrain changed and the monster can't remain submerged.
@@ -439,7 +439,7 @@ static bool _prepare_del_ench(monster* mon, const mon_enchant &me)
     for (adjacent_iterator ai(mon->pos()); ai; ++ai)
     {
         if (!actor_at(*ai)
-            && monster_habitable_grid(mon, grd(*ai))
+            && monster_habitable_grid(mon, env.grid(*ai))
             && !trap_at(*ai))
         {
             if (one_chance_in(++okay_squares))
@@ -773,14 +773,14 @@ void monster::remove_enchantment_effect(const mon_enchant &me, bool quiet)
 
         if (you.can_see(*this))
         {
-            if (!quiet && feat_is_watery(grd(pos())))
+            if (!quiet && feat_is_watery(env.grid(pos())))
             {
                 mprf(MSGCH_WARN, "%s bursts forth from the water.",
                      name(DESC_A, true).c_str());
                 seen_monster(this);
             }
         }
-        else if (you.see_cell(pos()) && feat_is_watery(grd(pos())))
+        else if (you.see_cell(pos()) && feat_is_watery(env.grid(pos())))
         {
             mpr("Something invisible bursts forth from the water.");
             interrupt_activity(activity_interrupt::force);
@@ -1197,8 +1197,8 @@ static bool _merfolk_avatar_movement_effect(const monster* mons)
         const coord_def newpos = tracer.path_taken[0];
 
         if (!in_bounds(newpos)
-            || is_feat_dangerous(grd(newpos))
-            || !you.can_pass_through_feat(grd(newpos))
+            || is_feat_dangerous(env.grid(newpos))
+            || !you.can_pass_through_feat(env.grid(newpos))
             || !cell_see_cell(mons->pos(), newpos, LOS_NO_TRANS))
         {
             do_resist = true;
@@ -1307,7 +1307,7 @@ static void _merfolk_avatar_song(monster* mons)
     // Can only call up drowned souls if there's free deep water nearby
     vector<coord_def> deep_water;
     for (radius_iterator ri(mons->pos(), LOS_RADIUS, C_SQUARE); ri; ++ri)
-        if (grd(*ri) == DNGN_DEEP_WATER && !actor_at(*ri))
+        if (env.grid(*ri) == DNGN_DEEP_WATER && !actor_at(*ri))
             deep_water.push_back(*ri);
 
     if (deep_water.size())
@@ -1460,7 +1460,7 @@ void monster::apply_enchantment(const mon_enchant &me)
     case ENCH_AQUATIC_LAND:
         // Aquatic monsters lose hit points every turn they spend on dry land.
         ASSERT(mons_habitat(*this) == HT_WATER || mons_habitat(*this) == HT_LAVA);
-        if (monster_habitable_grid(this, grd(pos())))
+        if (monster_habitable_grid(this, env.grid(pos())))
         {
             del_ench(ENCH_AQUATIC_LAND);
             break;
@@ -1493,7 +1493,7 @@ void monster::apply_enchantment(const mon_enchant &me)
             break;
 
         // Now we handle the others:
-        const dungeon_feature_type grid = grd(pos());
+        const dungeon_feature_type grid = env.grid(pos());
 
         if (!monster_can_submerge(this, grid))
             del_ench(ENCH_SUBMERGED); // forced to surface
@@ -1525,7 +1525,7 @@ void monster::apply_enchantment(const mon_enchant &me)
     // Assumption: monster::res_fire has already been checked.
     case ENCH_STICKY_FLAME:
     {
-        if (feat_is_watery(grd(pos())) && ground_level())
+        if (feat_is_watery(env.grid(pos())) && ground_level())
         {
             if (you.can_see(*this))
             {
index 02cf7af..b63b022 100644 (file)
@@ -254,7 +254,7 @@ static bool _tentacle_pos_unknown(const monster *tentacle,
 
         // If there's an adjacent deep water tile, the segment
         // might be there instead.
-        if (grd(*ai) == DNGN_DEEP_WATER)
+        if (env.grid(*ai) == DNGN_DEEP_WATER)
         {
             const monster *mon = monster_at(*ai);
             if (mon && you.can_see(*mon))
@@ -269,7 +269,7 @@ static bool _tentacle_pos_unknown(const monster *tentacle,
             return true;
         }
 
-        if (grd(*ai) == DNGN_SHALLOW_WATER)
+        if (env.grid(*ai) == DNGN_SHALLOW_WATER)
         {
             const monster *mon = monster_at(*ai);
 
index d247000..25e1faa 100644 (file)
@@ -234,7 +234,7 @@ bool try_pathfind(monster* mon)
 static bool _is_level_exit(const coord_def& pos)
 {
     // All types of stairs.
-    if (feat_is_stair(grd(pos)))
+    if (feat_is_stair(env.grid(pos)))
         return true;
 
     // Teleportation and shaft traps.
@@ -277,17 +277,17 @@ static int _merfolk_avatar_water_score(coord_def p, bool& deep)
 
     for (adjacent_iterator ai(p); ai; ++ai)
     {
-        if (grd(*ai) == DNGN_SHALLOW_WATER)
+        if (env.grid(*ai) == DNGN_SHALLOW_WATER)
         {
             score++;
             near_floor = true;
         }
-        else if (grd(*ai) == DNGN_DEEP_WATER)
+        else if (env.grid(*ai) == DNGN_DEEP_WATER)
         {
             score++;
             deep = true;
         }
-        else if (feat_has_solid_floor(grd(*ai)))
+        else if (feat_has_solid_floor(env.grid(*ai)))
             near_floor = true;
     }
 
@@ -300,7 +300,7 @@ static int _merfolk_avatar_water_score(coord_def p, bool& deep)
         score += 6;
 
     // Slightly prefer standing in deep water, if possible
-    if (grd(p) == DNGN_DEEP_WATER)
+    if (env.grid(p) == DNGN_DEEP_WATER)
         score++;
 
     return score;
@@ -324,7 +324,7 @@ bool find_merfolk_avatar_water_target(monster* mon)
     // If our current location is good enough, don't bother moving towards
     // some other spot which might be somewhat better
     if (_merfolk_avatar_water_score(mon->pos(), deep) >= 12 && deep
-        && grd(mon->pos()) == DNGN_DEEP_WATER)
+        && env.grid(mon->pos()) == DNGN_DEEP_WATER)
     {
         mon->firing_pos = mon->pos();
         return true;
@@ -353,7 +353,7 @@ bool find_merfolk_avatar_water_target(monster* mon)
         int best_num = 0;
         for (radius_iterator ri(mon->pos(), LOS_NO_TRANS); ri; ++ri)
         {
-            if (!feat_is_water(grd(*ri)))
+            if (!feat_is_water(env.grid(*ri)))
                 continue;
 
             const int dist = grid_distance(mon->pos(), *ri);
@@ -591,7 +591,7 @@ static bool _choose_random_patrol_target_grid(monster* mon)
     for (radius_iterator ri(mon->patrol_point, you.current_vision, C_SQUARE, true);
          ri; ++ri)
     {
-        if (!in_bounds(*ri) || !mon->can_pass_through_feat(grd(*ri)))
+        if (!in_bounds(*ri) || !mon->can_pass_through_feat(env.grid(*ri)))
             continue;
 
         // Don't bother moving to squares (currently) occupied by a
@@ -1021,7 +1021,7 @@ static bool _can_safely_go_through(const monster * mon, const coord_def p)
 {
     ASSERT(map_bounds(p));
 
-    if (!monster_habitable_grid(mon, grd(p)))
+    if (!monster_habitable_grid(mon, env.grid(p)))
         return false;
 
     // Stupid monsters don't pathfind around shallow water
index 229c7de..b961210 100644 (file)
@@ -390,14 +390,14 @@ vector<coord_def> monster_pathfind::calc_waypoints()
 
 bool monster_pathfind::traversable(const coord_def& p)
 {
-    if (!traverse_unmapped && grd(p) == DNGN_UNSEEN)
+    if (!traverse_unmapped && env.grid(p) == DNGN_UNSEEN)
         return false;
 
     // XXX: Hack to be somewhat consistent with uses of
     //      opc_immob elsewhere in pathfinding.
     //      All of this should eventually be replaced by
     //      giving the monster a proper pathfinding LOS.
-    if (opc_immob(p) == OPC_OPAQUE && !feat_is_closed_door(grd(p)))
+    if (opc_immob(p) == OPC_OPAQUE && !feat_is_closed_door(env.grid(p)))
     {
         // XXX: Ugly hack to make thorn hunters use their briars for defensive
         //      cover instead of just pathing around them.
@@ -421,7 +421,7 @@ bool monster_pathfind::traversable(const coord_def& p)
     if (mons)
         return mons_traversable(p);
 
-    return feat_has_solid_floor(grd(p));
+    return feat_has_solid_floor(env.grid(p));
 }
 
 // Checks whether a given monster can pass over a certain position, respecting
@@ -451,7 +451,7 @@ int monster_pathfind::mons_travel_cost(coord_def npos)
     ASSERT(grid_distance(pos, npos) <= 1);
 
     // Doors need to be opened.
-    if (feat_is_closed_door(grd(npos)))
+    if (feat_is_closed_door(env.grid(npos)))
         return 2;
 
     // Travelling through water, entering or leaving water is more expensive
index fc74437..d455cbc 100644 (file)
@@ -100,7 +100,7 @@ bool positioned_monster_picker::veto(monster_type mon)
 {
     // Actually pick a monster that is happy where we want to put it.
     // Fish zombies on land are helpless and uncool.
-    if (in_bounds(pos) && !monster_habitable_grid(mon, grd(pos)))
+    if (in_bounds(pos) && !monster_habitable_grid(mon, env.grid(pos)))
         return true;
     // Optional positional veto
     if (posveto && posveto(mon, pos)) return true;
index 43d8bfc..32b2d20 100644 (file)
@@ -574,7 +574,7 @@ static bool _valid_monster_generation_location(const mgen_data &mg,
     }
 
     const monster_type montype = fixup_zombie_type(mg.cls, mg.base_type);
-    if (!monster_habitable_grid(montype, grd(mg_pos), mg.preferred_grid_feature)
+    if (!monster_habitable_grid(montype, env.grid(mg_pos), mg.preferred_grid_feature)
         || (mg.behaviour != BEH_FRIENDLY
             && is_sanctuary(mg_pos)
             && !mons_is_tentacle_segment(montype)))
@@ -593,7 +593,7 @@ static bool _valid_monster_generation_location(const mgen_data &mg,
     else if (mg.proximity == PROX_AWAY_FROM_STAIRS)
     {
         for (distance_iterator di(mg_pos, false, false, LOS_RADIUS); di; ++di)
-            if (feat_is_stone_stair(grd(*di)))
+            if (feat_is_stone_stair(env.grid(*di)))
                 return false;
     }
     // Check that the location is not proximal to an area where the player
@@ -606,9 +606,9 @@ static bool _valid_monster_generation_location(const mgen_data &mg,
             // player is starting on D:1
             if (env.absdepth0 == 0)
             {
-                if (feat_is_branch_exit(grd(*di))
+                if (feat_is_branch_exit(env.grid(*di))
                     // We may be checking before branch exit cleanup.
-                    || feat_is_stone_stair_up(grd(*di)))
+                    || feat_is_stone_stair_up(env.grid(*di)))
                 {
                     return false;
                 }
@@ -616,7 +616,7 @@ static bool _valid_monster_generation_location(const mgen_data &mg,
             else if (env.absdepth0 == starting_absdepth())
             {
                 // Delvers start on a (specific) D:5 downstairs.
-                if (grd(*di) == DNGN_STONE_STAIRS_DOWN_I)
+                if (env.grid(*di) == DNGN_STONE_STAIRS_DOWN_I)
                     return false;
             }
         }
@@ -912,7 +912,7 @@ static monster* _place_monster_aux(const mgen_data &mg, const monster *leader,
             (!is_sanctuary(mg.pos) || mons_is_tentacle_segment(montype)))
         && !monster_at(mg.pos)
         && (you.pos() != mg.pos || fedhas_passthrough_class(mg.cls))
-        && (force_pos || monster_habitable_grid(montype, grd(mg.pos))))
+        && (force_pos || monster_habitable_grid(montype, env.grid(mg.pos))))
     {
         fpos = mg.pos;
     }
@@ -1307,7 +1307,7 @@ static monster* _place_monster_aux(const mgen_data &mg, const monster *leader,
         mon->max_hit_points *= mon->blob_size;
     }
 
-    if (monster_can_submerge(mon, grd(fpos)) && !summoned)
+    if (monster_can_submerge(mon, env.grid(fpos)) && !summoned)
         mon->add_ench(ENCH_SUBMERGED);
 
     // Set attitude, behaviour and target.
@@ -1528,7 +1528,7 @@ static bool _good_zombie(monster_type base, monster_type cs,
 
     // Actually pick a monster that is happy where we want to put it.
     // Fish zombies on land are helpless and uncool.
-    if (in_bounds(pos) && !monster_habitable_grid(base, grd(pos)))
+    if (in_bounds(pos) && !monster_habitable_grid(base, env.grid(pos)))
         return false;
 
     if (cs == MONS_NO_MONSTER)
@@ -2722,9 +2722,9 @@ public:
         {
             return false;
         }
-        if (!_feat_compatible(feat_wanted, grd(dc)))
+        if (!_feat_compatible(feat_wanted, env.grid(dc)))
         {
-            if (passable.count(grd(dc)))
+            if (passable.count(env.grid(dc)))
                 good_square(dc);
             return false;
         }
@@ -2888,7 +2888,7 @@ monster* create_monster(mgen_data mg, bool fail_msg)
     if (!mg.force_place()
         || monster_at(mg.pos)
         || you.pos() == mg.pos && !fedhas_passthrough_class(mg.cls)
-        || !mons_class_can_pass(montype, grd(mg.pos)))
+        || !mons_class_can_pass(montype, env.grid(mg.pos)))
     {
         // Gods other than Xom will try to avoid placing their monsters
         // directly in harm's way.
@@ -2950,7 +2950,7 @@ bool find_habitable_spot_near(const coord_def& where, monster_type mon_type,
         if (!cell_see_cell(where, *ri, LOS_NO_TRANS))
             continue;
 
-        success = monster_habitable_grid(mon_type, grd(*ri));
+        success = monster_habitable_grid(mon_type, env.grid(*ri));
         if (success && viable_mon)
             success = !mons_avoids_cloud(viable_mon, *ri, true);
 
index 77da2ce..9b48b73 100644 (file)
@@ -158,7 +158,7 @@ static bool _valid_morph(monster* mons, monster_type new_mclass)
     }
 
     // Determine if the monster is happy on current tile.
-    return monster_habitable_grid(new_mclass, grd(mons->pos()));
+    return monster_habitable_grid(new_mclass, env.grid(mons->pos()));
 }
 
 static bool _is_poly_power_unsuitable(poly_power_type power,
@@ -355,7 +355,7 @@ void change_monster_type(monster* mons, monster_type targetc)
     // Allows for handling of submerged monsters which polymorph into
     // monsters that can't submerge on this square.
     if (mons->has_ench(ENCH_SUBMERGED)
-        && !monster_can_submerge(mons, grd(mons->pos())))
+        && !monster_can_submerge(mons, env.grid(mons->pos())))
     {
         mons->del_ench(ENCH_SUBMERGED);
     }
@@ -569,14 +569,14 @@ void slimify_monster(monster* mon)
             target = MONS_AZURE_JELLY;
     }
 
-    if (feat_is_water(grd(mon->pos()))) // Pick something amphibious.
+    if (feat_is_water(env.grid(mon->pos()))) // Pick something amphibious.
         target = (x < 7) ? MONS_JELLY : MONS_SLIME_CREATURE;
 
     if (mon->holiness() & MH_UNDEAD)
         target = MONS_DEATH_OOZE;
 
     // Bail out if jellies can't live here.
-    if (!monster_habitable_grid(target, grd(mon->pos())))
+    if (!monster_habitable_grid(target, env.grid(mon->pos())))
     {
         simple_monster_message(*mon, " quivers momentarily.");
         return;
index ae7c850..e4e6a1a 100644 (file)
@@ -812,7 +812,7 @@ void move_solo_tentacle(monster* tentacle)
                 bool near_tree = false;
                 for (adjacent_iterator ai(constrictee->pos()); ai; ++ai)
                 {
-                    if (feat_is_tree(grd(*ai)))
+                    if (feat_is_tree(env.grid(*ai)))
                     {
                         near_tree = true;
                         break;
@@ -829,7 +829,7 @@ void move_solo_tentacle(monster* tentacle)
                         {
                             for (adjacent_iterator ai2(*ai); ai2; ++ai2)
                             {
-                                if (feat_is_tree(grd(*ai2)))
+                                if (feat_is_tree(env.grid(*ai2)))
                                 {
                                     pull_constrictee = true;
                                     shift_constrictee = true;
@@ -1052,7 +1052,7 @@ void move_child_tentacles(monster* mons)
         if (tentacle->is_constricting() && retract_found)
         {
             constrictee = actor_by_mid(tentacle->constricting->begin()->first);
-            if (feat_has_solid_floor(grd(old_pos))
+            if (feat_has_solid_floor(env.grid(old_pos))
                 && constrictee->is_habitable(old_pos))
             {
                 pull_constrictee = true;
@@ -1237,7 +1237,7 @@ void mons_create_tentacles(monster* head)
     // unoccupied.
     for (adjacent_iterator adj_it(head->pos()); adj_it; ++adj_it)
     {
-        if (monster_habitable_grid(tent_type, grd(*adj_it))
+        if (monster_habitable_grid(tent_type, env.grid(*adj_it))
             && !actor_at(*adj_it))
         {
             adj_squares.push_back(*adj_it);
index 5089f98..1d01bc0 100644 (file)
@@ -336,7 +336,7 @@ static bool _mons_can_follow_player_from(const monster &mons,
     // (though they'll be ignored for transit), so any adjacent real
     // follower can follow through. (jpeg)
     if (within_level && !mons_class_can_use_transporter(mons.type)
-        || !within_level && !mons_can_use_stairs(mons, grd(from)))
+        || !within_level && !mons_can_use_stairs(mons, env.grid(from)))
     {
         if (_is_religious_follower(mons))
             return true;
index 10f08f2..fdb4226 100644 (file)
@@ -166,7 +166,7 @@ monster_type random_monster_at_grid(const coord_def& p, bool species)
     if (!initialised_randmons)
         _initialise_randmons();
 
-    const habitat_type ht = _grid2habitat(grd(p));
+    const habitat_type ht = _grid2habitat(env.grid(p));
     const vector<monster_type> &valid_mons = species ? species_by_habitat[ht]
                                                      : monsters_by_habitat[ht];
 
@@ -1087,11 +1087,11 @@ static void _mimic_vanish(const coord_def& pos, const string& name)
 static void _destroy_mimic_feature(const coord_def &pos)
 {
 #if TAG_MAJOR_VERSION == 34
-    const dungeon_feature_type feat = grd(pos);
+    const dungeon_feature_type feat = env.grid(pos);
 #endif
 
     unnotice_feature(level_pos(level_id::current(), pos));
-    grd(pos) = DNGN_FLOOR;
+    env.grid(pos) = DNGN_FLOOR;
     env.level_map_mask(pos) &= ~MMT_MIMIC;
     set_terrain_changed(pos);
     remove_markers_and_listeners_at(pos);
@@ -1110,7 +1110,7 @@ void discover_mimic(const coord_def& pos)
     if (!item && !feature_mimic)
         return;
 
-    const dungeon_feature_type feat = grd(pos);
+    const dungeon_feature_type feat = env.grid(pos);
 
     // If the feature has been destroyed, don't create a floor mimic.
     if (feature_mimic && !feat_is_mimicable(feat, false))
@@ -4188,7 +4188,7 @@ bool mons_can_traverse(const monster& mon, const coord_def& p,
         return false;
 
     // Includes sealed doors.
-    if (feat_is_closed_door(grd(p)) && _mons_can_pass_door(&mon, p))
+    if (feat_is_closed_door(env.grid(p)) && _mons_can_pass_door(&mon, p))
         return true;
 
     if (!mon.is_habitable(p))
@@ -4476,7 +4476,7 @@ string do_mon_str_replacements(const string &in_msg, const monster& mons,
 
     if (you.see_cell(mons.pos()))
     {
-        dungeon_feature_type feat = grd(mons.pos());
+        dungeon_feature_type feat = env.grid(mons.pos());
         if (feat_is_solid(feat) || feat >= NUM_FEATURES)
             msg = replace_all(msg, "@surface@", "buggy surface");
         else if (feat == DNGN_LAVA)
index ed8c051..2486d57 100644 (file)
@@ -251,7 +251,7 @@ mon_attitude_type monster::temp_attitude() const
 
 bool monster::swimming() const
 {
-    const dungeon_feature_type grid = grd(pos());
+    const dungeon_feature_type grid = env.grid(pos());
     return feat_is_watery(grid) && mons_primary_habitat(*this) == HT_WATER;
 }
 
@@ -265,7 +265,7 @@ bool monster::submerged() const
 
 bool monster::extra_balanced_at(const coord_def p) const
 {
-    const dungeon_feature_type grid = grd(p);
+    const dungeon_feature_type grid = env.grid(p);
     return (mons_genus(type) == MONS_DRACONIAN
             && draco_or_demonspawn_subspecies(*this) == MONS_GREY_DRACONIAN)
                 || grid == DNGN_SHALLOW_WATER
@@ -290,7 +290,7 @@ bool monster::extra_balanced() const
  */
 bool monster::floundering_at(const coord_def p) const
 {
-    const dungeon_feature_type grid = grd(p);
+    const dungeon_feature_type grid = env.grid(p);
     return (liquefied(p)
             || (feat_is_water(grid)
                 // Can't use monster_habitable_grid() because that'll return
@@ -2719,7 +2719,7 @@ bool monster::fumbles_attack()
         {
             mprf("%s %s", name(DESC_THE).c_str(), liquefied(pos())
                  ? "becomes momentarily stuck in the liquid earth."
-                 : grd(pos()) == DNGN_TOXIC_BOG
+                 : env.grid(pos()) == DNGN_TOXIC_BOG
                  ? "becomes momentarily stuck in the toxic bog."
                  : "splashes around in the water.");
         }
@@ -4229,7 +4229,7 @@ bool monster::shift(coord_def p)
     for (adjacent_iterator ai(p); ai; ++ai)
     {
         // Don't drop on anything but vanilla floor right now.
-        if (grd(*ai) != DNGN_FLOOR)
+        if (env.grid(*ai) != DNGN_FLOOR)
             continue;
 
         if (actor_at(*ai))
@@ -4783,7 +4783,7 @@ bool monster::check_set_valid_home(const coord_def &place,
     if (actor_at(place))
         return false;
 
-    if (!monster_habitable_grid(this, grd(place)))
+    if (!monster_habitable_grid(this, env.grid(place)))
         return false;
 
     if (!is_trap_safe(place, true))
@@ -4798,7 +4798,7 @@ bool monster::check_set_valid_home(const coord_def &place,
 
 bool monster::is_location_safe(const coord_def &place)
 {
-    if (!monster_habitable_grid(this, grd(place)))
+    if (!monster_habitable_grid(this, env.grid(place)))
         return false;
 
     if (!is_trap_safe(place, true))
@@ -4861,7 +4861,7 @@ bool monster::find_home_near_place(const coord_def &c)
                 continue;
             dist(*ai - c) = last_dist = dist(p - c) + 1;
 
-            if (!monster_habitable_grid(this, grd(*ai)))
+            if (!monster_habitable_grid(this, env.grid(*ai)))
                 continue;
 
             q.push(*ai);
@@ -5478,7 +5478,7 @@ void monster::apply_location_effects(const coord_def &oldpos,
 
     if (alive()
         && (mons_habitat(*this) == HT_WATER || mons_habitat(*this) == HT_LAVA)
-        && !monster_habitable_grid(this, grd(pos()))
+        && !monster_habitable_grid(this, env.grid(pos()))
         && !has_ench(ENCH_AQUATIC_LAND))
     {
         // Elemental wellsprings always have water beneath them
@@ -5493,19 +5493,19 @@ void monster::apply_location_effects(const coord_def &oldpos,
 
     if (alive() && has_ench(ENCH_AQUATIC_LAND))
     {
-        if (!monster_habitable_grid(this, grd(pos())))
+        if (!monster_habitable_grid(this, env.grid(pos())))
             simple_monster_message(*this, " flops around on dry land!");
-        else if (!monster_habitable_grid(this, grd(oldpos)))
+        else if (!monster_habitable_grid(this, env.grid(oldpos)))
         {
             if (you.can_see(*this))
             {
                 mprf("%s dives back into the %s!", name(DESC_THE).c_str(),
-                                                   feat_type_name(grd(pos())));
+                                                   feat_type_name(env.grid(pos())));
             }
             del_ench(ENCH_AQUATIC_LAND);
         }
         // This may have been called via dungeon_terrain_changed instead
-        // of by the monster moving move, in that case grd(oldpos) will
+        // of by the monster moving move, in that case env.grid(oldpos) will
         // be the current position that became watery.
         else
             del_ench(ENCH_AQUATIC_LAND);
@@ -5521,7 +5521,7 @@ void monster::apply_location_effects(const coord_def &oldpos,
 
     if (alive()
         && has_ench(ENCH_SUBMERGED)
-        && !monster_can_submerge(this, grd(pos())))
+        && !monster_can_submerge(this, env.grid(pos())))
     {
         del_ench(ENCH_SUBMERGED);
     }
@@ -5603,8 +5603,8 @@ bool monster::swap_with(monster* other)
         return false;
     }
 
-    if (!monster_habitable_grid(this, grd(new_pos))
-        || !monster_habitable_grid(other, grd(old_pos)))
+    if (!monster_habitable_grid(this, env.grid(new_pos))
+        || !monster_habitable_grid(other, env.grid(old_pos)))
     {
         return false;
     }
@@ -5639,7 +5639,7 @@ bool monster::do_shaft()
     // Handle instances of do_shaft() being invoked magically when
     // the monster isn't standing over a shaft.
     if (get_trap_type(pos()) != TRAP_SHAFT
-        && !feat_is_shaftable(grd(pos())))
+        && !feat_is_shaftable(env.grid(pos())))
     {
         return false;
     }
@@ -6086,7 +6086,7 @@ void monster::react_to_damage(const actor *oppressor, int damage,
                     mprf("As %s mount dies, %s plunges down into %s!",
                          pronoun(PRONOUN_POSSESSIVE).c_str(),
                          name(DESC_THE).c_str(),
-                         grd(pos()) == DNGN_LAVA ?
+                         env.grid(pos()) == DNGN_LAVA ?
                              "lava and is incinerated" :
                              "deep water and drowns");
                 }
@@ -6401,13 +6401,13 @@ item_def* monster::disarm()
     item_def *mons_wpn = mslot_item(MSLOT_WEAPON);
 
     // is it ok to move the weapon into your tile (w/o destroying it?)
-    const bool your_tile_ok = !feat_eliminates_items(grd(you.pos()));
+    const bool your_tile_ok = !feat_eliminates_items(env.grid(you.pos()));
 
     // It's ok to drop the weapon into deep water if it comes out right away,
     // but if the monster is on lava we just have to abort.
-    const bool mon_tile_ok = !feat_destroys_items(grd(pos()))
+    const bool mon_tile_ok = !feat_destroys_items(env.grid(pos()))
                              && (your_tile_ok
-                                 || !feat_eliminates_items(grd(pos())));
+                                 || !feat_eliminates_items(env.grid(pos())));
 
     if (!mons_wpn
         || mons_wpn->cursed()
index f67ece6..1fa874e 100644 (file)
@@ -58,7 +58,7 @@ static void _apply_move_time_taken(int additional_time_taken = 0);
 static void _swap_places(monster* mons, const coord_def &loc)
 {
     ASSERT(map_bounds(loc));
-    ASSERT(monster_habitable_grid(mons, grd(loc)));
+    ASSERT(monster_habitable_grid(mons, env.grid(loc)));
 
     if (monster_at(loc))
     {
@@ -106,7 +106,7 @@ static int _check_adjacent(dungeon_feature_type feat, coord_def& delta)
     set<coord_def> doors;
     for (adjacent_iterator ai(you.pos(), true); ai; ++ai)
     {
-        if (grd(*ai) == feat)
+        if (env.grid(*ai) == feat)
         {
             // Specialcase doors to take into account gates.
             if (feat_is_door(feat))
@@ -248,12 +248,12 @@ bool cancel_confused_move(bool stationary)
     for (adjacent_iterator ai(you.pos(), false); ai; ++ai)
     {
         if (!stationary
-            && is_feat_dangerous(grd(*ai), true)
-            && need_expiration_warning(grd(*ai))
-            && (dangerous == DNGN_FLOOR || grd(*ai) == DNGN_LAVA))
+            && is_feat_dangerous(env.grid(*ai), true)
+            && need_expiration_warning(env.grid(*ai))
+            && (dangerous == DNGN_FLOOR || env.grid(*ai) == DNGN_LAVA))
         {
-            dangerous = grd(*ai);
-            if (need_expiration_warning(DUR_FLIGHT, grd(*ai)))
+            dangerous = env.grid(*ai);
+            if (need_expiration_warning(DUR_FLIGHT, env.grid(*ai)))
                 flight = true;
             break;
         }
@@ -384,7 +384,7 @@ void open_door_action(coord_def move)
         return;
     }
 
-    const dungeon_feature_type feat = (in_bounds(doorpos) ? grd(doorpos)
+    const dungeon_feature_type feat = (in_bounds(doorpos) ? env.grid(doorpos)
                                                           : DNGN_UNSEEN);
     switch (feat)
     {
@@ -460,7 +460,7 @@ void close_door_action(coord_def move)
         delta = move;
 
     const coord_def doorpos = you.pos() + delta;
-    const dungeon_feature_type feat = (in_bounds(doorpos) ? grd(doorpos)
+    const dungeon_feature_type feat = (in_bounds(doorpos) ? env.grid(doorpos)
                                                           : DNGN_UNSEEN);
 
     switch (feat)
@@ -583,7 +583,7 @@ static spret _rampage_forward(coord_def move)
 
         // Don't rampage if our tracer path is broken by something we can't
         // safely pass through before it reaches a monster.
-        if (!you.can_pass_through(p) || is_feat_dangerous(grd(p)))
+        if (!you.can_pass_through(p) || is_feat_dangerous(env.grid(p)))
             return spret::fail;
 
         const monster* mon = monster_at(p);
@@ -890,12 +890,12 @@ void move_player_action(coord_def move)
 
     if (you.digging)
     {
-        if (feat_is_diggable(grd(targ)))
+        if (feat_is_diggable(env.grid(targ)))
             targ_pass = true;
         else // moving or attacking ends dig
         {
             you.digging = false;
-            if (feat_is_solid(grd(targ)))
+            if (feat_is_solid(env.grid(targ)))
                 mpr("You can't dig through that.");
             else
                 mpr("You retract your mandibles.");
@@ -1073,17 +1073,17 @@ void move_player_action(coord_def move)
     // BCR - Easy doors single move
     if ((Options.travel_open_doors || !you.running)
         && !attacking
-        && feat_is_closed_door(grd(targ)))
+        && feat_is_closed_door(env.grid(targ)))
     {
         open_door_action(move);
         move.reset();
         return;
     }
-    else if (!targ_pass && grd(targ) == DNGN_MALIGN_GATEWAY
+    else if (!targ_pass && env.grid(targ) == DNGN_MALIGN_GATEWAY
              && !attacking && !you.is_stationary())
     {
         if (!crawl_state.disables[DIS_CONFIRMATIONS]
-            && !prompt_dangerous_portal(grd(targ)))
+            && !prompt_dangerous_portal(env.grid(targ)))
         {
             // No rampage check because the portal blocks the
             // rampage tracer
@@ -1101,11 +1101,11 @@ void move_player_action(coord_def move)
         // No rampage check here, since you can't rampage at walls
         if (you.is_stationary())
             canned_msg(MSG_CANNOT_MOVE);
-        else if (grd(targ) == DNGN_OPEN_SEA)
+        else if (env.grid(targ) == DNGN_OPEN_SEA)
             mpr("The ferocious winds and tides of the open sea thwart your progress.");
-        else if (grd(targ) == DNGN_LAVA_SEA)
+        else if (env.grid(targ) == DNGN_LAVA_SEA)
             mpr("The endless sea of lava is not a nice place.");
-        else if (feat_is_tree(grd(targ)) && you_worship(GOD_FEDHAS))
+        else if (feat_is_tree(env.grid(targ)) && you_worship(GOD_FEDHAS))
             mpr("You cannot walk through the dense trees.");
 
         stop_running();
index 9b98e9f..68750b3 100644 (file)
@@ -395,7 +395,7 @@ void bring_to_safety()
         pos.x = random2(GXM);
         pos.y = random2(GYM);
         if (!in_bounds(pos)
-            || grd(pos) != DNGN_FLOOR
+            || env.grid(pos) != DNGN_FLOOR
             || cloud_at(pos)
             || monster_at(pos)
             || env.pgrid(pos) & FPROP_NO_TELE_INTO
@@ -407,7 +407,7 @@ void bring_to_safety()
         }
 
         for (adjacent_iterator ai(pos); ai; ++ai)
-            if (grd(*ai) == DNGN_SLIMY_WALL)
+            if (env.grid(*ai) == DNGN_SLIMY_WALL)
             {
                 tries++;
                 continue;
index 25c512b..61f123c 100644 (file)
@@ -137,7 +137,7 @@ bool player::floundering() const
 
 bool player::extra_balanced() const
 {
-    const dungeon_feature_type grid = grd(pos());
+    const dungeon_feature_type grid = env.grid(pos());
     return species == SP_GREY_DRACONIAN
               || form == transformation::tree
               || grid == DNGN_SHALLOW_WATER
@@ -805,8 +805,8 @@ bool player::is_web_immune() const
 bool player::shove(const char* feat_name)
 {
     for (distance_iterator di(pos()); di; ++di)
-        if (in_bounds(*di) && !actor_at(*di) && !is_feat_dangerous(grd(*di))
-            && can_pass_through_feat(grd(*di)))
+        if (in_bounds(*di) && !actor_at(*di) && !is_feat_dangerous(env.grid(*di))
+            && can_pass_through_feat(env.grid(*di)))
         {
             moveto(*di);
             if (*feat_name)
index f590f58..c69c887 100644 (file)
@@ -576,7 +576,7 @@ static void _decrement_durations()
         || you.transform_uncancellable)
     {
         if (form_can_fly()
-            || form_likes_water() && feat_is_water(grd(you.pos())))
+            || form_likes_water() && feat_is_water(env.grid(you.pos())))
         {
             // Disable emergency flight if it was active
             you.props.erase(EMERGENCY_FLIGHT_KEY);
@@ -997,7 +997,7 @@ void player_reacts()
         slime_wall_damage(&you, you.time_taken);
 
     // Icy shield and armour melt over lava.
-    if (grd(you.pos()) == DNGN_LAVA)
+    if (env.grid(you.pos()) == DNGN_LAVA)
         maybe_melt_player_enchantments(BEAM_FIRE, you.time_taken);
 
     _decrement_durations();
index 6efda51..e30ff8c 100644 (file)
@@ -352,7 +352,7 @@ bool swap_check(monster* mons, coord_def &loc, bool quiet)
         return false;
 
     // Don't move onto dangerous terrain.
-    if (is_feat_dangerous(grd(mons->pos())))
+    if (is_feat_dangerous(env.grid(mons->pos())))
     {
         canned_msg(MSG_UNTHINKING_ACT);
         return false;
@@ -398,13 +398,13 @@ bool swap_check(monster* mons, coord_def &loc, bool quiet)
     }
 
     // First try: move monster onto your position.
-    bool swap = !monster_at(loc) && monster_habitable_grid(mons, grd(loc));
+    bool swap = !monster_at(loc) && monster_habitable_grid(mons, env.grid(loc));
 
     if (monster_at(loc)
         && monster_at(loc)->type == MONS_TOADSTOOL
         && mons->type == MONS_WANDERING_MUSHROOM)
     {
-        swap = monster_habitable_grid(mons, grd(loc));
+        swap = monster_habitable_grid(mons, env.grid(loc));
     }
 
     // Choose an appropriate habitat square at random around the target.
@@ -413,7 +413,7 @@ bool swap_check(monster* mons, coord_def &loc, bool quiet)
         int num_found = 0;
 
         for (adjacent_iterator ai(mons->pos()); ai; ++ai)
-            if (!monster_at(*ai) && monster_habitable_grid(mons, grd(*ai))
+            if (!monster_at(*ai) && monster_habitable_grid(mons, env.grid(*ai))
                 && one_chance_in(++num_found))
             {
                 loc = *ai;
@@ -535,10 +535,10 @@ void move_player_to_grid(const coord_def& p, bool stepped)
     const coord_def old_pos = you.pos();
     const bool from_above = (old_pos == p);
     const dungeon_feature_type old_grid =
-        (from_above) ? DNGN_FLOOR : grd(old_pos);
+        (from_above) ? DNGN_FLOOR : env.grid(old_pos);
 
     // Really must be clear.
-    ASSERT(you.can_pass_through_feat(grd(p)));
+    ASSERT(you.can_pass_through_feat(env.grid(p)));
 
     // Better not be an unsubmerged monster either.
     ASSERT(!monster_at(p) || monster_at(p)->submerged()
@@ -4316,7 +4316,7 @@ bool napalm_player(int amount, string source, string source_aux)
 {
     ASSERT(!crawl_state.game_is_arena());
 
-    if (player_res_sticky_flame() || amount <= 0 || you.duration[DUR_WATER_HOLD] || feat_is_watery(grd(you.pos())))
+    if (player_res_sticky_flame() || amount <= 0 || you.duration[DUR_WATER_HOLD] || feat_is_watery(env.grid(you.pos())))
         return false;
 
     const int old_value = you.duration[DUR_LIQUID_FLAMES];
@@ -4335,7 +4335,7 @@ void dec_napalm_player(int delay)
 {
     delay = min(delay, you.duration[DUR_LIQUID_FLAMES]);
 
-    if (feat_is_watery(grd(you.pos())))
+    if (feat_is_watery(env.grid(you.pos())))
     {
         if (you.ground_level())
             mprf(MSGCH_WARN, "The flames go out!");
@@ -4738,8 +4738,8 @@ void enable_emergency_flight()
 {
     mprf("You can't survive in this terrain! You fly above the %s, but the "
          "process is draining.",
-         (grd(you.pos()) == DNGN_LAVA)       ? "lava" :
-         (grd(you.pos()) == DNGN_DEEP_WATER) ? "water"
+         (env.grid(you.pos()) == DNGN_LAVA)       ? "lava" :
+         (env.grid(you.pos()) == DNGN_DEEP_WATER) ? "water"
                                              : "buggy terrain");
 
     you.props[EMERGENCY_FLIGHT_KEY] = true;
@@ -4758,7 +4758,7 @@ bool land_player(bool quiet)
         return false;
 
     // Handle landing on (formerly) instakill terrain
-    if (is_feat_dangerous(grd(you.pos())))
+    if (is_feat_dangerous(env.grid(you.pos())))
     {
         enable_emergency_flight();
         return false;
@@ -5227,7 +5227,7 @@ bool player::is_sufficiently_rested() const
 
 bool player::in_water() const
 {
-    return ground_level() && !you.can_water_walk() && feat_is_water(grd(pos()));
+    return ground_level() && !you.can_water_walk() && feat_is_water(env.grid(pos()));
 }
 
 bool player::in_liquid() const
@@ -5254,8 +5254,8 @@ bool player::can_water_walk() const
 
 int player::visible_igrd(const coord_def &where) const
 {
-    if (grd(where) == DNGN_LAVA
-        || (grd(where) == DNGN_DEEP_WATER
+    if (env.grid(where) == DNGN_LAVA
+        || (env.grid(where) == DNGN_DEEP_WATER
             && !species_likes_water(species)))
     {
         return NON_ITEM;
@@ -7278,7 +7278,7 @@ int player::beam_resists(bolt &beam, int hurted, bool doEffects, string source)
 bool player::do_shaft()
 {
     if (!is_valid_shaft_level()
-        || !feat_is_shaftable(grd(pos()))
+        || !feat_is_shaftable(env.grid(pos()))
         || duration[DUR_SHAFT_IMMUNITY])
     {
         return false;
@@ -7303,7 +7303,7 @@ bool player::can_do_shaft_ability(bool quiet) const
         return false;
     }
 
-    if (feat_is_shaftable(grd(pos())))
+    if (feat_is_shaftable(env.grid(pos())))
     {
         if (!is_valid_shaft_level())
         {
@@ -7862,7 +7862,7 @@ void player_open_door(coord_def doorpos)
     for (const auto &dc : all_door)
     {
         if (cell_is_runed(dc))
-            explored_tracked_feature(grd(dc));
+            explored_tracked_feature(env.grid(dc));
         dgn_open_door(dc);
         set_terrain_changed(dc);
         dungeon_events.fire_position_event(DET_DOOR_OPENED, dc);
@@ -7872,9 +7872,9 @@ void player_open_door(coord_def doorpos)
         // door!
         if (env.map_knowledge(dc).seen())
         {
-            env.map_knowledge(dc).set_feature(grd(dc));
+            env.map_knowledge(dc).set_feature(env.grid(dc));
 #ifdef USE_TILE
-            env.tile_bk_bg(dc) = tileidx_feature_base(grd(dc));
+            env.tile_bk_bg(dc) = tileidx_feature_base(env.grid(dc));
 #endif
         }
 
@@ -8043,9 +8043,9 @@ void player_close_door(coord_def doorpos)
         // want the entire door to be updated.
         if (env.map_knowledge(dc).seen())
         {
-            env.map_knowledge(dc).set_feature(grd(dc));
+            env.map_knowledge(dc).set_feature(env.grid(dc));
 #ifdef USE_TILE
-            env.tile_bk_bg(dc) = tileidx_feature_base(grd(dc));
+            env.tile_bk_bg(dc) = tileidx_feature_base(env.grid(dc));
 #endif
         }
 
index 0626305..077c32e 100644 (file)
@@ -703,7 +703,7 @@ void dec_penance(int val)
 static bool _need_water_walking()
 {
     return you.ground_level() && you.species != SP_MERFOLK
-           && grd(you.pos()) == DNGN_DEEP_WATER;
+           && env.grid(you.pos()) == DNGN_DEEP_WATER;
 }
 
 static void _grant_temporary_waterwalk()
@@ -1283,8 +1283,8 @@ static int _pakellas_high_misc()
 static bool _give_pakellas_gift()
 {
     // Break early if giving a gift now means it would be lost.
-    if (!(feat_has_solid_floor(grd(you.pos()))
-        || feat_is_watery(grd(you.pos())) && species_likes_water(you.species)))
+    if (!(feat_has_solid_floor(env.grid(you.pos()))
+        || feat_is_watery(env.grid(you.pos())) && species_likes_water(you.species)))
     {
         return false;
     }
@@ -1371,8 +1371,8 @@ static bool _give_pakellas_gift()
 static bool _give_trog_oka_gift(bool forced)
 {
     // Break early if giving a gift now means it would be lost.
-    if (!(feat_has_solid_floor(grd(you.pos()))
-        || feat_is_watery(grd(you.pos())) && species_likes_water(you.species)))
+    if (!(feat_has_solid_floor(env.grid(you.pos()))
+        || feat_is_watery(env.grid(you.pos())) && species_likes_water(you.species)))
     {
         return false;
     }
@@ -1503,7 +1503,7 @@ static bool _gift_sif_kiku_gift(bool forced)
     bool success = false;
     book_type gift = NUM_BOOKS;
     // Break early if giving a gift now means it would be lost.
-    if (!feat_has_solid_floor(grd(you.pos())))
+    if (!feat_has_solid_floor(env.grid(you.pos())))
         return false;
 
     // Kikubaaqudgha gives the lesser Necromancy books in a quick
@@ -3706,7 +3706,7 @@ void join_religion(god_type which_god)
 
 void god_pitch(god_type which_god)
 {
-    if (which_god == GOD_BEOGH && grd(you.pos()) != DNGN_ALTAR_BEOGH)
+    if (which_god == GOD_BEOGH && env.grid(you.pos()) != DNGN_ALTAR_BEOGH)
         mpr("You bow before the missionary of Beogh.");
     else
     {
index 7a52778..ddae25e 100644 (file)
@@ -1390,14 +1390,14 @@ void destroy_shop_at(coord_def p)
     if (shop_at(p))
     {
         env.shop.erase(p);
-        grd(p) = DNGN_ABANDONED_SHOP;
+        env.grid(p) = DNGN_ABANDONED_SHOP;
         unnotice_feature(level_pos(level_id::current(), p));
     }
 }
 
 shop_struct *shop_at(const coord_def& where)
 {
-    if (grd(where) != DNGN_ENTER_SHOP)
+    if (env.grid(where) != DNGN_ENTER_SHOP)
         return nullptr;
 
     auto it = env.shop.find(where);
index d5047a5..6b02e9b 100644 (file)
@@ -852,7 +852,7 @@ bool fake_noisy(int loudness, const coord_def& where)
 // Permarock walls are assumed to completely kill noise.
 static int _noise_attenuation_millis(const coord_def &pos)
 {
-    const dungeon_feature_type feat = grd(pos);
+    const dungeon_feature_type feat = env.grid(pos);
 
     if (feat_is_permarock(feat))
         return NOISE_ATTENUATION_COMPLETE;
@@ -1259,7 +1259,7 @@ void noise_grid::write_noise_grid(FILE *outf) const
             if (you.pos() == coord_def(x, y))
                 write_cell(outf, p, '@');
             else
-                write_cell(outf, p, get_feature_def(grd[x][y]).symbol());
+                write_cell(outf, p, get_feature_def(env.grid[x][y]).symbol());
         }
         fprintf(outf, "<br>\n");
     }
index 58d8ea2..e1195b9 100644 (file)
@@ -110,7 +110,7 @@ static void _update_feat_at(const coord_def &gp)
     if (!you.see_cell(gp))
         return;
 
-    dungeon_feature_type feat = grd(gp);
+    dungeon_feature_type feat = env.grid(gp);
     unsigned colour = env.grid_colours(gp);
     trap_type trap = TRAP_UNASSIGNED;
     if (feat_is_trap(feat))
@@ -320,7 +320,7 @@ static bool _valid_invisible_spot(const coord_def &where, const monster* mons)
     if (mons_at && mons_at != mons)
         return false;
 
-    if (monster_habitable_grid(mons, grd(where)))
+    if (monster_habitable_grid(mons, env.grid(where)))
         return true;
 
     return false;
@@ -457,7 +457,7 @@ static void _update_monster(monster* mons)
 
     // Ripple effect?
     // Should match directn.cc's _mon_exposed
-    if (grd(gp) == DNGN_SHALLOW_WATER
+    if (env.grid(gp) == DNGN_SHALLOW_WATER
             && !mons->airborne()
             && !cloud_at(gp)
         || cloud_at(gp) && is_opaque_cloud(cloud_at(gp)->type)
index 2a0437c..e0bd893 100644 (file)
@@ -214,7 +214,7 @@ static int _get_mons_colour(const monster_info& mi)
     else if (mons_class_is_stationary(mi.type))
     {
         if (Options.feature_item_brand != CHATTR_NORMAL
-            && feat_stair_direction(grd(mi.pos)) != CMD_NO_CMD)
+            && feat_stair_direction(env.grid(mi.pos)) != CMD_NO_CMD)
         {
             col |= COLFLAG_FEATURE_ITEM;
         }
index a415ac5..6c04b19 100644 (file)
@@ -141,7 +141,7 @@ spret cast_big_c(int pow, spell_type spl, const actor *caster, bolt &beam,
 
     if (cell_is_solid(beam.target))
     {
-        const char *feat = feat_type_name(grd(beam.target));
+        const char *feat = feat_type_name(env.grid(beam.target));
         mprf("You can't place clouds on %s.", article_a(feat).c_str());
         return spret::abort;
     }
index 841f446..fa19627 100644 (file)
@@ -81,7 +81,7 @@ spret cast_fire_storm(int pow, bolt &beam, bool fail)
 
     if (cell_is_solid(beam.target))
     {
-        const char *feat = feat_type_name(grd(beam.target));
+        const char *feat = feat_type_name(env.grid(beam.target));
         mprf("You can't place the storm on %s.", article_a(feat).c_str());
         return spret::abort;
     }
@@ -962,7 +962,7 @@ static int _shatter_walls(coord_def where, int /*pow*/, actor *agent)
     if (env.markers.property_at(where, MAT_ANY, "veto_destroy") == "veto")
         return 0;
 
-    const dungeon_feature_type grid = grd(where);
+    const dungeon_feature_type grid = env.grid(where);
 
     switch (grid)
     {
@@ -1378,7 +1378,7 @@ static int _ignite_poison_bog(coord_def where, int pow, actor *agent)
 {
     const bool tracer = (pow == -1);  // Only testing damage, not dealing it
 
-    if (grd(where) != DNGN_TOXIC_BOG)
+    if (env.grid(where) != DNGN_TOXIC_BOG)
         return false;
 
     if (tracer)
@@ -2006,7 +2006,7 @@ bool setup_fragmentation_beam(bolt &beam, int pow, const actor *caster,
     beam.damage = dice_def(0, 5 + pow / 5);
 
     monster* mon = monster_at(target);
-    const dungeon_feature_type grid = grd(target);
+    const dungeon_feature_type grid = env.grid(target);
 
     if (target == you.pos())
     {
@@ -2435,7 +2435,7 @@ actor* forest_near_enemy(const actor *mon)
             continue;
 
         for (adjacent_iterator ai(*ri); ai; ++ai)
-            if (feat_is_tree(grd(*ai)) && cell_see_cell(pos, *ai, LOS_DEFAULT))
+            if (feat_is_tree(env.grid(*ai)) && cell_see_cell(pos, *ai, LOS_DEFAULT))
                 return foe;
     }
 
@@ -2446,7 +2446,7 @@ actor* forest_near_enemy(const actor *mon)
 void forest_message(const coord_def pos, const string &msg, msg_channel_type ch)
 {
     for (radius_iterator ri(pos, LOS_DEFAULT); ri; ++ri)
-        if (feat_is_tree(grd(*ri))
+        if (feat_is_tree(env.grid(*ri))
             && cell_see_cell(you.pos(), *ri, LOS_DEFAULT))
         {
             mprf(ch, "%s", msg.c_str());
@@ -2479,7 +2479,7 @@ void forest_damage(const actor *mon)
             continue;
 
         for (adjacent_iterator ai(*ri); ai; ++ai)
-            if (feat_is_tree(grd(*ai)) && cell_see_cell(pos, *ai, LOS_NO_TRANS))
+            if (feat_is_tree(env.grid(*ai)) && cell_see_cell(pos, *ai, LOS_NO_TRANS))
             {
                 int dmg = 0;
                 string msg;
@@ -3226,7 +3226,7 @@ spret cast_imb(int pow, bool fail)
 
 void actor_apply_toxic_bog(actor * act)
 {
-    if (grd(act->pos()) != DNGN_TOXIC_BOG)
+    if (env.grid(act->pos()) != DNGN_TOXIC_BOG)
         return;
 
     if (!act->ground_level())
@@ -3310,7 +3310,7 @@ spret cast_frozen_ramparts(int pow, bool fail)
                 spell_range(SPELL_FROZEN_RAMPARTS, -1, false), C_SQUARE,
                 LOS_NO_TRANS, true); ri; ++ri)
     {
-        const auto feat = grd(*ri);
+        const auto feat = env.grid(*ri);
         if (feat_is_wall(feat))
             wall_locs.push_back(*ri);
     }
index ee31c5a..65d4d5f 100644 (file)
@@ -848,7 +848,7 @@ static bool _do_imprison(int pow, const coord_def& where, bool zin)
 
             // Make sure we have a legitimate tile.
             proceed = false;
-            if (cell_is_solid(*ai) && !feat_is_opaque(grd(*ai)))
+            if (cell_is_solid(*ai) && !feat_is_opaque(env.grid(*ai)))
             {
                 success = false;
                 none_vis = false;
@@ -882,7 +882,7 @@ static bool _do_imprison(int pow, const coord_def& where, bool zin)
 
         // closed doors are solid, but we don't want a behaviour difference
         // between open and closed doors
-        proceed = !cell_is_solid(*ai) || feat_is_door(grd(*ai));
+        proceed = !cell_is_solid(*ai) || feat_is_door(env.grid(*ai));
         if (!zin && monster_at(*ai))
             proceed = false;
 
@@ -896,7 +896,7 @@ static bool _do_imprison(int pow, const coord_def& where, bool zin)
             if (trap_def *ptrap = trap_at(*ai))
             {
                 ptrap->destroy();
-                grd(*ai) = DNGN_FLOOR;
+                env.grid(*ai) = DNGN_FLOOR;
             }
 
             // Actually place the wall.
index 7cdb8ac..4fb6767 100644 (file)
@@ -249,7 +249,7 @@ passwall_path::passwall_path(const actor &act, const coord_def& dir, int max_ran
         path.emplace_back(pos);
         if (in_bounds(pos))
         {
-            if (!_feat_is_passwallable(grd(pos)))
+            if (!_feat_is_passwallable(env.grid(pos)))
             {
                 if (!dest_found)
                 {
@@ -352,9 +352,9 @@ bool passwall_path::check_moveto() const
     // assumes is_valid()
 
     string terrain_msg;
-    if (grd(actual_dest) == DNGN_DEEP_WATER)
+    if (env.grid(actual_dest) == DNGN_DEEP_WATER)
         terrain_msg = "You sense a deep body of water on the other side of the rock.";
-    else if (grd(actual_dest) == DNGN_LAVA)
+    else if (env.grid(actual_dest) == DNGN_LAVA)
         terrain_msg = "You sense an intense heat on the other side of the rock.";
 
     // Pre-confirm exclusions in unseen squares as well as the actual dest
index e1ffcff..a46150d 100644 (file)
@@ -226,7 +226,7 @@ spret cast_noxious_bog(int pow, bool fail)
 
 void noxious_bog_cell(coord_def p)
 {
-    if (grd(p) == DNGN_DEEP_WATER || grd(p) == DNGN_LAVA)
+    if (env.grid(p) == DNGN_DEEP_WATER || env.grid(p) == DNGN_LAVA)
         return;
 
     const int turns = 10
index 9e7290a..5628b63 100644 (file)
@@ -296,7 +296,7 @@ static void _place_dragon()
         vector<coord_def> spots;
         for (adjacent_iterator ai(target->pos()); ai; ++ai)
         {
-            if (monster_habitable_grid(MONS_FIRE_DRAGON, grd(*ai))
+            if (monster_habitable_grid(MONS_FIRE_DRAGON, env.grid(*ai))
                 && !actor_at(*ai))
             {
                 spots.push_back(*ai);
@@ -391,7 +391,7 @@ void doom_howl(int time)
         vector<coord_def> spots;
         for (adjacent_iterator ai(target->pos()); ai; ++ai)
         {
-            if (monster_habitable_grid(howlcalled, grd(*ai))
+            if (monster_habitable_grid(howlcalled, env.grid(*ai))
                 && !actor_at(*ai))
             {
                 spots.push_back(*ai);
@@ -1115,7 +1115,7 @@ coord_def find_gateway_location(actor* caster)
         for (int t = 0; t < 11; t++)
         {
             test = caster->pos() + (delta * (2+t));
-            if (!in_bounds(test) || !feat_is_malign_gateway_suitable(grd(test))
+            if (!in_bounds(test) || !feat_is_malign_gateway_suitable(env.grid(test))
                 || actor_at(test)
                 || count_neighbours_with_func(test, &feat_is_solid) != 0
                 || !caster->see_cell_no_trans(test))
@@ -1231,7 +1231,7 @@ static bool _water_adjacent(coord_def p)
 {
     for (orth_adjacent_iterator ai(p); ai; ++ai)
     {
-        if (feat_is_water(grd(*ai)))
+        if (feat_is_water(env.grid(*ai)))
             return true;
     }
 
@@ -1275,9 +1275,9 @@ spret cast_summon_forest(actor* caster, int pow, god_type god, bool fail)
         for (distance_iterator di(caster->pos(), false, true,
                                   LOS_DEFAULT_RANGE); di; ++di)
         {
-            if ((feat_is_wall(grd(*di)) && !feat_is_permarock(grd(*di))
+            if ((feat_is_wall(env.grid(*di)) && !feat_is_permarock(env.grid(*di))
                  && x_chance_in_y(pow, 150))
-                || (grd(*di) == DNGN_FLOOR && x_chance_in_y(pow, 1250)
+                || (env.grid(*di) == DNGN_FLOOR && x_chance_in_y(pow, 1250)
                     && !actor_at(*di) && !plant_forbidden_at(*di, true)))
             {
                 temp_change_terrain(*di, DNGN_TREE, duration,
@@ -1294,7 +1294,7 @@ spret cast_summon_forest(actor* caster, int pow, god_type god, bool fail)
 
             for (distance_iterator di(pond, true, false, 4); di && num > 0; ++di)
             {
-                if (grd(*di) == DNGN_FLOOR
+                if (env.grid(*di) == DNGN_FLOOR
                     && (di.radius() == 0 || _water_adjacent(*di))
                     && x_chance_in_y(4, di.radius() + 3))
                 {
@@ -1587,7 +1587,7 @@ int animate_remains(const coord_def &a, corpse_type class_allowed,
     if (is_sanctuary(a))
         return 0;
 
-    if (grd(a) == DNGN_DEEP_WATER)
+    if (env.grid(a) == DNGN_DEEP_WATER)
         return 0; // trapped in davy jones' locker...
 
     int number_found = 0;
@@ -3075,7 +3075,7 @@ bool fedhas_wall_of_briars()
 
 static void _overgrow_wall(const coord_def &pos)
 {
-    const dungeon_feature_type feat = grd(pos);
+    const dungeon_feature_type feat = env.grid(pos);
     const string what = feature_description(feat, NUM_TRAPS, "", DESC_THE);
 
     if (monster_at(pos))
@@ -3145,7 +3145,7 @@ spret fedhas_grow_ballistomycete(bool fail)
         return spret::abort;
     }
 
-    if (!monster_habitable_grid(MONS_BALLISTOMYCETE, grd(beam.target)))
+    if (!monster_habitable_grid(MONS_BALLISTOMYCETE, env.grid(beam.target)))
     {
         mpr("You can't grow a ballistomycete there.");
         return spret::abort;
@@ -3202,7 +3202,7 @@ spret fedhas_grow_oklob(bool fail)
         return spret::abort;
     }
 
-    if (!monster_habitable_grid(MONS_OKLOB_PLANT, grd(beam.target)))
+    if (!monster_habitable_grid(MONS_OKLOB_PLANT, env.grid(beam.target)))
     {
         mpr("You can't grow an oklob plant there.");
         return spret::abort;
index 27e15fe..50ccee7 100644 (file)
@@ -31,8 +31,8 @@ static bool _airtight(coord_def c)
 {
     // Broken by 6f473416 -- we should re-allow the wind through grates.
 
-    // return (feat_is_wall(grd(c)) || feat_is_opaque(grd(c))) && grd(c);
-    return !feat_is_reachable_past(grd(c));
+    // return (feat_is_wall(env.grid(c)) || feat_is_opaque(env.grid(c))) && env.grid(c);
+    return !feat_is_reachable_past(env.grid(c));
 }
 
 /* Explanation of the algorithm:
@@ -310,11 +310,11 @@ void tornado_damage(actor *caster, int dur, bool is_vortex)
             bool veto =
                 env.markers.property_at(*dam_i, MAT_ANY, "veto_destroy") == "veto";
 
-            if ((feat_is_tree(grd(*dam_i)) && !is_temp_terrain(*dam_i))
+            if ((feat_is_tree(env.grid(*dam_i)) && !is_temp_terrain(*dam_i))
                 && !veto && dur > 0
                 && bernoulli(rdur * 0.01, 0.05)) // 5% chance per 10 aut
             {
-                grd(*dam_i) = DNGN_FLOOR;
+                env.grid(*dam_i) = DNGN_FLOOR;
                 set_terrain_changed(*dam_i);
                 if (you.see_cell(*dam_i))
                     mpr("A tree falls to the hurricane!");
index cdd2542..440a39e 100644 (file)
@@ -289,7 +289,7 @@ void wizard_blink()
     // Allow wizard blink to send player into walls, in case the
     // user wants to alter that grid to something else.
     if (cell_is_solid(beam.target))
-        grd(beam.target) = DNGN_FLOOR;
+        env.grid(beam.target) = DNGN_FLOOR;
 
     move_player_to_grid(beam.target, false);
 }
@@ -368,7 +368,7 @@ spret frog_hop(bool fail)
 
 static bool _check_charge_through(coord_def pos)
 {
-    if (!you.can_pass_through_feat(grd(pos)))
+    if (!you.can_pass_through_feat(env.grid(pos)))
     {
         clear_messages();
         mprf("You can't roll into that!");
@@ -707,7 +707,7 @@ static bool _cell_vetoes_teleport(const coord_def cell, bool check_monsters = tr
     if (cell_is_solid(cell))
         return true;
 
-    return is_feat_dangerous(grd(cell), true) && !wizard_tele;
+    return is_feat_dangerous(env.grid(cell), true) && !wizard_tele;
 }
 
 static void _handle_teleport_update(bool large_change, const coord_def old_pos)
@@ -733,8 +733,8 @@ static void _handle_teleport_update(bool large_change, const coord_def old_pos)
 #ifdef USE_TILE
     if (you.species == SP_MERFOLK)
     {
-        const dungeon_feature_type new_grid = grd(you.pos());
-        const dungeon_feature_type old_grid = grd(old_pos);
+        const dungeon_feature_type new_grid = env.grid(you.pos());
+        const dungeon_feature_type old_grid = env.grid(old_pos);
         if (feat_is_water(old_grid) && !feat_is_water(new_grid)
             || !feat_is_water(old_grid) && feat_is_water(new_grid))
         {
@@ -1084,7 +1084,7 @@ spret cast_apportation(int pow, bolt& beam, bool fail)
     // less than dist.
     while (location_on_path < dist)
     {
-        if (!feat_eliminates_items(grd(new_spot)))
+        if (!feat_eliminates_items(env.grid(new_spot)))
             break;
         location_on_path++;
         if (location_on_path == dist)
@@ -1134,7 +1134,7 @@ spret cast_golubrias_passage(const coord_def& where, bool fail)
         randomized_where.y += random_range(-range, range);
     }
     while ((!in_bounds(randomized_where)
-            || grd(randomized_where) != DNGN_FLOOR
+            || env.grid(randomized_where) != DNGN_FLOOR
             || monster_at(randomized_where)
             || !you.see_cell(randomized_where)
             || you.trans_wall_blocking(randomized_where)
@@ -1149,7 +1149,7 @@ spret cast_golubrias_passage(const coord_def& where, bool fail)
         randomized_here.y += random_range(-range, range);
     }
     while ((!in_bounds(randomized_here)
-            || grd(randomized_here) != DNGN_FLOOR
+            || env.grid(randomized_here) != DNGN_FLOOR
             || monster_at(randomized_here)
             || !you.see_cell(randomized_here)
             || you.trans_wall_blocking(randomized_here)
@@ -1264,7 +1264,7 @@ static void _attract_actor(const actor* agent, actor* victim,
         ray.advance();
         const coord_def newpos = ray.pos();
 
-        if (!victim->can_pass_through_feat(grd(newpos)))
+        if (!victim->can_pass_through_feat(env.grid(newpos)))
         {
             victim->collide(newpos, agent, pow);
             break;
@@ -1333,7 +1333,7 @@ spret cast_gravitas(int pow, const coord_def& where, bool fail)
 
     mprf("Gravity reorients around %s.",
          mons                      ? mons->name(DESC_THE).c_str() :
-         feat_is_solid(grd(where)) ? feature_description(grd(where),
+         feat_is_solid(env.grid(where)) ? feature_description(env.grid(where),
                                                          NUM_TRAPS, "",
                                                          DESC_THE)
                                                          .c_str()
index fa28dd5..3755ea2 100644 (file)
@@ -67,14 +67,14 @@ bool check_annotation_exclusion_warning()
         crawl_state.level_annotation_shown = true;
     }
     else if (is_exclude_root(you.pos())
-             && feat_is_travelable_stair(grd(you.pos()))
+             && feat_is_travelable_stair(env.grid(you.pos()))
              && !strstr(get_exclusion_desc(you.pos()).c_str(), "cloud"))
     {
         mprf(MSGCH_WARN, "This staircase is marked as excluded!");
         might_be_dangerous = true;
     }
 
-    if (feat_is_travelable_stair(grd(you.pos())))
+    if (feat_is_travelable_stair(env.grid(you.pos())))
     {
         if (LevelInfo *li = travel_cache.find_level_info(level_id::current()))
         {
@@ -128,7 +128,7 @@ static bool _stair_moves_pre(dungeon_feature_type stair)
     if (crawl_state.prev_cmd == CMD_WIZARD)
         return false;
 
-    if (stair != grd(you.pos()))
+    if (stair != env.grid(you.pos()))
         return false;
 
     if (feat_stair_direction(stair) == CMD_NO_CMD)
@@ -1117,7 +1117,7 @@ static void _update_level_state()
 #endif
     for (rectangle_iterator ri(0); ri; ++ri)
     {
-        if (grd(*ri) == DNGN_SLIMY_WALL)
+        if (env.grid(*ri) == DNGN_SLIMY_WALL)
             env.level_state |= LSTATE_SLIMY_WALL;
 
         if (is_icecovered(*ri))
index 1b3bbd8..165f528 100644 (file)
@@ -244,7 +244,7 @@ bool Stash::unmark_trapping_nets()
 
 void Stash::update()
 {
-    feat = grd(pos);
+    feat = env.grid(pos);
     trap = NUM_TRAPS;
 
     if (is_boring_feature(feat))
@@ -1078,7 +1078,7 @@ void StashTracker::update_visible_stashes()
     for (radius_iterator ri(you.pos(),
                             you.xray_vision ? LOS_NONE : LOS_DEFAULT); ri; ++ri)
     {
-        const dungeon_feature_type feat = grd(*ri);
+        const dungeon_feature_type feat = env.grid(*ri);
 
         if ((!lev || !lev->update_stash(*ri))
             && (_grid_has_perceived_item(*ri)
index 7729b61..165b948 100644 (file)
@@ -929,7 +929,7 @@ static void _describe_stat_zero(status_info& inf, stat_type st)
 
 static void _describe_terrain(status_info& inf)
 {
-    switch (grd(you.pos()))
+    switch (env.grid(you.pos()))
     {
     case DNGN_SHALLOW_WATER:
         inf.light_colour = LIGHTBLUE;
index ed37e8a..46cec9a 100644 (file)
@@ -1085,9 +1085,9 @@ static void _ensure_entry(branch_type br)
         if (orig_terrain(*ri) == DNGN_STONE_STAIRS_UP_I)
         {
             for (distance_iterator di(*ri); di; ++di)
-                if (in_bounds(*di) && grd(*di) == DNGN_FLOOR)
+                if (in_bounds(*di) && env.grid(*di) == DNGN_FLOOR)
                 {
-                    grd(*di) = entry; // No need to update LOS, etc.
+                    env.grid(*di) = entry; // No need to update LOS, etc.
                     // Announce the repair even in non-debug builds.
                     mprf(MSGCH_ERROR, "Placing missing branch entry: %s.",
                          dungeon_feature_name(entry));
@@ -1117,7 +1117,7 @@ static void _add_missing_branches()
     {
         for (rectangle_iterator ri(0); ri; ++ri)
         {
-            if (grd(*ri) == DNGN_STONE_ARCH)
+            if (env.grid(*ri) == DNGN_STONE_ARCH)
             {
                 map_marker *marker = env.markers.find(*ri, MAT_FEATURE);
                 if (marker)
@@ -1134,7 +1134,7 @@ static void _add_missing_branches()
                     case DNGN_ENTER_DIS:
                     case DNGN_ENTER_GEHENNA:
                     case DNGN_ENTER_TARTARUS:
-                        grd(*ri) = featm->feat;
+                        env.grid(*ri) = featm->feat;
                         dprf("opened %s", dungeon_feature_name(featm->feat));
                         env.markers.remove(marker);
                         break;
@@ -1205,7 +1205,7 @@ static void _shunt_monsters_out_of_walls()
     {
         monster &m(env.mons[i]);
         if (m.alive() && in_bounds(m.pos()) && cell_is_solid(m.pos())
-            && (grd(m.pos()) != DNGN_MALIGN_GATEWAY
+            && (env.grid(m.pos()) != DNGN_MALIGN_GATEWAY
                 || mons_genus(m.type) != MONS_ELDRITCH_TENTACLE))
         {
             for (distance_iterator di(m.pos()); di; ++di)
@@ -1217,7 +1217,7 @@ static void _shunt_monsters_out_of_walls()
 #endif
                     mprf(MSGCH_ERROR, "Error: monster %s in %s at (%d,%d)",
                          m.name(DESC_PLAIN, true).c_str(),
-                         dungeon_feature_name(grd(m.pos())),
+                         dungeon_feature_name(env.grid(m.pos())),
                          m.pos().x, m.pos().y);
                     env.mgrid(m.pos()) = NON_MONSTER;
                     m.position = *di;
@@ -1305,7 +1305,7 @@ void tag_read(reader &inf, tag_type tag_id)
                          == "gammafunk_gauntlet_branching")
             {
                 auto exit = DNGN_EXIT_GAUNTLET;
-                grd(you.pos()) = exit;
+                env.grid(you.pos()) = exit;
                 // Announce the repair even in non-debug builds.
                 mprf(MSGCH_ERROR, "Placing emergency exit: %s.",
                      dungeon_feature_name(exit));
@@ -4499,7 +4499,7 @@ static void _tag_construct_level(writer &th)
     for (int count_x = 0; count_x < GXM; count_x++)
         for (int count_y = 0; count_y < GYM; count_y++)
         {
-            marshallByte(th, grd[count_x][count_y]);
+            marshallByte(th, env.grid[count_x][count_y]);
             marshallMapCell(th, env.map_knowledge[count_x][count_y]);
             marshallInt(th, env.pgrid[count_x][count_y].flags);
         }
@@ -6020,12 +6020,12 @@ static void _tag_read_level(reader &th)
         for (int j = 0; j < gy; j++)
         {
             dungeon_feature_type feat = unmarshallFeatureType(th);
-            grd[i][j] = feat;
+            env.grid[i][j] = feat;
             ASSERT(feat < NUM_FEATURES);
 
 #if TAG_MAJOR_VERSION == 34
             // Save these for potential destination clean up.
-            if (grd[i][j] == DNGN_TRANSPORTER)
+            if (env.grid[i][j] == DNGN_TRANSPORTER)
                 transporters.push_back(coord_def(i, j));
 #endif
             unmarshallMapCell(th, env.map_knowledge[i][j]);
@@ -6133,12 +6133,12 @@ static void _tag_read_level(reader &th)
     {
         for (auto& tr : transporters)
         {
-            if (grd(tr) != DNGN_TRANSPORTER)
+            if (env.grid(tr) != DNGN_TRANSPORTER)
                 continue;
 
             const coord_def dest = get_transporter_dest(tr);
             if (dest != INVALID_COORD)
-                grd(dest) = DNGN_TRANSPORTER_LANDING;
+                env.grid(dest) = DNGN_TRANSPORTER_LANDING;
         }
     }
     if (th.getMinorVersion() < TAG_MINOR_VETO_DISINT)
@@ -6270,7 +6270,7 @@ static void _tag_read_level_items(reader &th)
         if (th.getMinorVersion() == TAG_MINOR_0_11 && trap.type >= TRAP_TELEPORT)
             trap.type = (trap_type)(trap.type - 1);
         if (th.getMinorVersion() < TAG_MINOR_REVEAL_TRAPS)
-            grd(trap.pos) = trap.feature();
+            env.grid(trap.pos) = trap.feature();
         if (th.getMinorVersion() >= TAG_MINOR_TRAPS_DETERM
             && th.getMinorVersion() != TAG_MINOR_0_11
             && th.getMinorVersion() < TAG_MINOR_REVEALED_TRAPS)
@@ -6288,8 +6288,8 @@ static void _tag_read_level_items(reader &th)
         for (int j = 0; j < GYM; j++)
         {
             coord_def pos(i, j);
-            if (feat_is_trap(grd(pos)) && !map_find(env.trap, pos))
-                grd(pos) = DNGN_FLOOR;
+            if (feat_is_trap(env.grid(pos)) && !map_find(env.trap, pos))
+                env.grid(pos) = DNGN_FLOOR;
         }
 
 #endif
index 8929f27..eed0e30 100644 (file)
@@ -29,7 +29,7 @@
 static string _wallmsg(coord_def c)
 {
     ASSERT(map_bounds(c)); // there'd be an information leak
-    const char *wall = feat_type_name(grd(c));
+    const char *wall = feat_type_name(env.grid(c));
     return "There is " + article_a(wall) + " there.";
 }
 
@@ -142,7 +142,7 @@ bool targeter_charge::valid_aim(coord_def a)
                 return notify_fail(bad);
             return true;
         }
-        else if (is_feat_dangerous(grd(ray.pos())))
+        else if (is_feat_dangerous(env.grid(ray.pos())))
         {
             return notify_fail("There's "
                                + feature_description_at(ray.pos())
@@ -174,7 +174,7 @@ bool targeter_charge::set_aim(coord_def a)
 
         if (!can_charge_through_mons(ray.pos()))
             break;
-        if (is_feat_dangerous(grd(ray.pos())))
+        if (is_feat_dangerous(env.grid(ray.pos())))
             return false;
     }
     return true;
@@ -804,7 +804,7 @@ aff_type targeter_reach::is_affected(coord_def loc)
         return AFF_YES;
 
     if (((loc - origin) * 2 - (aim - origin)).abs() <= 1
-        && feat_is_reachable_past(grd(loc)))
+        && feat_is_reachable_past(env.grid(loc)))
     {
         return AFF_TRACER;
     }
@@ -1605,7 +1605,7 @@ bool targeter_overgrow::overgrow_affects_pos(const coord_def &p)
     if (env.markers.property_at(p, MAT_ANY, "veto_destroy") == "veto")
         return false;
 
-    const dungeon_feature_type feat = grd(p);
+    const dungeon_feature_type feat = env.grid(p);
     if (feat_is_open_door(feat))
     {
         const monster* const mons = monster_at(p);
index aa5e048..8d218e2 100644 (file)
@@ -144,7 +144,7 @@ static coord_def _random_monster_nearby_habitable_space(const monster& mon)
         if (!in_bounds(target))
             continue;
 
-        if (!monster_habitable_grid(&mon, grd(target)))
+        if (!monster_habitable_grid(&mon, env.grid(target)))
             continue;
 
         if (respect_sanctuary && is_sanctuary(target))
@@ -188,7 +188,7 @@ bool monster_space_valid(const monster* mons, coord_def target,
     if (testbits(env.pgrid(target), FPROP_NO_TELE_INTO))
         return false;
 
-    return monster_habitable_grid(mons, grd(target));
+    return monster_habitable_grid(mons, env.grid(target));
 }
 
 static bool _monster_random_space(const monster* mons, coord_def& target,
@@ -428,7 +428,7 @@ bool valid_blink_destination(const actor* moved, const coord_def& target,
     {
         if (!moved->is_habitable(target))
             return false;
-        if (moved->is_player() && is_feat_dangerous(grd(target), true))
+        if (moved->is_player() && is_feat_dangerous(env.grid(target), true))
             return false;
     }
     if (forbid_sanctuary && is_sanctuary(target))
index 7565dcc..72afa64 100644 (file)
@@ -383,7 +383,7 @@ bool feat_can_wall_jump_against(dungeon_feature_type feat)
  */
 bool cell_is_solid(const coord_def &c)
 {
-    return feat_is_solid(grd(c));
+    return feat_is_solid(env.grid(c));
 }
 
 /** Can a human stand on this feature without flying?
@@ -715,7 +715,7 @@ int count_neighbours_with_func(const coord_def& c, bool (*checker)(dungeon_featu
     int count = 0;
     for (adjacent_iterator ai(c); ai; ++ai)
     {
-        if (checker(grd(*ai)))
+        if (checker(env.grid(*ai)))
             count++;
     }
     return count;
@@ -727,7 +727,7 @@ static void _find_connected_identical(const coord_def &d,
                                       set<coord_def>& out,
                                       bool known_only)
 {
-    if (grd(d) != ft || (known_only && !env.map_knowledge(d).known()))
+    if (env.grid(d) != ft || (known_only && !env.map_knowledge(d).known()))
         return;
 
     string prop = env.markers.property_at(d, MAT_ANY, "connected_exclude");
@@ -756,7 +756,7 @@ void find_connected_identical(const coord_def &d, set<coord_def>& out, bool know
     if (!prop.empty())
         out.insert(d);
     else
-        _find_connected_identical(d, grd(d), out, known_only);
+        _find_connected_identical(d, env.grid(d), out, known_only);
 }
 
 void get_door_description(int door_size, const char** adjective, const char** noun)
@@ -782,7 +782,7 @@ coord_def get_random_stair()
     vector<coord_def> st;
     for (rectangle_iterator ri(1); ri; ++ri)
     {
-        const dungeon_feature_type feat = grd(*ri);
+        const dungeon_feature_type feat = env.grid(*ri);
         if (feat_is_travelable_stair(feat) && !feat_is_escape_hatch(feat)
             && feat != DNGN_EXIT_DUNGEON
             && feat != DNGN_EXIT_HELL)
@@ -802,7 +802,7 @@ static void _precompute_slime_wall_neighbours()
     map_mask_boolean &mask(*_slime_wall_precomputed_neighbour_mask);
     for (rectangle_iterator ri(1); ri; ++ri)
     {
-        if (grd(*ri) == DNGN_SLIMY_WALL)
+        if (env.grid(*ri) == DNGN_SLIMY_WALL)
         {
             for (adjacent_iterator ai(*ri); ai; ++ai)
                 mask(*ai) = true;
@@ -982,7 +982,7 @@ static coord_def _dgn_find_nearest_square(
 
 static bool _item_safe_square(const coord_def &pos)
 {
-    const dungeon_feature_type feat = grd(pos);
+    const dungeon_feature_type feat = env.grid(pos);
     return feat_is_traversable(feat) && !feat_destroys_items(feat);
 }
 
@@ -1012,7 +1012,7 @@ static bool _dgn_shift_item(const coord_def &pos, item_def &item)
 
 static bool _is_feature_shift_target(const coord_def &pos)
 {
-    return grd(pos) == DNGN_FLOOR && !dungeon_events.has_listeners_at(pos)
+    return env.grid(pos) == DNGN_FLOOR && !dungeon_events.has_listeners_at(pos)
            && !actor_at(pos);
 }
 
@@ -1041,14 +1041,14 @@ void dgn_move_entities_at(coord_def src, coord_def dst,
 
     move_notable_thing(src, dst);
 
-    dungeon_feature_type dfeat = grd(src);
+    dungeon_feature_type dfeat = env.grid(src);
     if (dfeat == DNGN_ENTER_SHOP)
     {
         ASSERT(shop_at(src));
         env.shop[dst] = env.shop[src];
         env.shop[dst].pos = dst;
         env.shop.erase(src);
-        grd(src) = DNGN_FLOOR;
+        env.grid(src) = DNGN_FLOOR;
     }
     else if (feat_is_trap(dfeat))
     {
@@ -1056,10 +1056,10 @@ void dgn_move_entities_at(coord_def src, coord_def dst,
         env.trap[dst] = env.trap[src];
         env.trap[dst].pos = dst;
         env.trap.erase(src);
-        grd(src) = DNGN_FLOOR;
+        env.grid(src) = DNGN_FLOOR;
     }
 
-    grd(dst) = dfeat;
+    env.grid(dst) = dfeat;
 
     if (move_monster || move_player)
         ASSERT(!actor_at(dst));
@@ -1126,7 +1126,7 @@ void dgn_move_entities_at(coord_def src, coord_def dst,
 
 static bool _dgn_shift_feature(const coord_def &pos)
 {
-    const dungeon_feature_type dfeat = grd(pos);
+    const dungeon_feature_type dfeat = env.grid(pos);
     if (!feat_is_critical(dfeat) && !env.markers.find(pos, MAT_ANY))
         return false;
 
@@ -1139,7 +1139,7 @@ static bool _dgn_shift_feature(const coord_def &pos)
 
 static void _dgn_check_terrain_items(const coord_def &pos, bool preserve_items)
 {
-    const dungeon_feature_type feat = grd(pos);
+    const dungeon_feature_type feat = env.grid(pos);
 
     int item = igrd(pos);
     while (item != NON_ITEM)
@@ -1232,7 +1232,7 @@ void dungeon_terrain_changed(const coord_def &pos,
                              bool temporary,
                              bool wizmode)
 {
-    if (grd(pos) == nfeat)
+    if (env.grid(pos) == nfeat)
         return;
     if (feat_is_wall(nfeat) && monster_at(pos))
         return;
@@ -1246,7 +1246,7 @@ void dungeon_terrain_changed(const coord_def &pos,
     }
 
 
-    _dgn_check_terrain_covering(pos, grd(pos), nfeat);
+    _dgn_check_terrain_covering(pos, env.grid(pos), nfeat);
 
     if (nfeat != DNGN_UNSEEN)
     {
@@ -1256,7 +1256,7 @@ void dungeon_terrain_changed(const coord_def &pos,
         if (!temporary)
             unnotice_feature(level_pos(level_id::current(), pos));
 
-        grd(pos) = nfeat;
+        env.grid(pos) = nfeat;
         // Reset feature tile
         env.tile_flv(pos).feat = 0;
         env.tile_flv(pos).feat_idx = 0;
@@ -1284,7 +1284,7 @@ void dungeon_terrain_changed(const coord_def &pos,
 
 static void _announce_swap_real(coord_def orig_pos, coord_def dest_pos)
 {
-    const dungeon_feature_type orig_feat = grd(dest_pos);
+    const dungeon_feature_type orig_feat = env.grid(dest_pos);
 
     const string orig_name =
         feature_description_at(dest_pos, false,
@@ -1340,8 +1340,8 @@ static void _announce_swap(coord_def pos1, coord_def pos2)
     if (!you.see_cell(pos1) && !you.see_cell(pos2))
         return;
 
-    const dungeon_feature_type feat1 = grd(pos1);
-    const dungeon_feature_type feat2 = grd(pos2);
+    const dungeon_feature_type feat1 = env.grid(pos1);
+    const dungeon_feature_type feat2 = env.grid(pos2);
 
     if (feat1 == feat2)
         return;
@@ -1374,8 +1374,8 @@ bool swap_features(const coord_def &pos1, const coord_def &pos2,
     if (is_sanctuary(pos1) || is_sanctuary(pos2))
         return false;
 
-    const dungeon_feature_type feat1 = grd(pos1);
-    const dungeon_feature_type feat2 = grd(pos2);
+    const dungeon_feature_type feat1 = env.grid(pos1);
+    const dungeon_feature_type feat2 = env.grid(pos2);
 
     if (is_notable_terrain(feat1) && !you.see_cell(pos1)
         && env.map_knowledge(pos1).known())
@@ -1413,7 +1413,7 @@ bool swap_features(const coord_def &pos1, const coord_def &pos2,
                 continue;
 
             if (!env.markers.find(pos, MAT_ANY)
-                && !is_notable_terrain(grd(pos))
+                && !is_notable_terrain(env.grid(pos))
                 && !cloud_at(pos))
             {
                 temp = pos;
@@ -1435,7 +1435,7 @@ bool swap_features(const coord_def &pos1, const coord_def &pos2,
     (void) move_notable_thing(pos1, temp);
     env.markers.move(pos1, temp);
     dungeon_events.move_listeners(pos1, temp);
-    grd(pos1) = DNGN_UNSEEN;
+    env.grid(pos1) = DNGN_UNSEEN;
     env.pgrid(pos1) = terrain_property_t{};
 
     (void) move_notable_thing(pos2, pos1);
@@ -1449,8 +1449,8 @@ bool swap_features(const coord_def &pos1, const coord_def &pos2,
     dungeon_events.move_listeners(temp, pos2);
 
     // Swap features and colours.
-    grd(pos2) = feat1;
-    grd(pos1) = feat2;
+    env.grid(pos2) = feat1;
+    env.grid(pos1) = feat2;
 
     env.grid_colours(pos1) = col2;
     env.grid_colours(pos2) = col1;
@@ -1573,7 +1573,7 @@ static bool _ok_dest_cell(const actor* orig_actor,
                           const dungeon_feature_type orig_feat,
                           const coord_def dest_pos)
 {
-    const dungeon_feature_type dest_feat = grd(dest_pos);
+    const dungeon_feature_type dest_feat = env.grid(dest_pos);
 
     if (orig_feat == dest_feat)
         return false;
@@ -1599,7 +1599,7 @@ bool slide_feature_over(const coord_def &src, coord_def preferred_dest,
 {
     ASSERT_IN_BOUNDS(src);
 
-    const dungeon_feature_type orig_feat = grd(src);
+    const dungeon_feature_type orig_feat = env.grid(src);
     const actor* orig_actor = actor_at(src);
 
     if (in_bounds(preferred_dest)
@@ -1893,9 +1893,9 @@ void set_terrain_changed(const coord_def p)
     if (cell_is_solid(p))
         delete_cloud(p);
 
-    if (grd(p) == DNGN_SLIMY_WALL)
+    if (env.grid(p) == DNGN_SLIMY_WALL)
         env.level_state |= LSTATE_SLIMY_WALL;
-    else if (grd(p) == DNGN_OPEN_DOOR)
+    else if (env.grid(p) == DNGN_OPEN_DOOR)
     {
         // Restore colour from door-change markers
         for (map_marker *marker : env.markers.get_markers_at(p))
@@ -1931,9 +1931,9 @@ void set_terrain_changed(const coord_def p)
  */
 bool cell_triggers_conduct(const coord_def p)
 {
-    return !(feat_is_endless(grd(p))
-             || grd(p) == DNGN_LAVA
-             || grd(p) == DNGN_DEEP_WATER
+    return !(feat_is_endless(env.grid(p))
+             || env.grid(p) == DNGN_LAVA
+             || env.grid(p) == DNGN_DEEP_WATER
              || env.pgrid(p) & FPROP_SEEN_OR_NOEXP);
 }
 
@@ -1962,7 +1962,7 @@ dungeon_feature_type orig_terrain(coord_def pos)
 {
     const map_marker *mark = env.markers.find(pos, MAT_TERRAIN_CHANGE);
     if (!mark)
-        return grd(pos);
+        return env.grid(pos);
 
     const map_terrain_change_marker *terch
         = dynamic_cast<const map_terrain_change_marker *>(mark);
@@ -1974,7 +1974,7 @@ dungeon_feature_type orig_terrain(coord_def pos)
 void temp_change_terrain(coord_def pos, dungeon_feature_type newfeat, int dur,
                          terrain_change_type type, const monster* mon)
 {
-    dungeon_feature_type old_feat = grd(pos);
+    dungeon_feature_type old_feat = env.grid(pos);
     for (map_marker *marker : env.markers.get_markers_at(pos))
     {
         if (marker->get_type() == MAT_TERRAIN_CHANGE)
@@ -2014,7 +2014,7 @@ void temp_change_terrain(coord_def pos, dungeon_feature_type newfeat, int dur,
 
     // If we are trying to change terrain into what it already is, don't actually
     // add another marker (unless the current terrain is due to some OTHER marker)
-    if (grd(pos) == newfeat && newfeat == old_feat)
+    if (env.grid(pos) == newfeat && newfeat == old_feat)
         return;
 
     int col = env.grid_colours(pos);
@@ -2056,20 +2056,20 @@ static bool _revert_terrain_to_floor(coord_def pos)
             else
             {
                 newfeat = tmarker->old_feature;
-                if (tmarker->new_feature == grd(pos))
+                if (tmarker->new_feature == env.grid(pos))
                     env.markers.remove(tmarker);
             }
         }
     }
 
-    if (grd(pos) == DNGN_RUNED_DOOR && newfeat != DNGN_RUNED_DOOR
-        || grd(pos) == DNGN_RUNED_CLEAR_DOOR
+    if (env.grid(pos) == DNGN_RUNED_DOOR && newfeat != DNGN_RUNED_DOOR
+        || env.grid(pos) == DNGN_RUNED_CLEAR_DOOR
            && newfeat != DNGN_RUNED_CLEAR_DOOR)
     {
-        explored_tracked_feature(grd(pos));
+        explored_tracked_feature(env.grid(pos));
     }
 
-    grd(pos) = newfeat;
+    env.grid(pos) = newfeat;
     set_terrain_changed(pos);
 
     tile_clear_flavour(pos);
@@ -2110,7 +2110,7 @@ bool revert_terrain_change(coord_def pos, terrain_change_type ctype)
     }
 
     // Don't revert opened sealed doors.
-    if (feat_is_door(newfeat) && grd(pos) == DNGN_OPEN_DOOR)
+    if (feat_is_door(newfeat) && env.grid(pos) == DNGN_OPEN_DOOR)
         newfeat = DNGN_UNSEEN;
 
     if (newfeat != DNGN_UNSEEN)
@@ -2154,7 +2154,7 @@ bool plant_forbidden_at(const coord_def &p, bool connectivity_only)
     {
         coord_def q = p + Compass[i];
 
-        if (feat_is_traversable(grd(q), true))
+        if (feat_is_traversable(env.grid(q), true))
         {
             ++passable;
             if (first < 0)
@@ -2211,12 +2211,12 @@ vector<coord_def> get_push_spaces(const coord_def& pos, bool push_actor,
             return results;
     }
 
-    dungeon_feature_type starting_feat = grd(pos);
+    dungeon_feature_type starting_feat = env.grid(pos);
     vector<coord_def> bad_spots; // used for items
 
     for (adjacent_iterator ai(pos); ai; ++ai)
     {
-        dungeon_feature_type feat = grd(*ai);
+        dungeon_feature_type feat = env.grid(*ai);
 
         // Make sure the spot wasn't already vetoed. This is used e.g. for
         // imprison, to pre-exclude all the spots where a wall will be.
@@ -2326,13 +2326,13 @@ coord_def push_actor_from(const coord_def& pos,
  */
 void dgn_close_door(const coord_def &dest)
 {
-    if (!feat_is_open_door(grd(dest)))
+    if (!feat_is_open_door(env.grid(dest)))
         return;
 
-    if (grd(dest) == DNGN_OPEN_CLEAR_DOOR)
-        grd(dest) = DNGN_CLOSED_CLEAR_DOOR;
+    if (env.grid(dest) == DNGN_OPEN_CLEAR_DOOR)
+        env.grid(dest) = DNGN_CLOSED_CLEAR_DOOR;
     else
-        grd(dest) = DNGN_CLOSED_DOOR;
+        env.grid(dest) = DNGN_CLOSED_DOOR;
 }
 
 /** Open any door at the given position. Handles the grid change, but does not
@@ -2342,16 +2342,16 @@ void dgn_close_door(const coord_def &dest)
  */
 void dgn_open_door(const coord_def &dest)
 {
-    if (!feat_is_closed_door(grd(dest)))
+    if (!feat_is_closed_door(env.grid(dest)))
         return;
 
-    if (grd(dest) == DNGN_CLOSED_CLEAR_DOOR
-        || grd(dest) == DNGN_RUNED_CLEAR_DOOR)
+    if (env.grid(dest) == DNGN_CLOSED_CLEAR_DOOR
+        || env.grid(dest) == DNGN_RUNED_CLEAR_DOOR)
     {
-        grd(dest) = DNGN_OPEN_CLEAR_DOOR;
+        env.grid(dest) = DNGN_OPEN_CLEAR_DOOR;
     }
     else
-        grd(dest) = DNGN_OPEN_DOOR;
+        env.grid(dest) = DNGN_OPEN_DOOR;
 }
 
 void ice_wall_damage(monster &mons, int delay)
index a278366..6b9e8fd 100644 (file)
@@ -388,7 +388,7 @@ static bool _fire_choose_item_and_target(int& slot, dist& target,
     }
     if (teleport && cell_is_solid(target.target))
     {
-        const char *feat = feat_type_name(grd(target.target));
+        const char *feat = feat_type_name(env.grid(target.target));
         mprf("There is %s there.", article_a(feat).c_str());
         return false;
     }
index 4a80dfe..ed4d578 100644 (file)
@@ -692,7 +692,7 @@ tileidx_t tileidx_tentacle(const monster_info& mon)
         // Find an adjacent tree to pretend we're connected to.
         for (adjacent_iterator ai(t_pos); ai; ++ai)
         {
-            if (feat_is_tree(grd(*ai)))
+            if (feat_is_tree(env.grid(*ai)))
             {
                 h_pos = *ai;
                 no_head_connect = false;
index 44fac56..ce087c3 100644 (file)
@@ -766,7 +766,7 @@ int DungeonRegion::handle_mouse(wm_mouse_event &event)
                 if (o == NON_ITEM)
                 {
                     // if on stairs, travel them
-                    const dungeon_feature_type feat = grd(gc);
+                    const dungeon_feature_type feat = env.grid(gc);
                     switch (feat_stair_direction(feat))
                     {
                     case CMD_GO_DOWNSTAIRS:
@@ -794,7 +794,7 @@ int DungeonRegion::handle_mouse(wm_mouse_event &event)
                 }
             }
 
-            const dungeon_feature_type feat = grd(gc);
+            const dungeon_feature_type feat = env.grid(gc);
             switch (feat_stair_direction(feat))
             {
             case CMD_GO_DOWNSTAIRS:
@@ -1089,7 +1089,7 @@ bool tile_dungeon_tip(const coord_def &gc, string &tip)
                 _add_tip(tip, "[L-Click] Travel");
             }
         }
-        else if (feat_is_closed_door(grd(gc)))
+        else if (feat_is_closed_door(env.grid(gc)))
         {
             if (!adjacent(gc, you.pos()) && i_feel_safe())
                 _add_tip(tip, "[L-Click] Travel");
@@ -1141,7 +1141,7 @@ bool tile_dungeon_tip(const coord_def &gc, string &tip)
         if (o == NON_ITEM)
         {
             // if on stairs, travel them
-            const dungeon_feature_type feat = grd(gc);
+            const dungeon_feature_type feat = env.grid(gc);
             if (feat_stair_direction(feat) == CMD_GO_DOWNSTAIRS
                 || feat_stair_direction(feat) == CMD_GO_UPSTAIRS)
             {
index dde0b50..1b3d042 100644 (file)
@@ -466,7 +466,7 @@ static tileidx_t _pick_dngn_tile_multi(vector<tileidx_t> candidates, int value)
 
 static bool _same_door_at(dungeon_feature_type feat, const coord_def &gc)
 {
-    const dungeon_feature_type door = grd(gc);
+    const dungeon_feature_type door = env.grid(gc);
 
     return door == feat
 #if TAG_MAJOR_VERSION == 34
@@ -528,27 +528,27 @@ void tile_init_flavour(const coord_def &gc, const int domino)
     else
         env.tile_flv(gc).wall = pick_dngn_tile(env.tile_flv(gc).wall, rand2);
 
-    if (feat_is_stone_stair(grd(gc)) && player_in_branch(BRANCH_SHOALS))
+    if (feat_is_stone_stair(env.grid(gc)) && player_in_branch(BRANCH_SHOALS))
     {
-        const bool up = feat_stair_direction(grd(gc)) == CMD_GO_UPSTAIRS;
+        const bool up = feat_stair_direction(env.grid(gc)) == CMD_GO_UPSTAIRS;
         env.tile_flv(gc).feat = up ? TILE_DNGN_SHOALS_STAIRS_UP
                                    : TILE_DNGN_SHOALS_STAIRS_DOWN;
     }
 
-    if (feat_is_escape_hatch(grd(gc)) && player_in_branch(BRANCH_TOMB))
+    if (feat_is_escape_hatch(env.grid(gc)) && player_in_branch(BRANCH_TOMB))
     {
-        const bool up = feat_stair_direction(grd(gc)) == CMD_GO_UPSTAIRS;
+        const bool up = feat_stair_direction(env.grid(gc)) == CMD_GO_UPSTAIRS;
         env.tile_flv(gc).feat = up ? TILE_DNGN_ONE_WAY_STAIRS_UP
                                    : TILE_DNGN_ONE_WAY_STAIRS_DOWN;
     }
 
-    if (feat_is_door(grd(gc)))
+    if (feat_is_door(env.grid(gc)))
     {
         // Check for gates.
-        bool door_left  = _same_door_at(grd(gc), coord_def(gc.x - 1, gc.y));
-        bool door_right = _same_door_at(grd(gc), coord_def(gc.x + 1, gc.y));
-        bool door_up    = _same_door_at(grd(gc), coord_def(gc.x, gc.y - 1));
-        bool door_down  = _same_door_at(grd(gc), coord_def(gc.x, gc.y + 1));
+        bool door_left  = _same_door_at(env.grid(gc), coord_def(gc.x - 1, gc.y));
+        bool door_right = _same_door_at(env.grid(gc), coord_def(gc.x + 1, gc.y));
+        bool door_up    = _same_door_at(env.grid(gc), coord_def(gc.x, gc.y - 1));
+        bool door_down  = _same_door_at(env.grid(gc), coord_def(gc.x, gc.y + 1));
 
         if (door_left || door_right || door_up || door_down)
         {
@@ -602,7 +602,7 @@ static bool _adjacent_target(dungeon_feature_type target, int x, int y)
     {
         if (!map_bounds(*ai))
             continue;
-        if (grd(*ai) == target)
+        if (env.grid(*ai) == target)
             return true;
     }
 
@@ -615,15 +615,15 @@ void tile_floor_halo(dungeon_feature_type target, tileidx_t tile)
     {
         for (int y = 0; y < GYM; y++)
         {
-            if (!feat_has_dry_floor(grd[x][y]))
+            if (!feat_has_dry_floor(env.grid[x][y]))
                 continue;
             if (!_adjacent_target(target, x, y))
                 continue;
 
-            bool l_flr = (x > 0 && feat_has_dry_floor(grd[x-1][y]));
-            bool r_flr = (x < GXM - 1 && feat_has_dry_floor(grd[x+1][y]));
-            bool u_flr = (y > 0 && feat_has_dry_floor(grd[x][y-1]));
-            bool d_flr = (y < GYM - 1 && feat_has_dry_floor(grd[x][y+1]));
+            bool l_flr = (x > 0 && feat_has_dry_floor(env.grid[x-1][y]));
+            bool r_flr = (x < GXM - 1 && feat_has_dry_floor(env.grid[x+1][y]));
+            bool u_flr = (y > 0 && feat_has_dry_floor(env.grid[x][y-1]));
+            bool d_flr = (y < GYM - 1 && feat_has_dry_floor(env.grid[x][y+1]));
 
             bool l_target = _adjacent_target(target, x-1, y);
             bool r_target = _adjacent_target(target, x+1, y);
index 0a2b476..321e657 100644 (file)
@@ -332,8 +332,8 @@ static void _jiyva_effects(int /*time_delta*/)
             {
                 newpos = random_in_bounds();
             }
-            while (grd(newpos) != DNGN_FLOOR
-                       && grd(newpos) != DNGN_SHALLOW_WATER
+            while (env.grid(newpos) != DNGN_FLOOR
+                       && env.grid(newpos) != DNGN_SHALLOW_WATER
                    || monster_at(newpos)
                    || cloud_at(newpos)
                    || testbits(env.pgrid(newpos), FPROP_NO_JIYVA));
@@ -573,7 +573,7 @@ static void _catchup_monster_move(monster* mon, int moves)
             break;
 
         const coord_def next(pos + inc);
-        const dungeon_feature_type feat = grd(next);
+        const dungeon_feature_type feat = env.grid(next);
         if (feat_is_solid(feat)
             || monster_at(next)
             || !monster_habitable_grid(mon, feat))
@@ -1115,7 +1115,7 @@ void timeout_terrain_changes(int duration, bool force)
             marker->duration -= duration;
 
         if (marker->change_type == TERRAIN_CHANGE_DOOR_SEAL
-            && !feat_is_sealed(grd(marker->pos)))
+            && !feat_is_sealed(env.grid(marker->pos)))
         {
             // TODO: could this be done inside `revert_terrain_change`? The
             // two things to test are corrupting sealed doors, and destroying
@@ -1170,7 +1170,7 @@ void setup_environment_effects()
             if (!in_bounds(x, y))
                 continue;
 
-            const int grid = grd[x][y];
+            const int grid = env.grid[x][y];
             if (grid == DNGN_LAVA
                     || (grid == DNGN_SHALLOW_WATER
                         && player_in_branch(BRANCH_SWAMP)))