From dea96bda4ba64b7bec3738bd5ab93ee435caa717 Mon Sep 17 00:00:00 2001 From: Haru Date: Tue, 20 Oct 2015 12:31:00 +0200 Subject: Fixed an issue preventing the mob_db2 from being loaded Follow-up to 3feef93 (thanks to kyeme) Signed-off-by: Haru --- src/map/mob.c | 13 +++++-------- src/map/mob.h | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'src/map') diff --git a/src/map/mob.c b/src/map/mob.c index a94abbd97..94d68df88 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -4256,19 +4256,13 @@ void mob_readdb(void) { int i; for (i = 0; i < ARRAYLENGTH(filename); ++i) { - if (i > 0) { - if (!exists(filename[i])) { - continue; - } - } - - mob->read_libconfig(filename[i]); + mob->read_libconfig(filename[i], i > 0 ? true : false); } mob->name_constants(); } -int mob_read_libconfig(const char *filename) +int mob_read_libconfig(const char *filename, bool ignore_missing) { config_t mob_db_conf; char filepath[256]; @@ -4279,6 +4273,9 @@ int mob_read_libconfig(const char *filename) nullpo_ret(filename); sprintf(filepath, "%s/%s", map->db_path, filename); + 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"))) { ShowError("can't read %s\n", filepath); return -1; diff --git a/src/map/mob.h b/src/map/mob.h index c20453cde..cc81c2fc3 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -366,7 +366,7 @@ struct mob_interface { 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); - int (*read_libconfig) (const char *filename); + int (*read_libconfig) (const char *filename, bool ignore_missing); void (*read_db_additional_fields) (struct mob_db *entry, int class_, config_setting_t *it, int n, const char *source); bool (*read_db_sub) (config_setting_t *mobt, int id, const char *source); void (*read_db_drops_sub) (struct mob_db *entry, struct status_data *mstatus, int class_, config_setting_t *t); -- cgit v1.2.3-70-g09d2