Index: src/map/clif.c =================================================================== --- src/map/clif.c (revision 17352) +++ src/map/clif.c (working copy) @@ -6598,7 +6598,7 @@ WBUFW(buf,0)=0x109; WBUFW(buf,2)=len+8; WBUFL(buf,4)=account_id; - safestrncpy((char *)WBUFP(buf,8), mes, len); + safestrncpy((char *)WBUFP(buf,8), mes, len); clif_send(buf,len+8,&sd->bl,PARTY); } } @@ -8866,13 +8866,14 @@ char *text, *name, *message; unsigned int packetlen, textlen, namelen, messagelen; int fd = sd->fd; + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; *name_ = NULL; *namelen_ = 0; *message_ = NULL; *messagelen_ = 0; - packetlen = RFIFOW(fd,2); + packetlen = RFIFOW(fd,info->pos[0]); // basic structure checks if( packetlen < 4 + 1 ) { // 4-byte header and at least an empty string is expected @@ -8880,7 +8881,7 @@ return false; } - text = (char*)RFIFOP(fd,4); + text = (char*)RFIFOP(fd,info->pos[1]); textlen = packetlen - 4; // process part of the packet @@ -9491,15 +9492,14 @@ void clif_parse_Hotkey(int fd, struct map_session_data *sd) { #ifdef HOTKEY_SAVING unsigned short idx; - int cmd; + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; - cmd = RFIFOW(fd, 0); - idx = RFIFOW(fd, packet_db[sd->packet_ver][cmd].pos[0]); + idx = RFIFOW(fd, info->pos[0]); if (idx >= MAX_HOTKEYS) return; - sd->status.hotkeys[idx].type = RFIFOB(fd, packet_db[sd->packet_ver][cmd].pos[1]); - sd->status.hotkeys[idx].id = RFIFOL(fd, packet_db[sd->packet_ver][cmd].pos[2]); - sd->status.hotkeys[idx].lv = RFIFOW(fd, packet_db[sd->packet_ver][cmd].pos[3]); + sd->status.hotkeys[idx].type = RFIFOB(fd,info->pos[1]); + sd->status.hotkeys[idx].id = RFIFOL(fd, info->pos[2]); + sd->status.hotkeys[idx].lv = RFIFOW(fd, info->pos[3]); #endif } @@ -9658,9 +9658,11 @@ /// There are various variants of this packet. void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) { - const char* text = (char*)RFIFOP(fd,4); - int textlen = RFIFOW(fd,2) - 4; + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + int textlen = RFIFOW(fd,info->pos[0]) - 4; + const char* text = (char*)RFIFOP(fd,info->pos[1]); + char *name, *message, *fakename = NULL; int namelen, messagelen; @@ -9673,7 +9675,7 @@ if( is_atcommand(fd, sd, message, 1) ) return; - if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) ) + if( sd->sc.cant.chat ) return; if( battle_config.min_chat_delay ) { //[Skotlex] @@ -9707,7 +9709,7 @@ safestrncpy((char*)WFIFOP(fd,4), fakename, textlen); aFree(fakename); } else { - memcpy(WFIFOP(fd,0), RFIFOP(fd,0), RFIFOW(fd,2)); + memcpy(WFIFOP(fd,0), RFIFOP(fd,0), RFIFOW(fd,info->pos[0])); WFIFOW(fd,0) = 0x8e; } WFIFOSET(fd, WFIFOW(fd,2)); @@ -9731,10 +9733,13 @@ { char command[MAP_NAME_LENGTH_EXT+25]; char* map_name; + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; - map_name = (char*)RFIFOP(fd,2); + map_name = (char*)RFIFOP(fd,info->pos[0]); map_name[MAP_NAME_LENGTH_EXT-1]='\0'; - sprintf(command, "%cmapmove %s %d %d", atcommand_symbol, map_name, RFIFOW(fd,18), RFIFOW(fd,20)); + sprintf(command, "%cmapmove %s %d %d", atcommand_symbol, map_name, + RFIFOW(fd,info->pos[1]), //x + RFIFOW(fd,info->pos[2])); //y is_atcommand(fd, sd, command, 1); } @@ -9780,9 +9785,10 @@ void clif_parse_ChangeDir(int fd, struct map_session_data *sd) { unsigned char headdir, dir; + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; - headdir = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); - dir = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); + headdir = RFIFOB(fd,info->pos[0]); + dir = RFIFOB(fd,info->pos[1]); pc_setdir(sd, dir, headdir); clif_changed_dir(&sd->bl, AREA_WOS); @@ -9944,9 +9950,10 @@ /// There are various variants of this packet, some of them have padding between fields. void clif_parse_ActionRequest(int fd, struct map_session_data *sd) { + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; clif_parse_ActionRequest_sub(sd, - RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]), - RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), + RFIFOB(fd,info->pos[1]), + RFIFOL(fd,info->pos[0]), gettick() ); } @@ -9959,7 +9966,7 @@ /// 1 = char-select (disconnect) void clif_parse_Restart(int fd, struct map_session_data *sd) { - switch(RFIFOB(fd,2)) { + switch(RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])) { case 0x00: pc_respawn(sd,CLR_RESPAWN); break; @@ -9994,7 +10001,7 @@ if ( is_atcommand(fd, sd, message, 1) ) return; - if (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)) + if (sd->sc.cant.chat) return; if (battle_config.min_chat_delay) { //[Skotlex] @@ -10118,8 +10125,9 @@ /// 0099 .W .?B 00 void clif_parse_Broadcast(int fd, struct map_session_data* sd) { char command[CHAT_SIZE_MAX+11]; - char* msg = (char*)RFIFOP(fd,4); - unsigned int len = RFIFOW(fd,2)-4; + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + unsigned int len = RFIFOW(fd,info->pos[0])-4; + char* msg = (char*)RFIFOP(fd,info->pos[1]); // as the length varies depending on the command used, just block unreasonably long strings mes_len_check(msg, len, CHAT_SIZE_MAX); @@ -10151,9 +10159,6 @@ if (fitem == NULL || fitem->bl.type != BL_ITEM || fitem->bl.m != sd->bl.m) break; - if( sd->sc.cant.pickup ) - break; - if (pc_cant_act(sd)) break; @@ -10171,10 +10176,10 @@ /// 00a2 .W .W (CZ_ITEM_THROW) /// 0363 .W .W (CZ_ITEM_THROW2) /// There are various variants of this packet, some of them have padding between fields. -void clif_parse_DropItem(int fd, struct map_session_data *sd) -{ - int item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2; - int item_amount = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); +void clif_parse_DropItem(int fd, struct map_session_data *sd){ + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + int item_index = RFIFOW(fd,info->pos[0]) -2; + int item_amount = RFIFOW(fd,info->pos[1]) ; for(;;) { if (pc_isdead(sd)) @@ -10234,12 +10239,13 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd) { int index, req_pos; + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; if(pc_isdead(sd)) { clif_clearunit_area(&sd->bl,CLR_DEAD); return; } - index = RFIFOW(fd,2)-2; + index = RFIFOW(fd,info->pos[0])-2; if (index < 0 || index >= MAX_INVENTORY) return; //Out of bounds check. @@ -10269,9 +10275,9 @@ pc_equipitem(sd,index,EQP_AMMO); else { #if PACKETVER >= 20120925 - req_pos = RFIFOL(fd,4); + req_pos = RFIFOL(fd,info->pos[1]); #else - req_pos = (int)RFIFOW(fd,4); + req_pos = (int)RFIFOW(fd,info->pos[1]); #endif pc_equipitem(sd,index,req_pos); } @@ -10297,7 +10303,7 @@ else if (pc_cant_act2(sd)) return; - index = RFIFOW(fd,2)-2; + index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2; pc_unequipitem(sd,index,1); } @@ -10319,7 +10325,7 @@ if (pc_cant_act2(sd)) return; - bl = map_id2bl(RFIFOL(fd,2)); + bl = map_id2bl(RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); if (!bl) return; switch (bl->type) { case BL_MOB: @@ -10341,9 +10347,10 @@ /// 1 = sell void clif_parse_NpcBuySellSelected(int fd,struct map_session_data *sd) { + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; if (sd->state.trading) return; - npc_buysellsel(sd,RFIFOL(fd,2),RFIFOB(fd,6)); + npc_buysellsel(sd,RFIFOL(fd,info->pos[0]),RFIFOB(fd,info->pos[1])); } @@ -10369,8 +10376,9 @@ /// 00c8 .W { .W .W }* void clif_parse_NpcBuyListSend(int fd, struct map_session_data* sd) { - int n = (RFIFOW(fd,2)-4) /4; - unsigned short* item_list = (unsigned short*)RFIFOP(fd,4); + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + int n = (RFIFOW(fd,info->pos[0])-4) /4; + unsigned short* item_list = (unsigned short*)RFIFOP(fd,info->pos[1]); int result; if( sd->state.trading || !sd->npc_shopid ) @@ -10406,9 +10414,10 @@ { int fail=0,n; unsigned short *item_list; + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; - n = (RFIFOW(fd,2)-4) /4; - item_list = (unsigned short*)RFIFOP(fd,4); + n = (RFIFOW(fd,info->pos[0])-4) /4; // (pktlen-(cmd+len))/listsize + item_list = (unsigned short*)RFIFOP(fd,info->pos[1]); if (sd->state.trading || !sd->npc_shopid) fail = 1; @@ -10428,11 +10437,12 @@ /// 1 = public void clif_parse_CreateChatRoom(int fd, struct map_session_data* sd) { - int len = RFIFOW(fd,2)-15; - int limit = RFIFOW(fd,4); - bool pub = (RFIFOB(fd,6) != 0); - const char* password = (char*)RFIFOP(fd,7); //not zero-terminated - const char* title = (char*)RFIFOP(fd,15); // not zero-terminated + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + int len = RFIFOW(fd,info->pos[0])-15; + int limit = RFIFOW(fd,info->pos[1]); + bool pub = (RFIFOB(fd,info->pos[2]) != 0); + const char* password = (char*)RFIFOP(fd,info->pos[3]); //not zero-terminated + const char* title = (char*)RFIFOP(fd,info->pos[4]); // not zero-terminated char s_password[CHATROOM_PASS_SIZE]; char s_title[CHATROOM_TITLE_SIZE]; @@ -10464,10 +10474,10 @@ /// Chatroom join request (CZ_REQ_ENTER_ROOM). /// 00d9 .L .8B -void clif_parse_ChatAddMember(int fd, struct map_session_data* sd) -{ - int chatid = RFIFOL(fd,2); - const char* password = (char*)RFIFOP(fd,6); // not zero-terminated +void clif_parse_ChatAddMember(int fd, struct map_session_data* sd){ + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + int chatid = RFIFOL(fd,info->pos[0]); + const char* password = (char*)RFIFOP(fd,info->pos[1]); // not zero-terminated chat_joinchat(sd,chatid,password); } @@ -10478,13 +10488,13 @@ /// type: /// 0 = private /// 1 = public -void clif_parse_ChatRoomStatusChange(int fd, struct map_session_data* sd) -{ - int len = RFIFOW(fd,2)-15; - int limit = RFIFOW(fd,4); - bool pub = (RFIFOB(fd,6) != 0); - const char* password = (char*)RFIFOP(fd,7); // not zero-terminated - const char* title = (char*)RFIFOP(fd,15); // not zero-terminated +void clif_parse_ChatRoomStatusChange(int fd, struct map_session_data* sd){ + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + int len = RFIFOW(fd,info->pos[0])-15; + int limit = RFIFOW(fd,info->pos[1]); + bool pub = (RFIFOB(fd,info->pos[2]) != 0); + const char* password = (char*)RFIFOP(fd,info->pos[3]); // not zero-terminated + const char* title = (char*)RFIFOP(fd,info->pos[4]); // not zero-terminated char s_password[CHATROOM_PASS_SIZE]; char s_title[CHATROOM_TITLE_SIZE]; @@ -10505,7 +10515,7 @@ /// 1 = normal void clif_parse_ChangeChatOwner(int fd, struct map_session_data* sd) { - chat_changechatowner(sd,(char*)RFIFOP(fd,6)); + chat_changechatowner(sd,(char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); } @@ -10513,7 +10523,7 @@ /// 00e2 .24B void clif_parse_KickFromChat(int fd,struct map_session_data *sd) { - chat_kickchat(sd,(char*)RFIFOP(fd,2)); + chat_kickchat(sd,(char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); } @@ -10547,7 +10557,7 @@ { struct map_session_data *t_sd; - t_sd = map_id2sd(RFIFOL(fd,2)); + t_sd = map_id2sd(RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); if(!sd->chatID && pc_cant_act(sd)) return; //You can trade while in a chatroom. @@ -10574,7 +10584,7 @@ /// 4 = rejected void clif_parse_TradeAck(int fd,struct map_session_data *sd) { - trade_tradeack(sd,RFIFOB(fd,2)); + trade_tradeack(sd,RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); } @@ -10582,8 +10592,9 @@ /// 00e8 .W .L void clif_parse_TradeAddItem(int fd,struct map_session_data *sd) { - short index = RFIFOW(fd,2); - int amount = RFIFOL(fd,4); + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + short index = RFIFOW(fd,info->pos[0]); + int amount = RFIFOL(fd,info->pos[1]); if( index == 0 ) trade_tradeaddzeny(sd, amount); @@ -10628,11 +10639,13 @@ /// 0126 .W .L void clif_parse_PutItemToCart(int fd,struct map_session_data *sd) { + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; if (pc_istrading(sd)) return; if (!pc_iscarton(sd)) return; - pc_putitemtocart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4)); + pc_putitemtocart(sd,RFIFOW(fd,info->pos[0])-2, + RFIFOL(fd,info->pos[1])); } @@ -10640,9 +10653,11 @@ /// 0127 .W .L void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd) { + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; if (!pc_iscarton(sd)) return; - pc_getitemfromcart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4)); + pc_getitemfromcart(sd,RFIFOW(fd,info->pos[0])-2, + RFIFOL(fd,info->pos[1])); } @@ -10672,7 +10687,7 @@ if( sd && pc_checkskill(sd, MC_CHANGECART) < 1 ) return; - type = (int)RFIFOW(fd,2); + type = (int)RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); #ifdef NEW_CARTS if( (type == 9 && sd->status.base_level > 131) || (type == 8 && sd->status.base_level > 121) || @@ -10703,7 +10718,7 @@ /// the like void clif_parse_StatusUp(int fd,struct map_session_data *sd) { - pc_statusup(sd,RFIFOW(fd,2)); + pc_statusup(sd,RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); } @@ -10711,7 +10726,7 @@ /// 0112 .W void clif_parse_SkillUp(int fd,struct map_session_data *sd) { - pc_skillup(sd,RFIFOW(fd,2)); + pc_skillup(sd,RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); } 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) @@ -10817,10 +10832,11 @@ uint16 skill_id, skill_lv; int tmp, target_id; unsigned int tick = gettick(); + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; - skill_lv = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); - skill_id = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); - target_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]); + skill_lv = RFIFOW(fd,info->pos[0]); + skill_id = RFIFOW(fd,info->pos[1]); + target_id = RFIFOL(fd,info->pos[2]); if( skill_lv < 1 ) skill_lv = 1; //No clue, I have seen the client do this with guild skills :/ [Skotlex] @@ -10993,16 +11009,17 @@ /// There are various variants of this packet, some of them have padding between fields. void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd) { + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; if (pc_cant_act(sd)) return; if (pc_issit(sd)) return; clif_parse_UseSkillToPosSub(fd, sd, - RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), //skill lv - RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]), //skill num - RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]), //pos x - RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3]), //pos y + RFIFOW(fd,info->pos[0]), //skill lv + RFIFOW(fd,info->pos[1]), //skill num + RFIFOW(fd,info->pos[2]), //pos x + RFIFOW(fd,info->pos[3]), //pos y -1 //Skill more info. ); } @@ -11014,17 +11031,18 @@ /// There are various variants of this packet, some of them have padding between fields. void clif_parse_UseSkillToPosMoreInfo(int fd, struct map_session_data *sd) { + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; if (pc_cant_act(sd)) return; if (pc_issit(sd)) return; clif_parse_UseSkillToPosSub(fd, sd, - RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), //Skill lv - RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]), //Skill num - RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]), //pos x - RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3]), //pos y - packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[4] //skill more info + RFIFOW(fd,info->pos[0]), //Skill lv + RFIFOW(fd,info->pos[1]), //Skill num + RFIFOW(fd,info->pos[2]), //pos x + RFIFOW(fd,info->pos[3]), //pos y + info->pos[4] //skill more info ); } @@ -11033,9 +11051,10 @@ /// 011b .W .16B void clif_parse_UseSkillMap(int fd, struct map_session_data* sd) { - uint16 skill_id = RFIFOW(fd,2); + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + uint16 skill_id = RFIFOW(fd,info->pos[0]); char map_name[MAP_NAME_LENGTH]; - mapindex_getmapname((char*)RFIFOP(fd,4), map_name); + mapindex_getmapname((char*)RFIFOP(fd,info->pos[1]), map_name); if(skill_id != sd->menuskill_id) return; @@ -11061,8 +11080,12 @@ /// Answer to pharmacy item selection dialog (CZ_REQMAKINGITEM). /// 018e .W { .W }*3 -void clif_parse_ProduceMix(int fd,struct map_session_data *sd) -{ +void clif_parse_ProduceMix(int fd,struct map_session_data *sd){ + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + int nameid = RFIFOW(fd,info->pos[0]); + int slot1 = RFIFOW(fd,info->pos[1]); + int slot2 = RFIFOW(fd,info->pos[2]); + int slot3 = RFIFOW(fd,info->pos[3]); switch( sd->menuskill_id ) { case -1: case AM_PHARMACY: @@ -11078,8 +11101,8 @@ clif_menuskill_clear(sd); return; } - if( skill_can_produce_mix(sd,RFIFOW(fd,2),sd->menuskill_val, 1) ) - skill_produce_mix(sd,0,RFIFOW(fd,2),RFIFOW(fd,4),RFIFOW(fd,6),RFIFOW(fd,8), 1); + if( skill_can_produce_mix(sd,nameid,sd->menuskill_val, 1) ) + skill_produce_mix(sd,0,nameid,slot1,slot2,slot3, 1); clif_menuskill_clear(sd); } @@ -11094,8 +11117,9 @@ /// 5 = GN_MAKEBOMB /// 6 = GN_S_PHARMACY void clif_parse_Cooking(int fd,struct map_session_data *sd) { - int type = RFIFOW(fd,2); - int nameid = RFIFOW(fd,4); + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + int type = RFIFOW(fd,info->pos[0]); + int nameid = RFIFOW(fd,info->pos[1]); int amount = sd->menuskill_val2?sd->menuskill_val2:1; if( type == 6 && sd->menuskill_id != GN_MIX_COOKING && sd->menuskill_id != GN_S_PHARMACY ) return; @@ -11124,7 +11148,7 @@ clif_menuskill_clear(sd); return; } - skill_repairweapon(sd,RFIFOW(fd,2)); + skill_repairweapon(sd,RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); clif_menuskill_clear(sd); } @@ -11156,10 +11180,10 @@ /// 255 = cancel /// NOTE: If there were more than 254 items in the list, choice /// overflows to choice%256. -void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd) -{ - int npc_id = RFIFOL(fd,2); - uint8 select = RFIFOB(fd,6); +void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd){ + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + int npc_id = RFIFOL(fd,info->pos[0]); + uint8 select = RFIFOB(fd,info->pos[1]); if( (select > sd->npc_menu && select != 0xff) || select == 0 ) { #ifdef SECURE_NPCTIMEOUT @@ -11183,16 +11207,16 @@ /// 00b9 .L void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd) { - npc_scriptcont(sd,RFIFOL(fd,2), false); + npc_scriptcont(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), false); } /// NPC numeric input dialog value (CZ_INPUT_EDITDLG). /// 0143 .L .L -void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd) -{ - int npcid = RFIFOL(fd,2); - int amount = (int)RFIFOL(fd,6); +void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd){ + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + int npcid = RFIFOL(fd,info->pos[0]); + int amount = (int)RFIFOL(fd,info->pos[1]); sd->npc_amount = amount; npc_scriptcont(sd, npcid, false); @@ -11201,11 +11225,11 @@ /// NPC text input dialog value (CZ_INPUT_EDITDLGSTR). /// 01d5 .W .L .?B -void clif_parse_NpcStringInput(int fd, struct map_session_data* sd) -{ - int message_len = RFIFOW(fd,2)-8; - int npcid = RFIFOL(fd,4); - const char* message = (char*)RFIFOP(fd,8); +void clif_parse_NpcStringInput(int fd, struct map_session_data* sd){ + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + int message_len = RFIFOW(fd,info->pos[0])-8; + int npcid = RFIFOL(fd,info->pos[1]); + const char* message = (char*)RFIFOP(fd,info->pos[2]); if( message_len <= 0 ) return; // invalid input @@ -11221,7 +11245,7 @@ { if (!sd->npc_id) //Avoid parsing anything when the script was done with. [Skotlex] return; - npc_scriptcont(sd, RFIFOL(fd,2), true); + npc_scriptcont(sd, RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), true); } @@ -11231,7 +11255,7 @@ /// -1 = cancel void clif_parse_ItemIdentify(int fd,struct map_session_data *sd) { - short idx = RFIFOW(fd,2); + short idx = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); if (sd->menuskill_id != MC_IDENTIFY) return; @@ -11246,8 +11270,8 @@ /// Answer to arrow crafting item selection dialog (CZ_REQ_MAKINGARROW). /// 01ae .W -void clif_parse_SelectArrow(int fd,struct map_session_data *sd) -{ +void clif_parse_SelectArrow(int fd,struct map_session_data *sd){ + int nameid = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); if (pc_istrading(sd)) { //Make it fail to avoid shop exploits where you sell something different than you see. clif_skill_fail(sd,sd->ud.skill_id,USESKILL_FAIL_LEVEL,0); @@ -11256,19 +11280,19 @@ } switch( sd->menuskill_id ) { case AC_MAKINGARROW: - skill_arrow_create(sd,RFIFOW(fd,2)); + skill_arrow_create(sd,nameid); break; case SA_CREATECON: - skill_produce_mix(sd,SA_CREATECON,RFIFOW(fd,2),0,0,0, 1); + skill_produce_mix(sd,SA_CREATECON,nameid,0,0,0, 1); break; case WL_READING_SB: - skill_spellbook(sd,RFIFOW(fd,2)); + skill_spellbook(sd,nameid); break; case GC_POISONINGWEAPON: - skill_poisoningweapon(sd,RFIFOW(fd,2)); + skill_poisoningweapon(sd,nameid); break; case NC_MAGICDECOY: - skill_magicdecoy(sd,RFIFOW(fd,2)); + skill_magicdecoy(sd,nameid); break; } @@ -11282,7 +11306,7 @@ { if (sd->menuskill_id != SA_AUTOSPELL) return; - skill_autospell(sd,RFIFOL(fd,2)); + skill_autospell(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); clif_menuskill_clear(sd); } @@ -11293,7 +11317,7 @@ { if (sd->state.trading != 0) return; - clif_use_card(sd,RFIFOW(fd,2)-2); + clif_use_card(sd,RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2); } @@ -11301,9 +11325,10 @@ /// 017c .W .W void clif_parse_InsertCard(int fd,struct map_session_data *sd) { + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; if (sd->state.trading != 0) return; - pc_insert_card(sd,RFIFOW(fd,2)-2,RFIFOW(fd,4)-2); + pc_insert_card(sd,RFIFOW(fd,info->pos[0])-2,RFIFOW(fd,info->pos[1])-2); } @@ -11329,7 +11354,7 @@ void clif_parse_ResetChar(int fd, struct map_session_data *sd) { char cmd[15]; - if( RFIFOW(fd,2) ) + if( RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]) ) sprintf(cmd,"%cresetskill",atcommand_symbol); else sprintf(cmd,"%cresetstat",atcommand_symbol); @@ -11343,9 +11368,10 @@ /// 019c .W .?B void clif_parse_LocalBroadcast(int fd, struct map_session_data* sd) { + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; char command[CHAT_SIZE_MAX+16]; - char* msg = (char*)RFIFOP(fd,4); - unsigned int len = RFIFOW(fd,2)-4; + unsigned int len = RFIFOW(fd,info->pos[0])-4; + char* msg = (char*)RFIFOP(fd,info->pos[1]); // as the length varies depending on the command used, just block unreasonably long strings mes_len_check(msg, len, CHAT_SIZE_MAX); @@ -11362,12 +11388,13 @@ void clif_parse_MoveToKafra(int fd, struct map_session_data *sd) { int item_index, item_amount; + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; if (pc_istrading(sd)) return; - item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2; - item_amount = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); + item_index = RFIFOW(fd,info->pos[0])-2; + item_amount = RFIFOL(fd,info->pos[1]); if (item_index < 0 || item_index >= MAX_INVENTORY || item_amount < 1) return; @@ -11386,9 +11413,10 @@ void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd) { int item_index, item_amount; + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; - item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-1; - item_amount = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); + item_index = RFIFOW(fd,info->pos[0])-1; + item_amount = RFIFOL(fd,info->pos[1]); if (sd->state.storage_flag == 1) storage_storageget(sd, item_index, item_amount); @@ -11399,34 +11427,41 @@ /// Request to move an item from cart to storage (CZ_MOVE_ITEM_FROM_CART_TO_STORE). /// 0129 .W .L -void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd) -{ +void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd){ + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + + int idx = RFIFOW(fd,info->pos[0]) - 2; + int amount = RFIFOL(fd,info->pos[1]); + if( sd->state.vending ) return; if (!pc_iscarton(sd)) return; if (sd->state.storage_flag == 1) - storage_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4)); + storage_storageaddfromcart(sd, idx, amount); else if (sd->state.storage_flag == 2) - storage_guild_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4)); + storage_guild_storageaddfromcart(sd, idx, amount); } /// Request to move an item from storage to cart (CZ_MOVE_ITEM_FROM_STORE_TO_CART). /// 0128 .W .L -void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd) -{ +void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd){ + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + int idx = RFIFOW(fd,info->pos[0]) - 1; + int amount = RFIFOL(fd,info->pos[1]); + if( sd->state.vending ) return; if (!pc_iscarton(sd)) return; if (sd->state.storage_flag == 1) - storage_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4)); + storage_storagegettocart(sd, idx, amount); else if (sd->state.storage_flag == 2) - storage_guild_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4)); + storage_guild_storagegettocart(sd, idx, amount); } @@ -11497,10 +11532,8 @@ /// Party creation request /// 00f9 .24B (CZ_MAKE_GROUP) -/// 01e8 .24B .B .B (CZ_MAKE_GROUP2) -void clif_parse_CreateParty(int fd, struct map_session_data *sd) -{ - char* name = (char*)RFIFOP(fd,2); +void clif_parse_CreateParty(int fd, struct map_session_data *sd){ + char* name = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); name[NAME_LENGTH-1] = '\0'; if( map[sd->bl.m].flag.partylock ) {// Party locked. @@ -11515,11 +11548,12 @@ party_create(sd,name,0,0); } -void clif_parse_CreateParty2(int fd, struct map_session_data *sd) -{ - char* name = (char*)RFIFOP(fd,2); - int item1 = RFIFOB(fd,26); - int item2 = RFIFOB(fd,27); +/// 01e8 .24B .B .B (CZ_MAKE_GROUP2) +void clif_parse_CreateParty2(int fd, struct map_session_data *sd){ + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + char* name = (char*)RFIFOP(fd,info->pos[0]); + int item1 = RFIFOB(fd,info->pos[1]); + int item2 = RFIFOB(fd,info->pos[2]); name[NAME_LENGTH-1] = '\0'; if( map[sd->bl.m].flag.partylock ) {// Party locked. @@ -11547,7 +11581,7 @@ return; } - t_sd = map_id2sd(RFIFOL(fd,2)); + t_sd = map_id2sd(RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); if(t_sd && t_sd->state.noask) {// @noask [LuzZza] clif_noask_sub(sd, t_sd, 1); @@ -11557,10 +11591,9 @@ party_invite(sd, t_sd); } -void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) -{ +void clif_parse_PartyInvite2(int fd, struct map_session_data *sd){ struct map_session_data *t_sd; - char *name = (char*)RFIFOP(fd,2); + char *name = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); name[NAME_LENGTH-1] = '\0'; if(map[sd->bl.m].flag.partylock) {// Party locked. @@ -11587,12 +11620,14 @@ /// 1 = accept void clif_parse_ReplyPartyInvite(int fd,struct map_session_data *sd) { - party_reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6)); + party_reply_invite(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), + RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1])); } void clif_parse_ReplyPartyInvite2(int fd,struct map_session_data *sd) { - party_reply_invite(sd,RFIFOL(fd,2),RFIFOB(fd,6)); + party_reply_invite(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), + RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1])); } @@ -11616,7 +11651,8 @@ clif_displaymessage(fd, msg_txt(sd,227)); return; } - party_removemember(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6)); + party_removemember(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), + (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1])); } @@ -11627,7 +11663,10 @@ { struct party_data *p; int i; + int expflag = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); + 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); + if( !sd->status.party_id ) return; @@ -11644,9 +11683,9 @@ #if PACKETVER < 20090603 //Client can't change the item-field - party_changeoption(sd, RFIFOL(fd,2), p->party.item); + party_changeoption(sd, expflag, p->party.item); #else - party_changeoption(sd, RFIFOL(fd,2), ((RFIFOB(fd,6)?1:0)|(RFIFOB(fd,7)?2:0))); + party_changeoption(sd, expflag, itemflag); #endif } @@ -11655,8 +11694,8 @@ /// 0108 .W .?B ( : ) 00 void clif_parse_PartyMessage(int fd, struct map_session_data* sd) { - const char* text = (char*)RFIFOP(fd,4); - int textlen = RFIFOW(fd,2) - 4; + int textlen = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]) - 4; + const char* text = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); char *name, *message; int namelen, messagelen; @@ -11668,7 +11707,7 @@ if( is_atcommand(fd, sd, message, 1) ) return; - if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) ) + if( sd->sc.cant.chat ) return; if( battle_config.min_chat_delay ) @@ -11687,9 +11726,8 @@ /// Changes Party Leader (CZ_CHANGE_GROUP_MASTER). /// 07da .L -void clif_parse_PartyChangeLeader(int fd, struct map_session_data* sd) -{ - party_changeleader(sd, map_id2sd(RFIFOL(fd,2))); +void clif_parse_PartyChangeLeader(int fd, struct map_session_data* sd){ + party_changeleader(sd, map_id2sd(RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]))); } @@ -11700,13 +11738,14 @@ /// 0802 .W .W { .W }*6 void clif_parse_PartyBookingRegisterReq(int fd, struct map_session_data* sd) { - short level = RFIFOW(fd,2); - short mapid = RFIFOW(fd,4); + short level = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); + short mapid = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); + int idxpbj = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]); short job[PARTY_BOOKING_JOBS]; int i; for(i=0; i.W .W .W .L .W -void clif_parse_PartyBookingSearchReq(int fd, struct map_session_data* sd) -{ - short level = RFIFOW(fd,2); - short mapid = RFIFOW(fd,4); - short job = RFIFOW(fd,6); - unsigned long lastindex = RFIFOL(fd,8); - short resultcount = RFIFOW(fd,12); +void clif_parse_PartyBookingSearchReq(int fd, struct map_session_data* sd){ + int cmd = RFIFOW(fd,0); + short level = RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[0]); + short mapid = RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[1]); + short job = RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[2]); + unsigned long lastindex = RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[3]); + short resultcount = RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[4]); party_booking_search(sd, level, mapid, job, lastindex, resultcount); } @@ -11805,9 +11844,10 @@ { short job[PARTY_BOOKING_JOBS]; int i; + int idxpbu = packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]; for(i=0; inpc_id ) {// using an NPC return; } - vending_vendinglistreq(sd,RFIFOL(fd,2)); + vending_vendinglistreq(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); } @@ -11888,9 +11928,9 @@ /// 0134 .W .L { .W .W }* void clif_parse_PurchaseReq(int fd, struct map_session_data* sd) { - int len = (int)RFIFOW(fd,2) - 8; - int id = (int)RFIFOL(fd,4); - const uint8* data = (uint8*)RFIFOP(fd,8); + int len = (int)RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]) - 8; + int id = (int)RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); + const uint8* data = (uint8*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]); vending_purchasereq(sd, id, sd->vended_id, data, len/4); @@ -11903,10 +11943,10 @@ /// 0801 .W .L .L { .W .W }* 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 uid = (int)RFIFOL(fd,8); - const uint8* data = (uint8*)RFIFOP(fd,12); + int len = (int)RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]) - 12; + int aid = (int)RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); + int uid = (int)RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]); + const uint8* data = (uint8*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3]); vending_purchasereq(sd, aid, uid, data, len/4); @@ -11921,12 +11961,12 @@ /// result: /// 0 = canceled /// 1 = open -void clif_parse_OpenVending(int fd, struct map_session_data* sd) -{ - short len = (short)RFIFOW(fd,2) - 85; - const char* message = (char*)RFIFOP(fd,4); - bool flag = (bool)RFIFOB(fd,84); - const uint8* data = (uint8*)RFIFOP(fd,85); +void clif_parse_OpenVending(int fd, struct map_session_data* sd){ + int cmd = RFIFOW(fd,0); + short len = (short)RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[0]) - 85; + const char* message = (char*)RFIFOP(fd,packet_db[sd->packet_ver][cmd].pos[1]); + bool flag = (bool)RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[2]); + const uint8* data = (uint8*)RFIFOP(fd,packet_db[sd->packet_ver][cmd].pos[3]); if( !flag ) sd->state.prevend = 0; @@ -11951,9 +11991,9 @@ /// Guild creation request (CZ_REQ_MAKE_GUILD). /// 0165 .L .24B -void clif_parse_CreateGuild(int fd,struct map_session_data *sd) -{ - char* name = (char*)RFIFOP(fd,6); +void clif_parse_CreateGuild(int fd,struct map_session_data *sd){ + //int charid = RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[0]); + char* name = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); name[NAME_LENGTH-1] = '\0'; if(map[sd->bl.m].flag.guildlock) { //Guild locked. @@ -11985,10 +12025,11 @@ /// 6 = notice void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd) { + int type = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); if( !sd->status.guild_id && !sd->bg_id ) return; - switch( RFIFOL(fd,2) ) + switch( type ) { case 0: // Basic Information Guild, hostile alliance information clif_guild_basicinfo(sd); @@ -12009,7 +12050,7 @@ clif_guild_expulsionlist(sd); break; default: - ShowError("clif: guild request info: unknown type %d\n", RFIFOL(fd,2)); + ShowError("clif: guild request info: unknown type %d\n", type); break; } } @@ -12020,11 +12061,14 @@ void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd) { int i; + int cmd = RFIFOW(fd,0); + int len = RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[0]); + int idxgpos = packet_db[sd->packet_ver][cmd].pos[1]; if(!sd->state.gmaster_flag) return; - for(i = 4; i < RFIFOW(fd,2); i += 40 ){ + for(i = idxgpos; i < len; i += 40 ){ guild_change_position(sd->status.guild_id, RFIFOL(fd,i), RFIFOL(fd,i+4), RFIFOL(fd,i+12), (char*)RFIFOP(fd,i+16)); } } @@ -12035,11 +12079,14 @@ void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd) { int i; + int cmd = RFIFOW(fd,0); + int len = RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[0]); + int idxgpos = packet_db[sd->packet_ver][cmd].pos[1]; if(!sd->state.gmaster_flag) return; - for(i=4;istatus.guild_id, RFIFOL(fd,i),RFIFOL(fd,i+4),RFIFOL(fd,i+8)); } @@ -12051,7 +12098,7 @@ void clif_parse_GuildRequestEmblem(int fd,struct map_session_data *sd) { struct guild* g; - int guild_id = RFIFOL(fd,2); + int guild_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); if( (g = guild_search(guild_id)) != NULL ) clif_guild_emblem(sd,g); @@ -12079,8 +12126,8 @@ /// 0153 .W .?B void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd) { - unsigned long emblem_len = RFIFOW(fd,2)-4; - const uint8* emblem = RFIFOP(fd,4); + unsigned long emblem_len = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-4; + const uint8* emblem = RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); if( !emblem_len || !sd->state.gmaster_flag ) return; @@ -12099,9 +12146,9 @@ /// 016e .L .60B .120B void clif_parse_GuildChangeNotice(int fd, struct map_session_data* sd) { - int guild_id = RFIFOL(fd,2); - char* msg1 = (char*)RFIFOP(fd,6); - char* msg2 = (char*)RFIFOP(fd,66); + int guild_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); + char* msg1 = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); + char* msg2 = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]); if(!sd->state.gmaster_flag) return; @@ -12138,7 +12185,7 @@ /// 0168 .L .L .L void clif_parse_GuildInvite(int fd,struct map_session_data *sd) { - struct map_session_data *t_sd = map_id2sd(RFIFOL(fd,2)); + struct map_session_data *t_sd = map_id2sd(RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1])); if (clif_sub_guild_invite(fd, sd, t_sd)) return; @@ -12148,7 +12195,7 @@ /// 0916 .24B (CZ_REQ_JOIN_GUILD2) void clif_parse_GuildInvite2(int fd, struct map_session_data *sd) { - struct map_session_data *t_sd = map_nick2sd((char *)RFIFOP(fd, 2)); + struct map_session_data *t_sd = map_nick2sd((char *)RFIFOP(fd, packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); if (clif_sub_guild_invite(fd, sd, t_sd)) return; @@ -12162,7 +12209,8 @@ /// 1 = accept void clif_parse_GuildReplyInvite(int fd,struct map_session_data *sd) { - guild_reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6)); + guild_reply_invite(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), + RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1])); } @@ -12179,7 +12227,10 @@ return; } - guild_leave(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14)); + guild_leave(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), + RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]), + RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]), + (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3])); } @@ -12192,17 +12243,20 @@ clif_displaymessage(fd, msg_txt(sd,228)); return; } - guild_expulsion(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14)); + guild_expulsion(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), + RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]), + RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]), + (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[3])); } /// Validates and processes guild messages (CZ_GUILD_CHAT). /// 017e .W .?B ( : ) 00 -void clif_parse_GuildMessage(int fd, struct map_session_data* sd) -{ - const char* text = (char*)RFIFOP(fd,4); - int textlen = RFIFOW(fd,2) - 4; +void clif_parse_GuildMessage(int fd, struct map_session_data* sd){ + int textlen = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]) - 4; + const char* text = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); + char *name, *message; int namelen, messagelen; @@ -12213,7 +12267,7 @@ if( is_atcommand(fd, sd, message, 1) ) return; - if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) ) + if( sd->sc.cant.chat ) return; if( battle_config.min_chat_delay ) @@ -12247,7 +12301,7 @@ return; } - t_sd = map_id2sd(RFIFOL(fd,2)); + t_sd = map_id2sd(RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); // @noask [LuzZza] if(t_sd && t_sd->state.noask) { @@ -12266,7 +12320,9 @@ /// 1 = accept void clif_parse_GuildReplyAlliance(int fd, struct map_session_data *sd) { - guild_reply_reqalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6)); + guild_reply_reqalliance(sd, + RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), + RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1])); } @@ -12284,7 +12340,9 @@ clif_displaymessage(fd, msg_txt(sd,228)); return; } - guild_delalliance(sd,RFIFOL(fd,2),RFIFOL(fd,6)); + guild_delalliance(sd, + RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), + RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1])); } @@ -12302,7 +12360,7 @@ return; } - t_sd = map_id2sd(RFIFOL(fd,2)); + t_sd = map_id2sd(RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); // @noask [LuzZza] if(t_sd && t_sd->state.noask) { @@ -12325,7 +12383,7 @@ clif_displaymessage(fd, msg_txt(sd,228)); return; } - guild_break(sd,(char*)RFIFOP(fd,2)); + guild_break(sd,(char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); } @@ -12340,30 +12398,27 @@ /// 2 = performance /// 3 = return to egg /// 4 = unequip accessory -void clif_parse_PetMenu(int fd, struct map_session_data *sd) -{ - pet_menu(sd,RFIFOB(fd,2)); +void clif_parse_PetMenu(int fd, struct map_session_data *sd){ + pet_menu(sd,RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); } /// Attempt to tame a monster (CZ_TRYCAPTURE_MONSTER). /// 019f .L -void clif_parse_CatchPet(int fd, struct map_session_data *sd) -{ - pet_catch_process2(sd,RFIFOL(fd,2)); +void clif_parse_CatchPet(int fd, struct map_session_data *sd){ + pet_catch_process2(sd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); } /// Answer to pet incubator egg selection dialog (CZ_SELECT_PETEGG). /// 01a7 .W -void clif_parse_SelectEgg(int fd, struct map_session_data *sd) -{ +void clif_parse_SelectEgg(int fd, struct map_session_data *sd){ if (sd->menuskill_id != SA_TAMINGMONSTER || sd->menuskill_val != -1) { //Forged packet, disconnect them [Kevin] clif_authfail_fd(fd, 0); return; } - pet_select_egg(sd,RFIFOW(fd,2)-2); + pet_select_egg(sd,RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2); clif_menuskill_clear(sd); } @@ -12395,7 +12450,7 @@ void clif_parse_SendEmotion(int fd, struct map_session_data *sd) { if(sd->pd) - clif_pet_emotion(sd->pd,RFIFOL(fd,2)); + clif_pet_emotion(sd->pd,RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); } @@ -12403,7 +12458,7 @@ /// 01a5 .24B void clif_parse_ChangePetName(int fd, struct map_session_data *sd) { - pet_change_name(sd,(char*)RFIFOP(fd,2)); + pet_change_name(sd,(char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); } @@ -12416,7 +12471,7 @@ struct block_list *target; int tid; - tid = RFIFOL(fd,2); + tid = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); target = map_id2bl(tid); if (!target) { clif_GM_kickack(sd, 0); @@ -12484,7 +12539,7 @@ char *player_name; char command[NAME_LENGTH+8]; - player_name = (char*)RFIFOP(fd,2); + player_name = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); player_name[NAME_LENGTH-1] = '\0'; sprintf(command, "%cjumpto %s", atcommand_symbol, player_name); @@ -12521,7 +12576,7 @@ char *player_name; char command [NAME_LENGTH+8]; - player_name = (char*)RFIFOP(fd,2); + player_name = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); player_name[NAME_LENGTH-1] = '\0'; sprintf(command, "%crecall %s", atcommand_symbol, player_name); @@ -12554,7 +12609,7 @@ char *monster_item_name; char command[NAME_LENGTH+10]; - monster_item_name = (char*)RFIFOP(fd,2); + monster_item_name = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); monster_item_name[NAME_LENGTH-1] = '\0'; // FIXME: Should look for item first, then for monster. @@ -12600,9 +12655,9 @@ struct map_session_data *dstsd; char command[NAME_LENGTH+15]; - id = RFIFOL(fd,2); - type = RFIFOB(fd,6); - value = RFIFOW(fd,7); + id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); + type = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); + value = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]); if( type == 0 ) value = -value; @@ -12627,7 +12682,7 @@ void clif_parse_GMRc(int fd, struct map_session_data* sd) { char command[NAME_LENGTH+15]; - char *name = (char*)RFIFOP(fd,2); + char *name = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); name[NAME_LENGTH-1] = '\0'; sprintf(command, "%cmute %d %s", atcommand_symbol, 60, name); @@ -12653,7 +12708,7 @@ /// 01df .L void clif_parse_GMReqAccountName(int fd, struct map_session_data *sd) { - int account_id = RFIFOL(fd,2); + int account_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); //TODO: find out if this works for any player or only for authorized GMs clif_account_name(sd, account_id, ""); // insert account name here >_< @@ -12673,9 +12728,9 @@ if( pc_has_permission(sd, PC_PERM_USE_CHANGEMAPTYPE) ) return; - x = RFIFOW(fd,2); - y = RFIFOW(fd,4); - type = RFIFOW(fd,6); + x = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); + y = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); + type = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]); map_setgatcell(sd->bl.m,x,y,type); clif_changemapcell(0,sd->bl.m,x,y,type,ALL_SAMEMAP); @@ -12695,9 +12750,9 @@ uint8 type; int i; - nick = (char*)RFIFOP(fd,2); // speed up + nick = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); nick[NAME_LENGTH-1] = '\0'; // to be sure that the player name has at most 23 characters - type = RFIFOB(fd,26); + type = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); if( type == 0 ) { // Add name to ignore list (block) if (strcmp(wisp_server_name, nick) == 0) { @@ -12744,7 +12799,7 @@ /// 1 = (/inall) allow all speech void clif_parse_PMIgnoreAll(int fd, struct map_session_data *sd) { - int type = RFIFOB(fd,2), flag; + int type = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), flag; if( type == 0 ) {// Deny all if( sd->state.ignoreAll ) { @@ -12956,7 +13011,7 @@ struct map_session_data *f_sd; int i; - f_sd = map_nick2sd((char*)RFIFOP(fd,2)); + f_sd = map_nick2sd((char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); // ensure that the request player's friend list is not full ARR_FIND(0, MAX_FRIENDS, i, sd->status.friends[i].char_id == 0); @@ -13009,12 +13064,12 @@ int account_id; char reply; - account_id = RFIFOL(fd,2); - //char_id = RFIFOL(fd,6); + account_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); + //char_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); #if PACKETVER < 6 - reply = RFIFOB(fd,10); + reply = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]); #else - reply = RFIFOL(fd,10); + reply = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]); #endif if( sd->bl.id == account_id ) {// adding oneself as friend @@ -13073,8 +13128,8 @@ int account_id, char_id; int i, j; - account_id = RFIFOL(fd,2); - char_id = RFIFOL(fd,6); + account_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); + char_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); // Search friend for (i = 0; i < MAX_FRIENDS && @@ -13382,17 +13437,15 @@ /// Request to change homunculus' name (CZ_RENAME_MER). /// 0231 .24B -void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd) -{ - merc_hom_change_name(sd,(char*)RFIFOP(fd,2)); +void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd){ + merc_hom_change_name(sd,(char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); } /// Request to warp/move homunculus/mercenary to it's owner (CZ_REQUEST_MOVETOOWNER). /// 0234 .L -void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd) -{ - int id = RFIFOL(fd,2); // Mercenary or Homunculus +void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd){ + int id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); // Mercenary or Homunculus struct block_list *bl = NULL; struct unit_data *ud = NULL; @@ -13413,7 +13466,7 @@ /// 0232 .L .3B void clif_parse_HomMoveTo(int fd, struct map_session_data *sd) { - int id = RFIFOL(fd,2); // Mercenary or Homunculus + int id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); // Mercenary or Homunculus struct block_list *bl = NULL; short x, y; @@ -13437,9 +13490,9 @@ void clif_parse_HomAttack(int fd,struct map_session_data *sd) { struct block_list *bl = NULL; - int id = RFIFOL(fd,2), - target_id = RFIFOL(fd,6), - action_type = RFIFOB(fd,10); + int id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); + int target_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); + int action_type = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[2]); if( merc_is_hom_active(sd->hd) && sd->hd->bl.id == id ) bl = &sd->hd->bl; @@ -13462,10 +13515,7 @@ /// 2 = delete void clif_parse_HomMenu(int fd, struct map_session_data *sd) { //[orn] - int cmd; - - cmd = RFIFOW(fd,0); - + int cmd = RFIFOW(fd,0); if(!merc_is_hom_active(sd->hd)) return; @@ -13785,14 +13835,14 @@ /// 0241 .L void clif_parse_Mail_read(int fd, struct map_session_data *sd) { - int mail_id = RFIFOL(fd,2); + int mail_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); if( mail_id <= 0 ) return; if( mail_invalid_operation(sd) ) return; - clif_Mail_read(sd, RFIFOL(fd,2)); + clif_Mail_read(sd, mail_id); } @@ -13800,7 +13850,7 @@ /// 0244 .L void clif_parse_Mail_getattach(int fd, struct map_session_data *sd) { - int mail_id = RFIFOL(fd,2); + int mail_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); int i; bool fail = false; @@ -13860,9 +13910,8 @@ /// Request to delete a mail (CZ_MAIL_DELETE). /// 0243 .L -void clif_parse_Mail_delete(int fd, struct map_session_data *sd) -{ - int mail_id = RFIFOL(fd,2); +void clif_parse_Mail_delete(int fd, struct map_session_data *sd){ + int mail_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); int i; if( !chrif_isconnected() ) @@ -13888,9 +13937,8 @@ /// Request to return a mail (CZ_REQ_MAIL_RETURN). /// 0273 .L .24B -void clif_parse_Mail_return(int fd, struct map_session_data *sd) -{ - int mail_id = RFIFOL(fd,2); +void clif_parse_Mail_return(int fd, struct map_session_data *sd){ + int mail_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); int i; if( mail_id <= 0 ) @@ -13908,10 +13956,9 @@ /// Request to add an item or Zeny to mail (CZ_MAIL_ADD_ITEM). /// 0247 .W .L -void clif_parse_Mail_setattach(int fd, struct map_session_data *sd) -{ - int idx = RFIFOW(fd,2); - int amount = RFIFOL(fd,4); +void clif_parse_Mail_setattach(int fd, struct map_session_data *sd){ + int idx = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); + int amount = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); unsigned char flag; if( !chrif_isconnected() ) @@ -13932,7 +13979,7 @@ /// 2 = remove zeny void clif_parse_Mail_winopen(int fd, struct map_session_data *sd) { - int flag = RFIFOW(fd,2); + int flag = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); if (flag == 0 || flag == 1) mail_removeitem(sd, 0); @@ -13946,6 +13993,7 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd) { struct mail_message msg; + int cmd = RFIFOW(fd,0); int body_len; if( !chrif_isconnected() ) @@ -13953,7 +14001,7 @@ if( sd->state.trading ) return; - if( RFIFOW(fd,2) < 69 ) { + if( RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[0]) < 69 ) { ShowWarning("Invalid Msg Len from account %d.\n", sd->status.account_id); return; } @@ -13964,7 +14012,7 @@ return; } - body_len = RFIFOB(fd,68); + body_len = RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[3]); if (body_len > MAIL_BODY_LENGTH) body_len = MAIL_BODY_LENGTH; @@ -13980,15 +14028,15 @@ msg.send_id = sd->status.char_id; msg.dest_id = 0; // will attempt to resolve name safestrncpy(msg.send_name, sd->status.name, NAME_LENGTH); - safestrncpy(msg.dest_name, (char*)RFIFOP(fd,4), NAME_LENGTH); - safestrncpy(msg.title, (char*)RFIFOP(fd,28), MAIL_TITLE_LENGTH); + safestrncpy(msg.dest_name, (char*)RFIFOP(fd,packet_db[sd->packet_ver][cmd].pos[1]), NAME_LENGTH); + safestrncpy(msg.title, (char*)RFIFOP(fd,packet_db[sd->packet_ver][cmd].pos[2]), MAIL_TITLE_LENGTH); if (msg.title[0] == '\0') { return; // Message has no length and somehow client verification was skipped. } if (body_len) - safestrncpy(msg.body, (char*)RFIFOP(fd,69), body_len + 1); + safestrncpy(msg.body, (char*)RFIFOP(fd,RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[4])), body_len + 1); else memset(msg.body, 0x00, MAIL_BODY_LENGTH); @@ -14100,10 +14148,10 @@ /// Request to add an item to the action (CZ_AUCTION_ADD_ITEM). /// 024c .W .L -void clif_parse_Auction_setitem(int fd, struct map_session_data *sd) -{ - int idx = RFIFOW(fd,2) - 2; - int amount = RFIFOL(fd,4); // Always 1 +void clif_parse_Auction_setitem(int fd, struct map_session_data *sd){ + int cmd = RFIFOW(fd,0); + int idx = RFIFOW(fd,packet_db[sd->packet_ver][cmd].pos[0]) - 2; + int amount = RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[1]); // Always 1 struct item_data *item; if( sd->auction.amount > 0 ) @@ -14180,10 +14228,11 @@ { struct auction_data auction; struct item_data *item; + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; - auction.price = RFIFOL(fd,2); - auction.buynow = RFIFOL(fd,6); - auction.hours = RFIFOW(fd,10); + auction.price = RFIFOL(fd,info->pos[0]); + auction.buynow = RFIFOL(fd,info->pos[1]); + auction.hours = RFIFOW(fd,info->pos[2]); // Invalid Situations... if( sd->auction.amount < 1 ) { @@ -14258,30 +14307,26 @@ /// Cancels an auction (CZ_AUCTION_ADD_CANCEL). /// 024e .L -void clif_parse_Auction_cancel(int fd, struct map_session_data *sd) -{ - unsigned int auction_id = RFIFOL(fd,2); - +void clif_parse_Auction_cancel(int fd, struct map_session_data *sd){ + unsigned int auction_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); intif_Auction_cancel(sd->status.char_id, auction_id); } /// Closes an auction (CZ_AUCTION_REQ_MY_SELL_STOP). /// 025d .L -void clif_parse_Auction_close(int fd, struct map_session_data *sd) -{ - unsigned int auction_id = RFIFOL(fd,2); - +void clif_parse_Auction_close(int fd, struct map_session_data *sd){ + unsigned int auction_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); intif_Auction_close(sd->status.char_id, auction_id); } /// Places a bid on an auction (CZ_AUCTION_BUY). /// 024f .L .L -void clif_parse_Auction_bid(int fd, struct map_session_data *sd) -{ - unsigned int auction_id = RFIFOL(fd,2); - int bid = RFIFOL(fd,6); +void clif_parse_Auction_bid(int fd, struct map_session_data *sd){ + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + unsigned int auction_id = RFIFOL(fd,info->pos[0]); + int bid = RFIFOL(fd,info->pos[1]); if( !pc_can_give_items(sd) ) { //They aren't supposed to give zeny [Inkfish] clif_displaymessage(sd->fd, msg_txt(sd,246)); @@ -14310,15 +14355,16 @@ /// 3 = misc /// 4 = name search /// 5 = auction id search -void clif_parse_Auction_search(int fd, struct map_session_data* sd) -{ +void clif_parse_Auction_search(int fd, struct map_session_data* sd){ char search_text[NAME_LENGTH]; - short type = RFIFOW(fd,2), page = RFIFOW(fd,32); - int price = RFIFOL(fd,4); // FIXME: bug #5071 + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + short type = RFIFOW(fd,info->pos[0]); + int price = RFIFOL(fd,info->pos[1]); // FIXME: bug #5071 + int page = RFIFOW(fd,info->pos[3]); clif_parse_Auction_cancelreg(fd, sd); - safestrncpy(search_text, (char*)RFIFOP(fd,8), sizeof(search_text)); + safestrncpy(search_text, (char*)RFIFOP(fd,info->pos[2]), sizeof(search_text)); intif_Auction_requestlist(sd->status.char_id, type, price, search_text, page); } @@ -14330,7 +14376,7 @@ /// 1 = buy (own bids) void clif_parse_Auction_buysell(int fd, struct map_session_data* sd) { - short type = RFIFOW(fd,2) + 6; + short type = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]) + 6; clif_parse_Auction_cancelreg(fd, sd); intif_Auction_requestlist(sd->status.char_id, type, 0, "", 1); @@ -14415,20 +14461,21 @@ int fail = 0; nullpo_retv(sd); - if( sd->state.trading || !sd->npc_shopid ) - fail = 1; - else { + struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; + if( sd->state.trading || !sd->npc_shopid ) + fail = 1; + else { #if PACKETVER < 20101116 - short nameid = RFIFOW(fd,2); - short amount = RFIFOW(fd,4); - int points = RFIFOL(fd,6); + short nameid = RFIFOW(fd,info->pos[0]); + short amount = RFIFOW(fd,info->pos[1]); + int points = RFIFOL(fd,info->pos[2]); fail = npc_cashshop_buy(sd, nameid, amount, points); #else - int len = RFIFOW(fd,2); - int points = RFIFOL(fd,4); - int count = RFIFOW(fd,8); - unsigned short* item_list = (unsigned short*)RFIFOP(fd,10); + int len = RFIFOW(fd,info->pos[0]); + int points = RFIFOL(fd,info->pos[1]); + int count = RFIFOW(fd,info->pos[2]); + unsigned short* item_list = (unsigned short*)RFIFOP(fd,info->pos[3]); if( len < 10 || len != 10 + count * 4) { @@ -14443,7 +14490,6 @@ } #endif - /// Adoption System /// @@ -14483,7 +14529,8 @@ /// 01f9 .L void clif_parse_Adopt_request(int fd, struct map_session_data *sd) { - struct map_session_data *tsd = map_id2sd(RFIFOL(fd,2)), *p_sd = map_charid2sd(sd->status.partner_id); + TBL_PC *tsd = map_id2sd(RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])); + TBL_PC *p_sd = map_charid2sd(sd->status.partner_id); if( pc_can_Adopt(sd, p_sd, tsd) ) { @@ -14500,9 +14547,10 @@ /// 1 = accepted void clif_parse_Adopt_reply(int fd, struct map_session_data *sd) { - int p1_id = RFIFOL(fd,2); - int p2_id = RFIFOL(fd,6); - int result = RFIFOL(fd,10); + int cmd = RFIFOW(fd,0); + int p1_id = RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[0]); + int p2_id = RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[1]); + int result = RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[2]); struct map_session_data* p1_sd = map_id2sd(p1_id); struct map_session_data* p2_sd = map_id2sd(p2_id); @@ -14568,7 +14616,7 @@ /// 02d6 .L void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd) { - int charid = RFIFOL(fd, 2); + int charid = RFIFOL(fd, packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); struct map_session_data* tsd = map_id2sd(charid); if (!tsd) @@ -14590,7 +14638,8 @@ /// 1 = enabled void clif_parse_EquipTick(int fd, struct map_session_data* sd) { - bool flag = (bool)RFIFOL(fd,6); + //int type = RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[0]); + bool flag = (bool)RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); sd->status.show_equip = flag; clif_equiptickack(sd, flag); } @@ -14721,7 +14770,9 @@ /// 02b6 .L .B void clif_parse_questStateAck(int fd, struct map_session_data * sd) { - quest_update_status(sd, RFIFOL(fd,2), RFIFOB(fd,6)?Q_ACTIVE:Q_INACTIVE); + int cmd = RFIFOW(fd,0); + quest_update_status(sd, RFIFOL(fd,packet_db[sd->packet_ver][cmd].pos[0]), + RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[1])?Q_ACTIVE:Q_INACTIVE); } @@ -14921,7 +14972,7 @@ /// 2 = delete void clif_parse_mercenary_action(int fd, struct map_session_data* sd) { - int option = RFIFOB(fd,2); + int option = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); if( sd->md == NULL ) return; @@ -15066,8 +15117,8 @@ /// 0x2db .W .?B ( : ) 00 void clif_parse_BattleChat(int fd, struct map_session_data* sd) { - const char* text = (char*)RFIFOP(fd,4); - int textlen = RFIFOW(fd,2) - 4; + int textlen = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]) - 4; + const char* text = (char*)RFIFOP(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); char *name, *message; int namelen, messagelen; @@ -15078,7 +15129,7 @@ if( is_atcommand(fd, sd, message, 1) ) return; - if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) ) + if( sd->sc.cant.chat ) return; if( battle_config.min_chat_delay ) { @@ -15340,19 +15391,18 @@ /// constructed, this state tracking was rendered useless, /// as the only skill unit, that is sent with 0x1c9 is /// Graffiti. -void clif_parse_LessEffect(int fd, struct map_session_data* sd) -{ +void clif_parse_LessEffect(int fd, struct map_session_data* sd){ int isLess = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); - sd->state.lesseffect = ( isLess != 0 ); } /// S 07e4 .w