viewing paste Unknown #6139 | Diff

Posted on the
  1. Index: src/map/clif.c
  2. ===================================================================
  3. --- src/map/clif.c	(revision 17352)
  4. +++ src/map/clif.c	(working copy)
  5. @@ -6598,7 +6598,7 @@
  6.  		WBUFW(buf,0)=0x109;
  7.  		WBUFW(buf,2)=len+8;
  8.  		WBUFL(buf,4)=account_id;
  9. -        safestrncpy((char *)WBUFP(buf,8), mes, len);
  10. +		safestrncpy((char *)WBUFP(buf,8), mes, len);
  11.  		clif_send(buf,len+8,&sd->bl,PARTY);
  12.  	}
  13.  }
  14. @@ -8866,13 +8866,14 @@
  15.  	char *text, *name, *message;
  16.  	unsigned int packetlen, textlen, namelen, messagelen;
  17.  	int fd = sd->fd;
  18. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  19.  
  20.  	*name_ = NULL;
  21.  	*namelen_ = 0;
  22.  	*message_ = NULL;
  23.  	*messagelen_ = 0;
  24.  
  25. -	packetlen = RFIFOW(fd,2);
  26. +	packetlen = RFIFOW(fd,info->pos[0]);
  27.  	// basic structure checks
  28.  	if( packetlen < 4 + 1 )
  29.  	{	// 4-byte header and at least an empty string is expected
  30. @@ -8880,7 +8881,7 @@
  31.  		return false;
  32.  	}
  33.  
  34. -	text = (char*)RFIFOP(fd,4);
  35. +	text = (char*)RFIFOP(fd,info->pos[1]);
  36.  	textlen = packetlen - 4;
  37.  
  38.  	// process <name> part of the packet
  39. @@ -9491,15 +9492,14 @@
  40.  void clif_parse_Hotkey(int fd, struct map_session_data *sd) {
  41.  #ifdef HOTKEY_SAVING
  42.  	unsigned short idx;
  43. -	int cmd;
  44. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  45.  
  46. -	cmd = RFIFOW(fd, 0);
  47. -	idx = RFIFOW(fd, packet_db[sd->packet_ver][cmd].pos[0]);
  48. +	idx = RFIFOW(fd, info->pos[0]);
  49.  	if (idx >= MAX_HOTKEYS) return;
  50.  
  51. -	sd->status.hotkeys[idx].type = RFIFOB(fd, packet_db[sd->packet_ver][cmd].pos[1]);
  52. -	sd->status.hotkeys[idx].id = RFIFOL(fd, packet_db[sd->packet_ver][cmd].pos[2]);
  53. -	sd->status.hotkeys[idx].lv = RFIFOW(fd, packet_db[sd->packet_ver][cmd].pos[3]);
  54. +	sd->status.hotkeys[idx].type = RFIFOB(fd,info->pos[1]);
  55. +	sd->status.hotkeys[idx].id = RFIFOL(fd, info->pos[2]);
  56. +	sd->status.hotkeys[idx].lv = RFIFOW(fd, info->pos[3]);
  57.  #endif
  58.  }
  59.  
  60. @@ -9658,9 +9658,11 @@
  61.  /// There are various variants of this packet.
  62.  void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
  63.  {
  64. -	const char* text = (char*)RFIFOP(fd,4);
  65. -	int textlen = RFIFOW(fd,2) - 4;
  66.  
  67. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  68. +	int textlen = RFIFOW(fd,info->pos[0]) - 4;
  69. +	const char* text = (char*)RFIFOP(fd,info->pos[1]);
  70. +
  71.  	char *name, *message, *fakename = NULL;
  72.  	int namelen, messagelen;
  73.  
  74. @@ -9673,7 +9675,7 @@
  75.  	if( is_atcommand(fd, sd, message, 1)  )
  76.  		return;
  77.  
  78. -	if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
  79. +	if( sd->sc.cant.chat )
  80.  		return;
  81.  
  82.  	if( battle_config.min_chat_delay ) { //[Skotlex]
  83. @@ -9707,7 +9709,7 @@
  84.  		safestrncpy((char*)WFIFOP(fd,4), fakename, textlen);
  85.  		aFree(fakename);
  86.  	} else {
  87. -		memcpy(WFIFOP(fd,0), RFIFOP(fd,0), RFIFOW(fd,2));
  88. +		memcpy(WFIFOP(fd,0), RFIFOP(fd,0), RFIFOW(fd,info->pos[0]));
  89.  		WFIFOW(fd,0) = 0x8e;
  90.  	}
  91.  	WFIFOSET(fd, WFIFOW(fd,2));
  92. @@ -9731,10 +9733,13 @@
  93.  {
  94.  	char command[MAP_NAME_LENGTH_EXT+25];
  95.  	char* map_name;
  96. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  97.  
  98. -	map_name = (char*)RFIFOP(fd,2);
  99. +	map_name = (char*)RFIFOP(fd,info->pos[0]);
  100.  	map_name[MAP_NAME_LENGTH_EXT-1]='\0';
  101. -	sprintf(command, "%cmapmove %s %d %d", atcommand_symbol, map_name, RFIFOW(fd,18), RFIFOW(fd,20));
  102. +	sprintf(command, "%cmapmove %s %d %d", atcommand_symbol, map_name,
  103. +	    RFIFOW(fd,info->pos[1]), //x
  104. +	    RFIFOW(fd,info->pos[2])); //y
  105.  	is_atcommand(fd, sd, command, 1);
  106.  }
  107.  
  108. @@ -9780,9 +9785,10 @@
  109.  void clif_parse_ChangeDir(int fd, struct map_session_data *sd)
  110.  {
  111.  	unsigned char headdir, dir;
  112. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  113.  
  114. -	headdir = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  115. -	dir = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  116. +	headdir = RFIFOB(fd,info->pos[0]);
  117. +	dir = RFIFOB(fd,info->pos[1]);
  118.  	pc_setdir(sd, dir, headdir);
  119.  
  120.  	clif_changed_dir(&sd->bl, AREA_WOS);
  121. @@ -9944,9 +9950,10 @@
  122.  /// There are various variants of this packet, some of them have padding between fields.
  123.  void clif_parse_ActionRequest(int fd, struct map_session_data *sd)
  124.  {
  125. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  126.  	clif_parse_ActionRequest_sub(sd,
  127. -		RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]),
  128. -		RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]),
  129. +		RFIFOB(fd,info->pos[1]),
  130. +		RFIFOL(fd,info->pos[0]),
  131.  		gettick()
  132.  	);
  133.  }
  134. @@ -9959,7 +9966,7 @@
  135.  ///     1 = char-select (disconnect)
  136.  void clif_parse_Restart(int fd, struct map_session_data *sd)
  137.  {
  138. -	switch(RFIFOB(fd,2)) {
  139. +	switch(RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])) {
  140.  	case 0x00:
  141.  		pc_respawn(sd,CLR_RESPAWN);
  142.  		break;
  143. @@ -9994,7 +10001,7 @@
  144.  	if ( is_atcommand(fd, sd, message, 1) )
  145.  		return;
  146.  
  147. -	if (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT))
  148. +	if (sd->sc.cant.chat)
  149.  		return;
  150.  
  151.  	if (battle_config.min_chat_delay) { //[Skotlex]
  152. @@ -10118,8 +10125,9 @@
  153.  /// 0099 <packet len>.W <text>.?B 00
  154.  void clif_parse_Broadcast(int fd, struct map_session_data* sd) {
  155.  	char command[CHAT_SIZE_MAX+11];
  156. -	char* msg = (char*)RFIFOP(fd,4);
  157. -	unsigned int len = RFIFOW(fd,2)-4;
  158. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  159. +	unsigned int len = RFIFOW(fd,info->pos[0])-4;
  160. +	char* msg = (char*)RFIFOP(fd,info->pos[1]);
  161.  
  162.  	// as the length varies depending on the command used, just block unreasonably long strings
  163.  	mes_len_check(msg, len, CHAT_SIZE_MAX);
  164. @@ -10151,9 +10159,6 @@
  165.  		if (fitem == NULL || fitem->bl.type != BL_ITEM || fitem->bl.m != sd->bl.m)
  166.  			break;
  167.  
  168. -		if( sd->sc.cant.pickup )
  169. -			break;
  170. -
  171.  		if (pc_cant_act(sd))
  172.  			break;
  173.  
  174. @@ -10171,10 +10176,10 @@
  175.  /// 00a2 <index>.W <amount>.W (CZ_ITEM_THROW)
  176.  /// 0363 <index>.W <amount>.W (CZ_ITEM_THROW2)
  177.  /// There are various variants of this packet, some of them have padding between fields.
  178. -void clif_parse_DropItem(int fd, struct map_session_data *sd)
  179. -{
  180. -	int item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
  181. -	int item_amount = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  182. +void clif_parse_DropItem(int fd, struct map_session_data *sd){
  183. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  184. +	int item_index  = RFIFOW(fd,info->pos[0]) -2;
  185. +	int item_amount = RFIFOW(fd,info->pos[1]) ;
  186.  
  187.  	for(;;) {
  188.  		if (pc_isdead(sd))
  189. @@ -10234,12 +10239,13 @@
  190.  void clif_parse_EquipItem(int fd,struct map_session_data *sd)
  191.  {
  192.  	int index, req_pos;
  193. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  194.  
  195.  	if(pc_isdead(sd)) {
  196.  		clif_clearunit_area(&sd->bl,CLR_DEAD);
  197.  		return;
  198.  	}
  199. -	index = RFIFOW(fd,2)-2;
  200. +	index = RFIFOW(fd,info->pos[0])-2;
  201.  	if (index < 0 || index >= MAX_INVENTORY)
  202.  		return; //Out of bounds check.
  203.  
  204. @@ -10269,9 +10275,9 @@
  205.  		pc_equipitem(sd,index,EQP_AMMO);
  206.  	else {
  207.  #if PACKETVER  >= 20120925
  208. -		req_pos = RFIFOL(fd,4);
  209. +		req_pos = RFIFOL(fd,info->pos[1]);
  210.  #else
  211. -		req_pos = (int)RFIFOW(fd,4);
  212. +		req_pos = (int)RFIFOW(fd,info->pos[1]);
  213.  #endif
  214.  		pc_equipitem(sd,index,req_pos);
  215.  	}
  216. @@ -10297,7 +10303,7 @@
  217.  	else if (pc_cant_act2(sd))
  218.  		return;
  219.  
  220. -	index = RFIFOW(fd,2)-2;
  221. +	index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
  222.  
  223.  	pc_unequipitem(sd,index,1);
  224.  }
  225. @@ -10319,7 +10325,7 @@
  226.  	if (pc_cant_act2(sd))
  227.  		return;
  228.  
  229. -	bl = map_id2bl(RFIFOL(fd,2));
  230. +	bl = map_id2bl(RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  231.  	if (!bl) return;
  232.  	switch (bl->type) {
  233.  		case BL_MOB:
  234. @@ -10341,9 +10347,10 @@
  235.  ///     1 = sell
  236.  void clif_parse_NpcBuySellSelected(int fd,struct map_session_data *sd)
  237.  {
  238. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  239.  	if (sd->state.trading)
  240.  		return;
  241. -	npc_buysellsel(sd,RFIFOL(fd,2),RFIFOB(fd,6));
  242. +	npc_buysellsel(sd,RFIFOL(fd,info->pos[0]),RFIFOB(fd,info->pos[1]));
  243.  }
  244.  
  245.  
  246. @@ -10369,8 +10376,9 @@
  247.  /// 00c8 <packet len>.W { <amount>.W <name id>.W }*
  248.  void clif_parse_NpcBuyListSend(int fd, struct map_session_data* sd)
  249.  {
  250. -	int n = (RFIFOW(fd,2)-4) /4;
  251. -	unsigned short* item_list = (unsigned short*)RFIFOP(fd,4);
  252. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  253. +	int n = (RFIFOW(fd,info->pos[0])-4) /4;
  254. +	unsigned short* item_list = (unsigned short*)RFIFOP(fd,info->pos[1]);
  255.  	int result;
  256.  
  257.  	if( sd->state.trading || !sd->npc_shopid )
  258. @@ -10406,9 +10414,10 @@
  259.  {
  260.  	int fail=0,n;
  261.  	unsigned short *item_list;
  262. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  263.  
  264. -	n = (RFIFOW(fd,2)-4) /4;
  265. -	item_list = (unsigned short*)RFIFOP(fd,4);
  266. +	n = (RFIFOW(fd,info->pos[0])-4) /4; // (pktlen-(cmd+len))/listsize
  267. +	item_list = (unsigned short*)RFIFOP(fd,info->pos[1]);
  268.  
  269.  	if (sd->state.trading || !sd->npc_shopid)
  270.  		fail = 1;
  271. @@ -10428,11 +10437,12 @@
  272.  ///     1 = public
  273.  void clif_parse_CreateChatRoom(int fd, struct map_session_data* sd)
  274.  {
  275. -	int len = RFIFOW(fd,2)-15;
  276. -	int limit = RFIFOW(fd,4);
  277. -	bool pub = (RFIFOB(fd,6) != 0);
  278. -	const char* password = (char*)RFIFOP(fd,7); //not zero-terminated
  279. -	const char* title = (char*)RFIFOP(fd,15); // not zero-terminated
  280. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  281. +	int len = RFIFOW(fd,info->pos[0])-15;
  282. +	int limit = RFIFOW(fd,info->pos[1]);
  283. +	bool pub = (RFIFOB(fd,info->pos[2]) != 0);
  284. +	const char* password = (char*)RFIFOP(fd,info->pos[3]); //not zero-terminated
  285. +	const char* title = (char*)RFIFOP(fd,info->pos[4]); // not zero-terminated
  286.  	char s_password[CHATROOM_PASS_SIZE];
  287.  	char s_title[CHATROOM_TITLE_SIZE];
  288.  
  289. @@ -10464,10 +10474,10 @@
  290.  
  291.  /// Chatroom join request (CZ_REQ_ENTER_ROOM).
  292.  /// 00d9 <chat ID>.L <passwd>.8B
  293. -void clif_parse_ChatAddMember(int fd, struct map_session_data* sd)
  294. -{
  295. -	int chatid = RFIFOL(fd,2);
  296. -	const char* password = (char*)RFIFOP(fd,6); // not zero-terminated
  297. +void clif_parse_ChatAddMember(int fd, struct map_session_data* sd){
  298. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  299. +	int chatid = RFIFOL(fd,info->pos[0]);
  300. +	const char* password = (char*)RFIFOP(fd,info->pos[1]); // not zero-terminated
  301.  
  302.  	chat_joinchat(sd,chatid,password);
  303.  }
  304. @@ -10478,13 +10488,13 @@
  305.  /// type:
  306.  ///     0 = private
  307.  ///     1 = public
  308. -void clif_parse_ChatRoomStatusChange(int fd, struct map_session_data* sd)
  309. -{
  310. -	int len = RFIFOW(fd,2)-15;
  311. -	int limit = RFIFOW(fd,4);
  312. -	bool pub = (RFIFOB(fd,6) != 0);
  313. -	const char* password = (char*)RFIFOP(fd,7); // not zero-terminated
  314. -	const char* title = (char*)RFIFOP(fd,15); // not zero-terminated
  315. +void clif_parse_ChatRoomStatusChange(int fd, struct map_session_data* sd){
  316. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  317. +	int len = RFIFOW(fd,info->pos[0])-15;
  318. +	int limit = RFIFOW(fd,info->pos[1]);
  319. +	bool pub = (RFIFOB(fd,info->pos[2]) != 0);
  320. +	const char* password = (char*)RFIFOP(fd,info->pos[3]); // not zero-terminated
  321. +	const char* title = (char*)RFIFOP(fd,info->pos[4]); // not zero-terminated
  322.  	char s_password[CHATROOM_PASS_SIZE];
  323.  	char s_title[CHATROOM_TITLE_SIZE];
  324.  
  325. @@ -10505,7 +10515,7 @@
  326.  ///     1 = normal
  327.  void clif_parse_ChangeChatOwner(int fd, struct map_session_data* sd)
  328.  {
  329. -	chat_changechatowner(sd,(char*)RFIFOP(fd,6));
  330. +	chat_changechatowner(sd,(char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  331.  }
  332.  
  333.  
  334. @@ -10513,7 +10523,7 @@
  335.  /// 00e2 <name>.24B
  336.  void clif_parse_KickFromChat(int fd,struct map_session_data *sd)
  337.  {
  338. -	chat_kickchat(sd,(char*)RFIFOP(fd,2));
  339. +	chat_kickchat(sd,(char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  340.  }
  341.  
  342.  
  343. @@ -10547,7 +10557,7 @@
  344.  {
  345.  	struct map_session_data *t_sd;
  346.  
  347. -	t_sd = map_id2sd(RFIFOL(fd,2));
  348. +	t_sd = map_id2sd(RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  349.  
  350.  	if(!sd->chatID && pc_cant_act(sd))
  351.  		return; //You can trade while in a chatroom.
  352. @@ -10574,7 +10584,7 @@
  353.  ///     4 = rejected
  354.  void clif_parse_TradeAck(int fd,struct map_session_data *sd)
  355.  {
  356. -	trade_tradeack(sd,RFIFOB(fd,2));
  357. +	trade_tradeack(sd,RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  358.  }
  359.  
  360.  
  361. @@ -10582,8 +10592,9 @@
  362.  /// 00e8 <index>.W <amount>.L
  363.  void clif_parse_TradeAddItem(int fd,struct map_session_data *sd)
  364.  {
  365. -	short index = RFIFOW(fd,2);
  366. -	int amount = RFIFOL(fd,4);
  367. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  368. +	short index = RFIFOW(fd,info->pos[0]);
  369. +	int amount = RFIFOL(fd,info->pos[1]);
  370.  
  371.  	if( index == 0 )
  372.  		trade_tradeaddzeny(sd, amount);
  373. @@ -10628,11 +10639,13 @@
  374.  /// 0126 <index>.W <amount>.L
  375.  void clif_parse_PutItemToCart(int fd,struct map_session_data *sd)
  376.  {
  377. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  378.  	if (pc_istrading(sd))
  379.  		return;
  380.  	if (!pc_iscarton(sd))
  381.  		return;
  382. -	pc_putitemtocart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
  383. +	pc_putitemtocart(sd,RFIFOW(fd,info->pos[0])-2,
  384. +		RFIFOL(fd,info->pos[1]));
  385.  }
  386.  
  387.  
  388. @@ -10640,9 +10653,11 @@
  389.  /// 0127 <index>.W <amount>.L
  390.  void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd)
  391.  {
  392. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  393.  	if (!pc_iscarton(sd))
  394.  		return;
  395. -	pc_getitemfromcart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
  396. +	pc_getitemfromcart(sd,RFIFOW(fd,info->pos[0])-2,
  397. +		RFIFOL(fd,info->pos[1]));
  398.  }
  399.  
  400.  
  401. @@ -10672,7 +10687,7 @@
  402.  	if( sd && pc_checkskill(sd, MC_CHANGECART) < 1 )
  403.  		return;
  404.  
  405. -	type = (int)RFIFOW(fd,2);
  406. +	type = (int)RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  407.  #ifdef NEW_CARTS
  408.  	if( (type == 9 && sd->status.base_level > 131) ||
  409.  		(type == 8 && sd->status.base_level > 121) ||
  410. @@ -10703,7 +10718,7 @@
  411.  ///     the like
  412.  void clif_parse_StatusUp(int fd,struct map_session_data *sd)
  413.  {
  414. -	pc_statusup(sd,RFIFOW(fd,2));
  415. +	pc_statusup(sd,RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  416.  }
  417.  
  418.  
  419. @@ -10711,7 +10726,7 @@
  420.  /// 0112 <skill id>.W
  421.  void clif_parse_SkillUp(int fd,struct map_session_data *sd)
  422.  {
  423. -	pc_skillup(sd,RFIFOW(fd,2));
  424. +	pc_skillup(sd,RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  425.  }
  426.  
  427.  static void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, int target_id)
  428. @@ -10817,10 +10832,11 @@
  429.  	uint16 skill_id, skill_lv;
  430.  	int tmp, target_id;
  431.  	unsigned int tick = gettick();
  432. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  433.  
  434. -	skill_lv = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  435. -	skill_id = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  436. -	target_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]);
  437. +	skill_lv = RFIFOW(fd,info->pos[0]);
  438. +	skill_id = RFIFOW(fd,info->pos[1]);
  439. +	target_id = RFIFOL(fd,info->pos[2]);
  440.  
  441.  	if( skill_lv < 1 ) skill_lv = 1; //No clue, I have seen the client do this with guild skills :/ [Skotlex]
  442.  
  443. @@ -10993,16 +11009,17 @@
  444.  /// There are various variants of this packet, some of them have padding between fields.
  445.  void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd)
  446.  {
  447. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  448.  	if (pc_cant_act(sd))
  449.  		return;
  450.  	if (pc_issit(sd))
  451.  		return;
  452.  
  453.  	clif_parse_UseSkillToPosSub(fd, sd,
  454. -		RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), //skill lv
  455. -		RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]), //skill num
  456. -		RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]), //pos x
  457. -		RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3]), //pos y
  458. +		RFIFOW(fd,info->pos[0]), //skill lv
  459. +		RFIFOW(fd,info->pos[1]), //skill num
  460. +		RFIFOW(fd,info->pos[2]), //pos x
  461. +		RFIFOW(fd,info->pos[3]), //pos y
  462.  		-1	//Skill more info.
  463.  	);
  464.  }
  465. @@ -11014,17 +11031,18 @@
  466.  /// There are various variants of this packet, some of them have padding between fields.
  467.  void clif_parse_UseSkillToPosMoreInfo(int fd, struct map_session_data *sd)
  468.  {
  469. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  470.  	if (pc_cant_act(sd))
  471.  		return;
  472.  	if (pc_issit(sd))
  473.  		return;
  474.  
  475.  	clif_parse_UseSkillToPosSub(fd, sd,
  476. -		RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), //Skill lv
  477. -		RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]), //Skill num
  478. -		RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]), //pos x
  479. -		RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3]), //pos y
  480. -		packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[4] //skill more info
  481. +		RFIFOW(fd,info->pos[0]), //Skill lv
  482. +		RFIFOW(fd,info->pos[1]), //Skill num
  483. +		RFIFOW(fd,info->pos[2]), //pos x
  484. +		RFIFOW(fd,info->pos[3]), //pos y
  485. +		info->pos[4] //skill more info
  486.  	);
  487.  }
  488.  
  489. @@ -11033,9 +11051,10 @@
  490.  /// 011b <skill id>.W <map name>.16B
  491.  void clif_parse_UseSkillMap(int fd, struct map_session_data* sd)
  492.  {
  493. -	uint16 skill_id = RFIFOW(fd,2);
  494. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  495. +	uint16 skill_id = RFIFOW(fd,info->pos[0]);
  496.  	char map_name[MAP_NAME_LENGTH];
  497. -	mapindex_getmapname((char*)RFIFOP(fd,4), map_name);
  498. +	mapindex_getmapname((char*)RFIFOP(fd,info->pos[1]), map_name);
  499.  
  500.  	if(skill_id != sd->menuskill_id)
  501.  		return;
  502. @@ -11061,8 +11080,12 @@
  503.  
  504.  /// Answer to pharmacy item selection dialog (CZ_REQMAKINGITEM).
  505.  /// 018e <name id>.W { <material id>.W }*3
  506. -void clif_parse_ProduceMix(int fd,struct map_session_data *sd)
  507. -{
  508. +void clif_parse_ProduceMix(int fd,struct map_session_data *sd){
  509. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  510. +	int nameid = RFIFOW(fd,info->pos[0]);
  511. +	int slot1  = RFIFOW(fd,info->pos[1]);
  512. +	int slot2  = RFIFOW(fd,info->pos[2]);
  513. +	int slot3  = RFIFOW(fd,info->pos[3]);
  514.  	switch( sd->menuskill_id ) {
  515.  		case -1:
  516.  		case AM_PHARMACY:
  517. @@ -11078,8 +11101,8 @@
  518.  		clif_menuskill_clear(sd);
  519.  		return;
  520.  	}
  521. -	if( skill_can_produce_mix(sd,RFIFOW(fd,2),sd->menuskill_val, 1) )
  522. -		skill_produce_mix(sd,0,RFIFOW(fd,2),RFIFOW(fd,4),RFIFOW(fd,6),RFIFOW(fd,8), 1);
  523. +	if( skill_can_produce_mix(sd,nameid,sd->menuskill_val, 1) )
  524. +		skill_produce_mix(sd,0,nameid,slot1,slot2,slot3, 1);
  525.  	clif_menuskill_clear(sd);
  526.  }
  527.  
  528. @@ -11094,8 +11117,9 @@
  529.  ///     5 = GN_MAKEBOMB
  530.  ///     6 = GN_S_PHARMACY
  531.  void clif_parse_Cooking(int fd,struct map_session_data *sd) {
  532. -	int type = RFIFOW(fd,2);
  533. -	int nameid = RFIFOW(fd,4);
  534. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  535. +	int type = RFIFOW(fd,info->pos[0]);
  536. +	int nameid = RFIFOW(fd,info->pos[1]);
  537.  	int amount = sd->menuskill_val2?sd->menuskill_val2:1;
  538.  	if( type == 6 && sd->menuskill_id != GN_MIX_COOKING && sd->menuskill_id != GN_S_PHARMACY )
  539.  		return;
  540. @@ -11124,7 +11148,7 @@
  541.  		clif_menuskill_clear(sd);
  542.  		return;
  543.  	}
  544. -	skill_repairweapon(sd,RFIFOW(fd,2));
  545. +	skill_repairweapon(sd,RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  546.  	clif_menuskill_clear(sd);
  547.  }
  548.  
  549. @@ -11156,10 +11180,10 @@
  550.  ///     255   = cancel
  551.  /// NOTE: If there were more than 254 items in the list, choice
  552.  ///     overflows to choice%256.
  553. -void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
  554. -{
  555. -	int npc_id = RFIFOL(fd,2);
  556. -	uint8 select = RFIFOB(fd,6);
  557. +void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd){
  558. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  559. +	int npc_id = RFIFOL(fd,info->pos[0]);
  560. +	uint8 select = RFIFOB(fd,info->pos[1]);
  561.  
  562.  	if( (select > sd->npc_menu && select != 0xff) || select == 0 ) {
  563.  #ifdef SECURE_NPCTIMEOUT
  564. @@ -11183,16 +11207,16 @@
  565.  /// 00b9 <npc id>.L
  566.  void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd)
  567.  {
  568. -	npc_scriptcont(sd,RFIFOL(fd,2), false);
  569. +	npc_scriptcont(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), false);
  570.  }
  571.  
  572.  
  573.  /// NPC numeric input dialog value (CZ_INPUT_EDITDLG).
  574.  /// 0143 <npc id>.L <value>.L
  575. -void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd)
  576. -{
  577. -	int npcid = RFIFOL(fd,2);
  578. -	int amount = (int)RFIFOL(fd,6);
  579. +void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd){
  580. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  581. +	int npcid = RFIFOL(fd,info->pos[0]);
  582. +	int amount = (int)RFIFOL(fd,info->pos[1]);
  583.  
  584.  	sd->npc_amount = amount;
  585.  	npc_scriptcont(sd, npcid, false);
  586. @@ -11201,11 +11225,11 @@
  587.  
  588.  /// NPC text input dialog value (CZ_INPUT_EDITDLGSTR).
  589.  /// 01d5 <packet len>.W <npc id>.L <string>.?B
  590. -void clif_parse_NpcStringInput(int fd, struct map_session_data* sd)
  591. -{
  592. -	int message_len = RFIFOW(fd,2)-8;
  593. -	int npcid = RFIFOL(fd,4);
  594. -	const char* message = (char*)RFIFOP(fd,8);
  595. +void clif_parse_NpcStringInput(int fd, struct map_session_data* sd){
  596. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  597. +	int message_len = RFIFOW(fd,info->pos[0])-8;
  598. +	int npcid = RFIFOL(fd,info->pos[1]);
  599. +	const char* message = (char*)RFIFOP(fd,info->pos[2]);
  600.  
  601.  	if( message_len <= 0 )
  602.  		return; // invalid input
  603. @@ -11221,7 +11245,7 @@
  604.  {
  605.  	if (!sd->npc_id) //Avoid parsing anything when the script was done with. [Skotlex]
  606.  		return;
  607. -	npc_scriptcont(sd, RFIFOL(fd,2), true);
  608. +	npc_scriptcont(sd, RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), true);
  609.  }
  610.  
  611.  
  612. @@ -11231,7 +11255,7 @@
  613.  ///     -1 = cancel
  614.  void clif_parse_ItemIdentify(int fd,struct map_session_data *sd)
  615.  {
  616. -	short idx = RFIFOW(fd,2);
  617. +	short idx = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  618.  
  619.  	if (sd->menuskill_id != MC_IDENTIFY)
  620.  		return;
  621. @@ -11246,8 +11270,8 @@
  622.  
  623.  /// Answer to arrow crafting item selection dialog (CZ_REQ_MAKINGARROW).
  624.  /// 01ae <name id>.W
  625. -void clif_parse_SelectArrow(int fd,struct map_session_data *sd)
  626. -{
  627. +void clif_parse_SelectArrow(int fd,struct map_session_data *sd){
  628. +	int nameid = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  629.  	if (pc_istrading(sd)) {
  630.  	//Make it fail to avoid shop exploits where you sell something different than you see.
  631.  		clif_skill_fail(sd,sd->ud.skill_id,USESKILL_FAIL_LEVEL,0);
  632. @@ -11256,19 +11280,19 @@
  633.  	}
  634.  	switch( sd->menuskill_id ) {
  635.  		case AC_MAKINGARROW:
  636. -			skill_arrow_create(sd,RFIFOW(fd,2));
  637. +			skill_arrow_create(sd,nameid);
  638.  			break;
  639.  		case SA_CREATECON:
  640. -			skill_produce_mix(sd,SA_CREATECON,RFIFOW(fd,2),0,0,0, 1);
  641. +			skill_produce_mix(sd,SA_CREATECON,nameid,0,0,0, 1);
  642.  			break;
  643.  		case WL_READING_SB:
  644. -			skill_spellbook(sd,RFIFOW(fd,2));
  645. +			skill_spellbook(sd,nameid);
  646.  			break;
  647.  		case GC_POISONINGWEAPON:
  648. -			skill_poisoningweapon(sd,RFIFOW(fd,2));
  649. +			skill_poisoningweapon(sd,nameid);
  650.  			break;
  651.  		case NC_MAGICDECOY:
  652. -			skill_magicdecoy(sd,RFIFOW(fd,2));
  653. +			skill_magicdecoy(sd,nameid);
  654.  			break;
  655.  	}
  656.  
  657. @@ -11282,7 +11306,7 @@
  658.  {
  659.  	if (sd->menuskill_id != SA_AUTOSPELL)
  660.  		return;
  661. -	skill_autospell(sd,RFIFOL(fd,2));
  662. +	skill_autospell(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  663.  	clif_menuskill_clear(sd);
  664.  }
  665.  
  666. @@ -11293,7 +11317,7 @@
  667.  {
  668.  	if (sd->state.trading != 0)
  669.  		return;
  670. -	clif_use_card(sd,RFIFOW(fd,2)-2);
  671. +	clif_use_card(sd,RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2);
  672.  }
  673.  
  674.  
  675. @@ -11301,9 +11325,10 @@
  676.  /// 017c <card index>.W <equip index>.W
  677.  void clif_parse_InsertCard(int fd,struct map_session_data *sd)
  678.  {
  679. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  680.  	if (sd->state.trading != 0)
  681.  		return;
  682. -	pc_insert_card(sd,RFIFOW(fd,2)-2,RFIFOW(fd,4)-2);
  683. +	pc_insert_card(sd,RFIFOW(fd,info->pos[0])-2,RFIFOW(fd,info->pos[1])-2);
  684.  }
  685.  
  686.  
  687. @@ -11329,7 +11354,7 @@
  688.  void clif_parse_ResetChar(int fd, struct map_session_data *sd) {
  689.  	char cmd[15];
  690.  
  691. -	if( RFIFOW(fd,2) )
  692. +	if( RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]) )
  693.  		sprintf(cmd,"%cresetskill",atcommand_symbol);
  694.  	else
  695.  		sprintf(cmd,"%cresetstat",atcommand_symbol);
  696. @@ -11343,9 +11368,10 @@
  697.  /// 019c <packet len>.W <text>.?B
  698.  void clif_parse_LocalBroadcast(int fd, struct map_session_data* sd)
  699.  {
  700. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  701.  	char command[CHAT_SIZE_MAX+16];
  702. -	char* msg = (char*)RFIFOP(fd,4);
  703. -	unsigned int len = RFIFOW(fd,2)-4;
  704. +	unsigned int len = RFIFOW(fd,info->pos[0])-4;
  705. +	char* msg = (char*)RFIFOP(fd,info->pos[1]);
  706.  
  707.  	// as the length varies depending on the command used, just block unreasonably long strings
  708.  	mes_len_check(msg, len, CHAT_SIZE_MAX);
  709. @@ -11362,12 +11388,13 @@
  710.  void clif_parse_MoveToKafra(int fd, struct map_session_data *sd)
  711.  {
  712.  	int item_index, item_amount;
  713. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  714.  
  715.  	if (pc_istrading(sd))
  716.  		return;
  717.  
  718. -	item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
  719. -	item_amount = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  720. +	item_index = RFIFOW(fd,info->pos[0])-2;
  721. +	item_amount = RFIFOL(fd,info->pos[1]);
  722.  	if (item_index < 0 || item_index >= MAX_INVENTORY || item_amount < 1)
  723.  		return;
  724.  
  725. @@ -11386,9 +11413,10 @@
  726.  void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd)
  727.  {
  728.  	int item_index, item_amount;
  729. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  730.  
  731. -	item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-1;
  732. -	item_amount = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  733. +	item_index = RFIFOW(fd,info->pos[0])-1;
  734. +	item_amount = RFIFOL(fd,info->pos[1]);
  735.  
  736.  	if (sd->state.storage_flag == 1)
  737.  		storage_storageget(sd, item_index, item_amount);
  738. @@ -11399,34 +11427,41 @@
  739.  
  740.  /// Request to move an item from cart to storage (CZ_MOVE_ITEM_FROM_CART_TO_STORE).
  741.  /// 0129 <index>.W <amount>.L
  742. -void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd)
  743. -{
  744. +void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd){
  745. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  746. +
  747. +	int idx = RFIFOW(fd,info->pos[0]) - 2;
  748. +	int amount = RFIFOL(fd,info->pos[1]);
  749. +
  750.  	if( sd->state.vending )
  751.  		return;
  752.  	if (!pc_iscarton(sd))
  753.  		return;
  754.  
  755.  	if (sd->state.storage_flag == 1)
  756. -		storage_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
  757. +		storage_storageaddfromcart(sd, idx, amount);
  758.  	else if (sd->state.storage_flag == 2)
  759. -		storage_guild_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
  760. +		storage_guild_storageaddfromcart(sd, idx, amount);
  761.  }
  762.  
  763.  
  764.  /// Request to move an item from storage to cart (CZ_MOVE_ITEM_FROM_STORE_TO_CART).
  765.  /// 0128 <index>.W <amount>.L
  766. -void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd)
  767. -{
  768. +void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd){
  769. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  770. +	int idx = RFIFOW(fd,info->pos[0]) - 1;
  771. +	int amount = RFIFOL(fd,info->pos[1]);
  772. +
  773.  	if( sd->state.vending )
  774.  		return;
  775.  	if (!pc_iscarton(sd))
  776.  		return;
  777.  
  778.  	if (sd->state.storage_flag == 1)
  779. -		storage_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
  780. +		storage_storagegettocart(sd, idx, amount);
  781.  	else
  782.  	if (sd->state.storage_flag == 2)
  783. -		storage_guild_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
  784. +		storage_guild_storagegettocart(sd, idx, amount);
  785.  }
  786.  
  787.  
  788. @@ -11497,10 +11532,8 @@
  789.  
  790.  /// Party creation request
  791.  /// 00f9 <party name>.24B (CZ_MAKE_GROUP)
  792. -/// 01e8 <party name>.24B <item pickup rule>.B <item share rule>.B (CZ_MAKE_GROUP2)
  793. -void clif_parse_CreateParty(int fd, struct map_session_data *sd)
  794. -{
  795. -	char* name = (char*)RFIFOP(fd,2);
  796. +void clif_parse_CreateParty(int fd, struct map_session_data *sd){
  797. +	char* name = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  798.  	name[NAME_LENGTH-1] = '\0';
  799.  
  800.  	if( map[sd->bl.m].flag.partylock ) {// Party locked.
  801. @@ -11515,11 +11548,12 @@
  802.  	party_create(sd,name,0,0);
  803.  }
  804.  
  805. -void clif_parse_CreateParty2(int fd, struct map_session_data *sd)
  806. -{
  807. -	char* name = (char*)RFIFOP(fd,2);
  808. -	int item1 = RFIFOB(fd,26);
  809. -	int item2 = RFIFOB(fd,27);
  810. +/// 01e8 <party name>.24B <item pickup rule>.B <item share rule>.B (CZ_MAKE_GROUP2)
  811. +void clif_parse_CreateParty2(int fd, struct map_session_data *sd){
  812. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  813. +	char* name = (char*)RFIFOP(fd,info->pos[0]);
  814. +	int item1 = RFIFOB(fd,info->pos[1]);
  815. +	int item2 = RFIFOB(fd,info->pos[2]);
  816.  	name[NAME_LENGTH-1] = '\0';
  817.  
  818.  	if( map[sd->bl.m].flag.partylock ) {// Party locked.
  819. @@ -11547,7 +11581,7 @@
  820.  		return;
  821.  	}
  822.  
  823. -	t_sd = map_id2sd(RFIFOL(fd,2));
  824. +	t_sd = map_id2sd(RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  825.  
  826.  	if(t_sd && t_sd->state.noask) {// @noask [LuzZza]
  827.  		clif_noask_sub(sd, t_sd, 1);
  828. @@ -11557,10 +11591,9 @@
  829.  	party_invite(sd, t_sd);
  830.  }
  831.  
  832. -void clif_parse_PartyInvite2(int fd, struct map_session_data *sd)
  833. -{
  834. +void clif_parse_PartyInvite2(int fd, struct map_session_data *sd){
  835.  	struct map_session_data *t_sd;
  836. -	char *name = (char*)RFIFOP(fd,2);
  837. +	char *name = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  838.  	name[NAME_LENGTH-1] = '\0';
  839.  
  840.  	if(map[sd->bl.m].flag.partylock) {// Party locked.
  841. @@ -11587,12 +11620,14 @@
  842.  ///     1 = accept
  843.  void clif_parse_ReplyPartyInvite(int fd,struct map_session_data *sd)
  844.  {
  845. -	party_reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6));
  846. +	party_reply_invite(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]),
  847. +	    RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]));
  848.  }
  849.  
  850.  void clif_parse_ReplyPartyInvite2(int fd,struct map_session_data *sd)
  851.  {
  852. -	party_reply_invite(sd,RFIFOL(fd,2),RFIFOB(fd,6));
  853. +	party_reply_invite(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]),
  854. +	    RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]));
  855.  }
  856.  
  857.  
  858. @@ -11616,7 +11651,8 @@
  859.  		clif_displaymessage(fd, msg_txt(sd,227));
  860.  		return;
  861.  	}
  862. -	party_removemember(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6));
  863. +	party_removemember(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]),
  864. +	    (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]));
  865.  }
  866.  
  867.  
  868. @@ -11627,7 +11663,10 @@
  869.  {
  870.  	struct party_data *p;
  871.  	int i;
  872. +	int expflag = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  873. +	int itemflag = (RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1])?1:0)|(RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2])?2:0);
  874.  
  875. +
  876.  	if( !sd->status.party_id )
  877.  		return;
  878.  
  879. @@ -11644,9 +11683,9 @@
  880.  
  881.  #if PACKETVER < 20090603
  882.  	//Client can't change the item-field
  883. -	party_changeoption(sd, RFIFOL(fd,2), p->party.item);
  884. +	party_changeoption(sd, expflag, p->party.item);
  885.  #else
  886. -	party_changeoption(sd, RFIFOL(fd,2), ((RFIFOB(fd,6)?1:0)|(RFIFOB(fd,7)?2:0)));
  887. +	party_changeoption(sd, expflag, itemflag);
  888.  #endif
  889.  }
  890.  
  891. @@ -11655,8 +11694,8 @@
  892.  /// 0108 <packet len>.W <text>.?B (<name> : <message>) 00
  893.  void clif_parse_PartyMessage(int fd, struct map_session_data* sd)
  894.  {
  895. -	const char* text = (char*)RFIFOP(fd,4);
  896. -	int textlen = RFIFOW(fd,2) - 4;
  897. +	int textlen = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]) - 4;
  898. +	const char* text = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  899.  
  900.  	char *name, *message;
  901.  	int namelen, messagelen;
  902. @@ -11668,7 +11707,7 @@
  903.  	if( is_atcommand(fd, sd, message, 1)  )
  904.  		return;
  905.  
  906. -	if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
  907. +	if( sd->sc.cant.chat )
  908.  		return;
  909.  
  910.  	if( battle_config.min_chat_delay )
  911. @@ -11687,9 +11726,8 @@
  912.  
  913.  /// Changes Party Leader (CZ_CHANGE_GROUP_MASTER).
  914.  /// 07da <account id>.L
  915. -void clif_parse_PartyChangeLeader(int fd, struct map_session_data* sd)
  916. -{
  917. -	party_changeleader(sd, map_id2sd(RFIFOL(fd,2)));
  918. +void clif_parse_PartyChangeLeader(int fd, struct map_session_data* sd){
  919. +	party_changeleader(sd, map_id2sd(RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])));
  920.  }
  921.  
  922.  
  923. @@ -11700,13 +11738,14 @@
  924.  /// 0802 <level>.W <map id>.W { <job>.W }*6
  925.  void clif_parse_PartyBookingRegisterReq(int fd, struct map_session_data* sd)
  926.  {
  927. -	short level = RFIFOW(fd,2);
  928. -	short mapid = RFIFOW(fd,4);
  929. +	short level = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  930. +	short mapid = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  931. +	int idxpbj = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]);
  932.  	short job[PARTY_BOOKING_JOBS];
  933.  	int i;
  934.  
  935.  	for(i=0; i<PARTY_BOOKING_JOBS; i++)
  936. -		job[i] = RFIFOB(fd,6+i*2);
  937. +		job[i] = RFIFOB(fd,idxpbj+i*2);
  938.  
  939.  	party_booking_register(sd, level, mapid, job);
  940.  }
  941. @@ -11731,13 +11770,13 @@
  942.  
  943.  /// Request to search for party booking advertisments (CZ_PARTY_BOOKING_REQ_SEARCH).
  944.  /// 0804 <level>.W <map id>.W <job>.W <last index>.L <result count>.W
  945. -void clif_parse_PartyBookingSearchReq(int fd, struct map_session_data* sd)
  946. -{
  947. -	short level = RFIFOW(fd,2);
  948. -	short mapid = RFIFOW(fd,4);
  949. -	short job = RFIFOW(fd,6);
  950. -	unsigned long lastindex = RFIFOL(fd,8);
  951. -	short resultcount = RFIFOW(fd,12);
  952. +void clif_parse_PartyBookingSearchReq(int fd, struct map_session_data* sd){
  953. +	int cmd = RFIFOW(fd,0);
  954. +	short level = RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[0]);
  955. +	short mapid = RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[1]);
  956. +	short job = RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[2]);
  957. +	unsigned long lastindex = RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[3]);
  958. +	short resultcount = RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[4]);
  959.  
  960.  	party_booking_search(sd, level, mapid, job, lastindex, resultcount);
  961.  }
  962. @@ -11805,9 +11844,10 @@
  963.  {
  964.  	short job[PARTY_BOOKING_JOBS];
  965.  	int i;
  966. +	int idxpbu = packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0];
  967.  
  968.  	for(i=0; i<PARTY_BOOKING_JOBS; i++)
  969. -		job[i] = RFIFOW(fd,2+i*2);
  970. +		job[i] = RFIFOW(fd,idxpbu+i*2);
  971.  
  972.  	party_booking_update(sd, job);
  973.  }
  974. @@ -11880,7 +11920,7 @@
  975.  	if( sd->npc_id ) {// using an NPC
  976.  		return;
  977.  	}
  978. -	vending_vendinglistreq(sd,RFIFOL(fd,2));
  979. +	vending_vendinglistreq(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  980.  }
  981.  
  982.  
  983. @@ -11888,9 +11928,9 @@
  984.  /// 0134 <packet len>.W <account id>.L { <amount>.W <index>.W }*
  985.  void clif_parse_PurchaseReq(int fd, struct map_session_data* sd)
  986.  {
  987. -	int len = (int)RFIFOW(fd,2) - 8;
  988. -	int id = (int)RFIFOL(fd,4);
  989. -	const uint8* data = (uint8*)RFIFOP(fd,8);
  990. +	int len = (int)RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]) - 8;
  991. +	int id = (int)RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  992. +	const uint8* data = (uint8*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]);
  993.  
  994.  	vending_purchasereq(sd, id, sd->vended_id, data, len/4);
  995.  
  996. @@ -11903,10 +11943,10 @@
  997.  /// 0801 <packet len>.W <account id>.L <unique id>.L { <amount>.W <index>.W }*
  998.  void clif_parse_PurchaseReq2(int fd, struct map_session_data* sd)
  999.  {
  1000. -	int len = (int)RFIFOW(fd,2) - 12;
  1001. -	int aid = (int)RFIFOL(fd,4);
  1002. -	int uid = (int)RFIFOL(fd,8);
  1003. -	const uint8* data = (uint8*)RFIFOP(fd,12);
  1004. +	int len = (int)RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]) - 12;
  1005. +	int aid = (int)RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  1006. +	int uid = (int)RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]);
  1007. +	const uint8* data = (uint8*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3]);
  1008.  
  1009.  	vending_purchasereq(sd, aid, uid, data, len/4);
  1010.  
  1011. @@ -11921,12 +11961,12 @@
  1012.  /// result:
  1013.  ///     0 = canceled
  1014.  ///     1 = open
  1015. -void clif_parse_OpenVending(int fd, struct map_session_data* sd)
  1016. -{
  1017. -	short len = (short)RFIFOW(fd,2) - 85;
  1018. -	const char* message = (char*)RFIFOP(fd,4);
  1019. -	bool flag = (bool)RFIFOB(fd,84);
  1020. -	const uint8* data = (uint8*)RFIFOP(fd,85);
  1021. +void clif_parse_OpenVending(int fd, struct map_session_data* sd){
  1022. +	int cmd = RFIFOW(fd,0);
  1023. +	short len = (short)RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[0]) - 85;
  1024. +	const char* message = (char*)RFIFOP(fd,packet_db[sd->packet_ver][cmd].pos[1]);
  1025. +	bool flag = (bool)RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[2]);
  1026. +	const uint8* data = (uint8*)RFIFOP(fd,packet_db[sd->packet_ver][cmd].pos[3]);
  1027.  
  1028.  	if( !flag )
  1029.  		sd->state.prevend = 0;
  1030. @@ -11951,9 +11991,9 @@
  1031.  
  1032.  /// Guild creation request (CZ_REQ_MAKE_GUILD).
  1033.  /// 0165 <char id>.L <guild name>.24B
  1034. -void clif_parse_CreateGuild(int fd,struct map_session_data *sd)
  1035. -{
  1036. -	char* name = (char*)RFIFOP(fd,6);
  1037. +void clif_parse_CreateGuild(int fd,struct map_session_data *sd){
  1038. +	//int charid = RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[0]);
  1039. +	char* name = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  1040.  	name[NAME_LENGTH-1] = '\0';
  1041.  
  1042.  	if(map[sd->bl.m].flag.guildlock) { //Guild locked.
  1043. @@ -11985,10 +12025,11 @@
  1044.  ///     6 = notice
  1045.  void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd)
  1046.  {
  1047. +	int type = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1048.  	if( !sd->status.guild_id && !sd->bg_id )
  1049.  		return;
  1050.  
  1051. -	switch( RFIFOL(fd,2) )
  1052. +	switch( type )
  1053.  	{
  1054.  	case 0:	// Basic Information Guild, hostile alliance information
  1055.  		clif_guild_basicinfo(sd);
  1056. @@ -12009,7 +12050,7 @@
  1057.  		clif_guild_expulsionlist(sd);
  1058.  		break;
  1059.  	default:
  1060. -		ShowError("clif: guild request info: unknown type %d\n", RFIFOL(fd,2));
  1061. +		ShowError("clif: guild request info: unknown type %d\n", type);
  1062.  		break;
  1063.  	}
  1064.  }
  1065. @@ -12020,11 +12061,14 @@
  1066.  void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd)
  1067.  {
  1068.  	int i;
  1069. +	int cmd = RFIFOW(fd,0);
  1070. +	int len = RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[0]);
  1071. +	int idxgpos = packet_db[sd->packet_ver][cmd].pos[1];
  1072.  
  1073.  	if(!sd->state.gmaster_flag)
  1074.  		return;
  1075.  
  1076. -	for(i = 4; i < RFIFOW(fd,2); i += 40 ){
  1077. +	for(i = idxgpos; i < len; i += 40 ){
  1078.  		guild_change_position(sd->status.guild_id, RFIFOL(fd,i), RFIFOL(fd,i+4), RFIFOL(fd,i+12), (char*)RFIFOP(fd,i+16));
  1079.  	}
  1080.  }
  1081. @@ -12035,11 +12079,14 @@
  1082.  void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd)
  1083.  {
  1084.  	int i;
  1085. +	int cmd = RFIFOW(fd,0);
  1086. +	int len = RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[0]);
  1087. +	int idxgpos = packet_db[sd->packet_ver][cmd].pos[1];
  1088.  
  1089.  	if(!sd->state.gmaster_flag)
  1090.  		return;
  1091.  
  1092. -	for(i=4;i<RFIFOW(fd,2);i+=12){
  1093. +	for(i=idxgpos;i<len;i+=12){
  1094.  		guild_change_memberposition(sd->status.guild_id,
  1095.  			RFIFOL(fd,i),RFIFOL(fd,i+4),RFIFOL(fd,i+8));
  1096.  	}
  1097. @@ -12051,7 +12098,7 @@
  1098.  void clif_parse_GuildRequestEmblem(int fd,struct map_session_data *sd)
  1099.  {
  1100.  	struct guild* g;
  1101. -	int guild_id = RFIFOL(fd,2);
  1102. +	int guild_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1103.  
  1104.  	if( (g = guild_search(guild_id)) != NULL )
  1105.  		clif_guild_emblem(sd,g);
  1106. @@ -12079,8 +12126,8 @@
  1107.  /// 0153 <packet len>.W <emblem data>.?B
  1108.  void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd)
  1109.  {
  1110. -	unsigned long emblem_len = RFIFOW(fd,2)-4;
  1111. -	const uint8* emblem = RFIFOP(fd,4);
  1112. +	unsigned long emblem_len = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-4;
  1113. +	const uint8* emblem = RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  1114.  
  1115.  	if( !emblem_len || !sd->state.gmaster_flag )
  1116.  		return;
  1117. @@ -12099,9 +12146,9 @@
  1118.  /// 016e <guild id>.L <msg1>.60B <msg2>.120B
  1119.  void clif_parse_GuildChangeNotice(int fd, struct map_session_data* sd)
  1120.  {
  1121. -	int guild_id = RFIFOL(fd,2);
  1122. -	char* msg1 = (char*)RFIFOP(fd,6);
  1123. -	char* msg2 = (char*)RFIFOP(fd,66);
  1124. +	int guild_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1125. +	char* msg1 = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  1126. +	char* msg2 = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]);
  1127.  
  1128.  	if(!sd->state.gmaster_flag)
  1129.  		return;
  1130. @@ -12138,7 +12185,7 @@
  1131.  /// 0168 <account id>.L <inviter account id>.L <inviter char id>.L
  1132.  void clif_parse_GuildInvite(int fd,struct map_session_data *sd)
  1133.  {
  1134. -	struct map_session_data *t_sd = map_id2sd(RFIFOL(fd,2));
  1135. +	struct map_session_data *t_sd = map_id2sd(RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]));
  1136.  
  1137.  	if (clif_sub_guild_invite(fd, sd, t_sd))
  1138.  		return;
  1139. @@ -12148,7 +12195,7 @@
  1140.  /// 0916 <char name>.24B (CZ_REQ_JOIN_GUILD2)
  1141.  void
  1142.  clif_parse_GuildInvite2(int fd, struct map_session_data *sd) {
  1143. -	struct map_session_data *t_sd = map_nick2sd((char *)RFIFOP(fd, 2));
  1144. +	struct map_session_data *t_sd = map_nick2sd((char *)RFIFOP(fd, packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  1145.  
  1146.  	if (clif_sub_guild_invite(fd, sd, t_sd))
  1147.  		return;
  1148. @@ -12162,7 +12209,8 @@
  1149.  ///     1 = accept
  1150.  void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd)
  1151.  {
  1152. -	guild_reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6));
  1153. +	guild_reply_invite(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]),
  1154. +	    RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]));
  1155.  }
  1156.  
  1157.  
  1158. @@ -12179,7 +12227,10 @@
  1159.  		return;
  1160.  	}
  1161.  
  1162. -	guild_leave(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14));
  1163. +	guild_leave(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]),
  1164. +	    RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]),
  1165. +	    RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]),
  1166. +	    (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3]));
  1167.  }
  1168.  
  1169.  
  1170. @@ -12192,17 +12243,20 @@
  1171.  		clif_displaymessage(fd, msg_txt(sd,228));
  1172.  		return;
  1173.  	}
  1174. -	guild_expulsion(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14));
  1175. +	guild_expulsion(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]),
  1176. +	    RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]),
  1177. +	    RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]),
  1178. +	    (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3]));
  1179.  }
  1180.  
  1181.  
  1182.  /// Validates and processes guild messages (CZ_GUILD_CHAT).
  1183.  /// 017e <packet len>.W <text>.?B (<name> : <message>) 00
  1184. -void clif_parse_GuildMessage(int fd, struct map_session_data* sd)
  1185. -{
  1186. -	const char* text = (char*)RFIFOP(fd,4);
  1187. -	int textlen = RFIFOW(fd,2) - 4;
  1188. +void clif_parse_GuildMessage(int fd, struct map_session_data* sd){
  1189. +	int textlen = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]) - 4;
  1190. +	const char* text = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  1191.  
  1192. +
  1193.  	char *name, *message;
  1194.  	int namelen, messagelen;
  1195.  
  1196. @@ -12213,7 +12267,7 @@
  1197.  	if( is_atcommand(fd, sd, message, 1) )
  1198.  		return;
  1199.  
  1200. -	if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
  1201. +	if( sd->sc.cant.chat )
  1202.  		return;
  1203.  
  1204.  	if( battle_config.min_chat_delay )
  1205. @@ -12247,7 +12301,7 @@
  1206.  		return;
  1207.  	}
  1208.  
  1209. -	t_sd = map_id2sd(RFIFOL(fd,2));
  1210. +	t_sd = map_id2sd(RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  1211.  
  1212.  	// @noask [LuzZza]
  1213.  	if(t_sd && t_sd->state.noask) {
  1214. @@ -12266,7 +12320,9 @@
  1215.  ///     1 = accept
  1216.  void clif_parse_GuildReplyAlliance(int fd, struct map_session_data *sd)
  1217.  {
  1218. -	guild_reply_reqalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
  1219. +	guild_reply_reqalliance(sd,
  1220. +	    RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]),
  1221. +	    RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]));
  1222.  }
  1223.  
  1224.  
  1225. @@ -12284,7 +12340,9 @@
  1226.  		clif_displaymessage(fd, msg_txt(sd,228));
  1227.  		return;
  1228.  	}
  1229. -	guild_delalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6));
  1230. +	guild_delalliance(sd,
  1231. +	    RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]),
  1232. +	    RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]));
  1233.  }
  1234.  
  1235.  
  1236. @@ -12302,7 +12360,7 @@
  1237.  		return;
  1238.  	}
  1239.  
  1240. -	t_sd = map_id2sd(RFIFOL(fd,2));
  1241. +	t_sd = map_id2sd(RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  1242.  
  1243.  	// @noask [LuzZza]
  1244.  	if(t_sd && t_sd->state.noask) {
  1245. @@ -12325,7 +12383,7 @@
  1246.  		clif_displaymessage(fd, msg_txt(sd,228));
  1247.  		return;
  1248.  	}
  1249. -	guild_break(sd,(char*)RFIFOP(fd,2));
  1250. +	guild_break(sd,(char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  1251.  }
  1252.  
  1253.  
  1254. @@ -12340,30 +12398,27 @@
  1255.  ///     2 = performance
  1256.  ///     3 = return to egg
  1257.  ///     4 = unequip accessory
  1258. -void clif_parse_PetMenu(int fd, struct map_session_data *sd)
  1259. -{
  1260. -	pet_menu(sd,RFIFOB(fd,2));
  1261. +void clif_parse_PetMenu(int fd, struct map_session_data *sd){
  1262. +	pet_menu(sd,RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  1263.  }
  1264.  
  1265.  
  1266.  /// Attempt to tame a monster (CZ_TRYCAPTURE_MONSTER).
  1267.  /// 019f <id>.L
  1268. -void clif_parse_CatchPet(int fd, struct map_session_data *sd)
  1269. -{
  1270. -	pet_catch_process2(sd,RFIFOL(fd,2));
  1271. +void clif_parse_CatchPet(int fd, struct map_session_data *sd){
  1272. +	pet_catch_process2(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  1273.  }
  1274.  
  1275.  
  1276.  /// Answer to pet incubator egg selection dialog (CZ_SELECT_PETEGG).
  1277.  /// 01a7 <index>.W
  1278. -void clif_parse_SelectEgg(int fd, struct map_session_data *sd)
  1279. -{
  1280. +void clif_parse_SelectEgg(int fd, struct map_session_data *sd){
  1281.  	if (sd->menuskill_id != SA_TAMINGMONSTER || sd->menuskill_val != -1) {
  1282.  		//Forged packet, disconnect them [Kevin]
  1283.  		clif_authfail_fd(fd, 0);
  1284.  		return;
  1285.  	}
  1286. -	pet_select_egg(sd,RFIFOW(fd,2)-2);
  1287. +	pet_select_egg(sd,RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2);
  1288.  	clif_menuskill_clear(sd);
  1289.  }
  1290.  
  1291. @@ -12395,7 +12450,7 @@
  1292.  void clif_parse_SendEmotion(int fd, struct map_session_data *sd)
  1293.  {
  1294.  	if(sd->pd)
  1295. -		clif_pet_emotion(sd->pd,RFIFOL(fd,2));
  1296. +		clif_pet_emotion(sd->pd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  1297.  }
  1298.  
  1299.  
  1300. @@ -12403,7 +12458,7 @@
  1301.  /// 01a5 <name>.24B
  1302.  void clif_parse_ChangePetName(int fd, struct map_session_data *sd)
  1303.  {
  1304. -	pet_change_name(sd,(char*)RFIFOP(fd,2));
  1305. +	pet_change_name(sd,(char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  1306.  }
  1307.  
  1308.  
  1309. @@ -12416,7 +12471,7 @@
  1310.  	struct block_list *target;
  1311.  	int tid;
  1312.  
  1313. -	tid = RFIFOL(fd,2);
  1314. +	tid = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1315.  	target = map_id2bl(tid);
  1316.  	if (!target) {
  1317.  		clif_GM_kickack(sd, 0);
  1318. @@ -12484,7 +12539,7 @@
  1319.  	char *player_name;
  1320.  	char command[NAME_LENGTH+8];
  1321.  
  1322. -	player_name = (char*)RFIFOP(fd,2);
  1323. +	player_name = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1324.  	player_name[NAME_LENGTH-1] = '\0';
  1325.  
  1326.  	sprintf(command, "%cjumpto %s", atcommand_symbol, player_name);
  1327. @@ -12521,7 +12576,7 @@
  1328.  	char *player_name;
  1329.  	char command [NAME_LENGTH+8];
  1330.  
  1331. -	player_name = (char*)RFIFOP(fd,2);
  1332. +	player_name = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1333.  	player_name[NAME_LENGTH-1] = '\0';
  1334.  
  1335.  	sprintf(command, "%crecall %s", atcommand_symbol, player_name);
  1336. @@ -12554,7 +12609,7 @@
  1337.  	char *monster_item_name;
  1338.  	char command[NAME_LENGTH+10];
  1339.  
  1340. -	monster_item_name = (char*)RFIFOP(fd,2);
  1341. +	monster_item_name = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1342.  	monster_item_name[NAME_LENGTH-1] = '\0';
  1343.  
  1344.  	// FIXME: Should look for item first, then for monster.
  1345. @@ -12600,9 +12655,9 @@
  1346.  	struct map_session_data *dstsd;
  1347.  	char command[NAME_LENGTH+15];
  1348.  
  1349. -	id = RFIFOL(fd,2);
  1350. -	type = RFIFOB(fd,6);
  1351. -	value = RFIFOW(fd,7);
  1352. +	id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1353. +	type = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  1354. +	value = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]);
  1355.  
  1356.  	if( type == 0 )
  1357.  		value = -value;
  1358. @@ -12627,7 +12682,7 @@
  1359.  void clif_parse_GMRc(int fd, struct map_session_data* sd)
  1360.  {
  1361.  	char command[NAME_LENGTH+15];
  1362. -	char *name = (char*)RFIFOP(fd,2);
  1363. +	char *name = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1364.  
  1365.  	name[NAME_LENGTH-1] = '\0';
  1366.  	sprintf(command, "%cmute %d %s", atcommand_symbol, 60, name);
  1367. @@ -12653,7 +12708,7 @@
  1368.  /// 01df <account id>.L
  1369.  void clif_parse_GMReqAccountName(int fd, struct map_session_data *sd)
  1370.  {
  1371. -	int account_id = RFIFOL(fd,2);
  1372. +	int account_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1373.  
  1374.  	//TODO: find out if this works for any player or only for authorized GMs
  1375.  	clif_account_name(sd, account_id, ""); // insert account name here >_<
  1376. @@ -12673,9 +12728,9 @@
  1377.  	if( pc_has_permission(sd, PC_PERM_USE_CHANGEMAPTYPE) )
  1378.  		return;
  1379.  
  1380. -	x = RFIFOW(fd,2);
  1381. -	y = RFIFOW(fd,4);
  1382. -	type = RFIFOW(fd,6);
  1383. +	x = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1384. +	y = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  1385. +	type = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]);
  1386.  
  1387.  	map_setgatcell(sd->bl.m,x,y,type);
  1388.  	clif_changemapcell(0,sd->bl.m,x,y,type,ALL_SAMEMAP);
  1389. @@ -12695,9 +12750,9 @@
  1390.  	uint8 type;
  1391.  	int i;
  1392.  
  1393. -	nick = (char*)RFIFOP(fd,2); // speed up
  1394. +	nick = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1395.  	nick[NAME_LENGTH-1] = '\0'; // to be sure that the player name has at most 23 characters
  1396. -	type = RFIFOB(fd,26);
  1397. +	type = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  1398.  
  1399.  	if( type == 0 ) { // Add name to ignore list (block)
  1400.  		if (strcmp(wisp_server_name, nick) == 0) {
  1401. @@ -12744,7 +12799,7 @@
  1402.  ///     1 = (/inall) allow all speech
  1403.  void clif_parse_PMIgnoreAll(int fd, struct map_session_data *sd)
  1404.  {
  1405. -	int type = RFIFOB(fd,2), flag;
  1406. +	int type = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), flag;
  1407.  
  1408.  	if( type == 0 ) {// Deny all
  1409.  		if( sd->state.ignoreAll ) {
  1410. @@ -12956,7 +13011,7 @@
  1411.  	struct map_session_data *f_sd;
  1412.  	int i;
  1413.  
  1414. -	f_sd = map_nick2sd((char*)RFIFOP(fd,2));
  1415. +	f_sd = map_nick2sd((char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  1416.  
  1417.  	// ensure that the request player's friend list is not full
  1418.  	ARR_FIND(0, MAX_FRIENDS, i, sd->status.friends[i].char_id == 0);
  1419. @@ -13009,12 +13064,12 @@
  1420.  	int account_id;
  1421.  	char reply;
  1422.  
  1423. -	account_id = RFIFOL(fd,2);
  1424. -	//char_id = RFIFOL(fd,6);
  1425. +	account_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1426. +	//char_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  1427.  #if PACKETVER < 6
  1428. -	reply = RFIFOB(fd,10);
  1429. +	reply = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]);
  1430.  #else
  1431. -	reply = RFIFOL(fd,10);
  1432. +	reply = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]);
  1433.  #endif
  1434.  
  1435.  	if( sd->bl.id == account_id ) {// adding oneself as friend
  1436. @@ -13073,8 +13128,8 @@
  1437.  	int account_id, char_id;
  1438.  	int i, j;
  1439.  
  1440. -	account_id = RFIFOL(fd,2);
  1441. -	char_id = RFIFOL(fd,6);
  1442. +	account_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1443. +	char_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  1444.  
  1445.  	// Search friend
  1446.  	for (i = 0; i < MAX_FRIENDS &&
  1447. @@ -13382,17 +13437,15 @@
  1448.  
  1449.  /// Request to change homunculus' name (CZ_RENAME_MER).
  1450.  /// 0231 <name>.24B
  1451. -void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd)
  1452. -{
  1453. -	merc_hom_change_name(sd,(char*)RFIFOP(fd,2));
  1454. +void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd){
  1455. +	merc_hom_change_name(sd,(char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  1456.  }
  1457.  
  1458.  
  1459.  /// Request to warp/move homunculus/mercenary to it's owner (CZ_REQUEST_MOVETOOWNER).
  1460.  /// 0234 <id>.L
  1461. -void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd)
  1462. -{
  1463. -	int id = RFIFOL(fd,2); // Mercenary or Homunculus
  1464. +void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd){
  1465. +	int id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); // Mercenary or Homunculus
  1466.  	struct block_list *bl = NULL;
  1467.  	struct unit_data *ud = NULL;
  1468.  
  1469. @@ -13413,7 +13466,7 @@
  1470.  /// 0232 <id>.L <position data>.3B
  1471.  void clif_parse_HomMoveTo(int fd, struct map_session_data *sd)
  1472.  {
  1473. -	int id = RFIFOL(fd,2); // Mercenary or Homunculus
  1474. +	int id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); // Mercenary or Homunculus
  1475.  	struct block_list *bl = NULL;
  1476.  	short x, y;
  1477.  
  1478. @@ -13437,9 +13490,9 @@
  1479.  void clif_parse_HomAttack(int fd,struct map_session_data *sd)
  1480.  {
  1481.  	struct block_list *bl = NULL;
  1482. -	int id = RFIFOL(fd,2),
  1483. -		target_id = RFIFOL(fd,6),
  1484. -		action_type = RFIFOB(fd,10);
  1485. +	int id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1486. +	int target_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  1487. +	int action_type = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]);
  1488.  
  1489.  	if( merc_is_hom_active(sd->hd) && sd->hd->bl.id == id )
  1490.  		bl = &sd->hd->bl;
  1491. @@ -13462,10 +13515,7 @@
  1492.  ///     2 = delete
  1493.  void clif_parse_HomMenu(int fd, struct map_session_data *sd)
  1494.  {	//[orn]
  1495. -	int cmd;
  1496. -
  1497. -	cmd = RFIFOW(fd,0);
  1498. -
  1499. +	int cmd = RFIFOW(fd,0);
  1500.  	if(!merc_is_hom_active(sd->hd))
  1501.  		return;
  1502.  
  1503. @@ -13785,14 +13835,14 @@
  1504.  /// 0241 <mail id>.L
  1505.  void clif_parse_Mail_read(int fd, struct map_session_data *sd)
  1506.  {
  1507. -	int mail_id = RFIFOL(fd,2);
  1508. +	int mail_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1509.  
  1510.  	if( mail_id <= 0 )
  1511.  		return;
  1512.  	if( mail_invalid_operation(sd) )
  1513.  		return;
  1514.  
  1515. -	clif_Mail_read(sd, RFIFOL(fd,2));
  1516. +	clif_Mail_read(sd, mail_id);
  1517.  }
  1518.  
  1519.  
  1520. @@ -13800,7 +13850,7 @@
  1521.  /// 0244 <mail id>.L
  1522.  void clif_parse_Mail_getattach(int fd, struct map_session_data *sd)
  1523.  {
  1524. -	int mail_id = RFIFOL(fd,2);
  1525. +	int mail_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1526.  	int i;
  1527.  	bool fail = false;
  1528.  
  1529. @@ -13860,9 +13910,8 @@
  1530.  
  1531.  /// Request to delete a mail (CZ_MAIL_DELETE).
  1532.  /// 0243 <mail id>.L
  1533. -void clif_parse_Mail_delete(int fd, struct map_session_data *sd)
  1534. -{
  1535. -	int mail_id = RFIFOL(fd,2);
  1536. +void clif_parse_Mail_delete(int fd, struct map_session_data *sd){
  1537. +	int mail_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1538.  	int i;
  1539.  
  1540.  	if( !chrif_isconnected() )
  1541. @@ -13888,9 +13937,8 @@
  1542.  
  1543.  /// Request to return a mail (CZ_REQ_MAIL_RETURN).
  1544.  /// 0273 <mail id>.L <receive name>.24B
  1545. -void clif_parse_Mail_return(int fd, struct map_session_data *sd)
  1546. -{
  1547. -	int mail_id = RFIFOL(fd,2);
  1548. +void clif_parse_Mail_return(int fd, struct map_session_data *sd){
  1549. +	int mail_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1550.  	int i;
  1551.  
  1552.  	if( mail_id <= 0 )
  1553. @@ -13908,10 +13956,9 @@
  1554.  
  1555.  /// Request to add an item or Zeny to mail (CZ_MAIL_ADD_ITEM).
  1556.  /// 0247 <index>.W <amount>.L
  1557. -void clif_parse_Mail_setattach(int fd, struct map_session_data *sd)
  1558. -{
  1559. -	int idx = RFIFOW(fd,2);
  1560. -	int amount = RFIFOL(fd,4);
  1561. +void clif_parse_Mail_setattach(int fd, struct map_session_data *sd){
  1562. +	int idx = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1563. +	int amount = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  1564.  	unsigned char flag;
  1565.  
  1566.  	if( !chrif_isconnected() )
  1567. @@ -13932,7 +13979,7 @@
  1568.  ///     2 = remove zeny
  1569.  void clif_parse_Mail_winopen(int fd, struct map_session_data *sd)
  1570.  {
  1571. -	int flag = RFIFOW(fd,2);
  1572. +	int flag = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1573.  
  1574.  	if (flag == 0 || flag == 1)
  1575.  		mail_removeitem(sd, 0);
  1576. @@ -13946,6 +13993,7 @@
  1577.  void clif_parse_Mail_send(int fd, struct map_session_data *sd)
  1578.  {
  1579.  	struct mail_message msg;
  1580. +	int cmd = RFIFOW(fd,0);
  1581.  	int body_len;
  1582.  
  1583.  	if( !chrif_isconnected() )
  1584. @@ -13953,7 +14001,7 @@
  1585.  	if( sd->state.trading )
  1586.  		return;
  1587.  
  1588. -	if( RFIFOW(fd,2) < 69 ) {
  1589. +	if( RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[0]) < 69 ) {
  1590.  		ShowWarning("Invalid Msg Len from account %d.\n", sd->status.account_id);
  1591.  		return;
  1592.  	}
  1593. @@ -13964,7 +14012,7 @@
  1594.  		return;
  1595.  	}
  1596.  
  1597. -	body_len = RFIFOB(fd,68);
  1598. +	body_len = RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[3]);
  1599.  
  1600.  	if (body_len > MAIL_BODY_LENGTH)
  1601.  		body_len = MAIL_BODY_LENGTH;
  1602. @@ -13980,15 +14028,15 @@
  1603.  	msg.send_id = sd->status.char_id;
  1604.  	msg.dest_id = 0; // will attempt to resolve name
  1605.  	safestrncpy(msg.send_name, sd->status.name, NAME_LENGTH);
  1606. -	safestrncpy(msg.dest_name, (char*)RFIFOP(fd,4), NAME_LENGTH);
  1607. -	safestrncpy(msg.title, (char*)RFIFOP(fd,28), MAIL_TITLE_LENGTH);
  1608. +	safestrncpy(msg.dest_name, (char*)RFIFOP(fd,packet_db[sd->packet_ver][cmd].pos[1]), NAME_LENGTH);
  1609. +	safestrncpy(msg.title, (char*)RFIFOP(fd,packet_db[sd->packet_ver][cmd].pos[2]), MAIL_TITLE_LENGTH);
  1610.  
  1611.  	if (msg.title[0] == '\0') {
  1612.  		return; // Message has no length and somehow client verification was skipped.
  1613.  	}
  1614.  
  1615.  	if (body_len)
  1616. -		safestrncpy(msg.body, (char*)RFIFOP(fd,69), body_len + 1);
  1617. +		safestrncpy(msg.body, (char*)RFIFOP(fd,RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[4])), body_len + 1);
  1618.  	else
  1619.  		memset(msg.body, 0x00, MAIL_BODY_LENGTH);
  1620.  
  1621. @@ -14100,10 +14148,10 @@
  1622.  
  1623.  /// Request to add an item to the action (CZ_AUCTION_ADD_ITEM).
  1624.  /// 024c <index>.W <count>.L
  1625. -void clif_parse_Auction_setitem(int fd, struct map_session_data *sd)
  1626. -{
  1627. -	int idx = RFIFOW(fd,2) - 2;
  1628. -	int amount = RFIFOL(fd,4); // Always 1
  1629. +void clif_parse_Auction_setitem(int fd, struct map_session_data *sd){
  1630. +	int cmd = RFIFOW(fd,0);
  1631. +	int idx = RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[0]) - 2;
  1632. +	int amount = RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[1]); // Always 1
  1633.  	struct item_data *item;
  1634.  
  1635.  	if( sd->auction.amount > 0 )
  1636. @@ -14180,10 +14228,11 @@
  1637.  {
  1638.  	struct auction_data auction;
  1639.  	struct item_data *item;
  1640. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  1641.  
  1642. -	auction.price = RFIFOL(fd,2);
  1643. -	auction.buynow = RFIFOL(fd,6);
  1644. -	auction.hours = RFIFOW(fd,10);
  1645. +	auction.price = RFIFOL(fd,info->pos[0]);
  1646. +	auction.buynow = RFIFOL(fd,info->pos[1]);
  1647. +	auction.hours = RFIFOW(fd,info->pos[2]);
  1648.  
  1649.  	// Invalid Situations...
  1650.  	if( sd->auction.amount < 1 ) {
  1651. @@ -14258,30 +14307,26 @@
  1652.  
  1653.  /// Cancels an auction (CZ_AUCTION_ADD_CANCEL).
  1654.  /// 024e <auction id>.L
  1655. -void clif_parse_Auction_cancel(int fd, struct map_session_data *sd)
  1656. -{
  1657. -	unsigned int auction_id = RFIFOL(fd,2);
  1658. -
  1659. +void clif_parse_Auction_cancel(int fd, struct map_session_data *sd){
  1660. +	unsigned int auction_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1661.  	intif_Auction_cancel(sd->status.char_id, auction_id);
  1662.  }
  1663.  
  1664.  
  1665.  /// Closes an auction (CZ_AUCTION_REQ_MY_SELL_STOP).
  1666.  /// 025d <auction id>.L
  1667. -void clif_parse_Auction_close(int fd, struct map_session_data *sd)
  1668. -{
  1669. -	unsigned int auction_id = RFIFOL(fd,2);
  1670. -
  1671. +void clif_parse_Auction_close(int fd, struct map_session_data *sd){
  1672. +	unsigned int auction_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1673.  	intif_Auction_close(sd->status.char_id, auction_id);
  1674.  }
  1675.  
  1676.  
  1677.  /// Places a bid on an auction (CZ_AUCTION_BUY).
  1678.  /// 024f <auction id>.L <money>.L
  1679. -void clif_parse_Auction_bid(int fd, struct map_session_data *sd)
  1680. -{
  1681. -	unsigned int auction_id = RFIFOL(fd,2);
  1682. -	int bid = RFIFOL(fd,6);
  1683. +void clif_parse_Auction_bid(int fd, struct map_session_data *sd){
  1684. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  1685. +	unsigned int auction_id = RFIFOL(fd,info->pos[0]);
  1686. +	int bid = RFIFOL(fd,info->pos[1]);
  1687.  
  1688.  	if( !pc_can_give_items(sd) ) { //They aren't supposed to give zeny [Inkfish]
  1689.  		clif_displaymessage(sd->fd, msg_txt(sd,246));
  1690. @@ -14310,15 +14355,16 @@
  1691.  ///     3 = misc
  1692.  ///     4 = name search
  1693.  ///     5 = auction id search
  1694. -void clif_parse_Auction_search(int fd, struct map_session_data* sd)
  1695. -{
  1696. +void clif_parse_Auction_search(int fd, struct map_session_data* sd){
  1697.  	char search_text[NAME_LENGTH];
  1698. -	short type = RFIFOW(fd,2), page = RFIFOW(fd,32);
  1699. -	int price = RFIFOL(fd,4);  // FIXME: bug #5071
  1700. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  1701. +	short type = RFIFOW(fd,info->pos[0]);
  1702. +	int price = RFIFOL(fd,info->pos[1]);  // FIXME: bug #5071
  1703. +	int page = RFIFOW(fd,info->pos[3]);
  1704.  
  1705.  	clif_parse_Auction_cancelreg(fd, sd);
  1706.  
  1707. -	safestrncpy(search_text, (char*)RFIFOP(fd,8), sizeof(search_text));
  1708. +	safestrncpy(search_text, (char*)RFIFOP(fd,info->pos[2]), sizeof(search_text));
  1709.  	intif_Auction_requestlist(sd->status.char_id, type, price, search_text, page);
  1710.  }
  1711.  
  1712. @@ -14330,7 +14376,7 @@
  1713.  ///     1 = buy (own bids)
  1714.  void clif_parse_Auction_buysell(int fd, struct map_session_data* sd)
  1715.  {
  1716. -	short type = RFIFOW(fd,2) + 6;
  1717. +	short type = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]) + 6;
  1718.  	clif_parse_Auction_cancelreg(fd, sd);
  1719.  
  1720.  	intif_Auction_requestlist(sd->status.char_id, type, 0, "", 1);
  1721. @@ -14415,20 +14461,21 @@
  1722.  	int fail = 0;
  1723.  	nullpo_retv(sd);
  1724.  
  1725. -    if( sd->state.trading || !sd->npc_shopid )
  1726. -        fail = 1;
  1727. -    else {
  1728. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  1729. +	if( sd->state.trading || !sd->npc_shopid )
  1730. +		fail = 1;
  1731. +	else {
  1732.  #if PACKETVER < 20101116
  1733. -		short nameid = RFIFOW(fd,2);
  1734. -		short amount = RFIFOW(fd,4);
  1735. -		int points = RFIFOL(fd,6);
  1736. +		short nameid = RFIFOW(fd,info->pos[0]);
  1737. +		short amount = RFIFOW(fd,info->pos[1]);
  1738. +		int points   = RFIFOL(fd,info->pos[2]);
  1739.  
  1740.  		fail = npc_cashshop_buy(sd, nameid, amount, points);
  1741.  #else
  1742. -		int len = RFIFOW(fd,2);
  1743. -		int points = RFIFOL(fd,4);
  1744. -		int count = RFIFOW(fd,8);
  1745. -		unsigned short* item_list = (unsigned short*)RFIFOP(fd,10);
  1746. +		int len    = RFIFOW(fd,info->pos[0]);
  1747. +		int points = RFIFOL(fd,info->pos[1]);
  1748. +		int count  = RFIFOW(fd,info->pos[2]);
  1749. +		unsigned short* item_list = (unsigned short*)RFIFOP(fd,info->pos[3]);
  1750.  
  1751.  		if( len < 10 || len != 10 + count * 4)
  1752.  		{
  1753. @@ -14443,7 +14490,6 @@
  1754.  }
  1755.  #endif
  1756.  
  1757. -
  1758.  /// Adoption System
  1759.  ///
  1760.  
  1761. @@ -14483,7 +14529,8 @@
  1762.  /// 01f9 <account id>.L
  1763.  void clif_parse_Adopt_request(int fd, struct map_session_data *sd)
  1764.  {
  1765. -	struct map_session_data *tsd = map_id2sd(RFIFOL(fd,2)), *p_sd = map_charid2sd(sd->status.partner_id);
  1766. +	TBL_PC *tsd = map_id2sd(RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  1767. +	TBL_PC *p_sd = map_charid2sd(sd->status.partner_id);
  1768.  
  1769.  	if( pc_can_Adopt(sd, p_sd, tsd) )
  1770.  	{
  1771. @@ -14500,9 +14547,10 @@
  1772.  ///     1 = accepted
  1773.  void clif_parse_Adopt_reply(int fd, struct map_session_data *sd)
  1774.  {
  1775. -	int p1_id = RFIFOL(fd,2);
  1776. -	int p2_id = RFIFOL(fd,6);
  1777. -	int result = RFIFOL(fd,10);
  1778. +	int cmd = RFIFOW(fd,0);
  1779. +	int p1_id = RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[0]);
  1780. +	int p2_id = RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[1]);
  1781. +	int result = RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[2]);
  1782.  	struct map_session_data* p1_sd = map_id2sd(p1_id);
  1783.  	struct map_session_data* p2_sd = map_id2sd(p2_id);
  1784.  
  1785. @@ -14568,7 +14616,7 @@
  1786.  /// 02d6 <account id>.L
  1787.  void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd)
  1788.  {
  1789. -	int charid = RFIFOL(fd, 2);
  1790. +	int charid = RFIFOL(fd, packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  1791.  	struct map_session_data* tsd = map_id2sd(charid);
  1792.  
  1793.  	if (!tsd)
  1794. @@ -14590,7 +14638,8 @@
  1795.  ///         1 = enabled
  1796.  void clif_parse_EquipTick(int fd, struct map_session_data* sd)
  1797.  {
  1798. -	bool flag = (bool)RFIFOL(fd,6);
  1799. +	//int type = RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[0]);
  1800. +	bool flag = (bool)RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  1801.  	sd->status.show_equip = flag;
  1802.  	clif_equiptickack(sd, flag);
  1803.  }
  1804. @@ -14721,7 +14770,9 @@
  1805.  /// 02b6 <quest id>.L <active>.B
  1806.  void clif_parse_questStateAck(int fd, struct map_session_data * sd)
  1807.  {
  1808. -	quest_update_status(sd, RFIFOL(fd,2), RFIFOB(fd,6)?Q_ACTIVE:Q_INACTIVE);
  1809. +	int cmd = RFIFOW(fd,0);
  1810. +	quest_update_status(sd, RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[0]),
  1811. +	    RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[1])?Q_ACTIVE:Q_INACTIVE);
  1812.  }
  1813.  
  1814.  
  1815. @@ -14921,7 +14972,7 @@
  1816.  ///     2 = delete
  1817.  void clif_parse_mercenary_action(int fd, struct map_session_data* sd)
  1818.  {
  1819. -	int option = RFIFOB(fd,2);
  1820. +	int option = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1821.  	if( sd->md == NULL )
  1822.  		return;
  1823.  
  1824. @@ -15066,8 +15117,8 @@
  1825.  /// 0x2db <packet len>.W <text>.?B (<name> : <message>) 00
  1826.  void clif_parse_BattleChat(int fd, struct map_session_data* sd)
  1827.  {
  1828. -	const char* text = (char*)RFIFOP(fd,4);
  1829. -	int textlen = RFIFOW(fd,2) - 4;
  1830. +	int textlen = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]) - 4;
  1831. +	const char* text = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
  1832.  
  1833.  	char *name, *message;
  1834.  	int namelen, messagelen;
  1835. @@ -15078,7 +15129,7 @@
  1836.  	if( is_atcommand(fd, sd, message, 1) )
  1837.  		return;
  1838.  
  1839. -	if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
  1840. +	if( sd->sc.cant.chat )
  1841.  		return;
  1842.  
  1843.  	if( battle_config.min_chat_delay ) {
  1844. @@ -15340,19 +15391,18 @@
  1845.  ///         constructed, this state tracking was rendered useless,
  1846.  ///         as the only skill unit, that is sent with 0x1c9 is
  1847.  ///         Graffiti.
  1848. -void clif_parse_LessEffect(int fd, struct map_session_data* sd)
  1849. -{
  1850. +void clif_parse_LessEffect(int fd, struct map_session_data* sd){
  1851.  	int isLess = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1852. -
  1853.  	sd->state.lesseffect = ( isLess != 0 );
  1854.  }
  1855.  
  1856.  /// S 07e4 <length>.w <option>.l <val>.l {<index>.w <amount>.w).4b*
  1857.  void clif_parse_ItemListWindowSelected(int fd, struct map_session_data* sd) {
  1858. -	int n = (RFIFOW(fd,2)-12) / 4;
  1859. -	int type = RFIFOL(fd,4);
  1860. -	int flag = RFIFOL(fd,8); // Button clicked: 0 = Cancel, 1 = OK
  1861. -	unsigned short* item_list = (unsigned short*)RFIFOP(fd,12);
  1862. +	int cmd = RFIFOW(fd,0);
  1863. +	int n = (RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[0])-12) / 4;
  1864. +	int type = RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[0]);
  1865. +	int flag = RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[0]); // Button clicked: 0 = Cancel, 1 = OK
  1866. +	unsigned short* item_list = (unsigned short*)RFIFOP(fd,packet_db[sd->packet_ver][cmd].pos[0]);
  1867.  
  1868.  	if( sd->state.trading || sd->npc_shopid )
  1869.  		return;
  1870. @@ -16238,13 +16288,14 @@
  1871.  	if( sd->menuskill_id != SC_AUTOSHADOWSPELL )
  1872.  		return;
  1873.  
  1874. +
  1875.  	if( pc_istrading(sd) ) {
  1876.  		clif_skill_fail(sd,sd->ud.skill_id,0,0);
  1877.  		clif_menuskill_clear(sd);
  1878.  		return;
  1879.  	}
  1880.  
  1881. -	skill_select_menu(sd,RFIFOW(fd,6));
  1882. +	skill_select_menu(sd,RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]));
  1883.  
  1884.  	clif_menuskill_clear(sd);
  1885.  }
  1886. @@ -16272,21 +16323,21 @@
  1887.  /// 	1 = move item to normal tab
  1888.  void clif_parse_MoveItem(int fd, struct map_session_data *sd) {
  1889.  #if PACKETVER >= 20111122
  1890. -	int index;
  1891. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  1892. +	int index = RFIFOW(fd,info->pos[0])-2;
  1893. +	int type = RFIFOB(fd, info->pos[1]);
  1894.  
  1895.  	/* can't move while dead. */
  1896.  	if(pc_isdead(sd)) {
  1897.  		return;
  1898.  	}
  1899.  
  1900. -	index = RFIFOW(fd,2)-2;
  1901. -
  1902.  	if (index < 0 || index >= MAX_INVENTORY)
  1903.  		return;
  1904.  
  1905. -	if ( sd->status.inventory[index].favorite && RFIFOB(fd, 4) == 1 )
  1906. +	if ( sd->status.inventory[index].favorite && type == 1 )
  1907.  		sd->status.inventory[index].favorite = 0;
  1908. -	else if( RFIFOB(fd, 4) == 0 )
  1909. +	else if( type == 0 )
  1910.  		sd->status.inventory[index].favorite = 1;
  1911.  	else
  1912.  		return;/* nothing to do. */
  1913. @@ -16348,6 +16399,29 @@
  1914.  	// No need to do anything here
  1915.  }
  1916.  
  1917. +//08c0 <len>.W <openIdentity>.L <itemcount>.W (ZC_ACK_SE_CASH_ITEM_LIST2)
  1918. +void clif_parse_CashShopReqTab(int fd, struct map_session_data *sd) {
  1919. +	short tab = RFIFOW(fd, packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
  1920. +	int j;
  1921. +
  1922. +	if( tab < 0 || tab > CASHSHOP_TAB_SEARCH )
  1923. +		return;
  1924. +
  1925. +	WFIFOHEAD(fd, 10 + ( cash_shop_items[tab].count * 6 ) );
  1926. +	WFIFOW(fd, 0) = 0x8c0;
  1927. +	WFIFOW(fd, 2) = 10 + ( cash_shop_items[tab].count * 6 );
  1928. +	WFIFOL(fd, 4) = tab;
  1929. +	WFIFOW(fd, 8) = cash_shop_items[tab].count;
  1930. +
  1931. +	for( j = 0; j < cash_shop_items[tab].count; j++ ) {
  1932. +		WFIFOW(fd, 10 + ( 6 * j ) ) = cash_shop_items[tab].item[j]->nameid;
  1933. +		WFIFOL(fd, 12 + ( 6 * j ) ) = cash_shop_items[tab].item[j]->price;
  1934. +	}
  1935. +
  1936. +	WFIFOSET(fd, 10 + ( cash_shop_items[tab].count * 6 ));
  1937. +}
  1938. +
  1939. +//08ca <len>.W <itemcount> W <tabcode>.W (ZC_ACK_SCHEDULER_CASHITEM)
  1940.  void clif_cashshop_list( int fd ){
  1941.  	int tab;
  1942.  
  1943. @@ -16377,14 +16451,16 @@
  1944.  // TODO: find a more accurate date for this
  1945.  #if PACKETVER >= 20130320
  1946.  void clif_parse_cashshop_buy( int fd, struct map_session_data *sd ){
  1947. -	uint16 length = RFIFOW( fd, 2 );
  1948. -	uint16 count = RFIFOL( fd, 4 );
  1949. +	struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
  1950. +	uint16 length = RFIFOW( fd, info->pos[0] );
  1951. +	uint16 count = RFIFOW( fd, info->pos[1] );
  1952.  
  1953.  	if( length < 10 || length < ( 10 + count * 6 ) ){
  1954.  		return;
  1955.  	}
  1956.  
  1957. -	cashshop_buylist( sd, RFIFOL( fd, 6 ), count, (uint16 *)RFIFOP( fd, 10 ) );
  1958. +	cashshop_buylist( sd, RFIFOL( fd, info->pos[2] ),
  1959. +	    count, (uint16 *)RFIFOP( fd, info->pos[3] ) );
  1960.  }
  1961.  #endif
  1962.  
  1963. @@ -17056,6 +17132,7 @@
  1964.  		{ clif_parse_cashshop_close, "cashshopclose" },
  1965.  		{ clif_parse_cashshop_list_request, "cashshopitemlist" },
  1966.  		{ clif_parse_cashshop_buy, "cashshopbuy" },
  1967. +		{ clif_parse_CashShopReqTab, "cashshopreqtab"},
  1968.  		/* */
  1969.  		{ clif_parse_MoveItem , "moveitem" },
  1970.  		{ clif_parse_GuildInvite2 , "guildinvite2" },
  1971.  
Viewed 1279 times, submitted by lighta.