summaryrefslogtreecommitdiff
path: root/src/char
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/char
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/char')
-rw-r--r--src/char/char.c7
-rw-r--r--src/char/char.h2
-rw-r--r--src/char/geoip.c5
-rw-r--r--src/char/int_guild.c2
4 files changed, 11 insertions, 5 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 37db77300..66bfdd4ee 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -120,8 +120,6 @@ char char_achievement_db[256] = "char_achievements";
static struct char_interface char_s;
struct char_interface *chr;
-char db_path[1024] = "db";
-
static char wisp_server_name[NAME_LENGTH] = "Server";
static char login_ip_str[128];
static uint32 login_ip = 0;
@@ -5792,7 +5790,8 @@ static bool char_config_read_database(const char *filename, const struct config_
if (autosave_interval <= 0)
autosave_interval = DEFAULT_AUTOSAVE_INTERVAL;
}
- libconfig->setting_lookup_mutable_string(setting, "db_path", db_path, sizeof(db_path));
+ libconfig->setting_lookup_mutable_string(setting, "db_path", chr->db_path, sizeof(chr->db_path));
+ libconfig->set_db_path(chr->db_path);
libconfig->setting_lookup_bool_real(setting, "log_char", &chr->enable_logs);
return true;
}
@@ -6454,6 +6453,8 @@ void char_defaults(void)
chr = &char_s;
memset(chr->server, 0, sizeof(chr->server));
+ sprintf(chr->db_path, "db");
+ libconfig->set_db_path(chr->db_path);
chr->login_fd = 0;
chr->char_fd = -1;
diff --git a/src/char/char.h b/src/char/char.h
index 5de3e2a80..3b8bcff2e 100644
--- a/src/char/char.h
+++ b/src/char/char.h
@@ -124,6 +124,8 @@ struct char_interface {
bool show_save_log; ///< Show loading/saving messages.
bool enable_logs; ///< Whether to log char server operations.
+ char db_path[256]; //< Database directory (db)
+
int (*waiting_disconnect) (int tid, int64 tick, int id, intptr_t data);
int (*delete_char_sql) (int char_id);
struct DBData (*create_online_char_data) (union DBKey key, va_list args);
diff --git a/src/char/geoip.c b/src/char/geoip.c
index 2870e5f0c..67c057aff 100644
--- a/src/char/geoip.c
+++ b/src/char/geoip.c
@@ -23,6 +23,7 @@
#include "geoip.h"
#include "common/cbasetypes.h"
+#include "common/conf.h"
#include "common/memmgr.h"
#include "common/showmsg.h"
@@ -141,7 +142,9 @@ static void geoip_init(void)
geoip->data->active = true;
- db = fopen("./db/GeoIP.dat","rb");
+ char file_path[256];
+ libconfig->format_db_path("GeoIP.dat", file_path, sizeof(file_path));
+ db = fopen(file_path, "rb");
if (db == NULL) {
ShowError("geoip_readdb: Error reading GeoIP.dat!\n");
geoip->final(false);
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index 87cb3bee0..3e9d50f8d 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -747,7 +747,7 @@ static int inter_guild_sql_init(void)
inter_guild->castle_db = idb_alloc(DB_OPT_RELEASE_DATA);
//Read exp file
- sv->readdb("db", DBPATH"exp_guild.txt", ',', 1, 1, MAX_GUILDLEVEL, inter_guild->exp_parse_row);
+ sv->readdb(chr->db_path, DBPATH"exp_guild.txt", ',', 1, 1, MAX_GUILDLEVEL, inter_guild->exp_parse_row);
timer->add_func_list(inter_guild->save_timer, "inter_guild->save_timer");
timer->add(timer->gettick() + 10000, inter_guild->save_timer, 0, 0);