summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
authorKenpachi Developer <Kenpachi.Developer@gmx.de>2020-02-15 10:47:15 +0100
committerHaru <haru@dotalux.com>2020-04-05 21:20:35 +0200
commit6c8b9ea316d231fe045d6cac7156b5804277e6f4 (patch)
tree870e5dae669bf1fabbc8c76c4ca894fc55d5f4da /src/map/atcommand.c
parent3ec0863d06c804028cc2caf237c60bb4d7b5a6a7 (diff)
downloadhercules-6c8b9ea316d231fe045d6cac7156b5804277e6f4.tar.gz
hercules-6c8b9ea316d231fe045d6cac7156b5804277e6f4.tar.bz2
hercules-6c8b9ea316d231fe045d6cac7156b5804277e6f4.tar.xz
hercules-6c8b9ea316d231fe045d6cac7156b5804277e6f4.zip
Apply code style to ACMD(makeegg) function
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c55
1 files changed, 31 insertions, 24 deletions
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 <pet>
+ * @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 <pet>).
+ if (*message == '\0') {
+ clif->message(fd, msg_fd(fd, 1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
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;
}