summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c194
1 files changed, 121 insertions, 73 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;
}