summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c24
-rw-r--r--src/map/atcommand.h4
-rw-r--r--src/map/battleground.c14
-rw-r--r--src/map/channel.c16
-rw-r--r--src/map/clif.c24
-rw-r--r--src/map/itemdb.c51
-rw-r--r--src/map/itemdb.h8
-rw-r--r--src/map/map.c46
-rw-r--r--src/map/mob.c36
-rw-r--r--src/map/mob.h16
-rw-r--r--src/map/pc.c14
-rw-r--r--src/map/pc_groups.c26
-rw-r--r--src/map/pc_groups.h12
-rw-r--r--src/map/quest.c17
-rw-r--r--src/map/quest.h5
-rw-r--r--src/map/script.c22
-rw-r--r--src/map/status.c36
-rw-r--r--src/map/status.h6
18 files changed, 190 insertions, 187 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index bc539837d..eb48adc1d 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -3613,16 +3613,16 @@ ACMD(reloadskilldb)
* @reloadatcommand - reloads conf/atcommand.conf conf/groups.conf
*------------------------------------------*/
ACMD(reloadatcommand) {
- config_t run_test;
+ struct config_t run_test;
- if (libconfig->read_file(&run_test, "conf/groups.conf")) {
+ if (!libconfig->load_file(&run_test, "conf/groups.conf")) {
clif->message(fd, msg_fd(fd,1036)); // Error reading groups.conf, reload failed.
return false;
}
libconfig->destroy(&run_test);
- if (libconfig->read_file(&run_test, map->ATCOMMAND_CONF_FILENAME)) {
+ if (!libconfig->load_file(&run_test, map->ATCOMMAND_CONF_FILENAME)) {
clif->message(fd, msg_fd(fd,1037)); // Error reading atcommand.conf, reload failed.
return false;
}
@@ -10006,13 +10006,13 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa
*
*------------------------------------------*/
void atcommand_config_read(const char* config_filename) {
- config_t atcommand_config;
- config_setting_t *aliases = NULL, *help = NULL, *nolog = NULL;
+ struct config_t atcommand_config;
+ struct config_setting_t *aliases = NULL, *help = NULL, *nolog = NULL;
const char *symbol = NULL;
int num_aliases = 0;
nullpo_retv(config_filename);
- if (libconfig->read_file(&atcommand_config, config_filename))
+ if (!libconfig->load_file(&atcommand_config, config_filename))
return;
// Command symbols
@@ -10041,7 +10041,7 @@ void atcommand_config_read(const char* config_filename) {
int count = libconfig->setting_length(aliases);
for (i = 0; i < count; ++i) {
- config_setting_t *command;
+ struct config_setting_t *command;
const char *commandname = NULL;
int j = 0, alias_count = 0;
AtCommandInfo *commandinfo = NULL;
@@ -10079,7 +10079,7 @@ void atcommand_config_read(const char* config_filename) {
int count = libconfig->setting_length(nolog);
for (i = 0; i < count; ++i) {
- config_setting_t *command;
+ struct config_setting_t *command;
const char *commandname = NULL;
AtCommandInfo *commandinfo = NULL;
@@ -10101,7 +10101,7 @@ void atcommand_config_read(const char* config_filename) {
int i;
for (i = 0; i < count; ++i) {
- config_setting_t *command;
+ struct config_setting_t *command;
const char *commandname;
AtCommandInfo *commandinfo = NULL;
@@ -10144,7 +10144,7 @@ static inline int atcommand_command_type2idx(AtCommandType type)
* Loads permissions for groups to use commands.
*
*/
-void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **commands_, size_t sz)
+void atcommand_db_load_groups(GroupSettings **groups, struct config_setting_t **commands_, size_t sz)
{
DBIterator *iter = db_iterator(atcommand->db);
AtCommandInfo *atcmd;
@@ -10157,7 +10157,7 @@ void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **command
CREATE(atcmd->char_groups, char, sz);
for (i = 0; i < sz; i++) {
GroupSettings *group = groups[i];
- config_setting_t *commands = commands_[i];
+ struct config_setting_t *commands = commands_[i];
int result = 0;
int idx = -1;
@@ -10178,7 +10178,7 @@ void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **command
}
if (commands != NULL) {
- config_setting_t *cmd = NULL;
+ struct config_setting_t *cmd = NULL;
// <commandname> : <bool> (only atcommand)
if (config_setting_lookup_bool(commands, atcmd->command, &result) && result) {
diff --git a/src/map/atcommand.h b/src/map/atcommand.h
index 5c4acdf01..a4f9afce7 100644
--- a/src/map/atcommand.h
+++ b/src/map/atcommand.h
@@ -23,7 +23,6 @@
#include "map/pc_groups.h"
#include "common/hercules.h"
-#include "common/conf.h"
#include "common/db.h"
#include <stdarg.h>
@@ -34,6 +33,7 @@
struct map_session_data;
struct AtCommandInfo;
struct block_list;
+struct config_setting_t;
/**
* Defines
@@ -110,7 +110,7 @@ struct atcommand_interface {
bool (*create) (char *name, AtCommandFunc func);
bool (*can_use) (struct map_session_data *sd, const char *command);
bool (*can_use2) (struct map_session_data *sd, const char *command, AtCommandType type);
- void (*load_groups) (GroupSettings **groups, config_setting_t **commands_, size_t sz);
+ void (*load_groups) (GroupSettings **groups, struct config_setting_t **commands_, size_t sz);
AtCommandInfo* (*exists) (const char* name);
bool (*msg_read) (const char *cfg_name, bool allow_override);
void (*final_msg) (void);
diff --git a/src/map/battleground.c b/src/map/battleground.c
index e3fedbf34..d25aef851 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -330,18 +330,18 @@ enum bg_queue_types bg_str2teamtype (const char *str) {
}
void bg_config_read(void) {
- config_t bg_conf;
- config_setting_t *data = NULL;
+ struct config_t bg_conf;
+ struct config_setting_t *data = NULL;
const char *config_filename = "conf/battlegrounds.conf"; // FIXME hardcoded name
- if (libconfig->read_file(&bg_conf, config_filename))
+ if (!libconfig->load_file(&bg_conf, config_filename))
return;
data = libconfig->lookup(&bg_conf, "battlegrounds");
if (data != NULL) {
- config_setting_t *settings = libconfig->setting_get_elem(data, 0);
- config_setting_t *arenas;
+ struct config_setting_t *settings = libconfig->setting_get_elem(data, 0);
+ struct config_setting_t *arenas;
const char *delay_var;
int offline = 0;
@@ -361,8 +361,8 @@ void bg_config_read(void) {
int arena_count = libconfig->setting_length(arenas);
CREATE( bg->arena, struct bg_arena *, arena_count );
for(i = 0; i < arena_count; i++) {
- config_setting_t *arena = libconfig->setting_get_elem(arenas, i);
- config_setting_t *reward;
+ struct config_setting_t *arena = libconfig->setting_get_elem(arenas, i);
+ struct config_setting_t *reward;
const char *aName, *aEvent, *aDelayVar, *aTeamTypes;
int minLevel = 0, maxLevel = 0;
int prizeWin, prizeLoss, prizeDraw;
diff --git a/src/map/channel.c b/src/map/channel.c
index d778b355d..45b59898c 100644
--- a/src/map/channel.c
+++ b/src/map/channel.c
@@ -589,19 +589,19 @@ void channel_quit_guild(struct map_session_data *sd)
void read_channels_config(void)
{
- config_t channels_conf;
- config_setting_t *chsys = NULL;
+ struct config_t channels_conf;
+ struct config_setting_t *chsys = NULL;
const char *config_filename = "conf/channels.conf"; // FIXME hardcoded name
- if (libconfig->read_file(&channels_conf, config_filename))
+ if (!libconfig->load_file(&channels_conf, config_filename))
return;
chsys = libconfig->lookup(&channels_conf, "chsys");
if (chsys != NULL) {
- config_setting_t *settings = libconfig->setting_get_elem(chsys, 0);
- config_setting_t *channels;
- config_setting_t *colors;
+ struct config_setting_t *settings = libconfig->setting_get_elem(chsys, 0);
+ struct config_setting_t *channels;
+ struct config_setting_t *colors;
int i,k;
const char *local_name, *ally_name,
*local_color, *ally_color,
@@ -710,7 +710,7 @@ void read_channels_config(void)
CREATE(channel->config->colors, unsigned int, color_count);
CREATE(channel->config->colors_name, char *, color_count);
for(i = 0; i < color_count; i++) {
- config_setting_t *color = libconfig->setting_get_elem(colors, i);
+ struct config_setting_t *color = libconfig->setting_get_elem(colors, i);
CREATE(channel->config->colors_name[i], char, HCS_NAME_LENGTH);
@@ -771,7 +771,7 @@ void read_channels_config(void)
int channel_count = libconfig->setting_length(channels);
for(i = 0; i < channel_count; i++) {
- config_setting_t *chan = libconfig->setting_get_elem(channels, i);
+ struct config_setting_t *chan = libconfig->setting_get_elem(channels, i);
const char *name = config_setting_name(chan);
const char *color = libconfig->setting_get_string_elem(channels,i);
diff --git a/src/map/clif.c b/src/map/clif.c
index 3b2f255ef..66a8e92b8 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -17308,8 +17308,8 @@ void clif_parse_MoveItem(int fd, struct map_session_data *sd) {
/* [Ind/Hercules] */
void clif_cashshop_db(void) {
- config_t cashshop_conf;
- config_setting_t *cashshop = NULL, *cats = NULL;
+ struct config_t cashshop_conf;
+ struct config_setting_t *cashshop = NULL, *cats = NULL;
const char *config_filename = "db/cashshop_db.conf"; // FIXME hardcoded name
int i, item_count_t = 0;
for( i = 0; i < CASHSHOP_TAB_MAX; i++ ) {
@@ -17317,16 +17317,14 @@ void clif_cashshop_db(void) {
clif->cs.item_count[i] = 0;
}
- if (libconfig->read_file(&cashshop_conf, config_filename)) {
- ShowError("can't read %s\n", config_filename);
+ if (!libconfig->load_file(&cashshop_conf, config_filename))
return;
- }
cashshop = libconfig->lookup(&cashshop_conf, "cash_shop");
if( cashshop != NULL && (cats = libconfig->setting_get_elem(cashshop, 0)) != NULL ) {
for(i = 0; i < CASHSHOP_TAB_MAX; i++) {
- config_setting_t *cat;
+ struct config_setting_t *cat;
char entry_name[10];
sprintf(entry_name,"cat_%d",i);
@@ -17335,7 +17333,7 @@ void clif_cashshop_db(void) {
int k, item_count = libconfig->setting_length(cat);
for(k = 0; k < item_count; k++) {
- config_setting_t *entry = libconfig->setting_get_elem(cat,k);
+ struct config_setting_t *entry = libconfig->setting_get_elem(cat,k);
const char *name = config_setting_name(entry);
int price = libconfig->setting_get_int(entry);
struct item_data * data = NULL;
@@ -18368,8 +18366,8 @@ void clif_parse_RouletteRecvItem(int fd, struct map_session_data* sd) {
}
bool clif_parse_roulette_db(void) {
- config_t roulette_conf;
- config_setting_t *roulette = NULL, *levels = NULL;
+ struct config_t roulette_conf;
+ struct config_setting_t *roulette = NULL, *levels = NULL;
const char *config_filename = "db/roulette_db.conf"; // FIXME hardcoded name
int i, j, item_count_t = 0;
@@ -18377,15 +18375,13 @@ bool clif_parse_roulette_db(void) {
clif->rd.items[i] = 0;
}
- if (libconfig->read_file(&roulette_conf, config_filename)) {
- ShowError("can't read %s\n", config_filename);
+ if (!libconfig->load_file(&roulette_conf, config_filename))
return false;
- }
roulette = libconfig->lookup(&roulette_conf, "roulette");
if( roulette != NULL && (levels = libconfig->setting_get_elem(roulette, 0)) != NULL ) {
for(i = 0; i < MAX_ROULETTE_LEVEL; i++) {
- config_setting_t *level;
+ struct config_setting_t *level;
char entry_name[10];
sprintf(entry_name,"level_%d",i+1);
@@ -18394,7 +18390,7 @@ bool clif_parse_roulette_db(void) {
int k, item_count = libconfig->setting_length(level);
for(k = 0; k < item_count; k++) {
- config_setting_t *entry = libconfig->setting_get_elem(level,k);
+ struct config_setting_t *entry = libconfig->setting_get_elem(level,k);
const char *name = config_setting_name(entry);
int qty = libconfig->setting_get_int(entry);
struct item_data * data = NULL;
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index bd552dd16..da72ab05a 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -637,8 +637,8 @@ int itemdb_isidentified2(struct item_data *data) {
}
void itemdb_read_groups(void) {
- config_t item_group_conf;
- config_setting_t *itg = NULL, *it = NULL;
+ 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
@@ -648,10 +648,8 @@ void itemdb_read_groups(void) {
int i = 0, count = 0, c;
unsigned int *gsize = NULL;
- if (libconfig->read_file(&item_group_conf, config_filename)) {
- ShowError("can't read %s\n", config_filename);
+ if (!libconfig->load_file(&item_group_conf, config_filename))
return;
- }
gsize = aMalloc( libconfig->setting_length(item_group_conf.root) * sizeof(unsigned int) );
@@ -929,8 +927,8 @@ bool itemdb_read_cached_packages(const char *config_filename) {
return true;
}
void itemdb_read_packages(void) {
- config_t item_packages_conf;
- config_setting_t *itg = NULL, *it = NULL, *t = NULL;
+ 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
@@ -946,10 +944,8 @@ void itemdb_read_packages(void) {
return;
}
- if (libconfig->read_file(&item_packages_conf, config_filename)) {
- ShowError("can't read %s\n", config_filename);
+ if (!libconfig->load_file(&item_packages_conf, config_filename))
return;
- }
must = aMalloc( libconfig->setting_length(item_packages_conf.root) * sizeof(unsigned int) );
random = aMalloc( libconfig->setting_length(item_packages_conf.root) * sizeof(unsigned int) );
@@ -1161,8 +1157,8 @@ void itemdb_read_packages(void) {
}
void itemdb_read_chains(void) {
- config_t item_chain_conf;
- config_setting_t *itc = NULL;
+ 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
@@ -1170,10 +1166,8 @@ void itemdb_read_chains(void) {
#endif
int i = 0, count = 0;
- if (libconfig->read_file(&item_chain_conf, config_filename)) {
- ShowError("can't read %s\n", config_filename);
+ if (!libconfig->load_file(&item_chain_conf, config_filename))
return;
- }
CREATE(itemdb->chains, struct item_chain, libconfig->setting_length(item_chain_conf.root));
itemdb->chain_count = (unsigned short)libconfig->setting_length(item_chain_conf.root);
@@ -1186,7 +1180,7 @@ void itemdb_read_chains(void) {
struct item_chain_entry *prev = NULL;
const char *name = config_setting_name(itc);
int c = 0;
- config_setting_t *entry = NULL;
+ struct config_setting_t *entry = NULL;
script->set_constant2(name, i-1, false, false);
itemdb->chains[count].qty = (unsigned short)libconfig->setting_length(itc);
@@ -1535,7 +1529,7 @@ int itemdb_validate_entry(struct item_data *entry, int n, const char *source) {
return item->nameid;
}
-void itemdb_readdb_additional_fields(int itemid, config_setting_t *it, int n, const char *source)
+void itemdb_readdb_additional_fields(int itemid, struct config_setting_t *it, int n, const char *source)
{
// do nothing. plugins can do own work
}
@@ -1553,9 +1547,9 @@ void itemdb_readdb_additional_fields(int itemid, config_setting_t *it, int n, co
* validation errors.
* @return Nameid of the validated entry, or 0 in case of failure.
*/
-int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source) {
+int itemdb_readdb_libconfig_sub(struct config_setting_t *it, int n, const char *source) {
struct item_data id = { 0 };
- config_setting_t *t = NULL;
+ struct config_setting_t *t = NULL;
const char *str = NULL;
int i32 = 0;
bool inherit = false;
@@ -1736,7 +1730,7 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
if ( (t = libconfig->setting_get_member(it, "Trade")) ) {
if (config_setting_is_group(t)) {
- config_setting_t *tt = NULL;
+ struct config_setting_t *tt = NULL;
if ((tt = libconfig->setting_get_member(t, "override"))) {
id.gm_lv_trade_override = libconfig->setting_get_int(tt);
@@ -1802,7 +1796,7 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
if ((t = libconfig->setting_get_member(it, "Nouse"))) {
if (config_setting_is_group(t)) {
- config_setting_t *nt = NULL;
+ struct config_setting_t *nt = NULL;
if ((nt = libconfig->setting_get_member(t, "override"))) {
id.item_usage.override = libconfig->setting_get_int(nt);
@@ -1850,7 +1844,7 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
return itemdb->validate_entry(&id, n, source);
}
-bool itemdb_lookup_const(const config_setting_t *it, const char *name, int *value)
+bool itemdb_lookup_const(const struct config_setting_t *it, const char *name, int *value)
{
nullpo_retr(false, name);
nullpo_retr(false, value);
@@ -1879,19 +1873,24 @@ bool itemdb_lookup_const(const config_setting_t *it, const char *name, int *valu
*/
int itemdb_readdb_libconfig(const char *filename) {
bool duplicate[MAX_ITEMDB];
- config_t item_db_conf;
- config_setting_t *itdb, *it;
+ struct config_t item_db_conf;
+ struct config_setting_t *itdb, *it;
char filepath[256];
int i = 0, count = 0;
nullpo_ret(filename);
+
sprintf(filepath, "%s/%s", map->db_path, filename);
- memset(&duplicate,0,sizeof(duplicate));
- if( libconfig->read_file(&item_db_conf, filepath) || !(itdb = libconfig->setting_get_member(item_db_conf.root, "item_db")) ) {
+ if (!libconfig->load_file(&item_db_conf, filepath))
+ return 0;
+
+ if ((itdb = libconfig->setting_get_member(item_db_conf.root, "item_db")) == NULL) {
ShowError("can't read %s\n", filepath);
return 0;
}
+ memset(&duplicate,0,sizeof(duplicate));
+
while( (it = libconfig->setting_get_elem(itdb,i++)) ) {
int nameid = itemdb->readdb_libconfig_sub(it, i-1, filename);
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index 8a0ec389d..b83c27ed2 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -23,10 +23,10 @@
/* #include "map/map.h" */
#include "common/hercules.h"
-#include "common/conf.h"
#include "common/db.h"
#include "common/mmo.h" // ITEM_NAME_LENGTH
+struct config_setting_t;
struct script_code;
struct hplugin_data_store;
@@ -631,8 +631,8 @@ struct itemdb_interface {
void (*read_combos) (void);
int (*gendercheck) (struct item_data *id);
int (*validate_entry) (struct item_data *entry, int n, const char *source);
- void (*readdb_additional_fields) (int itemid, config_setting_t *it, int n, const char *source);
- int (*readdb_libconfig_sub) (config_setting_t *it, int n, const char *source);
+ void (*readdb_additional_fields) (int itemid, struct config_setting_t *it, int n, const char *source);
+ int (*readdb_libconfig_sub) (struct config_setting_t *it, int n, const char *source);
int (*readdb_libconfig) (const char *filename);
uint64 (*unique_id) (struct map_session_data *sd);
void (*read) (bool minimal);
@@ -641,7 +641,7 @@ struct itemdb_interface {
void (*clear) (bool total);
struct item_combo * (*id2combo) (unsigned short id);
bool (*is_item_usable) (struct item_data *item);
- bool (*lookup_const) (const config_setting_t *it, const char *name, int *value);
+ bool (*lookup_const) (const struct config_setting_t *it, const char *name, int *value);
};
#ifdef HERCULES_CORE
diff --git a/src/map/map.c b/src/map/map.c
index 3dad25fce..c17dd9b0e 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -4982,27 +4982,27 @@ enum bl_type map_zone_bl_type(const char *entry, enum map_zone_skill_subtype *su
}
/* [Ind/Hercules] */
void read_map_zone_db(void) {
- config_t map_zone_db;
- config_setting_t *zones = NULL;
+ 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
- if (libconfig->read_file(&map_zone_db, config_filename))
+ if (!libconfig->load_file(&map_zone_db, config_filename))
return;
zones = libconfig->lookup(&map_zone_db, "zones");
if (zones != NULL) {
struct map_zone_data *zone;
- config_setting_t *zone_e;
- config_setting_t *skills;
- config_setting_t *items;
- config_setting_t *mapflags;
- config_setting_t *commands;
- config_setting_t *caps;
+ struct config_setting_t *zone_e;
+ struct config_setting_t *skills;
+ struct config_setting_t *items;
+ struct config_setting_t *mapflags;
+ struct config_setting_t *commands;
+ struct config_setting_t *caps;
const char *name;
const char *zonename;
int i,h,v,j;
@@ -5054,7 +5054,7 @@ void read_map_zone_db(void) {
disabled_skills_count = libconfig->setting_length(skills);
/* validate */
for(h = 0; h < libconfig->setting_length(skills); h++) {
- config_setting_t *skillinfo = libconfig->setting_get_elem(skills, h);
+ struct config_setting_t *skillinfo = libconfig->setting_get_elem(skills, h);
name = config_setting_name(skillinfo);
if( !map->zone_str2skillid(name) ) {
ShowError("map_zone_db: unknown skill (%s) in disabled_skills for zone '%s', skipping skill...\n",name,zone->name);
@@ -5069,7 +5069,7 @@ void read_map_zone_db(void) {
/* all ok, process */
CREATE( zone->disabled_skills, struct map_zone_disabled_skill_entry *, disabled_skills_count );
for(h = 0, v = 0; h < libconfig->setting_length(skills); h++) {
- config_setting_t *skillinfo = libconfig->setting_get_elem(skills, h);
+ struct config_setting_t *skillinfo = libconfig->setting_get_elem(skills, h);
struct map_zone_disabled_skill_entry * entry;
enum bl_type type;
name = config_setting_name(skillinfo);
@@ -5092,7 +5092,7 @@ void read_map_zone_db(void) {
disabled_items_count = libconfig->setting_length(items);
/* validate */
for(h = 0; h < libconfig->setting_length(items); h++) {
- config_setting_t *item = libconfig->setting_get_elem(items, h);
+ struct config_setting_t *item = libconfig->setting_get_elem(items, h);
name = config_setting_name(item);
if( !map->zone_str2itemid(name) ) {
ShowError("map_zone_db: unknown item (%s) in disabled_items for zone '%s', skipping item...\n",name,zone->name);
@@ -5111,7 +5111,7 @@ void read_map_zone_db(void) {
CREATE(zone->cant_disable_items, int, zone->cant_disable_items_count);
}
for(h = 0, v = 0, j = 0; h < libconfig->setting_length(items); h++) {
- config_setting_t *item = libconfig->setting_get_elem(items, h);
+ struct config_setting_t *item = libconfig->setting_get_elem(items, h);
name = config_setting_name(item);
if( libconfig->setting_get_bool(item) ) { /* only add if enabled */
@@ -5143,7 +5143,7 @@ void read_map_zone_db(void) {
disabled_commands_count = libconfig->setting_length(commands);
/* validate */
for(h = 0; h < libconfig->setting_length(commands); h++) {
- config_setting_t *command = libconfig->setting_get_elem(commands, h);
+ struct config_setting_t *command = libconfig->setting_get_elem(commands, h);
name = config_setting_name(command);
if( !atcommand->exists(name) ) {
ShowError("map_zone_db: unknown command '%s' in disabled_commands for zone '%s', skipping entry...\n",name,zone->name);
@@ -5158,7 +5158,7 @@ void read_map_zone_db(void) {
/* all ok, process */
CREATE( zone->disabled_commands, struct map_zone_disabled_command_entry *, disabled_commands_count );
for(h = 0, v = 0; h < libconfig->setting_length(commands); h++) {
- config_setting_t *command = libconfig->setting_get_elem(commands, h);
+ struct config_setting_t *command = libconfig->setting_get_elem(commands, h);
struct map_zone_disabled_command_entry * entry;
int group_lv;
name = config_setting_name(command);
@@ -5179,7 +5179,7 @@ void read_map_zone_db(void) {
capped_skills_count = libconfig->setting_length(caps);
/* validate */
for(h = 0; h < libconfig->setting_length(caps); h++) {
- config_setting_t *cap = libconfig->setting_get_elem(caps, h);
+ struct config_setting_t *cap = libconfig->setting_get_elem(caps, h);
name = config_setting_name(cap);
if( !map->zone_str2skillid(name) ) {
ShowError("map_zone_db: unknown skill (%s) in skill_damage_cap for zone '%s', skipping skill...\n",name,zone->name);
@@ -5194,7 +5194,7 @@ void read_map_zone_db(void) {
/* all ok, process */
CREATE( zone->capped_skills, struct map_zone_skill_damage_cap_entry *, capped_skills_count );
for(h = 0, v = 0; h < libconfig->setting_length(caps); h++) {
- config_setting_t *cap = libconfig->setting_get_elem(caps, h);
+ struct config_setting_t *cap = libconfig->setting_get_elem(caps, h);
struct map_zone_skill_damage_cap_entry * entry;
enum bl_type type;
name = config_setting_name(cap);
@@ -5219,8 +5219,8 @@ void read_map_zone_db(void) {
/* process inheritance, aka loop through the whole thing again :P */
for (i = 0; i < zone_count; ++i) {
- config_setting_t *inherit_tree = NULL;
- config_setting_t *new_entry = NULL;
+ struct config_setting_t *inherit_tree = NULL;
+ struct config_setting_t *new_entry = NULL;
int inherit_count;
zone_e = libconfig->setting_get_elem(zones, i);
@@ -5278,7 +5278,7 @@ void read_map_zone_db(void) {
for(j = 0; j < disabled_skills_count_i; j++) {
int k;
for(k = 0; k < disabled_skills_count; k++) {
- config_setting_t *skillinfo = libconfig->setting_get_elem(skills, k);
+ struct config_setting_t *skillinfo = libconfig->setting_get_elem(skills, k);
if( map->zone_str2skillid(config_setting_name(skillinfo)) == izone->disabled_skills[j]->nameid ) {
break;
}
@@ -5302,7 +5302,7 @@ void read_map_zone_db(void) {
for(j = 0; j < disabled_items_count_i; j++) {
int k;
for(k = 0; k < disabled_items_count; k++) {
- config_setting_t *item = libconfig->setting_get_elem(items, k);
+ struct config_setting_t *item = libconfig->setting_get_elem(items, k);
name = config_setting_name(item);
@@ -5348,7 +5348,7 @@ void read_map_zone_db(void) {
for(j = 0; j < disabled_commands_count_i; j++) {
int k;
for(k = 0; k < disabled_commands_count; k++) {
- config_setting_t *command = libconfig->setting_get_elem(commands, k);
+ struct config_setting_t *command = libconfig->setting_get_elem(commands, k);
if( atcommand->exists(config_setting_name(command))->func == izone->disabled_commands[j]->cmd ) {
break;
}
@@ -5372,7 +5372,7 @@ void read_map_zone_db(void) {
for(j = 0; j < capped_skills_count_i; j++) {
int k;
for(k = 0; k < capped_skills_count; k++) {
- config_setting_t *cap = libconfig->setting_get_elem(caps, k);
+ struct config_setting_t *cap = libconfig->setting_get_elem(caps, k);
if( map->zone_str2skillid(config_setting_name(cap)) == izone->capped_skills[j]->nameid ) {
break;
}
diff --git a/src/map/mob.c b/src/map/mob.c
index 86f3ddc0d..2ae54ba69 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -46,6 +46,7 @@
#include "map/status.h"
#include "common/HPM.h"
#include "common/cbasetypes.h"
+#include "common/conf.h"
#include "common/db.h"
#include "common/ers.h"
#include "common/memmgr.h"
@@ -3691,7 +3692,7 @@ static inline int mob_parse_dbrow_cap_value(int class_, int min, int max, int va
* (mob_id is expected to be already set).
* @param[in] t The libconfig entry.
*/
-void mob_read_db_stats_sub(struct mob_db *entry, config_setting_t *t)
+void mob_read_db_stats_sub(struct mob_db *entry, struct config_setting_t *t)
{
int i32;
if (mob->lookup_const(t, "Str", &i32) && i32 >= 0) {
@@ -3722,10 +3723,10 @@ void mob_read_db_stats_sub(struct mob_db *entry, config_setting_t *t)
*
* @return The parsed mode.
*/
-int mob_read_db_mode_sub(struct mob_db *entry, config_setting_t *t)
+int mob_read_db_mode_sub(struct mob_db *entry, struct config_setting_t *t)
{
int mode = 0;
- config_setting_t *t2;
+ struct config_setting_t *t2;
if ((t2 = libconfig->setting_get_member(t, "CanMove")))
mode |= libconfig->setting_get_bool(t2) ? MD_CANMOVE : 0;
@@ -3768,9 +3769,9 @@ int mob_read_db_mode_sub(struct mob_db *entry, config_setting_t *t)
* (mob_id is expected to be already set).
* @param[in] t The libconfig entry.
*/
-void mob_read_db_mvpdrops_sub(struct mob_db *entry, config_setting_t *t)
+void mob_read_db_mvpdrops_sub(struct mob_db *entry, struct config_setting_t *t)
{
- config_setting_t *drop;
+ struct config_setting_t *drop;
int i = 0;
int idx = 0;
int i32;
@@ -3824,9 +3825,9 @@ void mob_read_db_mvpdrops_sub(struct mob_db *entry, config_setting_t *t)
* (mob_id, status.mode are expected to be already set).
* @param[in] t The libconfig entry.
*/
-void mob_read_db_drops_sub(struct mob_db *entry, config_setting_t *t)
+void mob_read_db_drops_sub(struct mob_db *entry, struct config_setting_t *t)
{
- config_setting_t *drop;
+ struct config_setting_t *drop;
int i = 0;
int idx = 0;
int i32;
@@ -4051,10 +4052,10 @@ int mob_db_validate_entry(struct mob_db *entry, int n, const char *source)
* validation errors.
* @return Mob ID of the validated entry, or 0 in case of failure.
*/
-int mob_read_db_sub(config_setting_t *mobt, int n, const char *source)
+int mob_read_db_sub(struct config_setting_t *mobt, int n, const char *source)
{
struct mob_db md = { 0 };
- config_setting_t *t = NULL;
+ struct config_setting_t *t = NULL;
const char *str = NULL;
int i32 = 0;
bool inherit = false;
@@ -4359,12 +4360,12 @@ int mob_read_db_sub(config_setting_t *mobt, int n, const char *source)
* @param[in] source Source of the entry (file name), to be displayed in
* case of validation errors.
*/
-void mob_read_db_additional_fields(struct mob_db *entry, config_setting_t *t, int n, const char *source)
+void mob_read_db_additional_fields(struct mob_db *entry, struct config_setting_t *t, int n, const char *source)
{
// do nothing. plugins can do own work
}
-bool mob_lookup_const(const config_setting_t *it, const char *name, int *value)
+bool mob_lookup_const(const struct config_setting_t *it, const char *name, int *value)
{
if (libconfig->setting_lookup_int(it, name, value))
{
@@ -4382,7 +4383,7 @@ bool mob_lookup_const(const config_setting_t *it, const char *name, int *value)
return false;
}
-bool mob_get_const(const config_setting_t *it, int *value)
+bool mob_get_const(const struct config_setting_t *it, int *value)
{
const char *str = config_setting_get_string(it);
if (str && *str && script->get_constant(str, value))
@@ -4419,10 +4420,10 @@ void mob_readdb(void) {
int mob_read_libconfig(const char *filename, bool ignore_missing)
{
bool duplicate[MAX_MOB_DB] = { 0 };
- config_t mob_db_conf;
+ struct config_t mob_db_conf;
char filepath[256];
- config_setting_t *mdb;
- config_setting_t *t;
+ struct config_setting_t *mdb;
+ struct config_setting_t *t;
int i = 0, count = 0;
nullpo_ret(filename);
@@ -4431,7 +4432,10 @@ int mob_read_libconfig(const char *filename, bool ignore_missing)
if (ignore_missing && !exists(filepath))
return 0;
- if (libconfig->read_file(&mob_db_conf, filepath) || !(mdb = libconfig->setting_get_member(mob_db_conf.root, "mob_db"))) {
+ if (!libconfig->load_file(&mob_db_conf, filepath))
+ return 0;
+
+ if ((mdb = libconfig->setting_get_member(mob_db_conf.root, "mob_db")) == NULL) {
ShowError("can't read %s\n", filepath);
return 0;
}
diff --git a/src/map/mob.h b/src/map/mob.h
index 9a5239b11..00e2b0723 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -510,16 +510,16 @@ struct mob_interface {
unsigned int (*drop_adjust) (int baserate, int rate_adjust, unsigned short rate_min, unsigned short rate_max);
void (*item_dropratio_adjust) (int nameid, int mob_id, int *rate_adjust);
void (*readdb) (void);
- bool (*lookup_const) (const config_setting_t *it, const char *name, int *value);
- bool (*get_const) (const config_setting_t *it, int *value);
+ bool (*lookup_const) (const struct config_setting_t *it, const char *name, int *value);
+ bool (*get_const) (const struct config_setting_t *it, int *value);
int (*db_validate_entry) (struct mob_db *entry, int n, const char *source);
int (*read_libconfig) (const char *filename, bool ignore_missing);
- void (*read_db_additional_fields) (struct mob_db *entry, config_setting_t *it, int n, const char *source);
- int (*read_db_sub) (config_setting_t *mobt, int id, const char *source);
- void (*read_db_drops_sub) (struct mob_db *entry, config_setting_t *t);
- void (*read_db_mvpdrops_sub) (struct mob_db *entry, config_setting_t *t);
- int (*read_db_mode_sub) (struct mob_db *entry, config_setting_t *t);
- void (*read_db_stats_sub) (struct mob_db *entry, config_setting_t *t);
+ void (*read_db_additional_fields) (struct mob_db *entry, struct config_setting_t *it, int n, const char *source);
+ int (*read_db_sub) (struct config_setting_t *mobt, int id, const char *source);
+ void (*read_db_drops_sub) (struct mob_db *entry, struct config_setting_t *t);
+ void (*read_db_mvpdrops_sub) (struct mob_db *entry, struct config_setting_t *t);
+ int (*read_db_mode_sub) (struct mob_db *entry, struct config_setting_t *t);
+ void (*read_db_stats_sub) (struct mob_db *entry, struct config_setting_t *t);
void (*name_constants) (void);
bool (*readdb_mobavail) (char *str[], int columns, int current);
int (*read_randommonster) (void);
diff --git a/src/map/pc.c b/src/map/pc.c
index 8d1df71a9..fb6fc523c 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -10642,8 +10642,8 @@ int pc_split_atoui(char* str, unsigned int* val, char sep, int max)
*/
void pc_read_skill_tree(void)
{
- config_t skill_tree_conf;
- config_setting_t *skt = NULL;
+ struct config_t skill_tree_conf;
+ struct config_setting_t *skt = NULL;
char config_filename[128];
int i = 0;
struct s_mapiterator *iter;
@@ -10651,14 +10651,12 @@ void pc_read_skill_tree(void)
bool loaded[CLASS_COUNT] = { false };
safesnprintf(config_filename, sizeof(config_filename), "%s/"DBPATH"skill_tree.conf", map->db_path);
- if (libconfig->read_file(&skill_tree_conf, config_filename)) {
- ShowError("can't read %s\n", config_filename);
+ if (!libconfig->load_file(&skill_tree_conf, config_filename))
return;
- }
// Foreach job
while ((skt = libconfig->setting_get_elem(skill_tree_conf.root, i++))) {
- config_setting_t *t = NULL;
+ struct config_setting_t *t = NULL;
int job_idx;
const char *job_name = config_setting_name(skt);
int job_id = pc->check_job_name(job_name);
@@ -10748,11 +10746,11 @@ void pc_read_skill_tree(void)
}
if ((t = libconfig->setting_get_member(skt, "skills")) != NULL) {
int j = 0;
- config_setting_t *sk = NULL;
+ struct config_setting_t *sk = NULL;
// Foreach skill
while ((sk = libconfig->setting_get_elem(t, j++)) != NULL) {
int skill_id, sk_idx;
- config_setting_t *rsk = NULL;
+ struct config_setting_t *rsk = NULL;
const char *sk_name = config_setting_name(sk);
struct skill_tree_entry *tree_entry = NULL;
diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c
index bd46b9616..72935adc3 100644
--- a/src/map/pc_groups.c
+++ b/src/map/pc_groups.c
@@ -63,12 +63,12 @@ static inline GroupSettings* name2group(const char* group_name)
* @private
*/
static void read_config(void) {
- config_t pc_group_config;
- config_setting_t *groups = NULL;
+ struct config_t pc_group_config;
+ struct config_setting_t *groups = NULL;
const char *config_filename = "conf/groups.conf"; // FIXME hardcoded name
int group_count = 0;
- if (libconfig->read_file(&pc_group_config, config_filename))
+ if (!libconfig->load_file(&pc_group_config, config_filename))
return;
groups = libconfig->lookup(&pc_group_config, "groups");
@@ -83,7 +83,7 @@ static void read_config(void) {
int id = 0, level = 0;
const char *groupname = NULL;
int log_commands = 0;
- config_setting_t *group = libconfig->setting_get_elem(groups, i);
+ struct config_setting_t *group = libconfig->setting_get_elem(groups, i);
if (!libconfig->setting_lookup_int(group, "id", &id)) {
ShowConfigWarning(group, "pc_groups:read_config: \"groups\" list member #%d has undefined id, removing...", i);
@@ -106,7 +106,7 @@ static void read_config(void) {
if (!libconfig->setting_lookup_string(group, "name", &groupname)) {
char temp[20];
- config_setting_t *name = NULL;
+ struct config_setting_t *name = NULL;
snprintf(temp, sizeof(temp), "Group %d", id);
if ((name = config_setting_add(group, "name", CONFIG_TYPE_STRING)) == NULL ||
!config_setting_set_string(name, temp)) {
@@ -148,7 +148,7 @@ static void read_config(void) {
// Check if all commands and permissions exist
iter = db_iterator(pcg->db);
for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) {
- config_setting_t *commands = group_settings->commands, *permissions = group_settings->permissions;
+ struct config_setting_t *commands = group_settings->commands, *permissions = group_settings->permissions;
int count = 0;
// Make sure there is "commands" group
@@ -157,7 +157,7 @@ static void read_config(void) {
count = libconfig->setting_length(commands);
for (i = 0; i < count; ++i) {
- config_setting_t *command = libconfig->setting_get_elem(commands, i);
+ struct config_setting_t *command = libconfig->setting_get_elem(commands, i);
const char *name = config_setting_name(command);
if (!atcommand->exists(name)) {
ShowConfigWarning(command, "pc_groups:read_config: non-existent command name '%s', removing...", name);
@@ -173,7 +173,7 @@ static void read_config(void) {
count = libconfig->setting_length(permissions);
for(i = 0; i < count; ++i) {
- config_setting_t *permission = libconfig->setting_get_elem(permissions, i);
+ struct config_setting_t *permission = libconfig->setting_get_elem(permissions, i);
const char *name = config_setting_name(permission);
int j;
@@ -193,7 +193,7 @@ static void read_config(void) {
while (i < group_count) {
iter = db_iterator(pcg->db);
for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) {
- config_setting_t *inherit = NULL,
+ struct config_setting_t *inherit = NULL,
*commands = group_settings->commands,
*permissions = group_settings->permissions;
int j, inherit_count = 0, done = 0;
@@ -258,11 +258,11 @@ static void read_config(void) {
// Pack permissions into GroupSettings.e_permissions for faster checking
iter = db_iterator(pcg->db);
for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) {
- config_setting_t *permissions = group_settings->permissions;
+ struct config_setting_t *permissions = group_settings->permissions;
int count = libconfig->setting_length(permissions);
for (i = 0; i < count; ++i) {
- config_setting_t *perm = libconfig->setting_get_elem(permissions, i);
+ struct config_setting_t *perm = libconfig->setting_get_elem(permissions, i);
const char *name = config_setting_name(perm);
int val = libconfig->setting_get_bool(perm);
int j;
@@ -280,9 +280,9 @@ static void read_config(void) {
// to atcommand->load_group() for processing.
if (group_count > 0) {
GroupSettings **pc_groups = NULL;
- config_setting_t **commands = NULL;
+ struct config_setting_t **commands = NULL;
CREATE(pc_groups, GroupSettings*, group_count);
- CREATE(commands, config_setting_t*, group_count);
+ CREATE(commands, struct config_setting_t*, group_count);
i = 0;
iter = db_iterator(pcg->db);
for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) {
diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h
index 62704fb12..3f95237b7 100644
--- a/src/map/pc_groups.h
+++ b/src/map/pc_groups.h
@@ -22,9 +22,11 @@
#define MAP_PC_GROUPS_H
#include "common/hercules.h"
-#include "common/conf.h"
#include "common/db.h"
+/* Forward Declarations */
+struct config_setting_t;
+
/// PC permissions
enum e_pc_permission {
PC_PERM_NONE = 0, // #0
@@ -66,11 +68,11 @@ struct GroupSettings {
bool log_commands; // groups.[].log_commands
int index; // internal index of the group (contiguous range starting at 0) [Ind]
/// Following are used/available only during config reading
- config_setting_t *commands; // groups.[].commands
- config_setting_t *permissions; // groups.[].permissions
- config_setting_t *inherit; // groups.[].inherit
+ struct config_setting_t *commands; // groups.[].commands
+ struct config_setting_t *permissions; // groups.[].permissions
+ struct config_setting_t *inherit; // groups.[].inherit
bool inheritance_done; // have all inheritance rules been evaluated?
- config_setting_t *root; // groups.[]
+ struct config_setting_t *root; // groups.[]
};
typedef struct GroupSettings GroupSettings;
diff --git a/src/map/quest.c b/src/map/quest.c
index 0dbea56f8..7e2421c79 100644
--- a/src/map/quest.c
+++ b/src/map/quest.c
@@ -425,10 +425,10 @@ int quest_check(struct map_session_data *sd, int quest_id, enum quest_check_type
* @return The parsed quest entry.
* @retval NULL in case of errors.
*/
-struct quest_db *quest_read_db_sub(config_setting_t *cs, int n, const char *source)
+struct quest_db *quest_read_db_sub(struct config_setting_t *cs, int n, const char *source)
{
struct quest_db *entry = NULL;
- config_setting_t *t = NULL;
+ struct config_setting_t *t = NULL;
int i32 = 0, quest_id;
const char *str = NULL;
/*
@@ -477,7 +477,7 @@ struct quest_db *quest_read_db_sub(config_setting_t *cs, int n, const char *sour
for (i = 0; i < len && entry->objectives_count < MAX_QUEST_OBJECTIVES; i++) {
// Note: We ensure that objectives_count < MAX_QUEST_OBJECTIVES because
// quest_log (as well as the client) expect this maximum size.
- config_setting_t *tt = libconfig->setting_get_elem(t, i);
+ struct config_setting_t *tt = libconfig->setting_get_elem(t, i);
int mob_id = 0, count = 0;
if (!tt)
break;
@@ -496,7 +496,7 @@ struct quest_db *quest_read_db_sub(config_setting_t *cs, int n, const char *sour
if ((t=libconfig->setting_get_member(cs, "Drops")) && config_setting_is_list(t)) {
int i, len = libconfig->setting_length(t);
for (i = 0; i < len; i++) {
- config_setting_t *tt = libconfig->setting_get_elem(t, i);
+ struct config_setting_t *tt = libconfig->setting_get_elem(t, i);
int mob_id = 0, nameid = 0, rate = 0;
if (!tt)
break;
@@ -527,13 +527,16 @@ struct quest_db *quest_read_db_sub(config_setting_t *cs, int n, const char *sour
int quest_read_db(void)
{
char filepath[256];
- config_t quest_db_conf;
- config_setting_t *qdb = NULL, *q = NULL;
+ struct config_t quest_db_conf;
+ struct config_setting_t *qdb = NULL, *q = NULL;
int i = 0, count = 0;
const char *filename = "quest_db.conf";
sprintf(filepath, "%s/%s", map->db_path, filename);
- if (libconfig->read_file(&quest_db_conf, filepath) || !(qdb = libconfig->setting_get_member(quest_db_conf.root, "quest_db"))) {
+ if (!libconfig->load_file(&quest_db_conf, filepath))
+ return -1;
+
+ if ((qdb = libconfig->setting_get_member(quest_db_conf.root, "quest_db")) == NULL) {
ShowError("can't read %s\n", filepath);
return -1;
}
diff --git a/src/map/quest.h b/src/map/quest.h
index 8e2cb4e23..e0768ef40 100644
--- a/src/map/quest.h
+++ b/src/map/quest.h
@@ -22,10 +22,11 @@
#define MAP_QUEST_H
#include "common/hercules.h"
-#include "common/conf.h"
#include "common/mmo.h" // enum quest_state
+/* Forward Declarations */
struct block_list;
+struct config_setting_t;
struct map_session_data;
#define MAX_QUEST_DB (60355+1) // Highest quest ID + 1
@@ -77,7 +78,7 @@ struct quest_interface {
int (*check) (struct map_session_data *sd, int quest_id, enum quest_check_type type);
void (*clear) (void);
int (*read_db) (void);
- struct quest_db *(*read_db_sub) (config_setting_t *cs, int n, const char *source);
+ struct quest_db *(*read_db_sub) (struct config_setting_t *cs, int n, const char *source);
};
#ifdef HERCULES_CORE
diff --git a/src/map/script.c b/src/map/script.c
index f3c839555..4b3bf960c 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -55,6 +55,7 @@
#include "map/storage.h"
#include "map/unit.h"
#include "common/cbasetypes.h"
+#include "common/conf.h"
#include "common/memmgr.h"
#include "common/md5calc.h"
#include "common/mmo.h" // NEW_CARTS
@@ -2289,15 +2290,18 @@ void script_set_constant2(const char *name, int value, bool is_parameter, bool i
*/
void read_constdb(void)
{
- config_t constants_conf;
+ struct config_t constants_conf;
char filepath[256];
- config_setting_t *cdb;
- config_setting_t *t;
+ struct config_setting_t *cdb;
+ struct config_setting_t *t;
int i = 0;
sprintf(filepath, "%s/constants.conf", map->db_path);
- if (libconfig->read_file(&constants_conf, filepath) || !(cdb = libconfig->setting_get_member(constants_conf.root, "constants_db"))) {
+ if (!libconfig->load_file(&constants_conf, filepath))
+ return;
+
+ if ((cdb = libconfig->setting_get_member(constants_conf.root, "constants_db")) == NULL) {
ShowError("can't read %s\n", filepath);
return;
}
@@ -4800,9 +4804,9 @@ uint8 script_add_language(const char *name) {
* Goes thru db/translations.conf file
**/
void script_load_translations(void) {
- config_t translations_conf;
+ struct config_t translations_conf;
const char *config_filename = "db/translations.conf"; // FIXME hardcoded name
- config_setting_t *translations = NULL;
+ struct config_setting_t *translations = NULL;
int i, size;
uint32 total = 0;
uint8 lang_id = 0, k;
@@ -4822,12 +4826,10 @@ void script_load_translations(void) {
script->add_language("English");/* 0 is default, which is whatever is in the npc files hardcoded (in our case, English) */
- if (libconfig->read_file(&translations_conf, config_filename)) {
- ShowError("load_translations: can't read '%s'\n", config_filename);
+ if (!libconfig->load_file(&translations_conf, config_filename))
return;
- }
- if( !(translations = libconfig->lookup(&translations_conf, "translations")) ) {
+ if ((translations = libconfig->lookup(&translations_conf, "translations")) == NULL) {
ShowError("load_translations: invalid format on '%s'\n",config_filename);
return;
}
diff --git a/src/map/status.c b/src/map/status.c
index 26db1750b..39df5c693 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -12556,9 +12556,9 @@ int status_get_sc_type(sc_type type) {
return status->dbs->sc_conf[type];
}
-void status_read_job_db_sub(int idx, const char *name, config_setting_t *jdb)
+void status_read_job_db_sub(int idx, const char *name, struct config_setting_t *jdb)
{
- config_setting_t *temp = NULL;
+ struct config_setting_t *temp = NULL;
int i32 = 0;
struct {
@@ -12698,7 +12698,7 @@ void status_read_job_db_sub(int idx, const char *name, config_setting_t *jdb)
if ((temp = libconfig->setting_get_member(jdb, "BaseASPD"))) {
int widx = 0;
- config_setting_t *wpn = NULL;
+ struct config_setting_t *wpn = NULL;
while ((wpn = libconfig->setting_get_elem(temp, widx++))) {
int w, wlen = ARRAYLENGTH(wnames);
const char *wname = config_setting_name(wpn);
@@ -12714,7 +12714,7 @@ void status_read_job_db_sub(int idx, const char *name, config_setting_t *jdb)
if ((temp = libconfig->setting_get_member(jdb, "HPTable"))) {
int level = 0, avg_increment, base;
- config_setting_t *hp = NULL;
+ struct config_setting_t *hp = NULL;
while (level <= MAX_LEVEL && (hp = libconfig->setting_get_elem(temp, level)) != NULL) {
i32 = libconfig->setting_get_int(hp);
status->dbs->HP_table[idx][++level] = min(i32, battle_config.max_hp);
@@ -12734,7 +12734,7 @@ void status_read_job_db_sub(int idx, const char *name, config_setting_t *jdb)
if ((temp = libconfig->setting_get_member(jdb, "SPTable"))) {
int level = 0, avg_increment, base;
- config_setting_t *sp = NULL;
+ struct config_setting_t *sp = NULL;
while (level <= MAX_LEVEL && (sp = libconfig->setting_get_elem(temp, level)) != NULL) {
i32 = libconfig->setting_get_int(sp);
status->dbs->SP_table[idx][++level] = min(i32, battle_config.max_sp);
@@ -12762,18 +12762,17 @@ void status_read_job_db_sub(int idx, const char *name, config_setting_t *jdb)
*------------------------------------------*/
void status_read_job_db(void) { /* [malufett/Hercules] */
int i = 0;
- config_t job_db_conf;
- config_setting_t *jdb = NULL;
+ struct config_t job_db_conf;
+ struct config_setting_t *jdb = NULL;
#ifdef RENEWAL_ASPD
const char *config_filename = "db/re/job_db.conf";
#else
const char *config_filename = "db/pre-re/job_db.conf";
#endif
- if ( libconfig->read_file(&job_db_conf, config_filename) ) {
- ShowError("can't read %s\n", config_filename);
+ if (!libconfig->load_file(&job_db_conf, config_filename))
return;
- }
+
while ( (jdb = libconfig->setting_get_elem(job_db_conf.root, i++)) ) {
int class_, idx;
const char *name = config_setting_name(jdb);
@@ -12833,9 +12832,9 @@ bool status_readdb_sizefix(char* fields[], int columns, int current)
* validation errors.
* @return # of the validated entry, or 0 in case of failure.
*/
-int status_readdb_refine_libconfig_sub(config_setting_t *r, const char *name, const char *source)
+int status_readdb_refine_libconfig_sub(struct config_setting_t *r, const char *name, const char *source)
{
- config_setting_t *rate = NULL;
+ struct config_setting_t *rate = NULL;
int type = REFINE_TYPE_ARMOR, bonus_per_level = 0, rnd_bonus_v = 0, rnd_bonus_lv = 0;
char lv[4];
nullpo_ret(r);
@@ -12866,7 +12865,7 @@ int status_readdb_refine_libconfig_sub(config_setting_t *r, const char *name, co
}
if ((rate=libconfig->setting_get_member(r, "Rates")) != NULL && config_setting_is_group(rate)) {
- config_setting_t *t = NULL;
+ struct config_setting_t *t = NULL;
bool duplicate[MAX_REFINE];
int bonus[MAX_REFINE], rnd_bonus[MAX_REFINE], chance[MAX_REFINE];
int i;
@@ -12926,17 +12925,16 @@ int status_readdb_refine_libconfig_sub(config_setting_t *r, const char *name, co
*/
int status_readdb_refine_libconfig(const char *filename) {
bool duplicate[REFINE_TYPE_MAX];
- config_t refine_db_conf;
- config_setting_t *r;
+ struct config_t refine_db_conf;
+ struct config_setting_t *r;
char filepath[256];
int i = 0, count = 0,type = 0;
sprintf(filepath, "%s/%s", map->db_path, filename);
- memset(&duplicate,0,sizeof(duplicate));
- if( libconfig->read_file(&refine_db_conf, filepath) ) {
- ShowError("can't read %s\n", filepath);
+ if (!libconfig->load_file(&refine_db_conf, filepath))
return 0;
- }
+
+ memset(&duplicate,0,sizeof(duplicate));
while((r = libconfig->setting_get_elem(refine_db_conf.root,i++))) {
char *name = config_setting_name(r);
diff --git a/src/map/status.h b/src/map/status.h
index be6d4c209..85219b280 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -21,11 +21,11 @@
#ifndef MAP_STATUS_H
#define MAP_STATUS_H
-#include "common/conf.h"
#include "common/hercules.h"
#include "common/mmo.h" // NEW_CARTS
struct block_list;
+struct config_setting_t;
struct elemental_data;
struct homun_data;
struct mercenary_data;
@@ -2298,10 +2298,10 @@ struct status_interface {
bool (*readdb_job2) (char *fields[], int columns, int current);
bool (*readdb_sizefix) (char *fields[], int columns, int current);
int (*readdb_refine_libconfig) (const char *filename);
- int (*readdb_refine_libconfig_sub) (config_setting_t *r, const char *name, const char *source);
+ int (*readdb_refine_libconfig_sub) (struct config_setting_t *r, const char *name, const char *source);
bool (*readdb_scconfig) (char *fields[], int columns, int current);
void (*read_job_db) (void);
- void (*read_job_db_sub) (int idx, const char *name, config_setting_t *jdb);
+ void (*read_job_db_sub) (int idx, const char *name, struct config_setting_t *jdb);
};
#ifdef HERCULES_CORE