diff options
author | Neil Moore <neil@s-z.org> | 2012-04-21 12:54:23 -0400 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2012-04-21 13:07:55 -0400 |
commit | 198c943b116acfd9a1997c48073f29e520e7c0c4 (patch) | |
tree | 652ce4619a8a9ad809bff4700b8f36753f9a1c93 /crawl-ref/source/l_item.cc | |
parent | cdc7f72a3fc6281ece8f509c4616639f205ef5d1 (diff) | |
download | crawl-ref-198c943b116acfd9a1997c48073f29e520e7c0c4.tar.gz crawl-ref-198c943b116acfd9a1997c48073f29e520e7c0c4.zip |
Avoid info leak, get_items_at -> get_item_at.
Returns an item or nil. This avoids leaking information about items
at the bottom of an unvisited pile. For the same reason, do not return
anything from an invisible pile (e.g. one at the bottom of deep water
for non-swimmers).
It would be nice to use the stash to return an entire visited pile,
but there doesn't seem to be a way to get a semi-permanent pointer
to an item_def in the stash.
Diffstat (limited to 'crawl-ref/source/l_item.cc')
-rw-r--r-- | crawl-ref/source/l_item.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/crawl-ref/source/l_item.cc b/crawl-ref/source/l_item.cc index 2a0086bd50..dff7b3dd4b 100644 --- a/crawl-ref/source/l_item.cc +++ b/crawl-ref/source/l_item.cc @@ -985,14 +985,16 @@ static int l_item_inslot(lua_State *ls) return (1); } -static int l_item_get_items_at(lua_State *ls) +static int l_item_get_item_at(lua_State *ls) { COORDSHOW(s, 1, 2) coord_def p = player2grid(s); - if (!you.see_cell(p)) - return (0); - lua_push_floor_items(ls, env.igrid(p)); + const int item = you.visible_igrd(p); + if (you.see_cell(p) && item != NON_ITEM) + clua_push_item(ls, &mitm[item]); + else + lua_pushnil(ls); return (1); } @@ -1072,7 +1074,7 @@ static const struct luaL_reg item_lib[] = { "equipped_at", l_item_equipped_at }, { "fired_item", l_item_fired_item }, { "inslot", l_item_inslot }, - { "get_items_at", l_item_get_items_at }, + { "get_item_at", l_item_get_item_at }, { NULL, NULL }, }; |