diff options
author | Dastgir <dastgirpojee@rocketmail.com> | 2015-08-03 17:08:19 +0530 |
---|---|---|
committer | Dastgir <dastgirpojee@rocketmail.com> | 2015-08-16 18:42:35 +0530 |
commit | 509df4d77031fdd5bbc1364ea4c99516589c018d (patch) | |
tree | a5f58c1cbc3af5f9a43004ac023b9aef919a0a07 /src/map | |
parent | d1f1c93fb7167c2c830e3ceb497feac39fce950b (diff) | |
download | hercules-509df4d77031fdd5bbc1364ea4c99516589c018d.tar.gz hercules-509df4d77031fdd5bbc1364ea4c99516589c018d.tar.bz2 hercules-509df4d77031fdd5bbc1364ea4c99516589c018d.tar.xz hercules-509df4d77031fdd5bbc1364ea4c99516589c018d.zip |
New EquipPackets Support
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/clif.c | 194 | ||||
-rw-r--r-- | src/map/clif.h | 2 | ||||
-rw-r--r-- | src/map/packets.h | 10 | ||||
-rw-r--r-- | src/map/packets_struct.h | 63 |
4 files changed, 188 insertions, 81 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index cc517c24f..53cee6c72 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2229,11 +2229,32 @@ void clif_addcards2(unsigned short *cards, struct item* item) { cards[3] = item->card[i]; } +/** + * Fills in RandomOptions(Bonuses) of items into the buffer + * + * Dummy datais used since this feature isn't supported yet (ITEM_RDM_OPT). + * A maximum of 5 random options can be supported. + * + * @param buf[in,out] The buffer to write to. The pointer must be valid and initialized. + * @param item[in] The source item. + */ +void clif_add_random_options(unsigned char* buf, struct item* item) +{ + int i; + for (i = 0; i < 5; i++){ + WBUFW(buf,i*5+0) = 0; // OptIndex + WBUFW(buf,i*5+2) = 0; // Value + WBUFB(buf,i*5+4) = 0; // Param1 + } +} + /// Notifies the client, about a received inventory item or the result of a pick-up request. /// 00a0 <index>.W <amount>.W <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W <equip location>.W <item type>.B <result>.B (ZC_ITEM_PICKUP_ACK) /// 029a <index>.W <amount>.W <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W <equip location>.W <item type>.B <result>.B <expire time>.L (ZC_ITEM_PICKUP_ACK2) /// 02d4 <index>.W <amount>.W <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W <equip location>.W <item type>.B <result>.B <expire time>.L <bindOnEquipType>.W (ZC_ITEM_PICKUP_ACK3) +/// 0990 <index>.W <amount>.W <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W <equip location>.L <item type>.B <result>.B <expire time>.L <bindOnEquipType>.W (ZC_ITEM_PICKUP_ACK_V5) +/// 0a0c <index>.W <amount>.W <name id>.W <identified>.B <damaged>.B <refine>.B <card1>.W <card2>.W <card3>.W <card4>.W <equip location>.L <item type>.B <result>.B <expire time>.L <bindOnEquipType>.W (ZC_ITEM_PICKUP_ACK_V6) void clif_additem(struct map_session_data *sd, int n, int amount, int fail) { struct packet_additem p; nullpo_retv(sd); @@ -2249,6 +2270,9 @@ void clif_additem(struct map_session_data *sd, int n, int amount, int fail) { p.count = amount; if( !fail ) { +#if PACKETVER >= 20150226 + int i; +#endif if( n < 0 || n >= MAX_INVENTORY || sd->status.inventory[n].nameid <=0 || sd->inventory_data[n] == NULL ) return; @@ -2272,6 +2296,13 @@ void clif_additem(struct map_session_data *sd, int n, int amount, int fail) { */ p.bindOnEquipType = sd->status.inventory[n].bound && !itemdb->isstackable2(sd->inventory_data[n]) ? 2 : sd->inventory_data[n]->flag.bindonequip ? 1 : 0; #endif +#if PACKETVER >= 20150226 + for (i=0; i<5; i++){ + p.option_data[i].index = 0; + p.option_data[i].value = 0; + p.option_data[i].param = 0; + } +#endif } p.result = (unsigned char)fail; @@ -2345,7 +2376,9 @@ void clif_item_sub(unsigned char *buf, int n, struct item *i, struct item_data * } void clif_item_equip(short idx, struct EQUIPITEM_INFO *p, struct item *i, struct item_data *id, int eqp_pos) { - +#if PACKETVER >= 20150226 + int j; +#endif p->index = idx; if (id->view_id > 0) @@ -2387,6 +2420,15 @@ void clif_item_equip(short idx, struct EQUIPITEM_INFO *p, struct item *i, struct p->Flag.PlaceETCTab = i->favorite ? 1 : 0; p->Flag.SpareBits = 0; #endif + +#if PACKETVER >= 20150226 + p->option_count = 0; + for (j=0; j<5; j++){ + p->option_data[j].index = 0; + p->option_data[j].value = 0; + p->option_data[j].param = 0; + } +#endif } void clif_item_normal(short idx, struct NORMALITEM_INFO *p, struct item *i, struct item_data *id) { p->index = idx; @@ -3754,18 +3796,13 @@ void clif_tradeadditem(struct map_session_data* sd, struct map_session_data* tsd { int fd; unsigned char *buf; -#if PACKETVER < 20100223 - const int cmd = 0xe9; -#else - const int cmd = 0x80f; -#endif nullpo_retv(sd); nullpo_retv(tsd); fd = tsd->fd; buf = WFIFOP(fd,0); - WFIFOHEAD(fd,packet_len(cmd)); - WBUFW(buf,0) = cmd; + WFIFOHEAD(fd,packet_len(tradeaddType)); + WBUFW(buf,0) = tradeaddType; if( index == 0 ) { #if PACKETVER < 20100223 @@ -3784,6 +3821,9 @@ void clif_tradeadditem(struct map_session_data* sd, struct map_session_data* tsd WBUFW(buf,13)= 0; //card (4w) WBUFW(buf,15)= 0; //card (4w) WBUFW(buf,17)= 0; //card (4w) +#if PACKETVER >= 20150226 + clif->add_random_options(WBUFP(buf, 19), &sd->status.inventory[index]); +#endif } else { @@ -3807,8 +3847,11 @@ void clif_tradeadditem(struct map_session_data* sd, struct map_session_data* tsd WBUFB(buf,9) = sd->status.inventory[index].attribute; // attribute WBUFB(buf,10)= sd->status.inventory[index].refine; //refine clif->addcards(WBUFP(buf, 11), &sd->status.inventory[index]); +#if PACKETVER >= 20150226 + clif->add_random_options(WBUFP(buf, 19), &sd->status.inventory[index]); +#endif } - WFIFOSET(fd,packet_len(cmd)); + WFIFOSET(fd,packet_len(tradeaddType)); } @@ -3919,36 +3962,31 @@ void clif_updatestorageamount(struct map_session_data* sd, int amount, int max_a void clif_storageitemadded(struct map_session_data* sd, struct item* i, int index, int amount) { int view,fd; + short j = 0; nullpo_retv(sd); nullpo_retv(i); fd=sd->fd; view = itemdb_viewid(i->nameid); -#if PACKETVER < 5 - WFIFOHEAD(fd,packet_len(0xf4)); - WFIFOW(fd, 0) = 0xf4; // Storage item added - WFIFOW(fd, 2) = index+1; // index - WFIFOL(fd, 4) = amount; // amount - WFIFOW(fd, 8) = ( view > 0 ) ? view : i->nameid; // id - WFIFOB(fd,10) = i->identify; //identify flag - WFIFOB(fd,11) = i->attribute; // attribute - WFIFOB(fd,12) = i->refine; //refine - clif->addcards(WFIFOP(fd,13), i); - WFIFOSET(fd,packet_len(0xf4)); -#else - WFIFOHEAD(fd,packet_len(0x1c4)); - WFIFOW(fd, 0) = 0x1c4; // Storage item added + + WFIFOHEAD(fd,packet_len(storageaddType)); + WFIFOW(fd, 0) = storageaddType; // Storage item added WFIFOW(fd, 2) = index+1; // index WFIFOL(fd, 4) = amount; // amount WFIFOW(fd, 8) = ( view > 0 ) ? view : i->nameid; // id +#if PACKETVER >= 5 WFIFOB(fd,10) = itemtype(itemdb_type(i->nameid)); //type - WFIFOB(fd,11) = i->identify; //identify flag - WFIFOB(fd,12) = i->attribute; // attribute - WFIFOB(fd,13) = i->refine; //refine - clif->addcards(WFIFOP(fd,14), i); - WFIFOSET(fd,packet_len(0x1c4)); + j += 1; #endif + WFIFOB(fd,10+j) = i->identify; //identify flag + WFIFOB(fd,11+j) = i->attribute; // attribute + WFIFOB(fd,12+j) = i->refine; //refine + clif->addcards(WFIFOP(fd,13+j), i); +#if PACKETVER >= 20150226 + clif->add_random_options(WFIFOP(fd,22), i); +#endif + WFIFOSET(fd,packet_len(storageaddType)); } @@ -5949,6 +5987,7 @@ void clif_cart_additem(struct map_session_data *sd,int n,int amount,int fail) { int view,fd; unsigned char *buf; + int offset = 0; nullpo_retv(sd); @@ -5956,38 +5995,27 @@ void clif_cart_additem(struct map_session_data *sd,int n,int amount,int fail) if(n<0 || n>=MAX_CART || sd->status.cart[n].nameid<=0) return; -#if PACKETVER < 5 - WFIFOHEAD(fd,packet_len(0x124)); - buf=WFIFOP(fd,0); - WBUFW(buf,0)=0x124; - WBUFW(buf,2)=n+2; - WBUFL(buf,4)=amount; - if((view = itemdb_viewid(sd->status.cart[n].nameid)) > 0) - WBUFW(buf,8)=view; - else - WBUFW(buf,8)=sd->status.cart[n].nameid; - WBUFB(buf,10)=sd->status.cart[n].identify; - WBUFB(buf,11)=sd->status.cart[n].attribute; - WBUFB(buf,12)=sd->status.cart[n].refine; - clif->addcards(WBUFP(buf,13), &sd->status.cart[n]); - WFIFOSET(fd,packet_len(0x124)); -#else - WFIFOHEAD(fd,packet_len(0x1c5)); + WFIFOHEAD(fd,packet_len(cartaddType)); buf=WFIFOP(fd,0); - WBUFW(buf,0)=0x1c5; + WBUFW(buf,0)=cartaddType; WBUFW(buf,2)=n+2; WBUFL(buf,4)=amount; if((view = itemdb_viewid(sd->status.cart[n].nameid)) > 0) WBUFW(buf,8)=view; else WBUFW(buf,8)=sd->status.cart[n].nameid; +#if PACKETVER > 5 WBUFB(buf,10)=itemdb_type(sd->status.cart[n].nameid); - WBUFB(buf,11)=sd->status.cart[n].identify; - WBUFB(buf,12)=sd->status.cart[n].attribute; - WBUFB(buf,13)=sd->status.cart[n].refine; - clif->addcards(WBUFP(buf,14), &sd->status.cart[n]); - WFIFOSET(fd,packet_len(0x1c5)); + offset = 1; +#endif + WBUFB(buf,10+offset)=sd->status.cart[n].identify; + WBUFB(buf,11+offset)=sd->status.cart[n].attribute; + WBUFB(buf,12+offset)=sd->status.cart[n].refine; + clif->addcards(WBUFP(buf,13+offset), &sd->status.cart[n]); +#if PACKETVER >= 20150226 + clif->add_random_options(WBUFP(buf,21+offset), &sd->status.cart[n]); #endif + WFIFOSET(fd,packet_len(cartaddType)); } @@ -6084,6 +6112,12 @@ void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_ven const int offset = 12; #endif +#if PACKETVER >= 20150226 + const int item_length = 47; +#else + const int item_length = 22; +#endif + nullpo_retv(sd); nullpo_retv(vending_items); nullpo_retv(vsd=map->id2sd(id)); @@ -6091,9 +6125,9 @@ void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_ven fd = sd->fd; count = vsd->vend_num; - WFIFOHEAD(fd, offset+count*22); + WFIFOHEAD(fd, offset+count*item_length); WFIFOW(fd,0) = cmd; - WFIFOW(fd,2) = offset+count*22; + WFIFOW(fd,2) = offset+count*item_length; WFIFOL(fd,4) = id; #if PACKETVER >= 20100105 WFIFOL(fd,8) = vsd->vender_id; @@ -6102,15 +6136,18 @@ void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_ven for( i = 0; i < count; i++ ) { int index = vending_items[i].index; struct item_data* data = itemdb->search(vsd->status.cart[index].nameid); - WFIFOL(fd,offset+ 0+i*22) = vending_items[i].value; - WFIFOW(fd,offset+ 4+i*22) = vending_items[i].amount; - WFIFOW(fd,offset+ 6+i*22) = vending_items[i].index + 2; - WFIFOB(fd,offset+ 8+i*22) = itemtype(data->type); - WFIFOW(fd,offset+ 9+i*22) = ( data->view_id > 0 ) ? data->view_id : vsd->status.cart[index].nameid; - WFIFOB(fd,offset+11+i*22) = vsd->status.cart[index].identify; - WFIFOB(fd,offset+12+i*22) = vsd->status.cart[index].attribute; - WFIFOB(fd,offset+13+i*22) = vsd->status.cart[index].refine; - clif->addcards(WFIFOP(fd,offset+14+i*22), &vsd->status.cart[index]); + WFIFOL(fd,offset+ 0+i*item_length) = vending_items[i].value; + WFIFOW(fd,offset+ 4+i*item_length) = vending_items[i].amount; + WFIFOW(fd,offset+ 6+i*item_length) = vending_items[i].index + 2; + WFIFOB(fd,offset+ 8+i*item_length) = itemtype(data->type); + WFIFOW(fd,offset+ 9+i*item_length) = ( data->view_id > 0 ) ? data->view_id : vsd->status.cart[index].nameid; + WFIFOB(fd,offset+11+i*item_length) = vsd->status.cart[index].identify; + WFIFOB(fd,offset+12+i*item_length) = vsd->status.cart[index].attribute; + WFIFOB(fd,offset+13+i*item_length) = vsd->status.cart[index].refine; + clif->addcards(WFIFOP(fd,offset+14+i*item_length), &vsd->status.cart[index]); +#if PACKETVER >= 20150226 + clif->add_random_options(WFIFOP(fd,offset+22+i*item_length), &vsd->status.cart[index]); +#endif } WFIFOSET(fd,WFIFOW(fd,2)); } @@ -6147,28 +6184,37 @@ void clif_buyvending(struct map_session_data* sd, int index, int amount, int fai void clif_openvending(struct map_session_data* sd, int id, struct s_vending* vending_items) { int i,fd; int count; + +#if PACKETVER >= 20150226 + const int item_length = 47; +#else + const int item_length = 22; +#endif nullpo_retv(sd); fd = sd->fd; count = sd->vend_num; - WFIFOHEAD(fd, 8+count*22); + WFIFOHEAD(fd, 8+count*item_length); WFIFOW(fd,0) = 0x136; - WFIFOW(fd,2) = 8+count*22; + WFIFOW(fd,2) = 8+count*item_length; WFIFOL(fd,4) = id; for( i = 0; i < count; i++ ) { int index = vending_items[i].index; struct item_data* data = itemdb->search(sd->status.cart[index].nameid); - WFIFOL(fd, 8+i*22) = vending_items[i].value; - WFIFOW(fd,12+i*22) = vending_items[i].index + 2; - WFIFOW(fd,14+i*22) = vending_items[i].amount; - WFIFOB(fd,16+i*22) = itemtype(data->type); - WFIFOW(fd,17+i*22) = ( data->view_id > 0 ) ? data->view_id : sd->status.cart[index].nameid; - WFIFOB(fd,19+i*22) = sd->status.cart[index].identify; - WFIFOB(fd,20+i*22) = sd->status.cart[index].attribute; - WFIFOB(fd,21+i*22) = sd->status.cart[index].refine; - clif->addcards(WFIFOP(fd,22+i*22), &sd->status.cart[index]); + WFIFOL(fd, 8+i*item_length) = vending_items[i].value; + WFIFOW(fd,12+i*item_length) = vending_items[i].index + 2; + WFIFOW(fd,14+i*item_length) = vending_items[i].amount; + WFIFOB(fd,16+i*item_length) = itemtype(data->type); + WFIFOW(fd,17+i*item_length) = ( data->view_id > 0 ) ? data->view_id : sd->status.cart[index].nameid; + WFIFOB(fd,19+i*item_length) = sd->status.cart[index].identify; + WFIFOB(fd,20+i*item_length) = sd->status.cart[index].attribute; + WFIFOB(fd,21+i*item_length) = sd->status.cart[index].refine; + clif->addcards(WFIFOP(fd,22+i*item_length), &sd->status.cart[index]); +#if PACKETVER >= 20150226 + clif->add_random_options(WFIFOP(fd,30+22+i*item_length), &sd->status.cart[index]); +#endif } WFIFOSET(fd,WFIFOW(fd,2)); @@ -19280,4 +19326,6 @@ void clif_defaults(void) { /* NPC Market */ clif->pNPCMarketClosed = clif_parse_NPCMarketClosed; clif->pNPCMarketPurchase = clif_parse_NPCMarketPurchase; + /* */ + clif->add_random_options = clif->add_random_options; } diff --git a/src/map/clif.h b/src/map/clif.h index c827406ca..47249e07e 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -1320,6 +1320,8 @@ struct clif_interface { /* NPC Market (by Ind after an extensive debugging of the packet, only possible thanks to Yommy <3) */ void (*pNPCMarketClosed) (int fd, struct map_session_data *sd); void (*pNPCMarketPurchase) (int fd, struct map_session_data *sd); + /* */ + void (*add_random_options) (unsigned char* buf, struct item* item); }; struct clif_interface *clif; diff --git a/src/map/packets.h b/src/map/packets.h index 6623c091c..e84607aaf 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -2852,6 +2852,16 @@ packet(0x96e,-1,clif->ackmergeitems); packet(0x0438,36,clif->pStoragePassword,0); #endif +#if PACKETVER >= 20150226 + packet(0x0A09,45); + packet(0x0A0A,47); + packet(0x0A0B,47); + packet(0x0A0C,56); + packet(0x0A0D,-1); + packet(0x0A0F,-1); + packet(0x0A10,-1); +#endif + // 2015-05-13aRagexe #if PACKETVER >= 20150513 packet(0x0369,7,clif->pActionRequest,2,6); diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 231321c88..bf3e006be 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -18,14 +18,37 @@ enum packet_headers { banking_checkType = 0x9a6, cart_additem_ackType = 0x12c, sc_notickType = 0x196, +#if PACKETVER >= 20150226 + cartaddType = 0xa0b, +#elif PACKETVER >= 5 + cartaddType = 0x1c5, +#else + cartaddType = 0x124, +#endif +#if PACKETVER >= 20150226 + storageaddType = 0xa0a, +#elif PACKETVER >= 5 + storageaddType = 0x1c4, +#else + storageaddType = 0xf4, +#endif +#if PACKETVER >= 20150226 + tradeaddType = 0xa09, +#elif PACKETVER >= 20100223 + tradeaddType = 0x80f, +#else + tradeaddType = 0x0e9, +#endif #if PACKETVER < 20061218 - additemType = 0xa0, + additemType = 0x0a0, #elif PACKETVER < 20071002 additemType = 0x29a, #elif PACKETVER < 20120925 additemType = 0x2d4, -#else +#elif PACKETVER < 20150226 additemType = 0x990, +#else + additemType = 0xa0c, #endif #if PACKETVER < 4 idle_unitType = 0x78, @@ -134,7 +157,9 @@ enum packet_headers { #else inventorylistnormalType = 0xa3, #endif -#if PACKETVER >= 20120925 +#if PACKETVER >= 20150226 + inventorylistequipType = 0xa0d, +#elif PACKETVER >= 20120925 inventorylistequipType = 0x992, #elif PACKETVER >= 20080102 inventorylistequipType = 0x2d0, @@ -152,7 +177,9 @@ enum packet_headers { #else storagelistnormalType = 0xa5, #endif -#if PACKETVER >= 20120925 +#if PACKETVER >= 20150226 + storagelistequipType = 0xa10, +#elif PACKETVER >= 20120925 storagelistequipType = 0x996, #elif PACKETVER >= 20080102 storagelistequipType = 0x2d1, @@ -170,7 +197,9 @@ enum packet_headers { #else cartlistnormalType = 0x123, #endif -#if PACKETVER >= 20120925 +#if PACKETVER >= 20150226 + cartlistequipType = 0xa0f, +#elif PACKETVER >= 20120925 cartlistequipType = 0x994, #elif PACKETVER >= 20080102 cartlistequipType = 0x2d2, @@ -179,6 +208,12 @@ enum packet_headers { #else cartlistequipType = 0x122, #endif +#if PACKETVER < 20100105 + vendinglistType = 0x133, +#else + vendinglistType = 0x800, +#endif + openvendingType = 0x136, #if PACKETVER >= 20120925 equipitemType = 0x998, #else @@ -213,8 +248,8 @@ enum packet_headers { #endif partyleaderchangedType = 0x7fc, rouletteinfoackType = 0xa1c, - roulettgenerateackType = 0xA20, - roulettercvitemackType = 0xA22, + roulettgenerateackType = 0xa20, + roulettercvitemackType = 0xa22, }; #if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute @@ -256,6 +291,12 @@ struct NORMALITEM_INFO { #endif } __attribute__((packed)); +struct RndOptions { + short index; + short value; + unsigned char param; +} __attribute__((packed)); + struct EQUIPITEM_INFO { short index; unsigned short ITID; @@ -292,6 +333,10 @@ struct EQUIPITEM_INFO { unsigned char SpareBits : 5; } Flag; #endif +#if PACKETVER >= 20150226 + unsigned char option_count; + struct RndOptions option_data[5]; +#endif } __attribute__((packed)); struct packet_authok { @@ -344,6 +389,9 @@ struct packet_additem { #if PACKETVER >= 20071002 unsigned short bindOnEquipType; #endif +#if PACKETVER >= 20150226 + struct RndOptions option_data[5]; +#endif } __attribute__((packed)); struct packet_dropflooritem { @@ -1034,7 +1082,6 @@ struct packet_party_leader_changed { unsigned int new_leader_aid; } __attribute__((packed)); - #if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(pop) #endif // not NetBSD < 6 / Solaris |