summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenpachi Developer <Kenpachi.Developer@gmx.de>2020-05-10 23:29:47 +0200
committerKenpachi Developer <Kenpachi.Developer@gmx.de>2020-05-12 03:45:25 +0200
commite14e4c77614afa2cacab9b5042554702da4b04fa (patch)
treeb660880f41e2bcb2bf92923d691e2ec7ef5a8100
parent41b883d4c27b21567eb2558b84ce80c43765b979 (diff)
downloadhercules-e14e4c77614afa2cacab9b5042554702da4b04fa.tar.gz
hercules-e14e4c77614afa2cacab9b5042554702da4b04fa.tar.bz2
hercules-e14e4c77614afa2cacab9b5042554702da4b04fa.tar.xz
hercules-e14e4c77614afa2cacab9b5042554702da4b04fa.zip
Read name of new map_reg_*_db tables from configuration file
-rw-r--r--conf/common/inter-server.conf3
-rw-r--r--src/map/map.c4
-rw-r--r--src/map/mapreg.h3
-rw-r--r--src/map/mapreg_sql.c39
4 files changed, 48 insertions, 1 deletions
diff --git a/conf/common/inter-server.conf b/conf/common/inter-server.conf
index 7696774d6..1bcf34e23 100644
--- a/conf/common/inter-server.conf
+++ b/conf/common/inter-server.conf
@@ -76,9 +76,10 @@ inter_configuration: {
acc_reg_str_db: "acc_reg_str_db"
char_reg_str_db: "char_reg_str_db"
char_reg_num_db: "char_reg_num_db"
-
global_acc_reg_num_db: "global_acc_reg_num_db"
global_acc_reg_str_db: "global_acc_reg_str_db"
+ map_reg_num_db: "map_reg_num_db"
+ map_reg_str_db: "map_reg_str_db"
}
pc: {
hotkey_db: "hotkey"
diff --git a/src/map/map.c b/src/map/map.c
index f66f40dfc..d9be46bfb 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -4486,6 +4486,10 @@ static bool inter_config_read_database_names(const char *filename, const struct
ShowError("inter_config_read: inter_configuration/database_names/registry was not found in %s!\n", filename);
return false;
}
+
+ if (!mapreg->config_read_registry(filename, setting, imported))
+ retval = false;
+
return retval;
}
diff --git a/src/map/mapreg.h b/src/map/mapreg.h
index b3b89e1b2..bd0e13e21 100644
--- a/src/map/mapreg.h
+++ b/src/map/mapreg.h
@@ -48,6 +48,8 @@ struct mapreg_interface {
struct eri *ers; //[Ind/Hercules]
/* */
char table[32];
+ char num_db[32]; //!< Name of SQL table which holds permanent global integer variables.
+ char str_db[32]; //!< Name of SQL table which holds permanent global string variables.
/* */
bool dirty; ///< Whether there are modified regs to be saved
/* */
@@ -63,6 +65,7 @@ struct mapreg_interface {
int (*save_timer) (int tid, int64 tick, int id, intptr_t data);
int (*destroyreg) (union DBKey key, struct DBData *data, va_list ap);
void (*reload) (void);
+ bool (*config_read_registry) (const char *filename, const struct config_setting_t *config, bool imported);
bool (*config_read) (const char *filename, const struct config_setting_t *config, bool imported);
};
diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c
index 2963637da..a461763fa 100644
--- a/src/map/mapreg_sql.c
+++ b/src/map/mapreg_sql.c
@@ -329,6 +329,42 @@ static void mapreg_reload(void)
}
/**
+ * Loads the mapreg database table names from configuration file.
+ *
+ * @param filename Path to configuration file. (Used in error and warning messages).
+ * @param config The current config being parsed.
+ * @param imported Whether the current config is imported from another file.
+ * @return True on success, otherwise false.
+ *
+ **/
+static bool mapreg_config_read_registry(const char *filename, const struct config_setting_t *config, bool imported)
+{
+ nullpo_retr(false, filename);
+ nullpo_retr(false, config);
+
+ bool ret_val = true;
+ size_t sz = sizeof(mapreg->num_db);
+ int result = libconfig->setting_lookup_mutable_string(config, "map_reg_num_db", mapreg->num_db, sz);
+
+ if (result != CONFIG_TRUE && !imported) {
+ ShowError("%s: inter_configuration/database_names/registry/map_reg_num_db was not found in %s!\n",
+ __func__, filename);
+ ret_val = false;
+ }
+
+ sz = sizeof(mapreg->str_db);
+ result = libconfig->setting_lookup_mutable_string(config, "map_reg_str_db", mapreg->str_db, sz);
+
+ if (result != CONFIG_TRUE && !imported) {
+ ShowError("%s: inter_configuration/database_names/registry/map_reg_str_db was not found in %s!\n",
+ __func__, filename);
+ ret_val = false;
+ }
+
+ return ret_val;
+}
+
+/**
* Finalizer.
*/
static void mapreg_final(void)
@@ -390,6 +426,8 @@ void mapreg_defaults(void)
mapreg->skip_insert = false;
safestrncpy(mapreg->table, "mapreg", sizeof(mapreg->table));
+ safestrncpy(mapreg->num_db, "map_reg_num_db", sizeof(mapreg->num_db));
+ safestrncpy(mapreg->str_db, "map_reg_str_db", sizeof(mapreg->str_db));
mapreg->dirty = false;
/* */
@@ -409,6 +447,7 @@ void mapreg_defaults(void)
mapreg->save_timer = script_autosave_mapreg;
mapreg->destroyreg = mapreg_destroyreg;
mapreg->reload = mapreg_reload;
+ mapreg->config_read_registry = mapreg_config_read_registry;
mapreg->config_read = mapreg_config_read;
}