summaryrefslogtreecommitdiff
path: root/src/common/HPM.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-08-02 01:35:41 +0200
committerHaru <haru@dotalux.com>2016-08-19 21:32:28 +0200
commit4e5b040d9db0e4dee576149c53fba070372b51c2 (patch)
treef3424b4a576ea5d44a1e1f29361d028e805d52c5 /src/common/HPM.c
parent67a84ce174851ed866b99737eec6bd0adfca6617 (diff)
downloadhercules-4e5b040d9db0e4dee576149c53fba070372b51c2.tar.gz
hercules-4e5b040d9db0e4dee576149c53fba070372b51c2.tar.bz2
hercules-4e5b040d9db0e4dee576149c53fba070372b51c2.tar.xz
hercules-4e5b040d9db0e4dee576149c53fba070372b51c2.zip
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 <haru@dotalux.com>
Diffstat (limited to 'src/common/HPM.c')
-rw-r--r--src/common/HPM.c5
1 files changed, 3 insertions, 2 deletions
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;
}