Jelajahi Sumber

- Added support for PACKETVER 20100105, which updates the vending related packets.


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14234 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex 15 tahun lalu
induk
melakukan
e91f9882ec
7 mengubah file dengan 53 tambahan dan 19 penghapusan
  1. 3 0
      db/packet_db.txt
  2. 1 1
      doc/script_commands.txt
  3. 2 1
      src/common/mmo.h
  4. 39 13
      src/map/clif.c
  5. 1 1
      src/map/clif.h
  6. 6 2
      src/map/vending.c
  7. 1 1
      src/map/vending.h

+ 3 - 0
db/packet_db.txt

@@ -1435,5 +1435,8 @@ packet_ver: 25
 //0x07f8,0
 //0x07f9,0
 
+//2010-01-05aRagexeRE
+0x0801,-1,purchasereq2,2:4:8:12
+
 //Add new packets here
 //packet_ver: 26

+ 1 - 1
doc/script_commands.txt

@@ -133,7 +133,7 @@
 //= 3.27.20090725
 //=       Added Quest Log related commands. [Inkfish]
 //= 3.28.20091119
-//=       Added showevent and itemsearch commands [Skotlex]
+//=       Added showevent and searchitem commands [Skotlex]
 //=       Added info on strcharinfo(3) [Skotlex]
 //=========================================================
 

+ 2 - 1
src/common/mmo.h

@@ -29,9 +29,10 @@
 // 20090603 - 2009-06-03aRagexeRE+ - 0x7d7, 0x7d8, 0x7d9, 0x7da
 // 20090617 - 2009-06-17aRagexeRE+ - 0x7d9
 // 20090922 - 2009-09-22aRagexeRE+ - 0x7e5, 0x7e7, 0x7e8, 0x7e9
+// 20100105 - 2010-01-05aRagexeRE+ - 0x801
 #ifndef PACKETVER
 	#define PACKETVER	20081126
-	//#define PACKETVER 20090922
+	//#define PACKETVER 20100105
 #endif
 // backward compatible PACKETVER 8 and 9
 #if PACKETVER == 8

+ 39 - 13
src/map/clif.c

@@ -5495,6 +5495,11 @@ void clif_vendinglist(struct map_session_data* sd, int id, struct s_vending* ven
 	int i,fd;
 	int count;
 	struct map_session_data* vsd;
+#if PACKETVER < 20100105
+	const int offset = 8;
+#else
+	const int offset = 12;
+#endif
 
 	nullpo_retv(sd);
 	nullpo_retv(vending);
@@ -5503,23 +5508,27 @@ void clif_vendinglist(struct map_session_data* sd, int id, struct s_vending* ven
 	fd = sd->fd;
 	count = vsd->vend_num;
 
-    WFIFOHEAD(fd, 8+count*22);
+	WFIFOHEAD(fd, offset+count*22);
 	WFIFOW(fd,0) = 0x133;
-	WFIFOW(fd,2) = 8+count*22;
+	WFIFOW(fd,2) = offset+count*22;
 	WFIFOL(fd,4) = id;
+#if PACKETVER >= 20100105
+	WFIFOL(fd,8) = vsd->status.char_id;
+#endif
+
 	for( i = 0; i < count; i++ )
 	{
 		int index = vending[i].index;
 		struct item_data* data = itemdb_search(vsd->status.cart[index].nameid);
-		WFIFOL(fd, 8+i*22) = vending[i].value;
-		WFIFOW(fd,12+i*22) = vending[i].amount;
-		WFIFOW(fd,14+i*22) = vending[i].index + 2;
-		WFIFOB(fd,16+i*22) = itemtype(data->type);
-		WFIFOW(fd,17+i*22) = ( data->view_id > 0 ) ? data->view_id : vsd->status.cart[index].nameid;
-		WFIFOB(fd,19+i*22) = vsd->status.cart[index].identify;
-		WFIFOB(fd,20+i*22) = vsd->status.cart[index].attribute;
-		WFIFOB(fd,21+i*22) = vsd->status.cart[index].refine;
-		clif_addcards(WFIFOP(fd, 22+i*22), &vsd->status.cart[index]);
+		WFIFOL(fd,offset+ 0+i*22) = vending[i].value;
+		WFIFOW(fd,offset+ 4+i*22) = vending[i].amount;
+		WFIFOW(fd,offset+ 6+i*22) = vending[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]);
 	}
 	WFIFOSET(fd,WFIFOW(fd,2));
 }
@@ -10489,7 +10498,21 @@ void clif_parse_PurchaseReq(int fd, struct map_session_data* sd)
 	int id = (int)RFIFOL(fd,4);
 	const uint8* data = (uint8*)RFIFOP(fd,8);
 
-	vending_purchasereq(sd, id, data, len/4);
+	vending_purchasereq(sd, id, -1, data, len/4);
+}
+
+/*==========================================
+ * Shop item(s) purchase request
+ * S 0134 <len>.w <AID>.l <CID>.l {<amount>.w <index>.w}.4B*
+ *------------------------------------------*/
+void clif_parse_PurchaseReq2(int fd, struct map_session_data* sd)
+{
+	int len = (int)RFIFOW(fd,2) - 12;
+	int aid = (int)RFIFOL(fd,4);
+	int cid = (int)RFIFOL(fd,8);
+	const uint8* data = (uint8*)RFIFOP(fd,12);
+
+	vending_purchasereq(sd, aid, cid, data, len/4);
 }
 
 /*==========================================
@@ -12923,7 +12946,7 @@ void clif_quest_show_event(struct map_session_data *sd, struct block_list *bl, s
 	WFIFOHEAD(fd, packet_len(0x446));
 	WFIFOW(fd, 0) = 0x446;
 	WFIFOL(fd, 2) = bl->id;
-	WFIFOW(fd, 6) = bl->x;                                                                                 
+	WFIFOW(fd, 6) = bl->x;
 	WFIFOW(fd, 8) = bl->y;
 	WFIFOW(fd, 10) = state;
 	WFIFOW(fd, 12) = color;
@@ -13824,6 +13847,8 @@ static int packetdb_readdb(void)
 #endif
 	    0,  0,  0,  0,  0,  8,  8, 32, -1,  5,  0,  0,  0,  0,  0,  0,
 	    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+	 //#0x800
+	    0, -1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 	};
 	struct {
 		void (*func)(int, struct map_session_data *);
@@ -13913,6 +13938,7 @@ static int packetdb_readdb(void)
 		{clif_parse_CloseVending,"closevending"},
 		{clif_parse_VendingListReq,"vendinglistreq"},
 		{clif_parse_PurchaseReq,"purchasereq"},
+		{clif_parse_PurchaseReq2,"purchasereq2"},
 		{clif_parse_OpenVending,"openvending"},
 		{clif_parse_CreateGuild,"createguild"},
 		{clif_parse_GuildCheckMaster,"guildcheckmaster"},

+ 1 - 1
src/map/clif.h

@@ -27,7 +27,7 @@ struct battleground_data;
 struct quest;
 #include <stdarg.h>
 // packet DB
-#define MAX_PACKET_DB		0x800
+#define MAX_PACKET_DB		0x810
 #define MAX_PACKET_VER		25
 
 struct s_packet_db {

+ 6 - 2
src/map/vending.c

@@ -56,14 +56,18 @@ void vending_vendinglistreq(struct map_session_data* sd, int id)
 /*==========================================
  * Purchase item(s) from a shop
  *------------------------------------------*/
-void vending_purchasereq(struct map_session_data* sd, int id, const uint8* data, int count)
+void vending_purchasereq(struct map_session_data* sd, int aid, int cid, const uint8* data, int count)
 {
 	int i, j, cursor, w, new_ = 0, blank, vend_list[MAX_VENDING];
 	double z;
 	struct s_vending vending[MAX_VENDING]; // against duplicate packets
-	struct map_session_data* vsd = map_id2sd(id);
+	struct map_session_data* vsd = map_id2sd(aid);
 
 	nullpo_retv(sd);
+#if PACKETVER >= 20100105
+	if( vsd->status.char_id != cid )
+		return; //Char-ID check
+#endif
 
 	if( vsd == NULL || vsd->vender_id == 0 || vsd->vender_id == sd->bl.id )
 		return; // invalid shop

+ 1 - 1
src/map/vending.h

@@ -17,6 +17,6 @@ struct s_vending {
 void vending_closevending(struct map_session_data* sd);
 void vending_openvending(struct map_session_data* sd, const char* message, bool flag, const uint8* data, int count);
 void vending_vendinglistreq(struct map_session_data* sd, int id);
-void vending_purchasereq(struct map_session_data* sd, int id, const uint8* data, int count);
+void vending_purchasereq(struct map_session_data* sd, int aid, int cid, const uint8* data, int count);
 
 #endif /* _VENDING_H_ */