Do not load Markov name generator if a CFG generator could be loaded (#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.
This commit is contained in:
parent
ae46637a04
commit
f70a5f6b3f
2 changed files with 3 additions and 1 deletions
|
@ -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';
|
||||
|
|
|
@ -48,7 +48,8 @@ private:
|
|||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue