summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/menu.cc
diff options
context:
space:
mode:
authorennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2009-03-31 03:08:39 +0000
committerennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2009-03-31 03:08:39 +0000
commit4f02417442109656263366ffcefd68231a0da7e9 (patch)
treebea44bde38ee94b163405ea82752d1c7e6202fa7 /crawl-ref/source/menu.cc
parent0425b58d7af48bde6dc27be5f700ede2c635923c (diff)
downloadcrawl-ref-4f02417442109656263366ffcefd68231a0da7e9.tar.gz
crawl-ref-4f02417442109656263366ffcefd68231a0da7e9.zip
[2722438] Fixing crash when viewing shop contents. shop_item* was being blindly casted to monsters*, which didn't play well with a non-existent virtual function table. Fixed by creating a ShopItemEntry and a MonstersMenuEntry class to differentiate the meaning of MenuEntry::data and to avoid crashes in the future by having MenuEntry::get_tiles() be a no-op.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9572 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/menu.cc')
-rw-r--r--crawl-ref/source/menu.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index c452cf7973..67af41fd61 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -685,10 +685,21 @@ void Menu::select_items(int key, int qty)
cgotoxy( x, y );
}
+MonsterMenuEntry::MonsterMenuEntry(const std::string &str, const monsters* mon, int hotkey) :
+ MenuEntry(str, MEL_ITEM, 1, hotkey)
+{
+ data = (void*)mon;
+ quantity = 1;
+}
+
#ifdef USE_TILE
bool MenuEntry::get_tiles(std::vector<tile_def>& tileset) const
{
- // Is this a monster?
+ return false;
+}
+
+bool MonsterMenuEntry::get_tiles(std::vector<tile_def>& tileset) const
+{
monsters *m = (monsters*)(data);
if (!m)
return (false);