summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/hiscores.cc
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2014-03-19 00:43:56 -0400
committerNeil Moore <neil@s-z.org>2014-03-19 00:44:15 -0400
commit3572bd17dd2691f046d3eb6e42bdccb58e47dff9 (patch)
tree4c3fbc7cba67009de1a0ed063716ae4f0645625c /crawl-ref/source/hiscores.cc
parentc6433edf40fc28bf02da3c17a004a5fedd1b6cec (diff)
downloadcrawl-ref-3572bd17dd2691f046d3eb6e42bdccb58e47dff9.tar.gz
crawl-ref-3572bd17dd2691f046d3eb6e42bdccb58e47dff9.zip
Fix bad ikiller for kraken tentacles.
Diffstat (limited to 'crawl-ref/source/hiscores.cc')
-rw-r--r--crawl-ref/source/hiscores.cc30
1 files changed, 27 insertions, 3 deletions
diff --git a/crawl-ref/source/hiscores.cc b/crawl-ref/source/hiscores.cc
index 66efff07dc..28cecd4d19 100644
--- a/crawl-ref/source/hiscores.cc
+++ b/crawl-ref/source/hiscores.cc
@@ -1136,6 +1136,31 @@ string scorefile_entry::short_kill_message() const
return msg;
}
+/**
+ * Remove from a string everything up to and including a given infix.
+ *
+ * @param[in,out] str The string to modify.
+ * @param[in] infix The infix to remove.
+ * @post If \c infix occured as a substring of <tt>str</tt>, \c str is updated
+ * by removing all characters up to and including the last character
+ * of the the first occurrence. Otherwise, \c str is unchanged.
+ * @return \c true if \c str was modified, \c false otherwise.
+ */
+static bool _strip_to(string &str, const char *infix)
+{
+ // Don't treat stripping the empty string as a change.
+ if (*infix == '\0')
+ return false;
+
+ size_t pos = str.find(infix);
+ if (pos != string::npos)
+ {
+ str.erase(0, pos + strlen(infix));
+ return true;
+ }
+ return false;
+}
+
void scorefile_entry::init_death_cause(int dam, int dsrc,
int dtype, const char *aux,
const char *dsrc_name)
@@ -1239,9 +1264,8 @@ void scorefile_entry::init_death_cause(int dam, int dsrc,
const CrawlVector& blame = mons->props["blame"].get_vector();
indirectkiller = blame[blame.size() - 1].get_string();
-
- if (indirectkiller.find(" by ") != string::npos)
- indirectkiller.erase(0, indirectkiller.find(" by ") + 4);
+ _strip_to(indirectkiller, " by ");
+ _strip_to(indirectkiller, "ed to "); // "attached to" and similar
killerpath = "";