diff --git a/sql-files/upgrades/upgrade_20200703.sql b/sql-files/upgrades/upgrade_20200703.sql new file mode 100644 index 0000000000..205de5191f --- /dev/null +++ b/sql-files/upgrades/upgrade_20200703.sql @@ -0,0 +1,103 @@ +-- Fix rename flag and intimacy in inventories +update `inventory` `i` +inner join `pet` `p` +on + `i`.`card0` = 256 +and + ( `i`.`card1` | ( `i`.`card2` << 16 ) ) = `p`.`pet_id` +set + `i`.`card3` = + ( + CASE + WHEN `p`.`intimate` < 100 THEN + 1 -- awkward + WHEN `p`.`intimate` < 250 THEN + 2 -- shy + WHEN `p`.`intimate` < 750 THEN + 3 -- neutral + WHEN `p`.`intimate` < 910 THEN + 4 -- cordial + WHEN `p`.`intimate` <= 1000 THEN + 5 -- loyal + ELSE 0 -- unrecognized + END << 1 + ) | `p`.`rename_flag` +; + +-- Fix rename flag and intimacy in carts +update `cart_inventory` `i` +inner join `pet` `p` +on + `i`.`card0` = 256 +and + ( `i`.`card1` | ( `i`.`card2` << 16 ) ) = `p`.`pet_id` +set + `i`.`card3` = + ( + CASE + WHEN `p`.`intimate` < 100 THEN + 1 -- awkward + WHEN `p`.`intimate` < 250 THEN + 2 -- shy + WHEN `p`.`intimate` < 750 THEN + 3 -- neutral + WHEN `p`.`intimate` < 910 THEN + 4 -- cordial + WHEN `p`.`intimate` <= 1000 THEN + 5 -- loyal + ELSE 0 -- unrecognized + END << 1 + ) | `p`.`rename_flag` +; + +-- Fix rename flag and intimacy in storages +update `storage` `i` +inner join `pet` `p` +on + `i`.`card0` = 256 +and + ( `i`.`card1` | ( `i`.`card2` << 16 ) ) = `p`.`pet_id` +set + `i`.`card3` = + ( + CASE + WHEN `p`.`intimate` < 100 THEN + 1 -- awkward + WHEN `p`.`intimate` < 250 THEN + 2 -- shy + WHEN `p`.`intimate` < 750 THEN + 3 -- neutral + WHEN `p`.`intimate` < 910 THEN + 4 -- cordial + WHEN `p`.`intimate` <= 1000 THEN + 5 -- loyal + ELSE 0 -- unrecognized + END << 1 + ) | `p`.`rename_flag` +; + +-- Fix rename flag and intimacy in guild storages +update `guild_storage` `i` +inner join `pet` `p` +on + `i`.`card0` = 256 +and + ( `i`.`card1` | ( `i`.`card2` << 16 ) ) = `p`.`pet_id` +set + `i`.`card3` = + ( + CASE + WHEN `p`.`intimate` < 100 THEN + 1 -- awkward + WHEN `p`.`intimate` < 250 THEN + 2 -- shy + WHEN `p`.`intimate` < 750 THEN + 3 -- neutral + WHEN `p`.`intimate` < 910 THEN + 4 -- cordial + WHEN `p`.`intimate` <= 1000 THEN + 5 -- loyal + ELSE 0 -- unrecognized + END << 1 + ) | `p`.`rename_flag` +; diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 81a8bc4690..3e28c7ce11 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -5968,7 +5968,7 @@ void getring (struct map_session_data* sd) memset(&item_tmp, 0, sizeof(item_tmp)); item_tmp.nameid = item_id; item_tmp.identify = 1; - item_tmp.card[0] = 255; + item_tmp.card[0] = CARD0_FORGE; item_tmp.card[2] = sd->status.partner_id; item_tmp.card[3] = sd->status.partner_id >> 16; @@ -8957,7 +8957,7 @@ ACMD_FUNC(itemlist) StringBuf_Clear(&buf); if( it->card[0] == CARD0_PET ) { // pet egg - if (it->card[3]) + if (it->card[3]&1) StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named) else StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed) diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 7518393b71..e02c74da73 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -2575,8 +2575,11 @@ static void clif_addcards( struct EQUIPSLOTINFO* buf, struct item* item ){ if( item->card[0] == CARD0_PET ){ buf->card[0] = 0; buf->card[1] = 0; - buf->card[2] = 0; - buf->card[3] = item->card[3]; //Pet renamed flag. + // Pet intimacy + // No idea when this was added exactly, but older clients have no problem if we send it anyway + buf->card[2] = item->card[3] >> 1; + // Pet renamed flag + buf->card[3] = item->card[3] & 1; return; } diff --git a/src/map/pet.cpp b/src/map/pet.cpp index 8e8baf3c6a..00cfd980ff 100644 --- a/src/map/pet.cpp +++ b/src/map/pet.cpp @@ -593,6 +593,28 @@ int pet_hungry_val(struct pet_data *pd) return 0; } +int16 pet_get_card3_intimacy( int intimacy ){ + if( intimacy < PET_INTIMATE_SHY ){ + // Awkward + return ( 1 << 1 ); + }else if( intimacy < PET_INTIMATE_NEUTRAL ){ + // Shy + return ( 2 << 1 ); + }else if( intimacy < PET_INTIMATE_CORDIAL ){ + // Neutral + return ( 3 << 1 ); + }else if( intimacy < PET_INTIMATE_LOYAL ){ + // Cordial + return ( 4 << 1 ); + }else if( intimacy <= PET_INTIMATE_MAX ){ + // Loyal + return ( 5 << 1 ); + }else{ + // Unknown + return 0; + } +} + /** * Set the value of the pet's intimacy. * @param pd : pet requesting @@ -606,8 +628,16 @@ void pet_set_intimate(struct pet_data *pd, int value) struct map_session_data *sd = pd->master; - if(pd->pet.intimate <= PET_INTIMATE_NONE) - pc_delitem(sd, pet_egg_search(sd, pd->pet.pet_id), 1, 0, 0, LOG_TYPE_OTHER); + int index = pet_egg_search( sd, pd->pet.pet_id ); + + if( pd->pet.intimate <= PET_INTIMATE_NONE ){ + pc_delitem( sd, index, 1, 0, 0, LOG_TYPE_OTHER ); + }else{ + // Remove everything except the rename flag + sd->inventory.u.items_inventory[index].card[3] &= 1; + + sd->inventory.u.items_inventory[index].card[3] |= pet_get_card3_intimacy( pd->pet.intimate ); + } if (sd) status_calc_pc(sd,SCO_NONE); @@ -1297,6 +1327,7 @@ bool pet_get_egg(uint32 account_id, short pet_class, int pet_id ) { tmp_item.card[1] = GetWord(pet_id,0); tmp_item.card[2] = GetWord(pet_id,1); tmp_item.card[3] = 0; //New pets are not named. + tmp_item.card[3] |= pet_get_card3_intimacy( pet->intimate ); // Store intimacy status based on initial intimacy if((ret = pc_additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER))) { clif_additem(sd,0,0,ret); @@ -1401,6 +1432,12 @@ int pet_change_name_ack(struct map_session_data *sd, char* name, int flag) clif_pet_equip_area(pd); clif_send_petstatus(sd); + int index = pet_egg_search( sd, pd->pet.pet_id ); + + if( index >= 0 ){ + sd->inventory.u.items_inventory[index].card[3] |= 1; + } + return 1; }