From 9e638765909b661706f206c6422843b0c75d12a8 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Wed, 18 Nov 2009 22:10:48 +0100 Subject: Remove union in show_type. show_type can now separately store feature type, item type and monster class. env.show and env.map_knowledge are guaranteed to have filled object.feat, so player terrain knowledge is available now. This is a bit of a hack. --- crawl-ref/source/show.cc | 40 +++++++++++++++++++++++++++++++++------- crawl-ref/source/show.h | 10 ++++------ 2 files changed, 37 insertions(+), 13 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/show.cc b/crawl-ref/source/show.cc index d342225d9b..ec18a5aae7 100644 --- a/crawl-ref/source/show.cc +++ b/crawl-ref/source/show.cc @@ -23,25 +23,51 @@ #include "viewmap.h" show_type::show_type() - : cls(SH_NOTHING), colour(0) + : cls(SH_NOTHING), + feat(DNGN_UNSEEN), + item(SHOW_ITEM_NONE), + mons(MONS_NO_MONSTER), + colour(0) { - // To quiet Valgrind warnings. - feat = (dungeon_feature_type) -1; } show_type::show_type(monster_type montype) - : cls(SH_MONSTER), mons(montype), colour(0) {} + : cls(SH_MONSTER), + feat(DNGN_UNSEEN), + item(SHOW_ITEM_NONE), + mons(montype), + colour(0) +{ +} show_type::show_type(dungeon_feature_type f) - : cls(SH_FEATURE), feat(f), colour(0) {} + : cls(SH_FEATURE), + feat(f), + item(SHOW_ITEM_NONE), + mons(MONS_NO_MONSTER), + colour(0) +{ +} static show_item_type _item_to_show_code(const item_def &item); show_type::show_type(const item_def &it) - : cls(SH_ITEM), item(_item_to_show_code(it)), colour(0) {} + : cls(SH_ITEM), + feat(DNGN_UNSEEN), + item(_item_to_show_code(it)), + mons(MONS_NO_MONSTER), + colour(0) +{ +} show_type::show_type(show_item_type t) - : cls(SH_ITEM), item(t), colour(0) {} + : cls(SH_ITEM), + feat(DNGN_UNSEEN), + item(t), + mons(MONS_NO_MONSTER), + colour(0) +{ +} bool show_type::operator < (const show_type &other) const { diff --git a/crawl-ref/source/show.h b/crawl-ref/source/show.h index be71529485..3f2e4cb88a 100644 --- a/crawl-ref/source/show.h +++ b/crawl-ref/source/show.h @@ -5,6 +5,7 @@ enum show_item_type { + SHOW_ITEM_NONE, SHOW_ITEM_ORB, SHOW_ITEM_WEAPON, SHOW_ITEM_ARMOUR, @@ -38,12 +39,9 @@ enum show_class struct show_type { show_class cls; - union - { - dungeon_feature_type feat; - show_item_type item; - monster_type mons; - }; + dungeon_feature_type feat; + show_item_type item; + monster_type mons; unsigned short colour; show_type(); -- cgit v1.2.3-54-g00ecf