From 95a4d6754449522d3eceacce0f602e206a38b511 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Sat, 28 Jul 2012 03:22:47 +0000 Subject: Added support for the "favorite item tab" feature. super-mega-thanks to Judas, credits to Fatal Error. Be aware this update requires a new column in the inventory db, run upgrade_svn16517.sql in your database. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16518 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/clif.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/map/pc.c | 5 +++-- 2 files changed, 55 insertions(+), 4 deletions(-) (limited to 'src/map') diff --git a/src/map/clif.c b/src/map/clif.c index 0bbeb9361..25b53686a 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2279,7 +2279,7 @@ void clif_item_sub(unsigned char *buf, int n, struct item *i, struct item_data * } } - +void clif_favorite_item(struct map_session_data* sd, unsigned short index); //Unified inventory function which sends all of the inventory (requires two packets, one for equipable items and one for stackable ones. [Skotlex] void clif_inventorylist(struct map_session_data *sd) { @@ -2367,7 +2367,16 @@ void clif_inventorylist(struct map_session_data *sd) WBUFW(bufe,2)=4+ne*se; clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF); } - +#if PACKETVER >= 20111122 + for( i = 0; i < MAX_INVENTORY; i++ ) { + if( sd->status.inventory[i].nameid <= 0 || sd->inventory_data[i] == NULL ) + continue; + + if ( sd->status.inventory[i].favorite ) + clif_favorite_item(sd, i); + } +#endif + if( buf ) aFree(buf); if( bufe ) aFree(bufe); } @@ -16115,6 +16124,45 @@ void clif_parse_SkillSelectMenu(int fd, struct map_session_data *sd) { clif_menuskill_clear(sd); } +/// Move Item from or to Personal Tab (CZ_WHATSOEVER) [FE] +/// 0907 .W +/// +/// R 0908 .w .b +/// type: +/// 0 = move item to personal tab +/// 1 = move item to normal tab +void clif_parse_MoveItem(int fd, struct map_session_data *sd) { +#if PACKETVER >= 20111122 + int index; + + if(pc_isdead(sd)) { + return; + } + index = RFIFOW(fd,2)-2; + if (index < 0 || index >= MAX_INVENTORY) + return; + if (sd->status.inventory[index].favorite && sd->status.inventory[index].favorite == 1) + sd->status.inventory[index].favorite = 0; + else + sd->status.inventory[index].favorite = 1; + + clif_favorite_item(sd, index); +#endif +} + + +/// Items that are in favorite tab of inventory (ZC_ITEM_FAVORITE). +/// 0900 .W .B +void clif_favorite_item(struct map_session_data* sd, unsigned short index) { + int fd = sd->fd; + + WFIFOHEAD(fd,packet_len(0x908)); + WFIFOW(fd,0) = 0x908; + WFIFOW(fd,2) = index+2; + WFIFOL(fd,4) = (sd->status.inventory[index].favorite == 1) ? 0 : 1; + WFIFOSET(fd,packet_len(0x908)); +} + /*========================================== * Main client packet processing function *------------------------------------------*/ @@ -16711,6 +16759,8 @@ static int packetdb_readdb(void) {clif_parse_SearchStoreInfoNextPage,"searchstoreinfonextpage"}, {clif_parse_CloseSearchStoreInfo,"closesearchstoreinfo"}, {clif_parse_SearchStoreInfoListItemClick,"searchstoreinfolistitemclick"}, + /* */ + { clif_parse_MoveItem , "moveitem" }, {NULL,NULL} }; diff --git a/src/map/pc.c b/src/map/pc.c index c697fd046..0f04cc017 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -3812,7 +3812,7 @@ int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reas sd->status.inventory[n].amount -= amount; sd->weight -= sd->inventory_data[n]->weight*amount ; - if(sd->status.inventory[n].amount<=0){ + if( sd->status.inventory[n].amount <= 0 ){ if(sd->status.inventory[n].equip) pc_unequipitem(sd,n,3); memset(&sd->status.inventory[n],0,sizeof(sd->status.inventory[0])); @@ -4267,6 +4267,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun sd->cart_num++; clif_cart_additem(sd,i,amount,0); } + sd->status.cart[i].favorite = 0;/* clear */ log_pick_pc(sd, log_type, amount, &sd->status.cart[i]); sd->cart_weight += w; @@ -4318,7 +4319,7 @@ int pc_putitemtocart(struct map_session_data *sd,int idx,int amount) if( item_data->nameid == 0 || amount < 1 || item_data->amount < amount || sd->state.vending ) return 1; - + if( pc_cart_additem(sd,item_data,amount,LOG_TYPE_NONE) == 0 ) return pc_delitem(sd,idx,amount,0,5,LOG_TYPE_NONE); -- cgit v1.2.3-60-g2f50