From e700c49e7cb2c3de678c697b342768824d1df664 Mon Sep 17 00:00:00 2001 From: Ibrahim Zidan Date: Tue, 9 Apr 2019 20:07:37 +0200 Subject: Automatically migrate pets to the new system that keeps hatched eggs in the inventory - The pet evolution update caused all already hatched eggs to get lost cause the previous system would actually remove the egg unlike the new one, this code will ensure the return of it. --- src/map/pet.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/map/pet.c b/src/map/pet.c index 96fe63c51..ce26b6cb1 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -348,6 +348,21 @@ static int pet_return_egg(struct map_session_data *sd, struct pet_data *pd) if (i != sd->status.inventorySize) { sd->status.inventory[i].attribute &= ~ATTR_BROKEN; sd->status.inventory[i].bound = IBT_NONE; + } else { + // The pet egg wasn't found: it was probably hatched with the old system that deleted the egg. + struct item tmp_item = {0}; + int flag; + + tmp_item.nameid = pd->petDB->EggID; + tmp_item.identify = 1; + tmp_item.card[0] = CARD0_PET; + tmp_item.card[1] = GetWord(pd->pet.pet_id, 0); + tmp_item.card[2] = GetWord(pd->pet.pet_id, 1); + tmp_item.card[3] = pd->pet.rename_flag; + if ((flag = pc->additem(sd, &tmp_item, 1, LOG_TYPE_EGG)) != 0) { + clif->additem(sd, 0, 0, flag); + map->addflooritem(&sd->bl, &tmp_item, 1, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0, false); + } } #if PACKETVER >= 20180704 clif->inventoryList(sd); -- cgit v1.2.3-60-g2f50