diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/atcommand.c | 6 | ||||
-rw-r--r-- | src/map/battleground.c | 2 | ||||
-rw-r--r-- | src/map/channel.c | 2 | ||||
-rw-r--r-- | src/map/clif.c | 8 | ||||
-rw-r--r-- | src/map/itemdb.c | 21 | ||||
-rw-r--r-- | src/map/map.c | 2 | ||||
-rw-r--r-- | src/map/mob.c | 5 | ||||
-rw-r--r-- | src/map/pc.c | 4 | ||||
-rw-r--r-- | src/map/pc_groups.c | 2 | ||||
-rw-r--r-- | src/map/quest.c | 5 | ||||
-rw-r--r-- | src/map/script.c | 11 | ||||
-rw-r--r-- | src/map/status.c | 12 |
12 files changed, 39 insertions, 41 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index bc539837d..3966ff2f1 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -3615,14 +3615,14 @@ ACMD(reloadskilldb) ACMD(reloadatcommand) { 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; } @@ -10012,7 +10012,7 @@ void atcommand_config_read(const char* config_filename) { 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 diff --git a/src/map/battleground.c b/src/map/battleground.c index e3fedbf34..995122d52 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -334,7 +334,7 @@ void bg_config_read(void) { 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"); diff --git a/src/map/channel.c b/src/map/channel.c index d778b355d..c1b28fd84 100644 --- a/src/map/channel.c +++ b/src/map/channel.c @@ -593,7 +593,7 @@ void read_channels_config(void) 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"); diff --git a/src/map/clif.c b/src/map/clif.c index 3b2f255ef..5b9e9c99e 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -17317,10 +17317,8 @@ 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"); @@ -18377,10 +18375,8 @@ 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 ) { diff --git a/src/map/itemdb.c b/src/map/itemdb.c index bd552dd16..83535f294 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -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) ); @@ -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) ); @@ -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); @@ -1885,13 +1879,18 @@ int itemdb_readdb_libconfig(const char *filename) { 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/map.c b/src/map/map.c index 3dad25fce..3089f7ce0 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -4990,7 +4990,7 @@ void read_map_zone_db(void) { #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"); diff --git a/src/map/mob.c b/src/map/mob.c index 86f3ddc0d..fc6e23427 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -4431,7 +4431,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/pc.c b/src/map/pc.c index 8d1df71a9..8fe1b7c57 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -10651,10 +10651,8 @@ 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++))) { diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index bd46b9616..5a86030fc 100644 --- a/src/map/pc_groups.c +++ b/src/map/pc_groups.c @@ -68,7 +68,7 @@ static void read_config(void) { 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"); diff --git a/src/map/quest.c b/src/map/quest.c index 0dbea56f8..9af7c8ea2 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -533,7 +533,10 @@ int quest_read_db(void) 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/script.c b/src/map/script.c index f3c839555..eb8879a2a 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2297,7 +2297,10 @@ void read_constdb(void) 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; } @@ -4822,12 +4825,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..32f7bc2d8 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -12770,10 +12770,9 @@ void status_read_job_db(void) { /* [malufett/Hercules] */ 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); @@ -12932,11 +12931,10 @@ int status_readdb_refine_libconfig(const char *filename) { 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); |