summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-16 11:35:18 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-16 12:19:59 +0100
commit94efa11e1613a3328378a2e1f9831f144490d434 (patch)
tree251c872158ffa4be53f8c0a0b52007b033d7820b
parent975e3a88520ca52bd5f8fcfb8ecda505d823a561 (diff)
downloadcrawl-ref-94efa11e1613a3328378a2e1f9831f144490d434.tar.gz
crawl-ref-94efa11e1613a3328378a2e1f9831f144490d434.zip
Fix information leakage in detect creatures.
Also fix tiles giving more information than console version. There's now mons_detected_base, which assigns a base monster type to every monster type based on the default displayed glyph. It just takes the first entry for a given glyph based on the mon-data.h order, so this may need tweaking in some cases.
-rw-r--r--crawl-ref/source/externs.h6
-rw-r--r--crawl-ref/source/mon-util.cc11
-rw-r--r--crawl-ref/source/mon-util.h1
-rw-r--r--crawl-ref/source/show.cc4
-rw-r--r--crawl-ref/source/show.h2
-rw-r--r--crawl-ref/source/spells2.cc2
-rw-r--r--crawl-ref/source/tilepick.cc2
7 files changed, 21 insertions, 7 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index e7ec27bf64..ac43447fe8 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -720,10 +720,12 @@ struct mon_display
monster_type type;
unsigned glyph;
unsigned colour;
+ monster_type detected; // What a monster of type "type" is detected as.
mon_display(monster_type m = MONS_NO_MONSTER,
- unsigned gly = 0,
- unsigned col = 0) : type(m), glyph(gly), colour(col) { }
+ unsigned gly = 0, unsigned col = 0,
+ monster_type d = MONS_NO_MONSTER)
+ : type(m), glyph(gly), colour(col), detected(d) { }
};
#include "msvc.h"
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 3d07524355..dc953f4305 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -215,6 +215,8 @@ void init_monsters()
void init_monster_symbols()
{
+ std::map<unsigned, monster_type> base_mons;
+ std::map<unsigned, monster_type>::iterator it;
for (int i = 0; i < NUM_MONSTERS; ++i)
{
mon_display &md = monster_symbols[i];
@@ -223,6 +225,10 @@ void init_monster_symbols()
{
md.glyph = me->showchar;
md.colour = me->colour;
+ it = base_mons.find(md.glyph);
+ if (it == base_mons.end() || it->first == MONS_PROGRAM_BUG)
+ base_mons[md.glyph] = static_cast<monster_type>(i);
+ md.detected = base_mons[md.glyph];
}
}
@@ -697,6 +703,11 @@ monster_type mons_genus(int mc)
return (smc->genus);
}
+monster_type mons_detected_base(monster_type mc)
+{
+ return (monster_symbols[mc].detected);
+}
+
monster_type draco_subspecies(const monsters *mon)
{
ASSERT(mons_genus(mon->type) == MONS_DRACONIAN);
diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h
index df57a774d7..aab07da8c6 100644
--- a/crawl-ref/source/mon-util.h
+++ b/crawl-ref/source/mon-util.h
@@ -636,6 +636,7 @@ bool mons_eats_corpses(const monsters *mon);
bool mons_eats_food(const monsters *mon);
bool mons_has_lifeforce(const monsters *mon);
monster_type mons_genus(int mc);
+monster_type mons_detected_base(monster_type mt);
monster_type mons_species(int mc);
bool mons_looks_stabbable(const monsters *m);
diff --git a/crawl-ref/source/show.cc b/crawl-ref/source/show.cc
index 13f01093c2..84c9e26640 100644
--- a/crawl-ref/source/show.cc
+++ b/crawl-ref/source/show.cc
@@ -28,8 +28,8 @@ show_type::show_type()
feat = (dungeon_feature_type) -1;
}
-show_type::show_type(const monsters* m)
- : cls(SH_MONSTER), mons(m->type), colour(0) {}
+show_type::show_type(monster_type montype)
+ : cls(SH_MONSTER), mons(montype), colour(0) {}
show_type::show_type(dungeon_feature_type f)
: cls(SH_FEATURE), feat(f), colour(0) {}
diff --git a/crawl-ref/source/show.h b/crawl-ref/source/show.h
index f21e24ece8..be71529485 100644
--- a/crawl-ref/source/show.h
+++ b/crawl-ref/source/show.h
@@ -50,7 +50,7 @@ struct show_type
show_type(dungeon_feature_type f);
show_type(const item_def &item);
show_type(show_item_type itemtype);
- show_type(const monsters* mons);
+ show_type(monster_type montype);
operator bool() const { return (cls != SH_NOTHING); }
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index 21e67164f8..fca185bf16 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -170,7 +170,7 @@ static bool _mark_detected_creature(coord_def where, const monsters *mon,
where = place;
}
- set_map_knowledge_obj(where, show_type(mon));
+ set_map_knowledge_obj(where, show_type(mons_detected_base(mon->type)));
set_map_knowledge_detected_mons(where);
#ifdef USE_TILE
diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc
index 4454eaf970..0e9de2c776 100644
--- a/crawl-ref/source/tilepick.cc
+++ b/crawl-ref/source/tilepick.cc
@@ -123,7 +123,7 @@ int tileidx_monster_base(const monsters *mon, bool detected)
// Show only base class for detected monsters.
if (detected)
- type = mons_genus(type);
+ type = mons_detected_base(mon->type);
switch (type)
{