diff options
author | Florian Diebold <flodiebold@gmail.com> | 2011-11-08 13:52:29 +0100 |
---|---|---|
committer | Florian Diebold <flodiebold@gmail.com> | 2011-11-23 19:06:47 +0100 |
commit | 6f45b76da0b15a4b77ed0d56a4feaa2002d3d185 (patch) | |
tree | 3c14f19eaaf51ce5a2f2ac0e827b191e5dcb03e0 /crawl-ref/source/kills.cc | |
parent | a9079440e36eb20841ba3b84182830033a1abb64 (diff) | |
download | crawl-ref-6f45b76da0b15a4b77ed0d56a4feaa2002d3d185.tar.gz crawl-ref-6f45b76da0b15a4b77ed0d56a4feaa2002d3d185.zip |
Allow querying the kill tracker by monster_info instead of monster.
This removes a hack I added while switching tile_place_monster to
monster_info.
Diffstat (limited to 'crawl-ref/source/kills.cc')
-rw-r--r-- | crawl-ref/source/kills.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/crawl-ref/source/kills.cc b/crawl-ref/source/kills.cc index 8dc230f7ce..b473a5ad5b 100644 --- a/crawl-ref/source/kills.cc +++ b/crawl-ref/source/kills.cc @@ -10,6 +10,7 @@ #include "describe.h" #include "mon-util.h" #include "mon-stuff.h" +#include "mon-info.h" #include "files.h" #include "ghost.h" #include "libutil.h" @@ -246,6 +247,11 @@ int KillMaster::num_kills(const monster* mon, kill_category cat) const return categorized_kills[cat].num_kills(mon); } +int KillMaster::num_kills(const monster_info& mon, kill_category cat) const +{ + return categorized_kills[cat].num_kills(mon); +} + int KillMaster::num_kills(const monster* mon) const { int total = 0; @@ -255,6 +261,15 @@ int KillMaster::num_kills(const monster* mon) const return total; } +int KillMaster::num_kills(const monster_info& mon) const +{ + int total = 0; + for (int cat = 0; cat < KC_NCATEGORIES; cat++) + total += categorized_kills[cat].num_kills(mon); + + return total; +} + /////////////////////////////////////////////////////////////////////////// bool Kills::empty() const @@ -377,6 +392,17 @@ void Kills::record_ghost_kill(const monster* mon) int Kills::num_kills(const monster* mon) const { kill_monster_desc desc(mon); + return num_kills(desc); +} + +int Kills::num_kills(const monster_info& mon) const +{ + kill_monster_desc desc(mon); + return num_kills(desc); +} + +int Kills::num_kills(kill_monster_desc desc) const +{ kill_map::const_iterator iter = kills.find(desc); int total = (iter == kills.end() ? 0 : iter->second.kills); @@ -657,6 +683,33 @@ kill_monster_desc::kill_monster_desc(const monster* mon) modifier = M_SHAPESHIFTER; } +kill_monster_desc::kill_monster_desc(const monster_info& mon) +{ + monnum = mon.type; + modifier = M_NORMAL; + switch (mon.type) + { + case MONS_ZOMBIE_LARGE: case MONS_ZOMBIE_SMALL: + modifier = M_ZOMBIE; + break; + case MONS_SKELETON_LARGE: case MONS_SKELETON_SMALL: + modifier = M_SKELETON; + break; + case MONS_SIMULACRUM_LARGE: case MONS_SIMULACRUM_SMALL: + modifier = M_SIMULACRUM; + break; + case MONS_SPECTRAL_THING: + modifier = M_SPECTRE; + break; + default: break; + } + if (modifier != M_NORMAL) + monnum = mon.base_type; + + if (mon.is(MB_SHAPESHIFTER)) + modifier = M_SHAPESHIFTER; +} + void kill_monster_desc::save(writer& outf) const { marshallShort(outf, (short) monnum); |