From 6c8b9ea316d231fe045d6cac7156b5804277e6f4 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Sat, 15 Feb 2020 10:47:15 +0100 Subject: Apply code style to ACMD(makeegg) function --- src/map/atcommand.c | 55 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index c84f14785..7e5e4a018 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -2744,42 +2744,49 @@ ACMD(guildlevelup) return true; } -/*========================================== +/** + * Creates a pet egg in the character's inventory. * - *------------------------------------------*/ + * @code{.herc} + * @makeegg + * @endcode + * + **/ ACMD(makeegg) { - struct item_data *item_data; - int id, pet_id; - - if (!*message) { - clif->message(fd, msg_fd(fd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg ). + if (*message == '\0') { + clif->message(fd, msg_fd(fd, 1015)); // Please enter a monster/egg name/ID (usage: @makeegg ). return false; } - if ((item_data = itemdb->search_name(message)) != NULL) // for egg name + struct item_data *item_data = itemdb->search_name(message); + int id; + + if (item_data != NULL) { // Egg name. id = item_data->nameid; - else - if ((id = mob->db_searchname(message)) != 0) // for monster name - ; - else - id = atoi(message); + } else { + id = mob->db_searchname(message); // Monster name. + + if (id == 0) + id = atoi(message); // Egg/monster ID. + } + + int pet_id = pet->search_petDB_index(id, PET_CLASS); - pet_id = pet->search_petDB_index(id, PET_CLASS); - if (pet_id < 0) + if (pet_id == INDEX_NOT_FOUND) pet_id = pet->search_petDB_index(id, PET_EGG); - if (pet_id >= 0) { - sd->catch_target_class = pet->db[pet_id].class_; - intif->create_pet( - sd->status.account_id, sd->status.char_id, - pet->db[pet_id].class_, mob->db(pet->db[pet_id].class_)->lv, - pet->db[pet_id].EggID, 0, (short)pet->db[pet_id].intimate, - PET_HUNGER_STUFFED, 0, 1, pet->db[pet_id].jname); - } else { - clif->message(fd, msg_fd(fd,180)); // The monster/egg name/id doesn't exist. + + if (pet_id == INDEX_NOT_FOUND) { + clif->message(fd, msg_fd(fd, 180)); // The monster/egg name/ID doesn't exist. return false; } + sd->catch_target_class = pet->db[pet_id].class_; + intif->create_pet(sd->status.account_id, sd->status.char_id, pet->db[pet_id].class_, + mob->db(pet->db[pet_id].class_)->lv, pet->db[pet_id].EggID, 0, + (short)pet->db[pet_id].intimate, PET_HUNGER_STUFFED, + 0, 1,pet->db[pet_id].jname); + return true; } -- cgit v1.2.3-70-g09d2