diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-08-15 00:26:00 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-08-15 00:30:19 -0400 |
commit | 717a8ea169d759c361f97cab0bfe0daeb6762691 (patch) | |
tree | 8912c562a7cfa0fc00f9721654a801af6b8c1c1d | |
parent | 2af2ae1ba4bc79dc3476399d496a8e0089204aad (diff) | |
download | crawl-ref-717a8ea169d759c361f97cab0bfe0daeb6762691.tar.gz crawl-ref-717a8ea169d759c361f97cab0bfe0daeb6762691.zip |
don't reinit skills until we see a valid skill line
otherwise, we can end up with no skills at all, which causes assertion
failures
-rw-r--r-- | crawl-ref/source/wiz-dump.cc | 20 | ||||
-rw-r--r-- | crawl-ref/source/wiz-dump.h | 4 |
2 files changed, 17 insertions, 7 deletions
diff --git a/crawl-ref/source/wiz-dump.cc b/crawl-ref/source/wiz-dump.cc index 78be75d59d..fa27bc8468 100644 --- a/crawl-ref/source/wiz-dump.cc +++ b/crawl-ref/source/wiz-dump.cc @@ -128,6 +128,12 @@ bool chardump_parser::_check_skill(const vector<string> &tokens) if (size <= 3 || tokens[1] != "Level") return false; + if (!seen_skills) + { + you.init_skills(); + seen_skills = true; + } + skill_type skill = skill_from_name(lowercase_string(tokens[3]).c_str()); double amount = atof(tokens[2].c_str()); set_skill_level(skill, amount); @@ -353,15 +359,17 @@ bool chardump_parser::_parse_from_file(const string &full_filename) if (f.eof()) return false; - you.init_skills(); - while (!f.eof()) _modify_character(f.get_line()); - init_skill_order(); - init_can_train(); - init_train(); - init_training(); + if (seen_skills) + { + init_skill_order(); + init_can_train(); + init_train(); + init_training(); + } + return true; } diff --git a/crawl-ref/source/wiz-dump.h b/crawl-ref/source/wiz-dump.h index 3016b47fed..fd406e55e0 100644 --- a/crawl-ref/source/wiz-dump.h +++ b/crawl-ref/source/wiz-dump.h @@ -8,7 +8,8 @@ class chardump_parser { public: - chardump_parser(const string &f) : filename(f), in_equipment(false) { } + chardump_parser(const string &f) + : filename(f), in_equipment(false), seen_skills(false) { } bool parse(); @@ -26,6 +27,7 @@ private: string filename; bool in_equipment; + bool seen_skills; }; void wizard_load_dump_file(); |