summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/pre-re/pet_db.conf2
-rw-r--r--db/re/pet_db.conf2
-rw-r--r--src/map/pet.c20
3 files changed, 14 insertions, 10 deletions
diff --git a/db/pre-re/pet_db.conf b/db/pre-re/pet_db.conf
index 28847bc78..d80434f46 100644
--- a/db/pre-re/pet_db.conf
+++ b/db/pre-re/pet_db.conf
@@ -35,9 +35,9 @@ pet_db:(
// ================ Mandatory fields ==============================
Id: ID (int)
Name: "Pet Name" (string)
+ EggItem: Egg Id (string, defaults to 0)
// ================ Optional fields ===============================
TamingItem: Taming Item (string, defaults to 0)
- EggItem: Egg Id (string, defaults to 0)
AccessoryItem: Equipment Id (string, defaults to 0)
FoodItem: Food Id (string, defaults to 0)
FoodEffectiveness: hunger points (int, defaults to 0)
diff --git a/db/re/pet_db.conf b/db/re/pet_db.conf
index 17d3bad2c..3a1ceb5e0 100644
--- a/db/re/pet_db.conf
+++ b/db/re/pet_db.conf
@@ -35,9 +35,9 @@ pet_db:(
// ================ Mandatory fields ==============================
Id: ID (int)
Name: "Pet Name" (string)
+ EggItem: Egg Id (string, defaults to 0)
// ================ Optional fields ===============================
TamingItem: Taming Item (string, defaults to 0)
- EggItem: Egg Id (string, defaults to 0)
AccessoryItem: Equipment Id (string, defaults to 0)
FoodItem: Food Id (string, defaults to 0)
FoodEffectiveness: hunger points (int, defaults to 0)
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;
}
}