From f71c45257cf0aa0d45c19045f4c91e9189cd25e2 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Fri, 14 Feb 2020 23:59:51 +0100 Subject: Change EggItem field in pet DB to be mandatory --- src/map/pet.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/map/pet.c b/src/map/pet.c index dbbce7e04..ba873dd4b 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -1365,19 +1365,23 @@ static int pet_read_db_sub(struct config_setting_t *it, int n, const char *sourc } safestrncpy(pet->db[n].jname, str, sizeof(pet->db[n].jname)); - if (libconfig->setting_lookup_string(it, "TamingItem", &str)) { - if (!(data = itemdb->name2id(str))) { - ShowWarning("pet_read_db_sub: Invalid item '%s' in pet %d of \"%s\", defaulting to 0.\n", str, pet->db[n].class_, source); - } else { - pet->db[n].itemID = data->nameid; - } + if (libconfig->setting_lookup_string(it, "EggItem", &str) == CONFIG_FALSE || *str == '\0') { + ShowWarning("pet_read_db_sub: Missing EggItem in pet %d of \"%s\", skipping.\n", pet->db[n].class_, source); + return 0; } - if (libconfig->setting_lookup_string(it, "EggItem", &str)) { + if ((data = itemdb->name2id(str)) == NULL) { + ShowWarning("pet_read_db_sub: Invalid EggItem '%s' in pet %d of \"%s\", skipping.\n", str, pet->db[n].class_, source); + return 0; + } + + pet->db[n].EggID = data->nameid; + + if (libconfig->setting_lookup_string(it, "TamingItem", &str)) { if (!(data = itemdb->name2id(str))) { ShowWarning("pet_read_db_sub: Invalid item '%s' in pet %d of \"%s\", defaulting to 0.\n", str, pet->db[n].class_, source); } else { - pet->db[n].EggID = data->nameid; + pet->db[n].itemID = data->nameid; } } -- cgit v1.2.3-70-g09d2