From 57f3e71ae59d5e4830bdf787d9f2d5e9d5fe8fc8 Mon Sep 17 00:00:00 2001 From: dolorous Date: Thu, 25 Sep 2008 17:30:31 +0000 Subject: In ouch(), use NON_MONSTER instead of 0 as the index for non-monster attacks, so as to avoid overlap with the first monster on the level. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6985 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/hiscores.cc | 88 ++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 48 deletions(-) (limited to 'crawl-ref/source/hiscores.cc') diff --git a/crawl-ref/source/hiscores.cc b/crawl-ref/source/hiscores.cc index 01babe6070..0adefdc5b0 100644 --- a/crawl-ref/source/hiscores.cc +++ b/crawl-ref/source/hiscores.cc @@ -777,69 +777,61 @@ void scorefile_entry::init_death_cause(int dam, int dsrc, // for death by monster if ((death_type == KILLED_BY_MONSTER || death_type == KILLED_BY_BEAM) - && death_source >= 0 && death_source < MAX_MONSTERS) + && !invalid_monster_index(death_source)) { const monsters *monster = &menv[death_source]; - if (monster->type >= 0 && monster->type < NUM_MONSTERS) + death_source = monster->type; + mon_num = monster->base_monster; + + // Previously the weapon was only used for dancing weapons, + // but now we pass it in as a string through the scorefile + // entry to be appended in hiscores_format_single in long or + // medium scorefile formats. + if (death_type == KILLED_BY_MONSTER + && monster->inv[MSLOT_WEAPON] != NON_ITEM) { - death_source = monster->type; - mon_num = monster->base_monster; - - // Previously the weapon was only used for dancing weapons, - // but now we pass it in as a string through the scorefile - // entry to be appended in hiscores_format_single in long or - // medium scorefile formats. - if (death_type == KILLED_BY_MONSTER - && monster->inv[MSLOT_WEAPON] != NON_ITEM) + // [ds] The highscore entry may be constructed while the player + // is alive (for notes), so make sure we don't reveal info we + // shouldn't. + if (you.hp <= 0) { - // [ds] The highscore entry may be constructed while the player - // is alive (for notes), so make sure we don't reveal info we - // shouldn't. - if (you.hp <= 0) - { #if HISCORE_WEAPON_DETAIL - set_ident_flags( mitm[monster->inv[MSLOT_WEAPON]], - ISFLAG_IDENT_MASK ); + set_ident_flags( mitm[monster->inv[MSLOT_WEAPON]], + ISFLAG_IDENT_MASK ); #else - // changing this to ignore the pluses to keep it short - unset_ident_flags( mitm[monster->inv[MSLOT_WEAPON]], - ISFLAG_IDENT_MASK ); + // changing this to ignore the pluses to keep it short + unset_ident_flags( mitm[monster->inv[MSLOT_WEAPON]], + ISFLAG_IDENT_MASK ); - set_ident_flags( mitm[monster->inv[MSLOT_WEAPON]], - ISFLAG_KNOW_TYPE ); + set_ident_flags( mitm[monster->inv[MSLOT_WEAPON]], + ISFLAG_KNOW_TYPE ); - // clear "runed" description text to make shorter yet - set_equip_desc( mitm[monster->inv[MSLOT_WEAPON]], 0 ); + // clear "runed" description text to make shorter yet + set_equip_desc( mitm[monster->inv[MSLOT_WEAPON]], 0 ); #endif - } - - // Setting this is redundant for dancing weapons, however - // we do care about the above indentification. -- bwr - if (monster->type != MONS_DANCING_WEAPON) - auxkilldata = mitm[monster->inv[MSLOT_WEAPON]].name(DESC_NOCAP_A); } - const bool death = you.hp <= 0; + // Setting this is redundant for dancing weapons, however + // we do care about the above indentification. -- bwr + if (monster->type != MONS_DANCING_WEAPON) + auxkilldata = mitm[monster->inv[MSLOT_WEAPON]].name(DESC_NOCAP_A); + } - death_source_name = monster->name(DESC_NOCAP_A, death); - if (monster->has_base_name()) - death_source_name += - ", " + monster->base_name(DESC_NOCAP_A, death); + const bool death = you.hp <= 0; - if (monster->has_ench(ENCH_SHAPESHIFTER)) - { - death_source_name += " (shapeshifter)"; - } - else if (monster->has_ench(ENCH_GLOWING_SHAPESHIFTER)) - { - death_source_name += " (glowing shapeshifter)"; - } - } + death_source_name = monster->name(DESC_NOCAP_A, death); + if (monster->has_base_name()) + death_source_name += + ", " + monster->base_name(DESC_NOCAP_A, death); + + if (monster->has_ench(ENCH_SHAPESHIFTER)) + death_source_name += " (shapeshifter)"; + else if (monster->has_ench(ENCH_GLOWING_SHAPESHIFTER)) + death_source_name += " (glowing shapeshifter)"; } else { - death_source = death_source; mon_num = 0; death_source_name[0] = 0; } @@ -867,7 +859,7 @@ void scorefile_entry::reset() best_skill = 0; best_skill_lvl = 0; death_type = KILLED_BY_SOMETHING; - death_source = 0; + death_source = NON_MONSTER; mon_num = 0; death_source_name[0] = 0; auxkilldata[0] = 0; @@ -1136,7 +1128,7 @@ std::string scorefile_entry::death_source_desc() const return (""); // XXX no longer handles mons_num correctly! FIXME - return (!death_source_name.empty()? + return (!death_source_name.empty() ? death_source_name : mons_type_name(death_source, DESC_NOCAP_A)); } -- cgit v1.2.3-54-g00ecf