From: <gi...@cr...> - 2012-07-30 23:08:39
|
via b63eec99caf0b940ad1307de980fd6d5e9491dff (commit) via ada134d4137d8d869c0f97e1cd4e553a2e58acc9 (commit) via 90551e86189b850caf36c73f3445c480abc79f59 (commit) from 1f7c9b4d1965058481aedfccae9fee892cafcc02 (commit) ----------------------------------------------------------------------- commit b63eec99caf0b940ad1307de980fd6d5e9491dff Author: Steve Melenchuk <sme...@gm...> Date: Mon Jul 30 17:05:06 2012 -0600 Fix crash on loading dumps of sufficiently skilled players. The skill exercise arrays would suffer integer overflow during the re-initialisation routines; this adjusts the relevant code to use longs (shudder) to avoid that issue. commit ada134d4137d8d869c0f97e1cd4e553a2e58acc9 Author: Steve Melenchuk <sme...@gm...> Date: Mon Jul 30 15:38:53 2012 -0600 Upgrade death curse message on mummy player death to actual death curse. Because, well, why not? commit 90551e86189b850caf36c73f3445c480abc79f59 Author: Frank Benkstein <fr...@be...> Date: Mon Jul 30 22:27:49 2012 +0200 Death-curse a monster that kills the player if the player is a mummy. ----------------------------------------------------------------------- Summary of changes: crawl-ref/source/hiscores.h | 1 + crawl-ref/source/ouch.cc | 32 +++++++++++++++++++++++++++++--- crawl-ref/source/skills.cc | 18 +++++++++--------- crawl-ref/source/spl-miscast.cc | 7 +++++++ 4 files changed, 46 insertions(+), 12 deletions(-) diff --git a/crawl-ref/source/hiscores.h b/crawl-ref/source/hiscores.h index aef8773..14f4896 100644 --- a/crawl-ref/source/hiscores.h +++ b/crawl-ref/source/hiscores.h @@ -155,6 +155,7 @@ public: std::string get_name() const { return name; } int get_score() const { return points; } int get_death_type() const { return death_type; } + int get_death_source() const { return death_source; } time_t get_death_time() const { return death_time; } xlog_fields get_fields() const; diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index aca97eb..a71e78e 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -64,6 +64,7 @@ #include "tutorial.h" #include "view.h" #include "shout.h" +#include "spl-miscast.h" #include "xom.h" static void _end_game(scorefile_entry &se); @@ -1437,12 +1438,37 @@ void _end_game(scorefile_entry &se) _delete_files(); + kill_method_type death_type = static_cast<kill_method_type>(se.get_death_type()); + int death_source = se.get_death_source(); + // death message - if (se.get_death_type() != KILLED_BY_LEAVING - && se.get_death_type() != KILLED_BY_QUITTING - && se.get_death_type() != KILLED_BY_WINNING) + if (death_type != KILLED_BY_LEAVING + && death_type != KILLED_BY_QUITTING + && death_type != KILLED_BY_WINNING) { mprnojoin("You die..."); // insert player name here? {dlb} + + // Mummy death curse + if (you.species == SP_MUMMY + && (death_type == KILLED_BY_MONSTER + || death_type == KILLED_BY_HEADBUTT + || death_type == KILLED_BY_BEAM + || death_type == KILLED_BY_DISINT + || death_type == KILLED_BY_SPORE + || death_type == KILLED_BY_CLOUD + || death_type == KILLED_BY_ROTTING + || death_type == KILLED_BY_REFLECTION + || death_type == KILLED_BY_ROLLING) + && !invalid_monster_index(death_source) + && menv[death_source].type != -1) + { + int pow = std::max(1, you.experience_level - 3); + mprf(MSGCH_MONSTER_SPELL, "A malignant aura surrounds %s.", + menv[death_source].name(DESC_THE).c_str()); + MiscastEffect(&menv[death_source], MHITYOU, SPTYP_NECROMANCY, + pow, random2avg(88, 3), "a mummy death curse"); + } + xom_death_message((kill_method_type) se.get_death_type()); switch (you.religion) diff --git a/crawl-ref/source/skills.cc b/crawl-ref/source/skills.cc index f9cca5b..9779cc7 100644 --- a/crawl-ref/source/skills.cc +++ b/crawl-ref/source/skills.cc @@ -490,8 +490,8 @@ void init_train() } } -static bool _cmp_rest(const std::pair<skill_type,int>& a, - const std::pair<skill_type,int>& b) +static bool _cmp_rest(const std::pair<skill_type,long>& a, + const std::pair<skill_type,long>& b) { return a.second < b.second; } @@ -507,12 +507,12 @@ static bool _cmp_rest(const std::pair<skill_type,int>& a, template <typename T, int SIZE> static void _scale_array(FixedVector<T, SIZE> &array, int scale, bool exact) { - int total = 0; + long total = 0; // First, we calculate the sum of the values to be scaled. for (int i = 0; i < NUM_SKILLS; ++i) total += array[i]; - std::vector<std::pair<skill_type,int> > rests; + std::vector<std::pair<skill_type,long> > rests; int scaled_total = 0; // All skills disabled, nothing to do. @@ -523,11 +523,11 @@ static void _scale_array(FixedVector<T, SIZE> &array, int scale, bool exact) for (int i = 0; i < NUM_SKILLS; ++i) if (array[i] > 0) { - int result = array[i] * scale; - const int rest = result % total; + long result = (long)array[i] * (long)scale; + const long rest = result % total; if (rest) - rests.push_back(std::pair<skill_type,int>(skill_type(i), rest)); - array[i] = result / total; + rests.push_back(std::pair<skill_type,long>(skill_type(i),rest)); + array[i] = (int)(result / total); scaled_total += array[i]; } @@ -539,7 +539,7 @@ static void _scale_array(FixedVector<T, SIZE> &array, int scale, bool exact) // We ensure that the percentage always add up to 100 by increasing the // training for skills which had the higher rest from the above scaling. std::sort(rests.begin(), rests.end(), _cmp_rest); - std::vector<std::pair<skill_type,int> >::iterator it = rests.begin(); + std::vector<std::pair<skill_type,long> >::iterator it = rests.begin(); while (scaled_total < scale && it != rests.end()) { ++array[it->first]; diff --git a/crawl-ref/source/spl-miscast.cc b/crawl-ref/source/spl-miscast.cc index c9925df..f376f28 100644 --- a/crawl-ref/source/spl-miscast.cc +++ b/crawl-ref/source/spl-miscast.cc @@ -185,6 +185,13 @@ void MiscastEffect::init() if (target_known && death_curse) source_known = true; } + else if (source == MHITYOU) + { + act_source = guilty = &you; + kc = KC_FRIENDLY; + kt = KILL_MISC; // don't give player XP for this + source_known = true; + } else { ASSERT(source == ZOT_TRAP_MISCAST -- Dungeon Crawl Stone Soup |