summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan O'Rear <stefanor@cox.net>2009-12-30 03:27:21 -0800
committerStefan O'Rear <stefanor@cox.net>2009-12-30 03:27:57 -0800
commit74c535b701b7642b74b45934e78cadd7ab67a0e4 (patch)
treed80cb308cfc2ccc45a9e7b47f085a0abe24369c0
parenta144abbba078cf5ec99f570f7b81da564577636a (diff)
downloadcrawl-ref-74c535b701b7642b74b45934e78cadd7ab67a0e4.tar.gz
crawl-ref-74c535b701b7642b74b45934e78cadd7ab67a0e4.zip
Ignore obscured items in the UI
I probably missed a few spots.
-rw-r--r--crawl-ref/source/directn.cc14
-rw-r--r--crawl-ref/source/food.cc12
-rw-r--r--crawl-ref/source/items.cc4
-rw-r--r--crawl-ref/source/l_item.cc2
-rw-r--r--crawl-ref/source/mon-act.cc9
-rw-r--r--crawl-ref/source/ouch.cc4
-rw-r--r--crawl-ref/source/player.cc11
-rw-r--r--crawl-ref/source/player.h1
-rw-r--r--crawl-ref/source/religion.cc7
-rw-r--r--crawl-ref/source/show.cc12
-rw-r--r--crawl-ref/source/showsymb.cc2
-rw-r--r--crawl-ref/source/spells4.cc4
-rw-r--r--crawl-ref/source/stash.cc8
-rw-r--r--crawl-ref/source/stuff.cc4
-rw-r--r--crawl-ref/source/stuff.h2
-rw-r--r--crawl-ref/source/tilepick.cc4
-rw-r--r--crawl-ref/source/tilereg.cc2
-rw-r--r--crawl-ref/source/tilesdl.cc4
-rw-r--r--crawl-ref/source/travel.cc4
-rw-r--r--crawl-ref/source/tutorial.cc4
20 files changed, 68 insertions, 46 deletions
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index 047dcd3974..58aac3b22a 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -523,7 +523,7 @@ void full_describe_view()
if (unknown_mimic) // It'll be on top.
list_items.push_back(get_mimic_item(mon));
- const int oid = igrd(*ri);
+ const int oid = you.visible_igrd(*ri);
if (oid == NON_ITEM)
continue;
@@ -1764,10 +1764,10 @@ std::string get_terse_square_desc(const coord_def &gc)
else
desc = mons.full_name(DESC_PLAIN, true);
}
- else if (igrd(gc) != NON_ITEM)
+ else if (you.visible_igrd(gc) != NON_ITEM)
{
- if (mitm[igrd(gc)].is_valid())
- desc = mitm[igrd(gc)].name(DESC_PLAIN);
+ if (mitm[you.visible_igrd(gc)].is_valid())
+ desc = mitm[you.visible_igrd(gc)].name(DESC_PLAIN);
}
else
desc = feature_description(gc, false, DESC_PLAIN, false);
@@ -1793,7 +1793,7 @@ void get_square_desc(const coord_def &c, describe_info &inf,
return;
const monsters* mons = monster_at(c);
- const int oid = igrd(c);
+ const int oid = you.visible_igrd(c);
if (mons && mons->visible_to(&you))
{
@@ -1836,7 +1836,7 @@ void full_describe_square(const coord_def &c)
return;
const monsters* mons = monster_at(c);
- const int oid = igrd(c);
+ const int oid = you.visible_igrd(c);
if (mons && mons->visible_to(&you))
{
@@ -3425,7 +3425,7 @@ static void _describe_cell(const coord_def& where, bool in_range)
cloud_described = true;
}
- int targ_item = igrd(where);
+ int targ_item = you.visible_igrd(where);
if (targ_item != NON_ITEM)
{
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index bd2db8d728..d17a4a5371 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -452,7 +452,7 @@ static bool _have_corpses_in_pack(bool remind)
bool butchery(int which_corpse)
{
- if (igrd(you.pos()) == NON_ITEM)
+ if (you.visible_igrd(you.pos()) == NON_ITEM)
{
if (!_have_corpses_in_pack(false))
mpr("There isn't anything here!");
@@ -503,7 +503,7 @@ bool butchery(int which_corpse)
int num_corpses = 0;
int corpse_id = -1;
bool prechosen = (which_corpse != -1);
- for (stack_iterator si(you.pos()); si; ++si)
+ for (stack_iterator si(you.pos(), true); si; ++si)
{
if (si->base_type == OBJ_CORPSES && si->sub_type == CORPSE_BODY)
{
@@ -577,7 +577,7 @@ bool butchery(int which_corpse)
bool did_weap_swap = false;
bool first_corpse = true;
int keyin;
- for (stack_iterator si(you.pos()); si; ++si)
+ for (stack_iterator si(you.pos(), true); si; ++si)
{
if (si->base_type != OBJ_CORPSES || si->sub_type != CORPSE_BODY)
continue;
@@ -790,7 +790,7 @@ bool eat_food(int slot)
if (result != -2) // else skip ahead to inventory
{
- if (igrd(you.pos()) != NON_ITEM)
+ if (you.visible_igrd(you.pos()) != NON_ITEM)
{
result = eat_from_floor(true);
if (result == 1)
@@ -1186,7 +1186,7 @@ int eat_from_floor(bool skip_chunks)
bool found_valid = false;
std::vector<item_def *> food_items;
- for (stack_iterator si(you.pos()); si; ++si )
+ for (stack_iterator si(you.pos(), true); si; ++si )
{
if (you.species == SP_VAMPIRE)
{
@@ -1483,7 +1483,7 @@ int prompt_eat_chunks()
// First search the stash on the floor, unless levitating.
if (you.flight_mode() != FL_LEVITATE)
{
- for (stack_iterator si(you.pos()); si; ++si)
+ for (stack_iterator si(you.pos(), true); si; ++si)
{
if (you.species == SP_VAMPIRE)
{
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index 1aaeda2dec..fe96b86d1b 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -1171,7 +1171,7 @@ void pickup()
return;
}
- int o = igrd(you.pos());
+ int o = you.visible_igrd(you.pos());
const int num_nonsquelched = _count_nonsquelched_items(o);
if (o == NON_ITEM)
@@ -2578,7 +2578,7 @@ static void _do_autopickup()
return;
}
- int o = igrd(you.pos());
+ int o = you.visible_igrd(you.pos());
std::string pickup_warning;
while (o != NON_ITEM)
diff --git a/crawl-ref/source/l_item.cc b/crawl-ref/source/l_item.cc
index e8dc23a2b1..ecd343be2a 100644
--- a/crawl-ref/source/l_item.cc
+++ b/crawl-ref/source/l_item.cc
@@ -48,7 +48,7 @@ void lua_set_exclusive_item(const item_def *item)
void lua_push_floor_items(lua_State *ls)
{
- lua_push_items(ls, igrd(you.pos()));
+ lua_push_items(ls, you.visible_igrd(you.pos()));
}
void lua_push_inv_items(lua_State *ls = NULL)
diff --git a/crawl-ref/source/mon-act.cc b/crawl-ref/source/mon-act.cc
index 18ad9a1b01..6aca56ffa8 100644
--- a/crawl-ref/source/mon-act.cc
+++ b/crawl-ref/source/mon-act.cc
@@ -2183,6 +2183,7 @@ static bool _monster_eat_item(monsters *monster, bool nearby)
bool death_ooze_ate_good = false;
bool death_ooze_ate_corpse = false;
+ // Jellies can swim, so don't check water
for (stack_iterator si(monster->pos());
si && eaten < max_eat && hps_changed < 50; ++si)
{
@@ -2466,6 +2467,14 @@ static bool _handle_pickup(monsters *monster)
if (monster->asleep() || monster->submerged())
return (false);
+ // Hack - Harpies fly over water, but we don't have a general
+ // system for monster igrd yet. Flying intelligent monsters
+ // (kenku!) would also count here.
+ dungeon_feature_type feat = grd(monster->pos());
+
+ if ((feat == DNGN_LAVA || feat == DNGN_DEEP_WATER) && !monster->flight_mode())
+ return (false);
+
const bool nearby = mons_near(monster);
int count_pickup = 0;
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc
index 34f8bc736c..2813101bbe 100644
--- a/crawl-ref/source/ouch.cc
+++ b/crawl-ref/source/ouch.cc
@@ -551,6 +551,10 @@ bool expose_items_to_element(beam_type flavour, const coord_def& where,
if (target_class == OBJ_UNASSIGNED)
return (false);
+ // Beams fly *over* water and lava.
+ if (grd(where) == DNGN_LAVA || grd(where) == DNGN_DEEP_WATER)
+ return (false);
+
for (stack_iterator si(where); si; ++si)
{
if (!si->is_valid())
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index e490908d1b..564bf18de1 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -5549,6 +5549,17 @@ bool player::can_swim() const
return (species == SP_MERFOLK && merfolk_change_is_safe(true));
}
+int player::visible_igrd(const coord_def &where) const
+{
+ if (grd(where) == DNGN_LAVA
+ || (grd(where) == DNGN_DEEP_WATER && species != SP_MERFOLK))
+ {
+ return (NON_ITEM);
+ }
+
+ return igrd(where);
+}
+
bool player::swimming() const
{
return in_water() && can_swim();
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index 1e5c58d47a..9c64409023 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -323,6 +323,7 @@ public:
bool in_water() const;
bool can_swim() const;
+ int visible_igrd(const coord_def&) const;
bool is_levitating() const;
bool cannot_speak() const;
bool invisible() const;
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 3845be27d2..80b277bc67 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -2266,7 +2266,7 @@ static bool _confirm_pray_sacrifice(god_type god)
return (false);
}
- for (stack_iterator si(you.pos()); si; ++si)
+ for (stack_iterator si(you.pos(), true); si; ++si)
{
if (_god_likes_item(god, *si)
&& (_is_risky_sacrifice(*si)
@@ -3811,7 +3811,7 @@ bool ely_destroy_weapons()
god_acting gdact;
bool success = false;
- for (stack_iterator si(you.pos()); si; ++si)
+ for (stack_iterator si(you.pos(), true); si; ++si)
{
item_def& item(*si);
if (item.base_type != OBJ_WEAPONS
@@ -4692,7 +4692,8 @@ void offer_items()
int i = igrd(you.pos());
- if (!god_likes_items(you.religion) && i != NON_ITEM)
+ if (!god_likes_items(you.religion) && i != NON_ITEM
+ && you.visible_igrd(you.pos()) != NON_ITEM)
{
simple_god_message(" doesn't care about such mundane gifts.",
you.religion);
diff --git a/crawl-ref/source/show.cc b/crawl-ref/source/show.cc
index 103d00b09d..0148d92438 100644
--- a/crawl-ref/source/show.cc
+++ b/crawl-ref/source/show.cc
@@ -224,8 +224,8 @@ void show_def::_update_item_at(const coord_def &gp, const coord_def &ep)
const monsters* m = monster_at(gp);
if (m && mons_is_unknown_mimic(m))
eitem = &get_mimic_item(m);
- else if (igrd(gp) != NON_ITEM)
- eitem = &mitm[igrd(gp)];
+ else if (you.visible_igrd(gp) != NON_ITEM)
+ eitem = &mitm[you.visible_igrd(gp)];
else
return;
@@ -235,10 +235,6 @@ void show_def::_update_item_at(const coord_def &gp, const coord_def &ep)
const dungeon_feature_type feat = grd(gp);
- if ((feat == DNGN_DEEP_WATER && you.species != SP_MERFOLK)
- || feat == DNGN_LAVA)
- return;
-
if (Options.feature_item_brand && is_critical_feature(feat))
ecol |= COLFLAG_FEATURE_ITEM;
else if (Options.trap_item_brand && feat_is_trap(feat))
@@ -251,7 +247,7 @@ void show_def::_update_item_at(const coord_def &gp, const coord_def &ep)
ecol = _feat_colour(gp, feat);
// monster(mimic)-owned items have link = NON_ITEM+1+midx
- if (eitem->link > NON_ITEM && igrd(gp) != NON_ITEM)
+ if (eitem->link > NON_ITEM && you.visible_igrd(gp) != NON_ITEM)
ecol |= COLFLAG_ITEM_HEAP;
else if (eitem->link < NON_ITEM && !crawl_state.arena)
ecol |= COLFLAG_ITEM_HEAP;
@@ -260,7 +256,7 @@ void show_def::_update_item_at(const coord_def &gp, const coord_def &ep)
}
#ifdef USE_TILE
- int idx = igrd(gp);
+ int idx = you.visible_igrd(gp);
if (idx != NON_ITEM)
{
if (feat_is_stair(feat))
diff --git a/crawl-ref/source/showsymb.cc b/crawl-ref/source/showsymb.cc
index 6f3c77fea6..6019065d7e 100644
--- a/crawl-ref/source/showsymb.cc
+++ b/crawl-ref/source/showsymb.cc
@@ -100,7 +100,7 @@ static int _get_mons_colour(const monsters *mons)
col |= COLFLAG_FEATURE_ITEM;
}
else if (Options.heap_brand != CHATTR_NORMAL
- && igrd(mons->pos()) != NON_ITEM
+ && you.visible_igrd(mons->pos()) != NON_ITEM
&& !crawl_state.arena)
{
col |= COLFLAG_ITEM_HEAP;
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index 03dbf76e72..d4c78afc48 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -1182,7 +1182,7 @@ void cast_fulsome_distillation(int /*pow*/)
int corpse = -1;
// Search items at the player's location for corpses.
- for (stack_iterator si(you.pos()); si; ++si)
+ for (stack_iterator si(you.pos(), true); si; ++si)
{
if (si->base_type == OBJ_CORPSES && si->sub_type == CORPSE_BODY)
{
@@ -1476,7 +1476,7 @@ bool cast_fragmentation(int pow, const dist& spd)
goto all_done;
}
- for (stack_iterator si(spd.target); si; ++si)
+ for (stack_iterator si(spd.target, true); si; ++si)
{
if (si->base_type == OBJ_CORPSES)
{
diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc
index 147dbc67d8..f40dc4005e 100644
--- a/crawl-ref/source/stash.cc
+++ b/crawl-ref/source/stash.cc
@@ -326,7 +326,7 @@ static bool _grid_has_mimic_item(const coord_def& pos)
static bool _grid_has_perceived_item(const coord_def& pos)
{
- return (igrd(pos) != NON_ITEM || _grid_has_mimic_item(pos));
+ return (you.visible_igrd(pos) != NON_ITEM || _grid_has_mimic_item(pos));
}
static bool _grid_has_perceived_multiple_items(const coord_def& pos)
@@ -336,7 +336,7 @@ static bool _grid_has_perceived_multiple_items(const coord_def& pos)
if (_grid_has_mimic_item(pos))
++count;
- for (stack_iterator si(pos); si && count < 2; ++si)
+ for (stack_iterator si(pos, true); si && count < 2; ++si)
++count;
return (count > 1);
@@ -361,7 +361,7 @@ void Stash::update()
items.clear();
// Now, grab all items on that square and fill our vector
- for (stack_iterator si(p); si; ++si)
+ for (stack_iterator si(p, true); si; ++si)
if (!is_filtered(*si))
add_item(*si);
@@ -384,7 +384,7 @@ void Stash::update()
pitem = &get_mimic_item(monster_at(p));
else
{
- pitem = &mitm[igrd(p)];
+ pitem = &mitm[you.visible_igrd(p)];
tutorial_first_item(*pitem);
}
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index ccff7125aa..9094d9b214 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -65,9 +65,9 @@
#include "tutorial.h"
#include "view.h"
-stack_iterator::stack_iterator(const coord_def& pos)
+stack_iterator::stack_iterator(const coord_def& pos, bool accesible)
{
- cur_link = igrd(pos);
+ cur_link = accesible ? you.visible_igrd(pos) : igrd(pos);
if ( cur_link != NON_ITEM )
next_link = mitm[cur_link].link;
else
diff --git a/crawl-ref/source/stuff.h b/crawl-ref/source/stuff.h
index 684df4175d..8d0e288db6 100644
--- a/crawl-ref/source/stuff.h
+++ b/crawl-ref/source/stuff.h
@@ -24,7 +24,7 @@ class stack_iterator : public std::iterator<std::forward_iterator_tag,
item_def>
{
public:
- explicit stack_iterator( const coord_def& pos );
+ explicit stack_iterator( const coord_def& pos, bool accessible = false );
explicit stack_iterator( int start_link );
operator bool() const;
diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc
index 723dbc0d00..8881bc867b 100644
--- a/crawl-ref/source/tilepick.cc
+++ b/crawl-ref/source/tilepick.cc
@@ -4795,7 +4795,7 @@ void tile_place_monster(int gx, int gy, int idx, bool foreground, bool detected)
if (!mons_is_known_mimic(mon))
{
// If necessary add item brand.
- if (igrd(gc) != NON_ITEM)
+ if (you.visible_igrd(gc) != NON_ITEM)
{
if (foreground)
t |= TILE_FLAG_S_UNDER;
@@ -4815,7 +4815,7 @@ void tile_place_monster(int gx, int gy, int idx, bool foreground, bool detected)
else if (menv[idx].holiness() == MH_PLANT)
{
// If necessary add item brand.
- if (igrd(gc) != NON_ITEM)
+ if (you.visible_igrd(gc) != NON_ITEM)
{
if (foreground)
t |= TILE_FLAG_S_UNDER;
diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc
index 4490e3a59a..65383f46b4 100644
--- a/crawl-ref/source/tilereg.cc
+++ b/crawl-ref/source/tilereg.cc
@@ -1745,7 +1745,7 @@ bool DungeonRegion::update_tip_text(std::string& tip)
tip += get_class_abbrev(you.char_class);
tip += ")";
- if (igrd(m_cursor[CURSOR_MOUSE]) != NON_ITEM)
+ if (you.visible_igrd(m_cursor[CURSOR_MOUSE]) != NON_ITEM)
tip += "\n[L-Click] Pick up items (g)";
const dungeon_feature_type feat = grd(m_cursor[CURSOR_MOUSE]);
diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc
index 50dbb83f58..62ac431970 100644
--- a/crawl-ref/source/tilesdl.cc
+++ b/crawl-ref/source/tilesdl.cc
@@ -1550,7 +1550,7 @@ void TilesFramework::update_inventory()
memset(inv_shown, 0, sizeof(inv_shown));
int num_ground = 0;
- for (int i = igrd(you.pos()); i != NON_ITEM; i = mitm[i].link)
+ for (int i = you.visible_igrd(you.pos()); i != NON_ITEM; i = mitm[i].link)
num_ground++;
// If the inventory is full, show at least one row of the ground.
@@ -1676,7 +1676,7 @@ void TilesFramework::update_inventory()
type = (object_class_type)(find - obj_syms);
}
- for (int i = igrd(you.pos()); i != NON_ITEM; i = mitm[i].link)
+ for (int i = you.visible_igrd(you.pos()); i != NON_ITEM; i = mitm[i].link)
{
if ((int)inv.size() >= mx * my)
break;
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index 28b593d97a..296e39318a 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -550,8 +550,8 @@ inline static void _check_interesting_square(int x, int y,
ed.found_item(pos, get_mimic_item(mons));
}
- if (igrd(pos) != NON_ITEM)
- ed.found_item( pos, mitm[ igrd(pos) ] );
+ if (you.visible_igrd(pos) != NON_ITEM)
+ ed.found_item( pos, mitm[ you.visible_igrd(pos) ] );
}
ed.found_feature( pos, grd(pos) );
diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc
index 69aeb760a2..e0e7d53b72 100644
--- a/crawl-ref/source/tutorial.cc
+++ b/crawl-ref/source/tutorial.cc
@@ -1887,7 +1887,7 @@ void learned_something_new(tutorial_event_type seen_what, coord_def gc)
text << "Ah, a corpse!";
else
{
- int i = igrd(gc);
+ int i = you.visible_igrd(gc);
while (i != NON_ITEM)
{
if (mitm[i].base_type == OBJ_CORPSES)
@@ -4680,7 +4680,7 @@ void tutorial_observe_cell(const coord_def& gc)
else if (grd(gc) == DNGN_ENTER_PORTAL_VAULT)
learned_something_new(TUT_SEEN_PORTAL, gc);
- const int it = igrd(gc);
+ const int it = you.visible_igrd(gc);
if (it != NON_ITEM)
{
const item_def& item(mitm[it]);