Skip to content

Commit

Permalink
Do not load Markov name generator if a CFG generator could be loaded (#…
Browse files Browse the repository at this point in the history
…921)

name_generator_factory::add_name_generator_from_config now only falls
back to loading a Markov-chain generator if the loading of the context-
free grammar generator fails or there is none available.
  • Loading branch information
gunchleoc authored and CelticMinstrel committed Feb 5, 2017
1 parent ae46637 commit f70a5f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/utils/name_generator_factory.cpp
Expand Up @@ -39,6 +39,7 @@ void name_generator_factory::add_name_generator_from_config(const config& config
if(config.has_attribute(cfg_name)) {
try {
name_generators_[id] = std::shared_ptr<name_generator>(new context_free_grammar_generator(config[cfg_name]));
return;
}
catch (const name_generator_invalid_exception& ex) {
lg::wml_error() << ex.what() << '\n';
Expand Down
3 changes: 2 additions & 1 deletion src/utils/name_generator_factory.hpp
Expand Up @@ -48,7 +48,8 @@ class name_generator_factory
std::map<std::string, std::shared_ptr<name_generator>> name_generators_;

/**
* Determines a name generator from WML data
* Determines a name generator from WML data. Tries first to load a context-free generator,
* then falls back to Markov.
* @param config the WML data to be parsed for name generators
* @param the prefix to look for
* @returns a name generator or nullptr if not found
Expand Down

0 comments on commit f70a5f6

Please sign in to comment.