From 717a8ea169d759c361f97cab0bfe0daeb6762691 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 15 Aug 2014 00:26:00 -0400 Subject: 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 --- crawl-ref/source/wiz-dump.cc | 20 ++++++++++++++------ 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 &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(); -- cgit v1.2.3-54-g00ecf