Skip to content

Commit

Permalink
prevent moving/dropping the pet egg if it's hatched (#4179)
Browse files Browse the repository at this point in the history
Fixes #4178
  • Loading branch information
sader1992 authored and Lemongrass3110 committed Jul 7, 2019
1 parent 87b8581 commit 454163c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/map/itemdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,12 @@ bool itemdb_isrestricted(struct item* item, int gmlv, int gmlv2, bool (*func)(st
return true;
}

bool itemdb_ishatched_egg(struct item* item) {
if (item && item->card[0] == CARD0_PET && item->attribute == 1)
return true;
return false;
}

/** Specifies if item-type should drop unidentified.
* @param nameid ID of item
*/
Expand Down
1 change: 1 addition & 0 deletions src/map/itemdb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@ bool itemdb_canguildstore_sub(struct item_data *itd, int gmlv, int unused);
bool itemdb_canmail_sub(struct item_data *itd, int gmlv, int unused);
bool itemdb_canauction_sub(struct item_data *itd, int gmlv, int unused);
bool itemdb_isrestricted(struct item* item, int gmlv, int gmlv2, bool (*func)(struct item_data*, int, int));
bool itemdb_ishatched_egg(struct item* item);
#define itemdb_isdropable(item, gmlv) itemdb_isrestricted(item, gmlv, 0, itemdb_isdropable_sub)
#define itemdb_cantrade(item, gmlv, gmlv2) itemdb_isrestricted(item, gmlv, gmlv2, itemdb_cantrade_sub)
#define itemdb_canpartnertrade(item, gmlv, gmlv2) itemdb_isrestricted(item, gmlv, gmlv2, itemdb_canpartnertrade_sub)
Expand Down
3 changes: 3 additions & 0 deletions src/map/mail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ enum mail_attach_result mail_setitem(struct map_session_data *sd, short idx, uin
if( idx < 0 || idx >= MAX_INVENTORY || sd->inventory_data[idx] == nullptr )
return MAIL_ATTACH_ERROR;

if (itemdb_ishatched_egg(&sd->inventory.u.items_inventory[idx]))
return MAIL_ATTACH_ERROR;

if( sd->inventory.u.items_inventory[idx].equipSwitch ){
return MAIL_ATTACH_EQUIPSWITCH;
}
Expand Down
9 changes: 8 additions & 1 deletion src/map/pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,9 @@ bool pc_can_sell_item(struct map_session_data *sd, struct item *item, enum npc_s
return false;
}

if (itemdb_ishatched_egg(item))
return false;

switch (shoptype) {
case NPCTYPE_SHOP:
if (item->bound && battle_config.allow_bound_sell&ISR_BOUND_SELLABLE && (
Expand Down Expand Up @@ -5359,6 +5362,10 @@ enum e_additem_result pc_cart_additem(struct map_session_data *sd,struct item *i

if(item->nameid == 0 || amount <= 0)
return ADDITEM_INVALID;

if (itemdb_ishatched_egg(item))
return ADDITEM_INVALID;

data = itemdb_search(item->nameid);

if( data->stack.cart && amount > data->stack.amount )
Expand Down Expand Up @@ -9374,7 +9381,7 @@ void pc_setmadogear(struct map_session_data* sd, int flag)
*------------------------------------------*/
bool pc_candrop(struct map_session_data *sd, struct item *item)
{
if( item && (item->expire_time || (item->bound && !pc_can_give_bounded_items(sd))) )
if( item && ((item->expire_time || (item->bound && !pc_can_give_bounded_items(sd))) || (itemdb_ishatched_egg(item))) )
return false;
if( !pc_can_give_items(sd) || sd->sc.cant.drop) //check if this GM level can drop items
return false;
Expand Down
3 changes: 3 additions & 0 deletions src/map/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ static enum e_storage_add storage_canAddItem(struct s_storage *stor, int idx, st
if (amount < 1 || amount > items[idx].amount)
return STORAGE_ADD_INVALID;

if (itemdb_ishatched_egg(&items[idx]))
return STORAGE_ADD_INVALID;

if (!stor->state.put)
return STORAGE_ADD_NOACCESS;

Expand Down
3 changes: 3 additions & 0 deletions src/map/trade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount)
return;
}

if (itemdb_ishatched_egg(item))
return;

if( item->expire_time ) { // Rental System
clif_displaymessage (sd->fd, msg_txt(sd,260));
clif_tradeitemok(sd, index+2, 1);
Expand Down

0 comments on commit 454163c

Please sign in to comment.