summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorIbrahim Zidan <brahem@aotsw.com>2019-04-09 20:07:37 +0200
committerIbrahim Zidan <brahem@aotsw.com>2019-04-09 20:07:37 +0200
commite700c49e7cb2c3de678c697b342768824d1df664 (patch)
treeffa5dc9d89bdbd7869a50f48c07cf760ee084e98 /src/map
parentab81d4012eac5c2c00c485971fc9b89bf69761be (diff)
downloadhercules-e700c49e7cb2c3de678c697b342768824d1df664.tar.gz
hercules-e700c49e7cb2c3de678c697b342768824d1df664.tar.bz2
hercules-e700c49e7cb2c3de678c697b342768824d1df664.tar.xz
hercules-e700c49e7cb2c3de678c697b342768824d1df664.zip
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.
Diffstat (limited to 'src/map')
-rw-r--r--src/map/pet.c15
1 files changed, 15 insertions, 0 deletions
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);