From 4e5b040d9db0e4dee576149c53fba070372b51c2 Mon Sep 17 00:00:00 2001 From: Haru Date: Tue, 2 Aug 2016 01:35:41 +0200 Subject: Added option to make plugin-defined battle config entries optional When a setting optional, no warning is issued on the console when said setting is not found in the config Signed-off-by: Haru --- src/common/HPM.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/common/HPM.c') diff --git a/src/common/HPM.c b/src/common/HPM.c index 17dc4408e..a134a4822 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -407,7 +407,7 @@ bool hpm_add_arg(unsigned int pluginID, char *name, bool has_param, CmdlineExecF * @retval true if the listener was added successfully. * @retval false in case of error. */ -bool hplugins_addconf(unsigned int pluginID, enum HPluginConfType type, char *name, void (*parse_func) (const char *key, const char *val), int (*return_func) (const char *key)) +bool hplugins_addconf(unsigned int pluginID, enum HPluginConfType type, char *name, void (*parse_func) (const char *key, const char *val), int (*return_func) (const char *key), bool required) { struct HPConfListenStorage *conf; int i; @@ -442,6 +442,7 @@ bool hplugins_addconf(unsigned int pluginID, enum HPluginConfType type, char *na safestrncpy(conf->key, name, HPM_ADDCONF_LENGTH); conf->parse_func = parse_func; conf->return_func = return_func; + conf->required = required; return true; } @@ -879,7 +880,7 @@ bool hplugins_parse_battle_conf(const struct config_t *config, const char *filen const struct HPConfListenStorage *entry = &VECTOR_INDEX(HPM->config_listeners[HPCT_BATTLE], i); const char *config_name = entry->key; if ((setting = libconfig->lookup(config, config_name)) == NULL) { - if (!imported) { + if (!imported && entry->required) { ShowWarning("Missing configuration '%s' in file %s!\n", config_name, filename); retval = false; } -- cgit v1.2.3-70-g09d2