summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2019-10-20 17:43:44 +0200
committerGitHub <noreply@github.com>2019-10-20 17:43:44 +0200
commit275edef51c858e9e55934ec3af92ec19db74f3d3 (patch)
tree81c4367dfb4d51fec9c71c2a407f502a514b6a67 /src/map
parentddd0e461fb8e451912a6aee90869023e2c2d8272 (diff)
parentbe955e59bcd950d6430189a8a23a608927665c02 (diff)
downloadhercules-275edef51c858e9e55934ec3af92ec19db74f3d3.tar.gz
hercules-275edef51c858e9e55934ec3af92ec19db74f3d3.tar.bz2
hercules-275edef51c858e9e55934ec3af92ec19db74f3d3.tar.xz
hercules-275edef51c858e9e55934ec3af92ec19db74f3d3.zip
Merge pull request #2547 from guilherme-gm/201910-dehardcode-db
Dehardcode DB files path
Diffstat (limited to 'src/map')
-rw-r--r--src/map/achievement.c6
-rw-r--r--src/map/clif.c9
-rw-r--r--src/map/guild.c3
-rw-r--r--src/map/itemdb.c24
-rw-r--r--src/map/map.c10
-rw-r--r--src/map/mob.c4
-rw-r--r--src/map/pc.c9
-rw-r--r--src/map/script.c3
-rw-r--r--src/map/skill.c2
-rw-r--r--src/map/status.c6
-rw-r--r--src/map/stylist.c3
11 files changed, 37 insertions, 42 deletions
diff --git a/src/map/achievement.c b/src/map/achievement.c
index 7ab80e183..c2ebb5fdd 100644
--- a/src/map/achievement.c
+++ b/src/map/achievement.c
@@ -1099,7 +1099,8 @@ static bool achievement_get_rewards(struct map_session_data *sd, const struct ac
*/
static void achievement_readdb_ranks(void)
{
- const char *filename = "db/achievement_rank_db.conf";
+ char filename[256];
+ libconfig->format_db_path("achievement_rank_db.conf", filename, sizeof(filename));
struct config_t ar_conf = { 0 };
struct config_setting_t *ardb = NULL, *conf = NULL;
int entry = 0;
@@ -1777,7 +1778,8 @@ static void achievement_readdb_additional_fields(const struct config_setting_t *
*/
static void achievement_readb(void)
{
- const char *filename = "db/"DBPATH"achievement_db.conf";
+ char filename[256];
+ libconfig->format_db_path(DBPATH"achievement_db.conf", filename, sizeof(filename));
struct config_t ach_conf = { 0 };
struct config_setting_t *achdb = NULL, *conf = NULL;
int entry = 0, count = 0;
diff --git a/src/map/clif.c b/src/map/clif.c
index 3abbc2c36..9f30408e4 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -19794,7 +19794,8 @@ static void clif_cashshop_db(void)
{
struct config_t cashshop_conf;
struct config_setting_t *cashshop = NULL, *cats = NULL;
- const char *config_filename = "db/cashshop_db.conf"; // FIXME hardcoded name
+ char config_filename[256];
+ libconfig->format_db_path("cashshop_db.conf", config_filename, sizeof(config_filename));
int i, item_count_t = 0;
for( i = 0; i < CASHSHOP_TAB_MAX; i++ ) {
CREATE(clif->cs.data[i], struct hCSData *, 1);
@@ -21065,7 +21066,8 @@ static bool clif_parse_roulette_db(void)
{
struct config_t roulette_conf;
struct config_setting_t *roulette = NULL, *levels = NULL;
- const char *config_filename = "db/roulette_db.conf"; // FIXME hardcoded name
+ char config_filename[256];
+ libconfig->format_db_path("roulette_db.conf", config_filename, sizeof(config_filename));
int i, j, item_count_t = 0;
for( i = 0; i < MAX_ROULETTE_LEVEL; i++ ) {
@@ -22549,7 +22551,8 @@ static bool clif_parse_attendance_db(void)
{
struct config_t attendance_conf;
struct config_setting_t *attendance = NULL, *it = NULL;
- const char *config_filename = "db/attendance_db.conf"; // FIXME hardcoded name
+ char config_filename[256];
+ libconfig->format_db_path("attendance_db.conf", config_filename, sizeof(config_filename));
int i = 0;
if (!libconfig->load_file(&attendance_conf, config_filename))
diff --git a/src/map/guild.c b/src/map/guild.c
index 3b611bb05..dbfe03d3e 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -152,7 +152,8 @@ static bool guild_read_castledb_libconfig(void)
{
struct config_t castle_conf;
struct config_setting_t *castle_db = NULL, *it = NULL;
- const char *config_filename = "db/castle_db.conf"; // FIXME hardcoded name
+ char config_filename[256];
+ libconfig->format_db_path("castle_db.conf", config_filename, sizeof(config_filename));
int i = 0;
if (libconfig->load_file(&castle_conf, config_filename) == 0)
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index a97325e57..5dc3d9317 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -846,11 +846,8 @@ static void itemdb_read_groups(void)
{
struct config_t item_group_conf;
struct config_setting_t *itg = NULL, *it = NULL;
-#ifdef RENEWAL
- const char *config_filename = "db/re/item_group.conf"; // FIXME hardcoded name
-#else
- const char *config_filename = "db/pre-re/item_group.conf"; // FIXME hardcoded name
-#endif
+ char config_filename[256];
+ libconfig->format_db_path(DBPATH"item_group.conf", config_filename, sizeof(config_filename));
const char *itname;
int i = 0, count = 0, c;
unsigned int *gsize = NULL;
@@ -1144,11 +1141,8 @@ static void itemdb_read_packages(void)
{
struct config_t item_packages_conf;
struct config_setting_t *itg = NULL, *it = NULL, *t = NULL;
-#ifdef RENEWAL
- const char *config_filename = "db/re/item_packages.conf"; // FIXME hardcoded name
-#else
- const char *config_filename = "db/pre-re/item_packages.conf"; // FIXME hardcoded name
-#endif
+ char config_filename[256];
+ libconfig->format_db_path(DBPATH"item_packages.conf", config_filename, sizeof(config_filename));
const char *itname;
int i = 0, count = 0, c = 0, highest_gcount = 0;
unsigned int *must = NULL, *random = NULL, *rgroup = NULL, **rgroups = NULL;
@@ -1393,7 +1387,8 @@ static void itemdb_read_options(void)
struct config_t item_options_db;
struct config_setting_t *ito = NULL, *conf = NULL;
int index = 0, count = 0;
- const char *filepath = "db/item_options.conf";
+ char filepath[256];
+ libconfig->format_db_path("item_options.conf", filepath, sizeof(filepath));
VECTOR_DECL(int) duplicate_id;
if (!libconfig->load_file(&item_options_db, filepath))
@@ -1494,11 +1489,8 @@ static void itemdb_read_chains(void)
{
struct config_t item_chain_conf;
struct config_setting_t *itc = NULL;
-#ifdef RENEWAL
- const char *config_filename = "db/re/item_chain.conf"; // FIXME hardcoded name
-#else
- const char *config_filename = "db/pre-re/item_chain.conf"; // FIXME hardcoded name
-#endif
+ char config_filename[256];
+ libconfig->format_db_path(DBPATH"item_chain.conf", config_filename, sizeof(config_filename));
int i = 0, count = 0;
if (!libconfig->load_file(&item_chain_conf, config_filename))
diff --git a/src/map/map.c b/src/map/map.c
index 957098dd4..50ad9a5cd 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -4054,6 +4054,7 @@ static bool map_config_read_database(const char *filename, struct config_t *conf
return false;
}
libconfig->setting_lookup_mutable_string(setting, "db_path", map->db_path, sizeof(map->db_path));
+ libconfig->set_db_path(map->db_path);
libconfig->setting_lookup_int(setting, "save_settings", &map->save_settings);
if (libconfig->setting_lookup_int(setting, "autosave_time", &map->autosave_interval) == CONFIG_TRUE) {
@@ -5573,12 +5574,8 @@ static void read_map_zone_db(void)
{
struct config_t map_zone_db;
struct config_setting_t *zones = NULL;
- /* TODO: #ifndef required for re/pre-re */
-#ifdef RENEWAL
- const char *config_filename = "db/re/map_zone_db.conf"; // FIXME hardcoded name
-#else
- const char *config_filename = "db/pre-re/map_zone_db.conf"; // FIXME hardcoded name
-#endif
+ char config_filename[256];
+ libconfig->format_db_path(DBPATH"map_zone_db.conf", config_filename, sizeof(config_filename));
if (!libconfig->load_file(&map_zone_db, config_filename))
return;
@@ -6776,6 +6773,7 @@ void map_defaults(void)
map->extra_scripts_count = 0;
sprintf(map->db_path ,"db");
+ libconfig->set_db_path(map->db_path);
sprintf(map->help_txt ,"conf/help.txt");
sprintf(map->charhelp_txt ,"conf/charhelp.txt");
diff --git a/src/map/mob.c b/src/map/mob.c
index d2d8727e3..56d07da92 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -4105,10 +4105,8 @@ static bool mob_read_optdrops_group(struct config_setting_t *group, int n)
*/
static bool mob_read_optdrops_db(void)
{
- const char *filename = "option_drop_groups.conf"; // FIXME hardcoded name
-
char filepath[256];
- safesnprintf(filepath, sizeof(filepath), "%s/%s", map->db_path, filename);
+ libconfig->format_db_path("option_drop_groups.conf", filepath, sizeof(filepath));
struct config_t option_groups;
if (libconfig->load_file(&option_groups, filepath) == CONFIG_FALSE) {
diff --git a/src/map/pc.c b/src/map/pc.c
index 5eccfbaf6..a8ff661e8 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -11533,12 +11533,9 @@ static bool pc_read_exp_db(void)
struct config_t exp_db_conf;
struct config_setting_t *edb = NULL;
int entry_count = 0;
-
-#ifdef RENEWAL
- const char *config_filename = "db/re/exp_group_db.conf";
-#else
- const char *config_filename = "db/pre-re/exp_group_db.conf";
-#endif
+ char config_filename[256];
+
+ libconfig->format_db_path(DBPATH"exp_group_db.conf", config_filename, sizeof(config_filename));
if (!libconfig->load_file(&exp_db_conf, config_filename))
return false;
diff --git a/src/map/script.c b/src/map/script.c
index ab7513ede..bd0fbb611 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -5150,7 +5150,8 @@ static uint8 script_add_language(const char *name)
static void script_load_translations(void)
{
struct config_t translations_conf;
- const char *config_filename = "db/translations.conf"; // FIXME hardcoded name
+ char config_filename[256];
+ libconfig->format_db_path("translations.conf", config_filename, sizeof(config_filename));
struct config_setting_t *translations = NULL;
int i, size;
int total = 0;
diff --git a/src/map/skill.c b/src/map/skill.c
index e44389d3c..7451fbf41 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -21109,7 +21109,7 @@ static bool skill_read_skilldb(const char *filename)
nullpo_retr(false, filename);
- sprintf(filepath,"db/%s",filename);
+ libconfig->format_db_path(filename, filepath, sizeof(filepath));
if (!libconfig->load_file(&skilldb, filepath)) {
return false; // Libconfig error report.
diff --git a/src/map/status.c b/src/map/status.c
index 96a02c023..d2c67b84e 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -13367,10 +13367,12 @@ static void status_read_job_db(void)
int i = 0;
struct config_t job_db_conf;
struct config_setting_t *jdb = NULL;
+ char config_filename[256];
+
#ifdef RENEWAL_ASPD
- const char *config_filename = "db/re/job_db.conf";
+ libconfig->format_db_path(DBPATH_RE"job_db.conf", config_filename, sizeof(config_filename));
#else
- const char *config_filename = "db/pre-re/job_db.conf";
+ libconfig->format_db_path(DBPATH_PRE"job_db.conf", config_filename, sizeof(config_filename));
#endif
if (!libconfig->load_file(&job_db_conf, config_filename))
diff --git a/src/map/stylist.c b/src/map/stylist.c
index 7e7c13bf7..438302214 100644
--- a/src/map/stylist.c
+++ b/src/map/stylist.c
@@ -40,7 +40,8 @@ static bool stylist_read_db_libconfig(void)
{
struct config_t stylist_conf;
struct config_setting_t *stylist_db = NULL, *it = NULL;
- const char *config_filename = "db/stylist_db.conf"; // FIXME hardcoded name
+ char config_filename[256];
+ libconfig->format_db_path("stylist_db.conf", config_filename, sizeof(config_filename));
int i = 0;
if (!libconfig->load_file(&stylist_conf, config_filename))