From c53f8a099151f2e8c26c0ab36f35d34256c0d6cb Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Fri, 7 Aug 2020 09:26:17 -0300 Subject: This is Hercules v2019.08.25 --- src/map/atcommand.c | 10 +- src/map/clif.c | 883 ++++++++++++++++++++++++++++++++--------- src/map/clif.h | 24 +- src/map/guild.c | 22 +- src/map/guild.h | 1 - src/map/homunculus.c | 2 +- src/map/intif.c | 329 +-------------- src/map/intif.h | 13 - src/map/itemdb.c | 4 +- src/map/messages_main.h | 94 ++++- src/map/messages_re.h | 94 ++++- src/map/messages_zero.h | 72 +++- src/map/mob.c | 6 +- src/map/npc.c | 20 +- src/map/npc.h | 6 +- src/map/packets_keys_main.h | 8 +- src/map/packets_keys_zero.h | 5 +- src/map/packets_shuffle_main.h | 8 +- src/map/packets_shuffle_re.h | 8 +- src/map/packets_shuffle_zero.h | 5 +- src/map/packets_struct.h | 121 +++++- src/map/party.c | 25 +- src/map/party.h | 1 - src/map/pc.c | 56 ++- src/map/pc.h | 5 +- src/map/pet.c | 2 +- src/map/quest.c | 2 +- src/map/refine.c | 2 +- src/map/script.c | 227 +++++++++-- src/map/script.h | 25 +- src/map/status.c | 4 +- src/map/status.h | 8 +- src/map/trade.c | 9 +- 33 files changed, 1426 insertions(+), 675 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 2fac5b4a4..22969606d 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -1107,8 +1107,10 @@ ACMD(kami) sscanf(message, "%199[^\n]", atcmd_output); if (stristr(info->command, "l") != NULL) clif->broadcast(&sd->bl, atcmd_output, (int)strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP); + else if (info->command[4] == 'b' || info->command[4] == 'B') + clif->broadcast(NULL, atcmd_output, (int)strlen(atcmd_output) + 1, BC_BLUE, ALL_CLIENT); else - intif->broadcast(atcmd_output, (int)strlen(atcmd_output) + 1, (*(info->command + 4) == 'b' || *(info->command + 4) == 'B') ? BC_BLUE : BC_YELLOW); + clif->broadcast(NULL, atcmd_output, (int)strlen(atcmd_output) + 1, BC_YELLOW, ALL_CLIENT); } else { if(!*message || (sscanf(message, "%10u %199[^\n]", &color, atcmd_output) < 2)) { clif->message(fd, msg_fd(fd,981)); // Please enter color and message (usage: @kamic ). @@ -1119,7 +1121,7 @@ ACMD(kami) clif->message(fd, msg_fd(fd,982)); // Invalid color. return false; } - intif->broadcast2(atcmd_output, (int)strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0); + clif->broadcast2(NULL, atcmd_output, (int)strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0, ALL_CLIENT); } return true; } @@ -5125,7 +5127,7 @@ ACMD(broadcast) } safesnprintf(atcmd_output, sizeof(atcmd_output), "%s: %s", sd->status.name, message); - intif->broadcast(atcmd_output, (int)strlen(atcmd_output) + 1, BC_DEFAULT); + clif->broadcast(NULL, atcmd_output, (int)strlen(atcmd_output) + 1, BC_DEFAULT, ALL_CLIENT); return true; } @@ -8263,7 +8265,7 @@ ACMD(request) } safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,278), message); // (@request): %s - intif->wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output); + pc->wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output); clif_disp_onlyself(sd, atcmd_output); clif->message(sd->fd,msg_fd(fd,279)); // @request sent. return true; diff --git a/src/map/clif.c b/src/map/clif.c index 3b7691ae4..1c245ed43 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -92,9 +92,6 @@ static struct packet_itemlist_equip itemlist_equip; static struct ZC_STORE_ITEMLIST_NORMAL storelist_normal; static struct ZC_STORE_ITEMLIST_EQUIP storelist_equip; static struct packet_viewequip_ack viewequip_list; -#if PACKETVER >= 20131223 -static struct packet_npc_market_result_ack npcmarket_result; -#endif // temporart buffer for send big packets char packet_buf[0xffff]; //#define DUMP_UNKNOWN_PACKET @@ -5254,58 +5251,79 @@ static int clif_insight(struct block_list *bl, va_list ap) return 0; } +static void clif_playerSkillToPacket(struct map_session_data *sd, struct SKILLDATA *skillData, int skillId, int idx, bool newSkill) +{ + nullpo_retv(sd); + nullpo_retv(skillData); + Assert_retv(idx >= 0 && idx < MAX_SKILL_DB); + + int skill_lv = sd->status.skill[idx].lv; + skillData->id = skillId; + skillData->inf = skill->get_inf(skillId); + skillData->level = skill_lv; + if (skill_lv > 0) { + skillData->sp = skill->get_sp(skillId, skill_lv); + skillData->range2 = skill->get_range2(&sd->bl, skillId, skill_lv); + } else { + skillData->sp = 0; + skillData->range2 = 0; + } +#if PACKETVER_RE_NUM >= 20190807 || PACKETVER_ZERO_NUM >= 20190814 + if (newSkill) + skillData->level2 = 0; + else + skillData->level2 = skill_lv; +#else + safestrncpy(skillData->name, skill->get_name(skillId), NAME_LENGTH); +#endif + if (sd->status.skill[idx].flag == SKILL_FLAG_PERMANENT) + skillData->upFlag = (skill_lv < skill->tree_get_max(skillId, sd->status.class)) ? 1 : 0; + else + skillData->upFlag = 0; +} + /// Updates whole skill tree (ZC_SKILLINFO_LIST). /// 010f .W { .W .L .W .W .W .24B .B }* static void clif_skillinfoblock(struct map_session_data *sd) { - int fd; - int i,len,id; - nullpo_retv(sd); - fd=sd->fd; - if (!fd) return; + int fd = sd->fd; + if (!fd) + return; + + WFIFOHEAD(fd, sizeof(struct PACKET_ZC_SKILLINFO_LIST) + MAX_SKILL_DB * sizeof(struct SKILLDATA)); + struct PACKET_ZC_SKILLINFO_LIST *p = WFIFOP(fd, 0); - WFIFOHEAD(fd, MAX_SKILL_DB * 37 + 4); - WFIFOW(fd,0) = 0x10f; - for ( i = 0, len = 4; i < MAX_SKILL_DB; i++) { - if( (id = sd->status.skill[i].id) != 0 ) { - int level; + p->packetType = HEADER_ZC_SKILLINFO_LIST; + int skillIndex = 0; + int len = sizeof(struct PACKET_ZC_SKILLINFO_LIST); + int i; + for (i = 0; i < MAX_SKILL_DB; i++) { + int id = sd->status.skill[i].id; + if (id != 0) { // workaround for bugreport:5348 - if (len + 37 > 8192) + if (len + sizeof(struct SKILLDATA) > 8192) break; - WFIFOW(fd, len) = id; - WFIFOL(fd, len + 2) = skill->get_inf(id); - level = sd->status.skill[i].lv; - WFIFOW(fd, len + 6) = level; - if (level) { - WFIFOW(fd, len + 8) = skill->get_sp(id, level); - WFIFOW(fd, len + 10)= skill->get_range2(&sd->bl, id, level); - } - else { - WFIFOW(fd, len + 8) = 0; - WFIFOW(fd, len + 10)= 0; - } - safestrncpy(WFIFOP(fd,len+12), skill->get_name(id), NAME_LENGTH); - if(sd->status.skill[i].flag == SKILL_FLAG_PERMANENT) - WFIFOB(fd,len+36) = (sd->status.skill[i].lv < skill->tree_get_max(id, sd->status.class))? 1:0; - else - WFIFOB(fd,len+36) = 0; - len += 37; + clif->playerSkillToPacket(sd, &p->skills[skillIndex], id, i, false); + len += sizeof(struct SKILLDATA); + skillIndex++; } } - WFIFOW(fd,2)=len; - WFIFOSET(fd,len); + p->packetLength = len; + WFIFOSET(fd, len); // workaround for bugreport:5348; send the remaining skills one by one to bypass packet size limit - for ( ; i < MAX_SKILL_DB; i++) { - if( (id = sd->status.skill[i].id) != 0 ) { + for (; i < MAX_SKILL_DB; i++) { + int id = sd->status.skill[i].id; + if (id != 0) { clif->addskill(sd, id); clif->skillinfo(sd, id, 0); } } } + /** * Server tells client 'sd' to add skill of id 'id' to it's skill tree (e.g. with Ice Falcion item) **/ @@ -5314,36 +5332,21 @@ static void clif_skillinfoblock(struct map_session_data *sd) /// 0111 .W .L .W .W .W .24B .B static void clif_addskill(struct map_session_data *sd, int id) { - int fd, skill_lv, idx = skill->get_index(id); - nullpo_retv(sd); - fd = sd->fd; - if (!fd) return; + int fd = sd->fd; + if (!fd) + return; + int idx = skill->get_index(id); if (sd->status.skill[idx].id <= 0) return; - skill_lv = sd->status.skill[idx].lv; - - WFIFOHEAD(fd, packet_len(0x111)); - WFIFOW(fd,0) = 0x111; - WFIFOW(fd,2) = id; - WFIFOL(fd,4) = skill->get_inf(id); - WFIFOW(fd,8) = skill_lv; - if (skill_lv > 0) { - WFIFOW(fd,10) = skill->get_sp(id, skill_lv); - WFIFOW(fd,12) = skill->get_range2(&sd->bl, id, skill_lv); - } else { - WFIFOW(fd,10) = 0; - WFIFOW(fd,12) = 0; - } - safestrncpy(WFIFOP(fd,14), skill->get_name(id), NAME_LENGTH); - if (sd->status.skill[idx].flag == SKILL_FLAG_PERMANENT) - WFIFOB(fd,38) = (skill_lv < skill->tree_get_max(id, sd->status.class))? 1:0; - else - WFIFOB(fd,38) = 0; - WFIFOSET(fd,packet_len(0x111)); + WFIFOHEAD(fd, sizeof(struct PACKET_ZC_ADD_SKILL)); + struct PACKET_ZC_ADD_SKILL *p = WFIFOP(fd, 0); + p->packetType = HEADER_ZC_ADD_SKILL; + clif->playerSkillToPacket(sd, &p->skill, id, idx, true); + WFIFOSET(fd, sizeof(struct PACKET_ZC_ADD_SKILL)); } /// Deletes a skill from the skill tree (ZC_SKILLINFO_DELETE). @@ -5396,32 +5399,34 @@ static void clif_skillup(struct map_session_data *sd, uint16 skill_id, int skill /// 07e1 .W .L .W .W .W .B static void clif_skillinfo(struct map_session_data *sd, int skill_id, int inf) { + nullpo_retv(sd); + const int fd = sd->fd; int idx = skill->get_index(skill_id); - int skill_lv; - - nullpo_retv(sd); Assert_retv(idx >= 0 && idx < MAX_SKILL_DB); - skill_lv = sd->status.skill[idx].lv; - - WFIFOHEAD(fd,packet_len(0x7e1)); - WFIFOW(fd,0) = 0x7e1; - WFIFOW(fd,2) = skill_id; - WFIFOL(fd,4) = inf?inf:skill->get_inf(skill_id); - WFIFOW(fd,8) = skill_lv; + WFIFOHEAD(fd, sizeof(struct PACKET_ZC_SKILLINFO_UPDATE2)); + struct PACKET_ZC_SKILLINFO_UPDATE2 *p = WFIFOP(fd, 0); + p->packetType = HEADER_ZC_SKILLINFO_UPDATE2; + int skill_lv = sd->status.skill[idx].lv; + p->id = skill_id; + p->inf = skill->get_inf(skill_id); + p->level = skill_lv; if (skill_lv > 0) { - WFIFOW(fd,10) = skill->get_sp(skill_id, skill_lv); - WFIFOW(fd,12) = skill->get_range2(&sd->bl, skill_id, skill_lv); + p->sp = skill->get_sp(skill_id, skill_lv); + p->range2 = skill->get_range2(&sd->bl, skill_id, skill_lv); } else { - WFIFOW(fd,10) = 0; - WFIFOW(fd,12) = 0; + p->sp = 0; + p->range2 = 0; } +#if PACKETVER_RE_NUM >= 20190807 || PACKETVER_ZERO_NUM >= 20190814 + p->level2 = skill_lv; +#endif if (sd->status.skill[idx].flag == SKILL_FLAG_PERMANENT) - WFIFOB(fd,14) = (skill_lv < skill->tree_get_max(skill_id, sd->status.class))? 1:0; + p->upFlag = (skill_lv < skill->tree_get_max(skill_id, sd->status.class)) ? 1 : 0; else - WFIFOB(fd,14) = 0; - WFIFOSET(fd,packet_len(0x7e1)); + p->upFlag = 0; + WFIFOSET(fd, sizeof(struct PACKET_ZC_SKILLINFO_UPDATE2)); } /// Notifies clients in area, that an object is about to use a skill. @@ -5993,7 +5998,7 @@ static void clif_cooking_list(struct map_session_data *sd, int trigger, uint16 s len = sizeof(struct PACKET_ZC_MAKINGITEM_LIST) + MAX_SKILL_PRODUCE_DB * sizeof(struct PACKET_ZC_MAKINGITEM_LIST_sub); WFIFOHEAD(fd, len); p = WFIFOP(fd, 0); - p->packetType = 0x25a; + p->packetType = HEADER_ZC_MAKINGITEM_LIST; p->makeItem = list_type; // list type c = 0; @@ -10980,9 +10985,13 @@ static void clif_parse_progressbar(int fd, struct map_session_data *sd) __attrib /// 02f1 static void clif_parse_progressbar(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int npc_id = sd->progressbar.npc_id; + Assert_retv(npc_id != 0); - if( timer->gettick() < sd->progressbar.timeout && sd->st ) + if (timer->gettick() < sd->progressbar.timeout && sd->st) sd->st->state = END; sd->progressbar.timeout = sd->state.workinprogress = sd->progressbar.npc_id = 0; @@ -11007,7 +11016,7 @@ static void clif_parse_WalkToXY(int fd, struct map_session_data *sd) ; //You CAN walk on this OPT1 value. /*else if( sd->progressbar.npc_id ) clif->progressbar_abort(sd);*/ - else if (pc_cant_act(sd)) + else if (pc_cant_act(sd) || pc_isvending(sd)) return; if(sd->sc.data[SC_RUN] || sd->sc.data[SC_WUGDASH]) @@ -11087,13 +11096,13 @@ static void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) sc = status->get_sc(bl); if (sc && sc->option&OPTION_INVISIBLE && !clif->isdisguised(bl) && bl->type != BL_NPC && //Skip hidden NPCs which can be seen using Maya Purple - pc_get_group_level(sd) < battle_config.hack_info_GM_level + !pc_has_permission(sd, PC_PERM_RECEIVE_HACK_INFO) ) { char gm_msg[256]; sprintf(gm_msg, "Hack on NameRequest: character '%s' (account: %d) requested the name of an invisible target (id: %d).\n", sd->status.name, sd->status.account_id, id); ShowWarning(gm_msg); // information is sent to all online GMs - intif->wis_message_to_gm(map->wisp_server_name, battle_config.hack_info_GM_level, gm_msg); + pc->wis_message_to_gm(map->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, gm_msg); return; } #endif // 0 @@ -11167,7 +11176,10 @@ static void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) timer->settick(sd->fontcolor_tid, td->tick+5000); } - color = channel->config->colors[sd->fontcolor - 1]; + int fontColor = sd->fontcolor - 1; + if (fontColor < 0 || fontColor >= channel->config->colors_count) + fontColor = 0; + color = channel->config->colors[fontColor]; WFIFOHEAD(fd, outlen + 12); WFIFOW(fd,0) = 0x2C1; WFIFOW(fd,2) = outlen + 12; @@ -11372,10 +11384,10 @@ static void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action return; } - if( pc_cant_act(sd) || pc_issit(sd) || sd->sc.option&OPTION_HIDE ) + if (pc_cant_act(sd) || pc_issit(sd) || sd->sc.option&OPTION_HIDE || pc_isvending(sd)) return; - if( sd->sc.option&OPTION_COSTUME ) + if (sd->sc.option & OPTION_COSTUME) return; if (!battle_config.sdelay_attack_enable && pc->checkskill(sd, SA_FREECAST) <= 0 && (skill->get_inf2(sd->ud.skill_id) & (INF2_FREE_CAST_REDUCED | INF2_FREE_CAST_NORMAL)) == 0) { @@ -11553,8 +11565,8 @@ static void clif_parse_WisMessage(int fd, struct map_session_data *sd) script->set_var(sd,output,(char *) split_data[i]); } - sprintf(output, "%s::OnWhisperGlobal", nd->exname); - npc->event(sd,output,0); // Calls the NPC label + safesnprintf(output, 255, "%s::OnWhisperGlobal", nd->exname); + npc->event(sd,output, 0); // Calls the NPC label return; } @@ -11581,12 +11593,8 @@ static void clif_parse_WisMessage(int fd, struct map_session_data *sd) dstsd = map->nick2sd(target); if (dstsd == NULL || strcmp(dstsd->status.name, target) != 0) { - // player is not on this map-server - // At this point, don't send wisp/page if it's not exactly the same name, because (example) - // if there are 'Test' player on an other map-server and 'test' player on this map-server, - // and if we ask for 'Test', we must not contact 'test' player - // so, we send information to inter-server, which is the only one which decide (and copy correct name). - intif->wis_message(sd, target, message, (int)strlen(message)); + // Character not found (or found through partial match). + clif->wis_end(sd->fd, 1); return; } @@ -11633,7 +11641,7 @@ static void clif_parse_Broadcast(int fd, struct map_session_data *sd) char command[sizeof commandname + 2 + CHAT_SIZE_MAX] = ""; // '@' command + ' ' + message + NUL int len = (int)RFIFOW(fd,2) - 4; - if (len < 0) + if (len <= 0) return; sprintf(command, "%c%s ", atcommand->at_symbol, commandname); @@ -11733,6 +11741,9 @@ static void clif_parse_UseItem(int fd, struct map_session_data *sd) { int n; + if (pc_isvending(sd)) + return; + if (pc_isdead(sd)) { clif->clearunit_area(&sd->bl, CLR_DEAD); return; @@ -11758,15 +11769,17 @@ static void clif_parse_EquipItem(int fd, struct map_session_data *sd) __attribut static void clif_parse_EquipItem(int fd, struct map_session_data *sd) { const struct packet_equip_item *p = RP2PTR(fd); - int index = 0; - if(pc_isdead(sd)) { + if (pc_isvending(sd)) + return; + + if (pc_isdead(sd)) { clif->clearunit_area(&sd->bl,CLR_DEAD); return; } - index = p->index - 2; - if (index >= sd->status.inventorySize) + int index = p->index - 2; + if (index < 0 || index >= sd->status.inventorySize) return; //Out of bounds check. if( sd->npc_id ) { @@ -11777,15 +11790,15 @@ static void clif_parse_EquipItem(int fd, struct map_session_data *sd) else if ( pc_cant_act2(sd) || sd->state.prerefining ) return; - if(!sd->status.inventory[index].identify) { - clif->equipitemack(sd, index, 0, EIA_FAIL);// fail + if (!sd->status.inventory[index].identify) { + clif->equipitemack(sd, index, 0, EIA_FAIL); // fail return; } - if(!sd->inventory_data[index]) + if (!sd->inventory_data[index]) return; - if(sd->inventory_data[index]->type == IT_PETARMOR){ + if (sd->inventory_data[index]->type == IT_PETARMOR) { pet->equipitem(sd, index); return; } @@ -11793,7 +11806,7 @@ static void clif_parse_EquipItem(int fd, struct map_session_data *sd) pc->update_idle_time(sd, BCIDLE_USEITEM); //Client doesn't send the position for ammo. - if(sd->inventory_data[index]->type == IT_AMMO) + if (sd->inventory_data[index]->type == IT_AMMO) pc->equipitem(sd, index, EQP_AMMO); else pc->equipitem(sd, index, p->wearLocation); @@ -11806,6 +11819,9 @@ static void clif_parse_UnequipItem(int fd, struct map_session_data *sd) { int index; + if (pc_isvending(sd)) + return; + if(pc_isdead(sd)) { clif->clearunit_area(&sd->bl,CLR_DEAD); return; @@ -11878,7 +11894,7 @@ static void clif_parse_NpcBuySellSelected(int fd, struct map_session_data *sd) _ /// 1 = sell static void clif_parse_NpcBuySellSelected(int fd, struct map_session_data *sd) { - if (sd->state.trading) + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) return; npc->buysellsel(sd, RFIFOL(fd,2), RFIFOB(fd,6)); } @@ -11914,9 +11930,12 @@ static void clif_parse_NpcBuyListSend(int fd, struct map_session_data *sd) __att /// 00c8 .W { .W .W }* static void clif_parse_NpcBuyListSend(int fd, struct map_session_data *sd) { - int n = ((int)RFIFOW(fd, 2) - sizeof(struct PACKET_CZ_PC_PURCHASE_ITEMLIST)) / sizeof(struct PACKET_CZ_PC_PURCHASE_ITEMLIST_sub); - int result; + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + const struct PACKET_CZ_PC_PURCHASE_ITEMLIST *p = RFIFOP(fd, 0); + int n = ((int)p->packetLength - sizeof(struct PACKET_CZ_PC_PURCHASE_ITEMLIST)) / sizeof(struct PACKET_CZ_PC_PURCHASE_ITEMLIST_sub); + int result; Assert_retv(n >= 0); @@ -11974,7 +11993,7 @@ static void clif_parse_NpcSellListSend(int fd, struct map_session_data *sd) Assert_retv(n >= 0); - if (sd->state.trading || !sd->npc_shopid) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd) || !sd->npc_shopid) { fail = 1; } else { struct itemlist item_list = { 0 }; @@ -12009,6 +12028,9 @@ static void clif_parse_CreateChatRoom(int fd, struct map_session_data *sd) __att /// 1 = public static void clif_parse_CreateChatRoom(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int len = (int)RFIFOW(fd, 2) - 15; int limit; bool pub; @@ -12025,6 +12047,9 @@ static void clif_parse_CreateChatRoom(int fd, struct map_session_data *sd) password = RFIFOP(fd, 7); //not zero-terminated title = RFIFOP(fd, 15); // not zero-terminated + if (limit < 0) + return; + if (pc_ismuted(&sd->sc, MANNER_NOROOM)) return; if(battle_config.basic_skill_check && !pc->check_basicskill(sd, 4)) { @@ -12051,6 +12076,9 @@ static void clif_parse_ChatAddMember(int fd, struct map_session_data *sd) __attr /// 00d9 .L .8B static void clif_parse_ChatAddMember(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int chatid = RFIFOL(fd,2); const char *password = RFIFOP(fd,6); // not zero-terminated @@ -12065,6 +12093,9 @@ static void clif_parse_ChatRoomStatusChange(int fd, struct map_session_data *sd) /// 1 = public static void clif_parse_ChatRoomStatusChange(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int len = (int)RFIFOW(fd, 2) - 15; int limit; bool pub; @@ -12077,6 +12108,8 @@ static void clif_parse_ChatRoomStatusChange(int fd, struct map_session_data *sd) return; limit = RFIFOW(fd, 4); + if (limit < 0) + return; pub = (RFIFOB(fd, 6) != 0); password = RFIFOP(fd, 7); // not zero-terminated title = RFIFOP(fd, 15); // not zero-terminated @@ -12095,6 +12128,9 @@ static void clif_parse_ChangeChatOwner(int fd, struct map_session_data *sd) __at /// 1 = normal static void clif_parse_ChangeChatOwner(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + chat->change_owner(sd, RFIFOP(fd,6)); // non null terminated } @@ -12103,6 +12139,9 @@ static void clif_parse_KickFromChat(int fd, struct map_session_data *sd) __attri /// 00e2 .24B static void clif_parse_KickFromChat(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + chat->kick(sd, RFIFOP(fd,2)); // non null terminated } @@ -12111,6 +12150,9 @@ static void clif_parse_ChatLeave(int fd, struct map_session_data *sd) __attribut /// 00e3 static void clif_parse_ChatLeave(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + chat->leave(sd, false); } @@ -12135,9 +12177,10 @@ static void clif_parse_TradeRequest(int fd, struct map_session_data *sd) __attri /// 00e4 .L static void clif_parse_TradeRequest(int fd, struct map_session_data *sd) { - struct map_session_data *t_sd; + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; - t_sd = map->id2sd(RFIFOL(fd,2)); + struct map_session_data *t_sd = map->id2sd(RFIFOL(fd, 2)); if (sd->chat_id == 0 && pc_cant_act(sd)) return; //You can trade while in a chatroom. @@ -12164,6 +12207,9 @@ static void clif_parse_TradeAck(int fd, struct map_session_data *sd) __attribute /// 4 = rejected static void clif_parse_TradeAck(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + trade->ack(sd,RFIFOB(fd,2)); } @@ -12172,6 +12218,9 @@ static void clif_parse_TradeAddItem(int fd, struct map_session_data *sd) __attri /// 00e8 .W .L static void clif_parse_TradeAddItem(int fd, struct map_session_data *sd) { + if (!sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + short index = RFIFOW(fd,2); int amount = RFIFOL(fd,4); @@ -12186,6 +12235,8 @@ static void clif_parse_TradeOk(int fd, struct map_session_data *sd) __attribute_ /// 00eb static void clif_parse_TradeOk(int fd, struct map_session_data *sd) { + if (pc_isdead(sd) || pc_isvending(sd)) + return; trade->ok(sd); } @@ -12194,6 +12245,9 @@ static void clif_parse_TradeCancel(int fd, struct map_session_data *sd) __attrib /// 00ed static void clif_parse_TradeCancel(int fd, struct map_session_data *sd) { + if (pc_isdead(sd) || pc_isvending(sd)) + return; + trade->cancel(sd); } @@ -12202,6 +12256,9 @@ static void clif_parse_TradeCommit(int fd, struct map_session_data *sd) __attrib /// 00ef static void clif_parse_TradeCommit(int fd, struct map_session_data *sd) { + if (pc_isdead(sd) || pc_isvending(sd)) + return; + trade->commit(sd); } @@ -12764,7 +12821,7 @@ static void clif_parse_ProduceMix(int fd, struct map_session_data *sd) default: return; } - if (pc_istrading(sd)) { + if (pc_istrading(sd) || pc_isdead(sd) || pc_isvending(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, 0); clif_menuskill_clear(sd); @@ -12795,7 +12852,7 @@ static void clif_parse_Cooking(int fd, struct map_session_data *sd) if (type == 6 && sd->menuskill_id != GN_MIX_COOKING && sd->menuskill_id != GN_S_PHARMACY) return; - if (pc_istrading(sd)) { + if (pc_istrading(sd) || pc_isdead(sd) || pc_isvending(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, 0); clif_menuskill_clear(sd); @@ -12815,7 +12872,7 @@ static void clif_parse_RepairItem(int fd, struct map_session_data *sd) if (sd->menuskill_id != BS_REPAIRWEAPON) return; - if (pc_istrading(sd)) { + if (pc_istrading(sd) || pc_isdead(sd) || pc_isvending(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, 0); clif_menuskill_clear(sd); @@ -12830,19 +12887,17 @@ static void clif_parse_WeaponRefine(int fd, struct map_session_data *sd) __attri /// 0222 .L static void clif_parse_WeaponRefine(int fd, struct map_session_data *sd) { - int idx; - sd->state.prerefining = 0; if (sd->menuskill_id != WS_WEAPONREFINE) //Packet exploit? return; - if (pc_istrading(sd)) { + if (pc_istrading(sd) || pc_isdead(sd) || pc_isvending(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, 0); clif_menuskill_clear(sd); return; } - idx = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); + int idx = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); skill->weaponrefine(sd, idx-2); clif_menuskill_clear(sd); } @@ -12857,6 +12912,9 @@ static void clif_parse_NpcSelectMenu(int fd, struct map_session_data *sd) __attr /// overflows to choice%256. static void clif_parse_NpcSelectMenu(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int npc_id = RFIFOL(fd,2); uint8 select = RFIFOB(fd,6); @@ -12882,6 +12940,9 @@ static void clif_parse_NpcNextClicked(int fd, struct map_session_data *sd) __att /// 00b9 .L static void clif_parse_NpcNextClicked(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + npc->scriptcont(sd,RFIFOL(fd,2), false); } @@ -12890,6 +12951,9 @@ static void clif_parse_NpcAmountInput(int fd, struct map_session_data *sd) __att /// 0143 .L .L static void clif_parse_NpcAmountInput(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int npcid = RFIFOL(fd,2); int amount = RFIFOL(fd,6); @@ -12914,6 +12978,9 @@ static void clif_parse_NpcStringInput(int fd, struct map_session_data *sd) __att /// 01d5 .W .L .?B static void clif_parse_NpcStringInput(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int len = RFIFOW(fd, 2); // [4144] can't confirm exact client version. At least >= correct for 20150513 #if PACKETVER >= 20151029 @@ -12941,6 +13008,8 @@ static void clif_parse_NpcCloseClicked(int fd, struct map_session_data *sd) { if (!sd->npc_id) //Avoid parsing anything when the script was done with. [Skotlex] return; + if (sd->state.trading || pc_isvending(sd)) + return; sd->state.dialog = 0; npc->scriptcont(sd, RFIFOL(fd,2), true); } @@ -12952,6 +13021,9 @@ static void clif_parse_ItemIdentify(int fd, struct map_session_data *sd) __attri /// -1 = cancel static void clif_parse_ItemIdentify(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + short idx = RFIFOW(fd,2); if (sd->menuskill_id != MC_IDENTIFY) @@ -12970,6 +13042,9 @@ static void clif_parse_ItemIdentify(int fd, struct map_session_data *sd) /// 0A35 .W static void clif_parse_OneClick_ItemIdentify(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int cmd = RFIFOW(fd,0); short idx = RFIFOW(fd, packet_db[cmd].pos[0]) - 2; int n; @@ -12977,7 +13052,7 @@ static void clif_parse_OneClick_ItemIdentify(int fd, struct map_session_data *sd if (idx < 0 || idx >= sd->status.inventorySize || sd->inventory_data[idx] == NULL || sd->status.inventory[idx].nameid <= 0) return; - if ((n = pc->have_magnifier(sd) ) != INDEX_NOT_FOUND && + if ((n = pc->have_magnifier(sd)) != INDEX_NOT_FOUND && pc->delitem(sd, n, 1, 0, DELITEM_NORMAL, LOG_TYPE_CONSUME) == 0) skill->identify(sd, idx); } @@ -12988,7 +13063,7 @@ static void clif_parse_SelectArrow(int fd, struct map_session_data *sd) __attrib static void clif_parse_SelectArrow(int fd, struct map_session_data *sd) { int itemId; - if (pc_istrading(sd)) { + if (pc_istrading(sd) || pc_isdead(sd) || pc_isvending(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, 0); clif_menuskill_clear(sd); @@ -13025,6 +13100,9 @@ static void clif_parse_AutoSpell(int fd, struct map_session_data *sd) __attribut /// 01ce .L static void clif_parse_AutoSpell(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + uint16 skill_id = RFIFOL(fd,2); sd->state.workinprogress = 0; @@ -13044,6 +13122,9 @@ static void clif_parse_UseCard(int fd, struct map_session_data *sd) __attribute_ /// 017a .W static void clif_parse_UseCard(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + clif->use_card(sd,RFIFOW(fd,2)-2); } @@ -13052,6 +13133,9 @@ static void clif_parse_InsertCard(int fd, struct map_session_data *sd) __attribu /// 017c .W .W static void clif_parse_InsertCard(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + pc->insert_card(sd,RFIFOW(fd,2)-2,RFIFOW(fd,4)-2); } @@ -13077,6 +13161,9 @@ static void clif_parse_ResetChar(int fd, struct map_session_data *sd) __attribut /// 1 = skill static void clif_parse_ResetChar(int fd, struct map_session_data *sd) { + if (pc_istrading(sd) || pc_isvending(sd)) + return; + char cmd[15]; if( RFIFOW(fd,2) ) @@ -13262,6 +13349,9 @@ static void clif_parse_CreateParty(int fd, struct map_session_data *sd) __attrib /// 01e8 .24B .B .B (CZ_MAKE_GROUP2) static void clif_parse_CreateParty(int fd, struct map_session_data *sd) { + if (pc_istrading(sd) || pc_isvending(sd)) + return; + char name[NAME_LENGTH]; safestrncpy(name, RFIFOP(fd,2), NAME_LENGTH); @@ -13282,6 +13372,9 @@ static void clif_parse_CreateParty(int fd, struct map_session_data *sd) static void clif_parse_CreateParty2(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); static void clif_parse_CreateParty2(int fd, struct map_session_data *sd) { + if (pc_istrading(sd) || pc_isvending(sd)) + return; + char name[NAME_LENGTH]; int item1 = RFIFOB(fd,26); int item2 = RFIFOB(fd,27); @@ -13307,6 +13400,9 @@ static void clif_parse_PartyInvite(int fd, struct map_session_data *sd) __attrib /// 02c4 .24B (CZ_PARTY_JOIN_REQ) static void clif_parse_PartyInvite(int fd, struct map_session_data *sd) { + if (pc_istrading(sd) || pc_isvending(sd)) + return; + struct map_session_data *t_sd; if(map->list[sd->bl.m].flag.partylock) { @@ -13328,6 +13424,9 @@ static void clif_parse_PartyInvite(int fd, struct map_session_data *sd) static void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); static void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) { + if (pc_istrading(sd) || pc_isvending(sd)) + return; + struct map_session_data *t_sd; char name[NAME_LENGTH]; @@ -13358,13 +13457,23 @@ static void clif_parse_ReplyPartyInvite(int fd, struct map_session_data *sd) __a /// 1 = accept static void clif_parse_ReplyPartyInvite(int fd, struct map_session_data *sd) { - party->reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6)); + if (pc_istrading(sd) || pc_isvending(sd)) { + party->reply_invite(sd, RFIFOL(fd, 2), 0); + return; + } + + party->reply_invite(sd, RFIFOL(fd, 2), RFIFOL(fd, 6)); } static void clif_parse_ReplyPartyInvite2(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); static void clif_parse_ReplyPartyInvite2(int fd, struct map_session_data *sd) { - party->reply_invite(sd,RFIFOL(fd,2),RFIFOB(fd,6)); + if (pc_istrading(sd) || pc_isvending(sd)) { + party->reply_invite(sd, RFIFOL(fd, 2), 0); + return; + } + + party->reply_invite(sd, RFIFOL(fd, 2), RFIFOB(fd, 6)); } static void clif_parse_LeaveParty(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); @@ -13372,7 +13481,10 @@ static void clif_parse_LeaveParty(int fd, struct map_session_data *sd) __attribu /// 0100 static void clif_parse_LeaveParty(int fd, struct map_session_data *sd) { - if(map->list[sd->bl.m].flag.partylock) { + if (pc_istrading(sd) || pc_isvending(sd)) + return; + + if (map->list[sd->bl.m].flag.partylock) { // Party locked. clif->message(fd, msg_fd(fd,227)); // Party modification is disabled in this map. return; @@ -13385,12 +13497,15 @@ static void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) __ /// 0103 .L .24B static void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) { - if(map->list[sd->bl.m].flag.partylock) { + if (pc_istrading(sd) || pc_isvending(sd)) + return; + + if (map->list[sd->bl.m].flag.partylock) { // Party locked. clif->message(fd, msg_fd(fd,227)); // Party modification is disabled in this map. return; } - party->removemember(sd, RFIFOL(fd,2), RFIFOP(fd,6)); + party->removemember(sd, RFIFOL(fd, 2), RFIFOP(fd, 6)); } static void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); @@ -13399,6 +13514,9 @@ static void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) __ /// 07d7 .L .B .B (CZ_GROUPINFO_CHANGE_V2) static void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) { + if (pc_istrading(sd) || pc_isvending(sd)) + return; + struct party_data *p; int i; @@ -13451,6 +13569,9 @@ static void clif_parse_PartyChangeLeader(int fd, struct map_session_data *sd) __ /// 07da .L static void clif_parse_PartyChangeLeader(int fd, struct map_session_data *sd) { + if (pc_istrading(sd) || pc_isvending(sd)) + return; + party->changeleader(sd, map->id2sd(RFIFOL(fd,2))); } @@ -13463,6 +13584,9 @@ static void clif_parse_PartyBookingRegisterReq(int fd, struct map_session_data * static void clif_parse_PartyBookingRegisterReq(int fd, struct map_session_data *sd) { #ifndef PARTY_RECRUIT + if (pc_istrading(sd) || pc_isvending(sd)) + return; + short level = RFIFOW(fd,2); short mapid = RFIFOW(fd,4); short job[PARTY_BOOKING_JOBS]; @@ -13505,6 +13629,9 @@ static void clif_parse_PartyBookingSearchReq(int fd, struct map_session_data *sd static void clif_parse_PartyBookingSearchReq(int fd, struct map_session_data *sd) { #ifndef PARTY_RECRUIT + if (pc_istrading(sd) || pc_isvending(sd)) + return; + short level = RFIFOW(fd,2); short mapid = RFIFOW(fd,4); short job = RFIFOW(fd,6); @@ -13556,7 +13683,10 @@ static void clif_parse_PartyBookingDeleteReq(int fd, struct map_session_data *sd static void clif_parse_PartyBookingDeleteReq(int fd, struct map_session_data *sd) { #ifndef PARTY_RECRUIT - if(party->booking_delete(sd)) + if (pc_istrading(sd) || pc_isvending(sd)) + return; + + if (party->booking_delete(sd)) clif->PartyBookingDeleteAck(sd, 0); #else return; @@ -13592,11 +13722,13 @@ static void clif_parse_PartyBookingUpdateReq(int fd, struct map_session_data *sd static void clif_parse_PartyBookingUpdateReq(int fd, struct map_session_data *sd) { #ifndef PARTY_RECRUIT + if (pc_istrading(sd) || pc_isvending(sd)) + return; + short job[PARTY_BOOKING_JOBS]; - int i; - for(i=0; ibooking_update(sd, job); #else @@ -13609,8 +13741,11 @@ static void clif_parse_PartyBookingUpdateReq(int fd, struct map_session_data *sd static void clif_PartyBookingInsertNotify(struct map_session_data *sd, struct party_booking_ad_info *pb_ad) { #ifndef PARTY_RECRUIT + if (pc_istrading(sd) || pc_isvending(sd)) + return; + int i; - uint8 buf[38+PARTY_BOOKING_JOBS*2]; + uint8 buf[38 + PARTY_BOOKING_JOBS * 2]; nullpo_retv(sd); if(pb_ad == NULL) return; @@ -13677,7 +13812,10 @@ static void clif_parse_PartyRecruitRegisterReq(int fd, struct map_session_data * static void clif_parse_PartyRecruitRegisterReq(int fd, struct map_session_data *sd) { #ifdef PARTY_RECRUIT - short level = RFIFOW(fd,2); + if (pc_istrading(sd) || pc_isvending(sd)) + return; + + short level = RFIFOW(fd, 2); const char *notice = RFIFOP(fd, 4); party->recruit_register(sd, level, notice); @@ -13748,6 +13886,9 @@ static void clif_parse_PartyRecruitSearchReq(int fd, struct map_session_data *sd static void clif_parse_PartyRecruitSearchReq(int fd, struct map_session_data *sd) { #ifdef PARTY_RECRUIT + if (pc_istrading(sd) || pc_isvending(sd)) + return; + short level = RFIFOW(fd, 2); short mapid = RFIFOW(fd, 4); unsigned long lastindex = RFIFOL(fd, 6); @@ -13765,7 +13906,10 @@ static void clif_parse_PartyRecruitDeleteReq(int fd, struct map_session_data *sd static void clif_parse_PartyRecruitDeleteReq(int fd, struct map_session_data *sd) { #ifdef PARTY_RECRUIT - if(party->booking_delete(sd)) + if (pc_istrading(sd) || pc_isvending(sd)) + return; + + if (party->booking_delete(sd)) clif->PartyRecruitDeleteAck(sd, 0); #else return; @@ -13801,6 +13945,9 @@ static void clif_parse_PartyRecruitUpdateReq(int fd, struct map_session_data *sd static void clif_parse_PartyRecruitUpdateReq(int fd, struct map_session_data *sd) { #ifdef PARTY_RECRUIT + if (pc_istrading(sd) || pc_isvending(sd)) + return; + const char *notice = RFIFOP(fd, 2); party->recruit_update(sd, notice); @@ -13874,6 +14021,9 @@ static void clif_parse_PartyBookingAddFilteringList(int fd, struct map_session_d static void clif_parse_PartyBookingAddFilteringList(int fd, struct map_session_data *sd) { #ifdef PARTY_RECRUIT + if (pc_istrading(sd) || pc_isvending(sd)) + return; + int index = RFIFOL(fd, 2); clif->PartyBookingAddFilteringList(index, sd); @@ -13888,6 +14038,9 @@ static void clif_parse_PartyBookingSubFilteringList(int fd, struct map_session_d static void clif_parse_PartyBookingSubFilteringList(int fd, struct map_session_data *sd) { #ifdef PARTY_RECRUIT + if (pc_istrading(sd) || pc_isvending(sd)) + return; + int gid = RFIFOL(fd, 2); clif->PartyBookingSubFilteringList(gid, sd); @@ -13902,6 +14055,9 @@ static void clif_parse_PartyBookingReqVolunteer(int fd, struct map_session_data static void clif_parse_PartyBookingReqVolunteer(int fd, struct map_session_data *sd) { #ifdef PARTY_RECRUIT + if (pc_istrading(sd) || pc_isvending(sd)) + return; + int index = RFIFOL(fd, 2); clif->PartyBookingVolunteerInfo(index, sd); @@ -13978,6 +14134,9 @@ static void clif_parse_PartyBookingRefuseVolunteer(int fd, struct map_session_da static void clif_parse_PartyBookingRefuseVolunteer(int fd, struct map_session_data *sd) { #ifdef PARTY_RECRUIT + if (pc_istrading(sd) || pc_isvending(sd)) + return; + unsigned int aid = RFIFOL(fd, 2); clif->PartyBookingRefuseVolunteer(aid, sd); @@ -14007,6 +14166,9 @@ static void clif_parse_PartyBookingCancelVolunteer(int fd, struct map_session_da static void clif_parse_PartyBookingCancelVolunteer(int fd, struct map_session_data *sd) { #ifdef PARTY_RECRUIT + if (pc_istrading(sd) || pc_isvending(sd)) + return; + int index = RFIFOL(fd, 2); clif->PartyBookingCancelVolunteer(index, sd); @@ -14082,6 +14244,9 @@ static void clif_parse_CloseVending(int fd, struct map_session_data *sd) __attri /// 012e static void clif_parse_CloseVending(int fd, struct map_session_data *sd) { + if (pc_istrading(sd) || pc_isdead(sd)) + return; + vending->close(sd); } @@ -14090,6 +14255,9 @@ static void clif_parse_VendingListReq(int fd, struct map_session_data *sd) __att /// 0130 .L static void clif_parse_VendingListReq(int fd, struct map_session_data *sd) { + if (pc_istrading(sd) || pc_isdead(sd)) + return; + if( sd->npc_id ) {// using an NPC return; } @@ -14101,6 +14269,9 @@ static void clif_parse_PurchaseReq(int fd, struct map_session_data *sd) __attrib /// 0134 .W .L { .W .W }* static void clif_parse_PurchaseReq(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int len = (int)RFIFOW(fd, 2) - 8; int id; const uint8 *data; @@ -14122,6 +14293,9 @@ static void clif_parse_PurchaseReq2(int fd, struct map_session_data *sd) __attri /// 0801 .W .L .L { .W .W }* static void clif_parse_PurchaseReq2(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int len = (int)RFIFOW(fd, 2) - 12; int aid; int uid; @@ -14148,25 +14322,25 @@ static void clif_parse_OpenVending(int fd, struct map_session_data *sd) __attrib /// 1 = open static void clif_parse_OpenVending(int fd, struct map_session_data *sd) { + if (pc_istrading(sd) || pc_isdead(sd) || sd->state.vending || sd->state.buyingstore) + return; + int len = (int)RFIFOW(fd, 2) - 85; - const char *message; - bool flag; - const uint8 *data; if (len < 0) return; - message = RFIFOP(fd,4); - flag = (RFIFOB(fd,84) != 0) ? true : false; - data = RFIFOP(fd,85); + const char *message = RFIFOP(fd, 4); + bool flag = (RFIFOB(fd, 84) != 0) ? true : false; + const uint8 *data = RFIFOP(fd, 85); - if( !flag ) + if (!flag) sd->state.prevend = sd->state.workinprogress = 0; - if(pc_ismuted(&sd->sc, MANNER_NOROOM)) + if (pc_ismuted(&sd->sc, MANNER_NOROOM)) return; - if( map->list[sd->bl.m].flag.novending ) { - clif->message (sd->fd, msg_sd(sd,276)); // "You can't open a shop on this map" + if (map->list[sd->bl.m].flag.novending) { + clif->message (sd->fd, msg_sd(sd, 276)); // "You can't open a shop on this map" return; } if (map->getcell(sd->bl.m, &sd->bl, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING)) { @@ -14185,11 +14359,14 @@ static void clif_parse_CreateGuild(int fd, struct map_session_data *sd) __attrib /// 0165 .L .24B static void clif_parse_CreateGuild(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + char name[NAME_LENGTH]; safestrncpy(name, RFIFOP(fd,6), NAME_LENGTH); - if(map->list[sd->bl.m].flag.guildlock) { - clif->message(fd, msg_fd(fd,228)); // Guild modification is disabled in this map. + if (map->list[sd->bl.m].flag.guildlock) { + clif->message(fd, msg_fd(fd, 228)); // Guild modification is disabled in this map. return; } @@ -14250,6 +14427,9 @@ static void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data * /// 0161 .W { .L .L .L .L .24B }* static void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int i; int count = (RFIFOW(fd, 2) - 4) / 40; @@ -14267,6 +14447,9 @@ static void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data /// 0155 .W { .L .L .L }* static void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int i; int len = RFIFOW(fd, 2); int count = (len - 4) / 12; @@ -14432,10 +14615,13 @@ static void clif_parse_GuildChangeEmblem(int fd, struct map_session_data *sd) __ /// 0153 .W .?B static void clif_parse_GuildChangeEmblem(int fd, struct map_session_data *sd) { - unsigned int emblem_len = RFIFOW(fd,2)-4; - const uint8* emblem = RFIFOP(fd,4); + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + + unsigned int emblem_len = RFIFOW(fd, 2) - 4; + const uint8* emblem = RFIFOP(fd, 4); - if( !emblem_len || !sd->state.gmaster_flag ) + if (!emblem_len || !sd->state.gmaster_flag) return; if (!clif->validate_emblem(emblem, emblem_len)) { @@ -14452,7 +14638,10 @@ static void clif_parse_GuildChangeNotice(int fd, struct map_session_data *sd) __ /// 016e .L .60B .120B static void clif_parse_GuildChangeNotice(int fd, struct map_session_data *sd) { - int guild_id = RFIFOL(fd,2); + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + + int guild_id = RFIFOL(fd, 2); char *msg1 = NULL, *msg2 = NULL; if (!sd->state.gmaster_flag) @@ -14504,6 +14693,9 @@ static void clif_parse_GuildInvite(int fd, struct map_session_data *sd) __attrib /// 0168 .L .L .L static void clif_parse_GuildInvite(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + struct map_session_data *t_sd = map->id2sd(RFIFOL(fd,2)); if (!clif_sub_guild_invite(fd, sd, t_sd)) @@ -14532,7 +14724,7 @@ static void clif_parse_GuildReplyInvite(int fd, struct map_session_data *sd) __a /// 1 = accept static 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, 2), RFIFOL(fd, 6)); } static void clif_parse_GuildLeave(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); @@ -14540,16 +14732,19 @@ static void clif_parse_GuildLeave(int fd, struct map_session_data *sd) __attribu /// 0159 .L .L .L .40B static void clif_parse_GuildLeave(int fd, struct map_session_data *sd) { - if(map->list[sd->bl.m].flag.guildlock) { - clif->message(fd, msg_fd(fd,228)); // Guild modification is disabled in this map. + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + + if (map->list[sd->bl.m].flag.guildlock) { + clif->message(fd, msg_fd(fd, 228)); // Guild modification is disabled in this map. return; } - if( sd->bg_id ) { - clif->message(fd, msg_fd(fd,870)); //"You can't leave battleground guilds." + if (sd->bg_id) { + clif->message(fd, msg_fd(fd, 870)); //"You can't leave battleground guilds." return; } - guild->leave(sd,RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOP(fd,14)); + guild->leave(sd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOL(fd, 10), RFIFOP(fd, 14)); } static void clif_parse_GuildExpulsion(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); @@ -14557,11 +14752,14 @@ static void clif_parse_GuildExpulsion(int fd, struct map_session_data *sd) __att /// 015b .L .L .L .40B static void clif_parse_GuildExpulsion(int fd, struct map_session_data *sd) { - if( map->list[sd->bl.m].flag.guildlock || sd->bg_id ) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + + if (map->list[sd->bl.m].flag.guildlock || sd->bg_id) { clif->message(fd, msg_fd(fd,228)); // Guild modification is disabled in this map. return; } - guild->expulsion(sd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOP(fd,14)); + guild->expulsion(sd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOL(fd, 10), RFIFOP(fd, 14)); } /** @@ -14594,6 +14792,9 @@ static void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) /// 0170 .L .L .L static void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + struct map_session_data *t_sd; if(!sd->state.gmaster_flag) @@ -14634,6 +14835,9 @@ static void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) __a /// 1 = Enemy static void clif_parse_GuildDelAlliance(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + if(!sd->state.gmaster_flag) return; @@ -14649,6 +14853,9 @@ static void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) __at /// 0180 .L static void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + struct map_session_data *t_sd; if(!sd->state.gmaster_flag) @@ -14678,6 +14885,9 @@ static void clif_parse_GuildBreak(int fd, struct map_session_data *sd) __attribu /// field name and size is same as the one in CH_DELETE_CHAR. static void clif_parse_GuildBreak(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + char key[40]; if( map->list[sd->bl.m].flag.guildlock ) { clif->message(fd, msg_fd(fd,228)); // Guild modification is disabled in this map. @@ -14701,7 +14911,10 @@ static void clif_parse_PetMenu(int fd, struct map_session_data *sd) __attribute_ /// 4 = unequip accessory static void clif_parse_PetMenu(int fd, struct map_session_data *sd) { - pet->menu(sd,RFIFOB(fd,2)); + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + + pet->menu(sd, RFIFOB(fd, 2)); } static void clif_parse_CatchPet(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); @@ -14709,7 +14922,10 @@ static void clif_parse_CatchPet(int fd, struct map_session_data *sd) __attribute /// 019f .L static void clif_parse_CatchPet(int fd, struct map_session_data *sd) { - pet->catch_process2(sd,RFIFOL(fd,2)); + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + + pet->catch_process2(sd, RFIFOL(fd, 2)); } static void clif_parse_SelectEgg(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); @@ -14717,10 +14933,13 @@ static void clif_parse_SelectEgg(int fd, struct map_session_data *sd) __attribut /// 01a7 .W static void clif_parse_SelectEgg(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + if (sd->menuskill_id != SA_TAMINGMONSTER || sd->menuskill_val != -1) { return; } - pet->select_egg(sd,RFIFOW(fd,2)-2); + pet->select_egg(sd, RFIFOW(fd, 2) - 2); clif_menuskill_clear(sd); } @@ -14760,6 +14979,9 @@ static void clif_parse_ChangePetName(int fd, struct map_session_data *sd) __attr /// 01a5 .24B static void clif_parse_ChangePetName(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + pet->change_name(sd, RFIFOP(fd,2)); } @@ -14768,6 +14990,9 @@ static void clif_parse_pet_evolution(int fd, struct map_session_data *sd) __attr /// 09fb .W .W {.W .W}*items static void clif_parse_pet_evolution(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + const struct PACKET_CZ_PET_EVOLUTION *p = RP2PTR(fd); int i = 0, idx, petIndex; @@ -14956,7 +15181,7 @@ static void clif_parse_GMShift(int fd, struct map_session_data *sd) { // FIXME: remove is supposed to receive account name for clients prior 20100803RE char player_name[NAME_LENGTH]; - char command[NAME_LENGTH+8]; + char command[NAME_LENGTH + 20]; safestrncpy(player_name, RFIFOP(fd,2), NAME_LENGTH); @@ -14975,7 +15200,7 @@ static void clif_parse_GMRemove2(int fd, struct map_session_data *sd) account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); if( (pl_sd = map->id2sd(account_id)) != NULL ) { - char command[NAME_LENGTH+8]; + char command[NAME_LENGTH + 20]; sprintf(command, "%cjumpto %s", atcommand->at_symbol, pl_sd->status.name); atcommand->exec(fd, sd, command, true); } @@ -15012,7 +15237,7 @@ static void clif_parse_GMRecall2(int fd, struct map_session_data *sd) account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); if( (pl_sd = map->id2sd(account_id)) != NULL ) { - char command[NAME_LENGTH+8]; + char command[NAME_LENGTH + 20]; sprintf(command, "%crecall %s", atcommand->at_symbol, pl_sd->status.name); atcommand->exec(fd, sd, command, true); } @@ -15343,6 +15568,9 @@ static void clif_parse_NoviceDoriDori(int fd, struct map_session_data *sd) __att /// 01e7 static void clif_parse_NoviceDoriDori(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + if (sd->state.doridori) return; switch (sd->job & MAPID_UPPERMASK) { @@ -15369,6 +15597,9 @@ static void clif_parse_NoviceExplosionSpirits(int fd, struct map_session_data *s /// "Help me out~ Please~ T_T" static void clif_parse_NoviceExplosionSpirits(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + /* [Ind/Hercules] */ /* game client is currently broken on this (not sure the packetver range) */ /* it sends the request when the criteria doesn't match (and of course we let it fail) */ @@ -15512,6 +15743,9 @@ static void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) __att /// 0202 .24B static void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + struct map_session_data *f_sd; int i; char nick[NAME_LENGTH]; @@ -15633,6 +15867,9 @@ static void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd) __ /// 0203 .L .L static void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + struct map_session_data *f_sd = NULL; int account_id, char_id; int i, j; @@ -15724,7 +15961,7 @@ static void clif_parse_PVPInfo(int fd, struct map_session_data *sd) /// ranking pointlist { .24B .L }*10 static void clif_ranklist_sub(struct PACKET_ZC_ACK_RANKING_sub *ranks, enum fame_list_type type) { -#if !(PACKETVER_RE_NUM >= 20190703 || PACKETVER_ZERO_NUM >= 20190724) +#if !(PACKETVER_MAIN_NUM >= 20190731 || PACKETVER_RE_NUM >= 20190703 || PACKETVER_ZERO_NUM >= 20190724) nullpo_retv(ranks); struct fame_list* list; @@ -15759,7 +15996,7 @@ static void clif_ranklist_sub(struct PACKET_ZC_ACK_RANKING_sub *ranks, enum fame static void clif_ranklist_sub2(uint32 *chars, uint32 *points, enum fame_list_type type) { -#if PACKETVER_RE_NUM >= 20190703 || PACKETVER_ZERO_NUM >= 20190724 +#if PACKETVER_MAIN_NUM >= 20190731 || PACKETVER_RE_NUM >= 20190703 || PACKETVER_ZERO_NUM >= 20190724 nullpo_retv(chars); nullpo_retv(points); @@ -15798,7 +16035,7 @@ static void clif_ranklist(struct map_session_data *sd, enum fame_list_type type) struct PACKET_ZC_ACK_RANKING *p = WFIFOP(fd, 0); p->packetType = HEADER_ZC_ACK_RANKING; p->rankType = type; -#if PACKETVER_RE_NUM >= 20190703 || PACKETVER_ZERO_NUM >= 20190724 +#if PACKETVER_MAIN_NUM >= 20190731 || PACKETVER_RE_NUM >= 20190703 || PACKETVER_ZERO_NUM >= 20190724 clif->ranklist_sub2(p->chars, p->points, type); #else clif->ranklist_sub(p->ranks, type); @@ -16007,6 +16244,9 @@ static void clif_parse_FeelSaveOk(int fd, struct map_session_data *sd) __attribu /// 2 = star static void clif_parse_FeelSaveOk(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int i; if (sd->menuskill_id != SG_FEEL) return; @@ -16048,6 +16288,9 @@ static void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd) /// 0231 .24B static void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + homun->change_name(sd, RFIFOP(fd,2)); } @@ -16056,6 +16299,9 @@ static void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd) __at /// 0234 .L static void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int id = RFIFOL(fd,2); // Mercenary or Homunculus struct block_list *bl = NULL; struct unit_data *ud = NULL; @@ -16077,6 +16323,9 @@ static void clif_parse_HomMoveTo(int fd, struct map_session_data *sd) __attribut /// 0232 .L .3B static void clif_parse_HomMoveTo(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int id = RFIFOL(fd,2); // Mercenary or Homunculus struct block_list *bl = NULL; short x, y; @@ -16100,6 +16349,9 @@ static void clif_parse_HomAttack(int fd, struct map_session_data *sd) __attribut /// always 0 static void clif_parse_HomAttack(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + struct block_list *bl = NULL; int id = RFIFOL(fd,2), target_id = RFIFOL(fd,6), @@ -16126,6 +16378,9 @@ static void clif_parse_HomMenu(int fd, struct map_session_data *sd) __attribute_ /// 2 = delete static void clif_parse_HomMenu(int fd, struct map_session_data *sd) { //[orn] + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int cmd; cmd = RFIFOW(fd,0); @@ -16141,6 +16396,11 @@ static void clif_parse_AutoRevive(int fd, struct map_session_data *sd) __attribu /// 0292 static void clif_parse_AutoRevive(int fd, struct map_session_data *sd) { + if (pc_istrading(sd) || pc_isvending(sd)) + return; + if (!pc_isdead(sd)) + return; + int item_position = pc->search_inventory(sd, ITEMID_TOKEN_OF_SIEGFRIED); int hpsp = 100; @@ -16162,7 +16422,7 @@ static void clif_parse_AutoRevive(int fd, struct map_session_data *sd) else pc->delitem(sd, item_position, 1, 0, DELITEM_SKILLUSE, LOG_TYPE_CONSUME); - clif->skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1); + clif->skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION, 4, 1); } /// Information about character's status values (ZC_ACK_STATUS_GM). @@ -16212,6 +16472,9 @@ static void clif_parse_Check(int fd, struct map_session_data *sd) __attribute__( /// 0213 .24B static void clif_parse_Check(int fd, struct map_session_data *sd) { + if (pc_istrading(sd) || pc_isvending(sd)) + return; + char charname[NAME_LENGTH]; struct map_session_data* pl_sd; @@ -16374,6 +16637,9 @@ static void clif_parse_Mail_refreshinbox(int fd, struct map_session_data *sd) __ /// 023f static void clif_parse_Mail_refreshinbox(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + struct mail_data* md = &sd->mail.inbox; if( md->amount < MAIL_MAX_INBOX && (md->full || sd->mail.changed) ) @@ -16457,6 +16723,9 @@ static void clif_parse_Mail_read(int fd, struct map_session_data *sd) __attribut /// 0241 .L static void clif_parse_Mail_read(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int mail_id = RFIFOL(fd,2); if( mail_id <= 0 ) @@ -16472,6 +16741,9 @@ static void clif_parse_Mail_getattach(int fd, struct map_session_data *sd) __att /// 0244 .L static void clif_parse_Mail_getattach(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int mail_id = RFIFOL(fd,2); int i; @@ -16540,6 +16812,9 @@ static void clif_parse_Mail_delete(int fd, struct map_session_data *sd) __attrib /// 0243 .L static void clif_parse_Mail_delete(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int mail_id = RFIFOL(fd,2); int i; @@ -16571,6 +16846,9 @@ static void clif_parse_Mail_return(int fd, struct map_session_data *sd) __attrib /// 0273 .L .24B static void clif_parse_Mail_return(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int mail_id = RFIFOL(fd,2); int i; @@ -16595,6 +16873,9 @@ static void clif_parse_Mail_setattach(int fd, struct map_session_data *sd) __att /// 0247 .W .L static void clif_parse_Mail_setattach(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int idx = RFIFOW(fd,2); int amount = RFIFOL(fd,4); unsigned char flag; @@ -16617,6 +16898,9 @@ static void clif_parse_Mail_winopen(int fd, struct map_session_data *sd) __attri /// 2 = remove zeny static void clif_parse_Mail_winopen(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int flag = RFIFOW(fd,2); if (flag == 0 || flag == 1) @@ -16631,6 +16915,9 @@ static void clif_parse_Mail_send(int fd, struct map_session_data *sd) __attribut static void clif_parse_Mail_send(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + struct mail_message msg; int body_len; int len = RFIFOW(fd, 2); @@ -16787,7 +17074,10 @@ static void clif_parse_Auction_cancelreg(int fd, struct map_session_data *sd) __ /// ? = junk, uninitialized value (ex. when switching between list filters) static void clif_parse_Auction_cancelreg(int fd, struct map_session_data *sd) { - if( sd->auction.amount > 0 ) + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + + if (sd->auction.amount > 0) clif->additem(sd, sd->auction.index, sd->auction.amount, 0); sd->auction.amount = 0; @@ -16798,8 +17088,11 @@ static void clif_parse_Auction_setitem(int fd, struct map_session_data *sd) __at /// 024c .W .L static 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 + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + + int idx = RFIFOW(fd, 2) - 2; + int amount = RFIFOL(fd, 4); // Always 1 struct item_data *item; if( !battle_config.feature_auction ) @@ -16877,6 +17170,9 @@ static void clif_parse_Auction_register(int fd, struct map_session_data *sd) __a /// 024d .L .L .W static void clif_parse_Auction_register(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + struct auction_data auction; struct item_data *item; @@ -16972,7 +17268,10 @@ static void clif_parse_Auction_cancel(int fd, struct map_session_data *sd) __att /// 024e .L static void clif_parse_Auction_cancel(int fd, struct map_session_data *sd) { - unsigned int auction_id = RFIFOL(fd,2); + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + + unsigned int auction_id = RFIFOL(fd, 2); intif->Auction_cancel(sd->status.char_id, auction_id); } @@ -16982,6 +17281,9 @@ static void clif_parse_Auction_close(int fd, struct map_session_data *sd) __attr /// 025d .L static void clif_parse_Auction_close(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + unsigned int auction_id = RFIFOL(fd,2); intif->Auction_close(sd->status.char_id, auction_id); @@ -16992,8 +17294,11 @@ static void clif_parse_Auction_bid(int fd, struct map_session_data *sd) __attrib /// 024f .L .L static void clif_parse_Auction_bid(int fd, struct map_session_data *sd) { - unsigned int auction_id = RFIFOL(fd,2); - int bid = RFIFOL(fd,6); + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + + unsigned int auction_id = RFIFOL(fd, 2); + int bid = RFIFOL(fd, 6); if( !pc_can_give_items(sd) ) { //They aren't supposed to give zeny [Inkfish] clif->message(sd->fd, msg_sd(sd,246)); // Your GM level doesn't authorize you to perform this action. @@ -17024,9 +17329,12 @@ static void clif_parse_Auction_search(int fd, struct map_session_data *sd) __att /// 5 = auction id search static void clif_parse_Auction_search(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + char search_text[NAME_LENGTH]; - short type = RFIFOW(fd,2), page = RFIFOW(fd,32); - int price = RFIFOL(fd,4); // FIXME: bug #5071 + short type = RFIFOW(fd, 2), page = RFIFOW(fd, 32); + int price = RFIFOL(fd, 4); // FIXME: bug #5071 if( !battle_config.feature_auction ) return; @@ -17045,7 +17353,10 @@ static void clif_parse_Auction_buysell(int fd, struct map_session_data *sd) __at /// 1 = buy (own bids) static void clif_parse_Auction_buysell(int fd, struct map_session_data *sd) { - short type = RFIFOW(fd,2) + 6; + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + + short type = RFIFOW(fd, 2) + 6; if( !battle_config.feature_auction ) return; @@ -17155,6 +17466,9 @@ static void clif_parse_cashshop_buy(int fd, struct map_session_data *sd) __attri /// 0288 .W .L .W { .W .W }.4B*count (PACKETVER >= 20100803) static void clif_parse_cashshop_buy(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int fail = 0; const struct PACKET_CZ_PC_BUY_CASH_POINT_ITEM *p = RFIFOP(fd, 0); @@ -17247,6 +17561,9 @@ static void clif_parse_Adopt_request(int fd, struct map_session_data *sd) __attr /// 01f9 .L static void clif_parse_Adopt_request(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + struct map_session_data *tsd = map->id2sd(RFIFOL(fd,2)), *p_sd = map->charid2sd(sd->status.partner_id); if( pc->can_Adopt(sd, p_sd, tsd) ) { @@ -17263,6 +17580,9 @@ static void clif_parse_Adopt_reply(int fd, struct map_session_data *sd) __attrib /// 1 = accepted static void clif_parse_Adopt_reply(int fd, struct map_session_data *sd) { + if (pc_isdead(sd)) + return; + int p1_id = RFIFOL(fd,2); int p2_id = RFIFOL(fd,6); int result = RFIFOL(fd,10); @@ -17330,6 +17650,9 @@ static void clif_parse_ViewPlayerEquip(int fd, struct map_session_data *sd) __at /// 02d6 .L static void clif_parse_ViewPlayerEquip(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int charid = RFIFOL(fd, 2); struct map_session_data* tsd = map->id2sd(charid); @@ -17357,6 +17680,9 @@ static void clif_parse_cz_config(int fd, struct map_session_data *sd) __attribut /// 1 = enabled static void clif_parse_cz_config(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + enum CZ_CONFIG type = RFIFOL(fd, 2); int flag = RFIFOL(fd, 6); @@ -17672,6 +17998,9 @@ static void clif_parse_questStateAck(int fd, struct map_session_data *sd) __attr /// 02b6 .L .B static void clif_parse_questStateAck(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + quest->update_status(sd, RFIFOL(fd,2), RFIFOB(fd,6)?Q_ACTIVE:Q_INACTIVE); } @@ -17891,6 +18220,9 @@ static void clif_parse_mercenary_action(int fd, struct map_session_data *sd) __a /// 2 = delete static void clif_parse_mercenary_action(int fd, struct map_session_data *sd) { + if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) + return; + int option = RFIFOB(fd,2); if (sd->md == NULL) return; @@ -18359,6 +18691,9 @@ static void clif_parse_ItemListWindowSelected(int fd, struct map_session_data *s /// S 07e4 .w