From eb9ae813b584f0df32b2eb5c8d307ac6a0a90210 Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Sat, 4 Jan 2020 03:22:10 +0100 Subject: [PATCH] Fixed pet eggs as mail attachments (#4506) Fixes #4327 Thanks to @RadianFord --- src/map/mail.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/map/mail.cpp b/src/map/mail.cpp index 780dc08d80..9148a6a7b8 100644 --- a/src/map/mail.cpp +++ b/src/map/mail.cpp @@ -16,6 +16,7 @@ #include "itemdb.hpp" #include "log.hpp" #include "pc.hpp" +#include "pet.hpp" void mail_clear(struct map_session_data *sd) { @@ -289,7 +290,22 @@ void mail_getattachment(struct map_session_data* sd, struct mail_message* msg, i for( i = 0; i < MAIL_MAX_ITEM; i++ ){ if( item->nameid > 0 && item->amount > 0 ){ - pc_additem(sd, &item[i], item[i].amount, LOG_TYPE_MAIL); + // If no card or special card id is set + if( item[i].card[0] == 0 ){ + // Check if it is a pet egg + std::shared_ptr pet = pet_db_search( item[i].nameid, PET_EGG ); + + // If it is a pet egg and the card data does not contain a pet id (see if clause above) + if( pet != nullptr ){ + // Create a new pet + pet_create_egg( sd, item[i].nameid ); + item_received = true; + continue; + } + } + + // Add the item normally + pc_additem( sd, &item[i], item[i].amount, LOG_TYPE_MAIL ); item_received = true; } }