diff options
-rw-r--r-- | crawl-ref/source/initfile.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 561cbeb645..fe3d8adcb4 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -2579,7 +2579,48 @@ void game_options::read_option_line(const std::string &str, bool runscript) } else if (key == "autoinscribe") { + if (field.empty()) + { + crawl_state.add_startup_error("Autoinscirbe string is empty"); + return; + } + + const size_t first = field.find_first_of(':'); + const size_t last = field.find_last_of(':'); + if (first == std::string::npos || first != last) + { + crawl_state.add_startup_error( + make_stringf("Autoinscribe string must have exactly " + "one colon: %s\n", field.c_str())); + return; + } + + if (first == 0) + { + crawl_state.add_startup_error( + make_stringf("Autoinscribe pattern is empty: %s\n", + field.c_str())); + return; + } + + if (last == field.length() - 1) + { + crawl_state.add_startup_error( + make_stringf("Autoinscribe result is empty: %s\n", + field.c_str())); + return; + } + std::vector<std::string> thesplit = split_string(":", field); + + if (thesplit.size() != 2) + { + crawl_state.add_startup_error( + make_stringf("Error parsing autoinscribe string: %s\n", + field.c_str())); + return; + } + autoinscriptions.push_back( std::pair<text_pattern,std::string>(thesplit[0], thesplit[1])); } |