From d813da0afb4ebeea2c25dbdae36060eee5424d45 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Mon, 1 Jun 2009 15:34:21 +0000 Subject: Apply r9873 to trunk. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9874 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/tilereg.cc | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'crawl-ref/source/tilereg.cc') diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc index 007f16c99c..3bb15874ae 100644 --- a/crawl-ref/source/tilereg.cc +++ b/crawl-ref/source/tilereg.cc @@ -17,6 +17,7 @@ REVISION("$Rev$"); #include "itemname.h" #include "it_use2.h" #include "item_use.h" +#include "items.h" #include "message.h" #include "misc.h" #include "menu.h" @@ -1315,21 +1316,24 @@ void InventoryRegion::render() const coord_def min_pos(sx, sy - dy); const coord_def max_pos(ex, ey); - std::string desc; - if (floor) + std::string desc = ""; + if (floor && is_valid_item(mitm[idx])) desc = mitm[idx].name(DESC_PLAIN); - else + else if (!floor && is_valid_item(you.inv[idx])) desc = you.inv[idx].name(DESC_INVENTORY_EQUIP); - m_tag_font->render_string(x, y, desc.c_str(), - min_pos, max_pos, WHITE, false, 200); + if (!desc.empty()) + { + m_tag_font->render_string(x, y, desc.c_str(), + min_pos, max_pos, WHITE, false, 200); + } } } void InventoryRegion::add_quad_char(char c, int x, int y, int ofs_x, int ofs_y) { int num = c - '0'; - assert(num >=0 && num <= 9); + assert(num >= 0 && num <= 9); int idx = TILE_NUM0 + num; m_buf_main.add(idx, x, y, ofs_x, ofs_y, false); @@ -1626,6 +1630,9 @@ bool InventoryRegion::update_tip_text(std::string& tip) { const item_def &item = mitm[idx]; + if (!is_valid_item(item)) + return (false); + tip = ""; if (m_items[item_idx].key) { @@ -1663,6 +1670,9 @@ bool InventoryRegion::update_tip_text(std::string& tip) else { const item_def &item = you.inv[idx]; + if (!is_valid_item(item)) + return (false); + tip = item.name(DESC_INVENTORY_EQUIP); if (!display_actions) @@ -1860,6 +1870,9 @@ bool InventoryRegion::update_alt_text(std::string &alt) else item = &you.inv[idx]; + if (!is_valid_item(*item)) + return (false); + describe_info inf; get_item_desc(*item, inf, true); -- cgit v1.2.3-54-g00ecf