summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2019-08-26 00:50:49 +0200
committerGitHub <noreply@github.com>2019-08-26 00:50:49 +0200
commit81e5138adab92c18c7b95f4ca55850be20dde462 (patch)
treea7c1908ddc8d213ceef453a835b9522ce97617a8 /src/map/clif.c
parent47f133c410d0004bf0cb05a4de5af2ee1944bcc3 (diff)
parent6629dfd05f4ebef7862cd2d499b7330acc8d82ac (diff)
downloadhercules-81e5138adab92c18c7b95f4ca55850be20dde462.tar.gz
hercules-81e5138adab92c18c7b95f4ca55850be20dde462.tar.bz2
hercules-81e5138adab92c18c7b95f4ca55850be20dde462.tar.xz
hercules-81e5138adab92c18c7b95f4ca55850be20dde462.zip
Merge pull request #2501 from 4144/fixes
Add some missing checks into clif.c
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c654
1 files changed, 566 insertions, 88 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 5522154d8..421274b0f 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -10985,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;
@@ -11012,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])
@@ -11172,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;
@@ -11377,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) {
@@ -11558,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;
}
@@ -11638,7 +11645,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);
@@ -11738,6 +11745,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;
@@ -11763,15 +11773,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 ) {
@@ -11782,15 +11794,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;
}
@@ -11798,7 +11810,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);
@@ -11811,6 +11823,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;
@@ -11883,7 +11898,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));
}
@@ -11919,9 +11934,12 @@ static void clif_parse_NpcBuyListSend(int fd, struct map_session_data *sd) __att
/// 00c8 <packet len>.W { <amount>.W <name id>.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);
@@ -11979,7 +11997,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 };
@@ -12014,6 +12032,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;
@@ -12030,6 +12051,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)) {
@@ -12056,6 +12080,9 @@ static void clif_parse_ChatAddMember(int fd, struct map_session_data *sd) __attr
/// 00d9 <chat ID>.L <passwd>.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
@@ -12070,6 +12097,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;
@@ -12082,6 +12112,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
@@ -12100,6 +12132,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
}
@@ -12108,6 +12143,9 @@ static void clif_parse_KickFromChat(int fd, struct map_session_data *sd) __attri
/// 00e2 <name>.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
}
@@ -12116,6 +12154,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);
}
@@ -12140,9 +12181,10 @@ static void clif_parse_TradeRequest(int fd, struct map_session_data *sd) __attri
/// 00e4 <account id>.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.
@@ -12169,6 +12211,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));
}
@@ -12177,6 +12222,9 @@ static void clif_parse_TradeAddItem(int fd, struct map_session_data *sd) __attri
/// 00e8 <index>.W <amount>.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);
@@ -12191,6 +12239,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);
}
@@ -12199,6 +12249,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);
}
@@ -12207,6 +12260,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);
}
@@ -12769,7 +12825,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);
@@ -12800,7 +12856,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);
@@ -12820,7 +12876,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);
@@ -12835,19 +12891,17 @@ static void clif_parse_WeaponRefine(int fd, struct map_session_data *sd) __attri
/// 0222 <index>.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);
}
@@ -12862,6 +12916,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);
@@ -12887,6 +12944,9 @@ static void clif_parse_NpcNextClicked(int fd, struct map_session_data *sd) __att
/// 00b9 <npc id>.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);
}
@@ -12895,6 +12955,9 @@ static void clif_parse_NpcAmountInput(int fd, struct map_session_data *sd) __att
/// 0143 <npc id>.L <value>.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);
@@ -12919,6 +12982,9 @@ static void clif_parse_NpcStringInput(int fd, struct map_session_data *sd) __att
/// 01d5 <packet len>.W <npc id>.L <string>.?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
@@ -12946,6 +13012,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);
}
@@ -12957,6 +13025,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)
@@ -12975,6 +13046,9 @@ static void clif_parse_ItemIdentify(int fd, struct map_session_data *sd)
/// 0A35 <index>.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;
@@ -12982,7 +13056,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);
}
@@ -12993,7 +13067,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);
@@ -13030,6 +13104,9 @@ static void clif_parse_AutoSpell(int fd, struct map_session_data *sd) __attribut
/// 01ce <skill id>.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;
@@ -13049,6 +13126,9 @@ static void clif_parse_UseCard(int fd, struct map_session_data *sd) __attribute_
/// 017a <card index>.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);
}
@@ -13057,6 +13137,9 @@ static void clif_parse_InsertCard(int fd, struct map_session_data *sd) __attribu
/// 017c <card index>.W <equip index>.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);
}
@@ -13082,6 +13165,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) )
@@ -13267,6 +13353,9 @@ static void clif_parse_CreateParty(int fd, struct map_session_data *sd) __attrib
/// 01e8 <party name>.24B <item pickup rule>.B <item share rule>.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);
@@ -13287,6 +13376,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);
@@ -13312,6 +13404,9 @@ static void clif_parse_PartyInvite(int fd, struct map_session_data *sd) __attrib
/// 02c4 <char name>.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) {
@@ -13333,6 +13428,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];
@@ -13363,13 +13461,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)));
@@ -13377,7 +13485,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;
@@ -13390,12 +13501,15 @@ static void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) __
/// 0103 <account id>.L <char name>.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)));
@@ -13404,6 +13518,9 @@ static void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) __
/// 07d7 <exp share rule>.L <item pickup rule>.B <item share rule>.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;
@@ -13456,6 +13573,9 @@ static void clif_parse_PartyChangeLeader(int fd, struct map_session_data *sd) __
/// 07da <account id>.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)));
}
@@ -13468,6 +13588,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];
@@ -13510,6 +13633,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);
@@ -13561,7 +13687,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;
@@ -13597,11 +13726,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; i<PARTY_BOOKING_JOBS; i++)
- job[i] = RFIFOW(fd,2+i*2);
+ for (int i = 0; i < PARTY_BOOKING_JOBS; i++)
+ job[i] = RFIFOW(fd, 2 + i * 2);
party->booking_update(sd, job);
#else
@@ -13614,8 +13745,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;
@@ -13682,7 +13816,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);
@@ -13753,6 +13890,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);
@@ -13770,7 +13910,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;
@@ -13806,6 +13949,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);
@@ -13879,6 +14025,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);
@@ -13893,6 +14042,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);
@@ -13907,6 +14059,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);
@@ -13983,6 +14138,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);
@@ -14012,6 +14170,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);
@@ -14087,6 +14248,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);
}
@@ -14095,6 +14259,9 @@ static void clif_parse_VendingListReq(int fd, struct map_session_data *sd) __att
/// 0130 <account id>.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;
}
@@ -14106,6 +14273,9 @@ static void clif_parse_PurchaseReq(int fd, struct map_session_data *sd) __attrib
/// 0134 <packet len>.W <account id>.L { <amount>.W <index>.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;
@@ -14127,6 +14297,9 @@ static void clif_parse_PurchaseReq2(int fd, struct map_session_data *sd) __attri
/// 0801 <packet len>.W <account id>.L <unique id>.L { <amount>.W <index>.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;
@@ -14153,25 +14326,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)) {
@@ -14190,11 +14363,14 @@ static void clif_parse_CreateGuild(int fd, struct map_session_data *sd) __attrib
/// 0165 <char id>.L <guild name>.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;
}
@@ -14255,6 +14431,9 @@ static void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *
/// 0161 <packet len>.W { <position id>.L <mode>.L <ranking>.L <pay rate>.L <name>.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;
@@ -14272,6 +14451,9 @@ static void clif_parse_GuildChangeMemberPosition(int fd, struct map_session_data
/// 0155 <packet len>.W { <account id>.L <char id>.L <position id>.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;
@@ -14437,10 +14619,13 @@ static void clif_parse_GuildChangeEmblem(int fd, struct map_session_data *sd) __
/// 0153 <packet len>.W <emblem data>.?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)) {
@@ -14457,7 +14642,10 @@ static void clif_parse_GuildChangeNotice(int fd, struct map_session_data *sd) __
/// 016e <guild id>.L <msg1>.60B <msg2>.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)
@@ -14509,6 +14697,9 @@ static void clif_parse_GuildInvite(int fd, struct map_session_data *sd) __attrib
/// 0168 <account id>.L <inviter account id>.L <inviter char id>.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))
@@ -14537,7 +14728,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)));
@@ -14545,16 +14736,19 @@ static void clif_parse_GuildLeave(int fd, struct map_session_data *sd) __attribu
/// 0159 <guild id>.L <account id>.L <char id>.L <reason>.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)));
@@ -14562,11 +14756,14 @@ static void clif_parse_GuildExpulsion(int fd, struct map_session_data *sd) __att
/// 015b <guild id>.L <account id>.L <char id>.L <reason>.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));
}
/**
@@ -14599,6 +14796,9 @@ static void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd)
/// 0170 <account id>.L <inviter account id>.L <inviter char id>.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)
@@ -14639,6 +14839,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;
@@ -14654,6 +14857,9 @@ static void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) __at
/// 0180 <account id>.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)
@@ -14683,6 +14889,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.
@@ -14706,7 +14915,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)));
@@ -14714,7 +14926,10 @@ static void clif_parse_CatchPet(int fd, struct map_session_data *sd) __attribute
/// 019f <id>.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)));
@@ -14722,10 +14937,13 @@ static void clif_parse_SelectEgg(int fd, struct map_session_data *sd) __attribut
/// 01a7 <index>.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);
}
@@ -14765,6 +14983,9 @@ static void clif_parse_ChangePetName(int fd, struct map_session_data *sd) __attr
/// 01a5 <name>.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));
}
@@ -14773,6 +14994,9 @@ static void clif_parse_pet_evolution(int fd, struct map_session_data *sd) __attr
/// 09fb <Length>.W <EvolvedPetEggID>.W {<index>.W <amount>.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;
@@ -14961,7 +15185,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);
@@ -14980,7 +15204,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);
}
@@ -15017,7 +15241,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);
}
@@ -15348,6 +15572,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) {
@@ -15374,6 +15601,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) */
@@ -15517,6 +15747,9 @@ static void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) __att
/// 0202 <name>.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];
@@ -15638,6 +15871,9 @@ static void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd) __
/// 0203 <account id>.L <char id>.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;
@@ -16012,6 +16248,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;
@@ -16053,6 +16292,9 @@ static void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd)
/// 0231 <name>.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));
}
@@ -16061,6 +16303,9 @@ static void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd) __at
/// 0234 <id>.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;
@@ -16082,6 +16327,9 @@ static void clif_parse_HomMoveTo(int fd, struct map_session_data *sd) __attribut
/// 0232 <id>.L <position data>.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;
@@ -16105,6 +16353,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),
@@ -16131,6 +16382,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);
@@ -16146,6 +16400,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;
@@ -16167,7 +16426,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).
@@ -16217,6 +16476,9 @@ static void clif_parse_Check(int fd, struct map_session_data *sd) __attribute__(
/// 0213 <char name>.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;
@@ -16379,6 +16641,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) )
@@ -16462,6 +16727,9 @@ static void clif_parse_Mail_read(int fd, struct map_session_data *sd) __attribut
/// 0241 <mail id>.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 )
@@ -16477,6 +16745,9 @@ static void clif_parse_Mail_getattach(int fd, struct map_session_data *sd) __att
/// 0244 <mail id>.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;
@@ -16545,6 +16816,9 @@ static void clif_parse_Mail_delete(int fd, struct map_session_data *sd) __attrib
/// 0243 <mail id>.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;
@@ -16576,6 +16850,9 @@ static void clif_parse_Mail_return(int fd, struct map_session_data *sd) __attrib
/// 0273 <mail id>.L <receive name>.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;
@@ -16600,6 +16877,9 @@ static void clif_parse_Mail_setattach(int fd, struct map_session_data *sd) __att
/// 0247 <index>.W <amount>.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;
@@ -16622,6 +16902,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)
@@ -16636,6 +16919,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);
@@ -16792,7 +17078,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;
@@ -16803,8 +17092,11 @@ static void clif_parse_Auction_setitem(int fd, struct map_session_data *sd) __at
/// 024c <index>.W <count>.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 )
@@ -16882,6 +17174,9 @@ static void clif_parse_Auction_register(int fd, struct map_session_data *sd) __a
/// 024d <now money>.L <max money>.L <delete hour>.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;
@@ -16977,7 +17272,10 @@ static void clif_parse_Auction_cancel(int fd, struct map_session_data *sd) __att
/// 024e <auction id>.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);
}
@@ -16987,6 +17285,9 @@ static void clif_parse_Auction_close(int fd, struct map_session_data *sd) __attr
/// 025d <auction id>.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);
@@ -16997,8 +17298,11 @@ static void clif_parse_Auction_bid(int fd, struct map_session_data *sd) __attrib
/// 024f <auction id>.L <money>.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.
@@ -17029,9 +17333,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;
@@ -17050,7 +17357,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;
@@ -17160,6 +17470,9 @@ static void clif_parse_cashshop_buy(int fd, struct map_session_data *sd) __attri
/// 0288 <packet len>.W <kafra points>.L <count>.W { <amount>.W <name id>.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);
@@ -17252,6 +17565,9 @@ static void clif_parse_Adopt_request(int fd, struct map_session_data *sd) __attr
/// 01f9 <account id>.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) ) {
@@ -17268,6 +17584,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);
@@ -17335,6 +17654,9 @@ static void clif_parse_ViewPlayerEquip(int fd, struct map_session_data *sd) __at
/// 02d6 <account id>.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);
@@ -17362,6 +17684,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);
@@ -17677,6 +18002,9 @@ static void clif_parse_questStateAck(int fd, struct map_session_data *sd) __attr
/// 02b6 <quest id>.L <active>.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);
}
@@ -17896,6 +18224,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;
@@ -18364,6 +18695,9 @@ static void clif_parse_ItemListWindowSelected(int fd, struct map_session_data *s
/// S 07e4 <length>.w <option>.l <val>.l {<index>.w <amount>.w).4b*
static void clif_parse_ItemListWindowSelected(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
int n = ((int)RFIFOW(fd, 2) - 12) / 4;
int type = RFIFOL(fd,4);
int flag = RFIFOL(fd,8); // Button clicked: 0 = Cancel, 1 = OK
@@ -18493,6 +18827,9 @@ static void clif_parse_ReqOpenBuyingStore(int fd, struct map_session_data *sd) _
/// 1 = open
static void clif_parse_ReqOpenBuyingStore(int fd, struct map_session_data *sd)
{
+ if (pc_istrading(sd) || pc_isdead(sd))
+ return;
+
const unsigned int blocksize = sizeof(struct PACKET_CZ_REQ_OPEN_BUYING_STORE_sub);
const struct PACKET_CZ_REQ_OPEN_BUYING_STORE_sub *itemlist;
char storename[MESSAGE_SIZE];
@@ -18656,6 +18993,9 @@ static void clif_buyingstore_disappear_entry_single(struct map_session_data *sd,
/// 0817 <account id>.L
static void clif_parse_ReqClickBuyingStore(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
int account_id;
account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
@@ -18700,6 +19040,9 @@ static void clif_parse_ReqTradeBuyingStore(int fd, struct map_session_data *sd)
/// 0819 <packet len>.W <account id>.L <store id>.L { <index>.W <name id>.W <amount>.W }*
static void clif_parse_ReqTradeBuyingStore(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const unsigned int blocksize = sizeof(struct PACKET_CZ_REQ_TRADE_BUYING_STORE_sub);
const struct PACKET_CZ_REQ_TRADE_BUYING_STORE_sub *itemlist;
int account_id;
@@ -18838,6 +19181,9 @@ static void clif_parse_SearchStoreInfo(int fd, struct map_session_data *sd) __at
/// cannot be searched.
static void clif_parse_SearchStoreInfo(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const unsigned int blocksize = sizeof(struct PACKET_CZ_SEARCH_STORE_INFO_item);
const struct PACKET_CZ_SEARCH_STORE_INFO_item* itemlist;
const struct PACKET_CZ_SEARCH_STORE_INFO_item* cardlist;
@@ -18986,6 +19332,9 @@ static void clif_parse_SearchStoreInfoNextPage(int fd, struct map_session_data *
/// 0838
static void clif_parse_SearchStoreInfoNextPage(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
searchstore->next(sd);
}
@@ -19024,6 +19373,9 @@ static void clif_parse_SearchStoreInfoListItemClick(int fd, struct map_session_d
/// 083c <account id>.L <store id>.L <nameid>.W
static void clif_parse_SearchStoreInfoListItemClick(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_SSILIST_ITEM_CLICK *p = RFIFOP(fd, 0);
searchstore->click(sd, p->AID, p->storeId, p->itemId);
}
@@ -19307,8 +19659,10 @@ static void clif_parse_SkillSelectMenu(int fd, struct map_session_data *sd) __at
*------------------------------------------*/
static void clif_parse_SkillSelectMenu(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
- if( sd->menuskill_id != SC_AUTOSHADOWSPELL )
+ if (sd->menuskill_id != SC_AUTOSHADOWSPELL)
return;
if (pc_istrading(sd) || sd->state.prevend) {
@@ -19354,9 +19708,8 @@ static void clif_parse_MoveItem(int fd, struct map_session_data *sd)
int index;
/* can't move while dead. */
- if(pc_isdead(sd)) {
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
return;
- }
index = RFIFOW(fd,2)-2;
@@ -19507,6 +19860,8 @@ static void clif_parse_dull(int fd, struct map_session_data *sd)
static void clif_parse_CashShopOpen(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
static void clif_parse_CashShopOpen(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
if (map->list[sd->bl.m].flag.nocashshop) {
clif->messagecolor_self(fd, COLOR_RED, msg_fd(fd,1489)); //Cash Shop is disabled in this map
@@ -19529,6 +19884,9 @@ static void clif_parse_CashShopClose(int fd, struct map_session_data *sd)
static void clif_parse_CashShopSchedule(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
static void clif_parse_CashShopSchedule(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
clif->cashShopSchedule(fd, sd);
}
@@ -19566,6 +19924,9 @@ void clif_cashShopSchedule(int fd, struct map_session_data *sd)
static void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
static void clif_parse_CashShopBuy(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
int len = RFIFOW(fd, 2);
unsigned short limit, i, j;
unsigned int kafra_pay;
@@ -19686,6 +20047,9 @@ static void clif_parse_CashShopReqTab(int fd, struct map_session_data *sd)
{
// [4144] packet exists only in 2011 and was dropped after
#if PACKETVER >= 20110222 && PACKETVER < 20120000
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
short tab = RFIFOW(fd, 2);
int j;
@@ -19840,6 +20204,9 @@ static void clif_bgqueue_notice_delete(struct map_session_data *sd, enum BATTLEG
static void clif_parse_bgqueue_register(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
static void clif_parse_bgqueue_register(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct packet_bgqueue_register *p = RP2PTR(fd);
struct bg_arena *arena = NULL;
if( !bg->queue_on ) return; /* temp, until feature is complete */
@@ -19880,6 +20247,9 @@ static void clif_bgqueue_update_info(struct map_session_data *sd, unsigned char
static void clif_parse_bgqueue_checkstate(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
static void clif_parse_bgqueue_checkstate(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct packet_bgqueue_checkstate *p = RP2PTR(fd);
if (sd->bg_queue.arena && sd->bg_queue.type) {
@@ -19892,6 +20262,9 @@ static void clif_parse_bgqueue_checkstate(int fd, struct map_session_data *sd)
static void clif_parse_bgqueue_revoke_req(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
static void clif_parse_bgqueue_revoke_req(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct packet_bgqueue_revoke_req *p = RP2PTR(fd);
if( sd->bg_queue.arena )
@@ -19903,6 +20276,9 @@ static void clif_parse_bgqueue_revoke_req(int fd, struct map_session_data *sd)
static void clif_parse_bgqueue_battlebegin_ack(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
static void clif_parse_bgqueue_battlebegin_ack(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct packet_bgqueue_battlebegin_ack *p = RP2PTR(fd);
struct bg_arena *arena;
@@ -20063,6 +20439,9 @@ static void clif_cart_additem_ack(struct map_session_data *sd, int flag)
static void clif_parse_BankDeposit(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
static void clif_parse_BankDeposit(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct packet_banking_deposit_req *p = RP2PTR(fd);
int money;
@@ -20079,6 +20458,9 @@ static void clif_parse_BankDeposit(int fd, struct map_session_data *sd)
static void clif_parse_BankWithdraw(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
static void clif_parse_BankWithdraw(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct packet_banking_withdraw_req *p = RP2PTR(fd);
int money;
@@ -20096,6 +20478,9 @@ static void clif_parse_BankCheck(int fd, struct map_session_data *sd) __attribut
static void clif_parse_BankCheck(int fd, struct map_session_data *sd)
{
#if PACKETVER >= 20130320
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
struct packet_banking_check p;
p.PacketType = banking_checkType;
@@ -20383,6 +20768,9 @@ static void clif_parse_NPCMarketPurchase(int fd, struct map_session_data *sd) __
static void clif_parse_NPCMarketPurchase(int fd, struct map_session_data *sd)
{
#if PACKETVER >= 20131223
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct packet_npc_market_purchase *p = RP2PTR(fd);
int count = (p->PacketLength - 4) / sizeof p->list[0];
struct itemlist item_list;
@@ -20426,6 +20814,9 @@ static void clif_parse_RouletteOpen(int fd, struct map_session_data *sd) __attri
static void clif_parse_RouletteOpen(int fd, struct map_session_data *sd)
{
#if PACKETVER >= 20140612
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
struct packet_roulette_open_ack p;
if( !battle_config.feature_roulette ) {
@@ -20451,6 +20842,9 @@ static void clif_parse_RouletteInfo(int fd, struct map_session_data *sd) __attri
static void clif_parse_RouletteInfo(int fd, struct map_session_data *sd)
{
#if PACKETVER >= 20140612
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
struct packet_roulette_info_ack p;
unsigned short i, j, count = 0;
@@ -20496,6 +20890,9 @@ static void clif_parse_RouletteClose(int fd, struct map_session_data *sd)
static void clif_parse_RouletteGenerate(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));
static void clif_parse_RouletteGenerate(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
unsigned char result = GENERATE_ROULETTE_SUCCESS;
short stage = sd->roulette.stage;
@@ -20555,6 +20952,8 @@ static void clif_parse_RouletteRecvItem(int fd, struct map_session_data *sd) __a
static void clif_parse_RouletteRecvItem(int fd, struct map_session_data *sd)
{
#if PACKETVER >= 20140612
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
struct packet_roulette_itemrecv_ack p;
if( !battle_config.feature_roulette ) {
@@ -21292,6 +21691,9 @@ static void clif_achievement_send_update(int fd, struct map_session_data *sd, co
static void clif_parse_achievement_get_reward(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_achievement_get_reward(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
int ach_id = RFIFOL(fd, 2);
const struct achievement_data *ad = NULL;
struct achievement *ach = NULL;
@@ -21334,6 +21736,9 @@ static void clif_achievement_reward_ack(int fd, struct map_session_data *sd, con
static void clif_parse_change_title(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_change_title(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
int title_id = RFIFOL(fd, 2);
if (title_id == sd->status.title_id) { // Same Title
@@ -21381,6 +21786,9 @@ static void clif_change_title_ack(int fd, struct map_session_data *sd, int title
static void clif_parse_rodex_open_write_mail(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_rodex_open_write_mail(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_REQ_OPEN_WRITE_MAIL *rPacket = RFIFOP(fd, 0);
int8 result = (rodex->isenabled() == true && sd->npc_id == 0) ? 1 : 0;
@@ -21406,6 +21814,9 @@ static void clif_rodex_open_write_mail(int fd, const char *receiver_name, int8 r
static void clif_parse_rodex_add_item(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_rodex_add_item(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_ADD_ITEM_TO_MAIL *rPacket = RFIFOP(fd, 0);
int16 idx = rPacket->index - 2;
@@ -21459,6 +21870,9 @@ static void clif_rodex_add_item_result(struct map_session_data *sd, int16 idx, i
static void clif_parse_rodex_remove_item(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_rodex_remove_item(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_REQ_REMOVE_ITEM_MAIL *rPacket = RFIFOP(fd, 0);
int16 idx = rPacket->index - 2;
@@ -21531,6 +21945,9 @@ static void clif_rodex_checkname_result(struct map_session_data *sd, int char_id
static void clif_parse_rodex_send_mail(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_rodex_send_mail(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_SEND_MAIL *rPacket = RFIFOP(fd, 0);
int8 result;
@@ -21761,6 +22178,9 @@ static void clif_rodex_send_refresh(int fd, struct map_session_data *sd, int8 op
static void clif_parse_rodex_next_maillist(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_rodex_next_maillist(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_REQ_NEXT_MAIL_LIST *packet = RFIFOP(fd, 0);
rodex->next_page(sd, packet->opentype, packet->Lower_MailID);
@@ -21769,6 +22189,9 @@ static void clif_parse_rodex_next_maillist(int fd, struct map_session_data *sd)
static void clif_parse_rodex_read_mail(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_rodex_read_mail(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_REQ_READ_MAIL *rPacket = RFIFOP(fd, 0);
rodex->read_mail(sd, rPacket->MailID);
@@ -21838,6 +22261,9 @@ static void clif_rodex_read_mail(struct map_session_data *sd, int8 opentype, str
static void clif_parse_rodex_delete_mail(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_rodex_delete_mail(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_REQ_DELETE_MAIL *rPacket = RFIFOP(fd, 0);
rodex->delete_mail(sd, rPacket->MailID);
@@ -21865,6 +22291,9 @@ static void clif_rodex_delete_mail(struct map_session_data *sd, int8 opentype, i
static void clif_parse_rodex_request_zeny(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_rodex_request_zeny(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_REQ_ZENY_FROM_MAIL *rPacket = RFIFOP(fd, 0);
rodex->get_zeny(sd, rPacket->opentype, rPacket->MailID);
@@ -21893,6 +22322,9 @@ static void clif_rodex_request_zeny(struct map_session_data *sd, int8 opentype,
static void clif_parse_rodex_request_items(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_rodex_request_items(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_REQ_ITEM_FROM_MAIL *rPacket = RFIFOP(fd, 0);
rodex->get_items(sd, rPacket->opentype, rPacket->MailID);
@@ -21932,6 +22364,9 @@ static void clif_rodex_icon(int fd, bool show)
static void clif_parse_rodex_refresh_maillist(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_rodex_refresh_maillist(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_REQ_REFRESH_MAIL_LIST *packet = RFIFOP(fd, 0);
#if PACKETVER >= 20170419
rodex->refresh(sd, RODEX_OPENTYPE_UNSET, packet->Upper_MailID);
@@ -21943,6 +22378,9 @@ static void clif_parse_rodex_refresh_maillist(int fd, struct map_session_data *s
static void clif_parse_rodex_open_mailbox(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_rodex_open_mailbox(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_REQ_OPEN_MAIL *packet = RFIFOP(fd, 0);
#if PACKETVER >= 20170419
rodex->open(sd, RODEX_OPENTYPE_UNSET, packet->char_Upper_MailID);
@@ -21955,6 +22393,9 @@ static void clif_parse_rodex_open_mailbox(int fd, struct map_session_data *sd)
static void clif_parse_rodex_close_mailbox(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_rodex_close_mailbox(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
rodex->clean(sd, 0);
intif->rodex_checkhasnew(sd);
}
@@ -21962,6 +22403,9 @@ static void clif_parse_rodex_close_mailbox(int fd, struct map_session_data *sd)
static void clif_parse_rodex_cancel_write_mail(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_rodex_cancel_write_mail(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
rodex->clean(sd, 1);
}
@@ -22120,8 +22564,10 @@ static time_t clif_attendance_getendtime(void)
static void clif_parse_open_ui_request(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_open_ui_request(int fd, struct map_session_data *sd)
{
- const struct PACKET_CZ_OPEN_UI *p = RP2PTR(fd);
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+ const struct PACKET_CZ_OPEN_UI *p = RP2PTR(fd);
clif->open_ui(sd, p->UIType);
}
@@ -22192,6 +22638,8 @@ static void clif_parse_attendance_reward_request(int fd, struct map_session_data
static void clif_parse_attendance_reward_request(int fd, struct map_session_data *sd)
{
#if PACKETVER_RE_NUM >= 20180307 || PACKETVER_MAIN_NUM >= 20180404 || PACKETVER_ZERO_NUM >= 20180411
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
struct rodex_message msg = { 0 };
struct attendance_entry *entry;
@@ -22273,6 +22721,9 @@ static void clif_parse_private_airship_request(int fd, struct map_session_data *
static void clif_parse_private_airship_request(int fd, struct map_session_data *sd)
{
#if PACKETVER_RE_NUM >= 20180321 || PACKETVER_MAIN_NUM >= 20180620 || defined(PACKETVER_ZERO)
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
char evname[EVENT_NAME_LENGTH];
struct event_data *ev = NULL;
const struct PACKET_CZ_PRIVATE_AIRSHIP_REQUEST *p = RP2PTR(fd);
@@ -22314,6 +22765,9 @@ static void clif_private_airship_response(struct map_session_data *sd, uint32 fl
static void clif_parse_cz_req_style_change(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_cz_req_style_change(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_REQ_STYLE_CHANGE *p = RP2PTR(fd);
if (p->HeadStyle > 0)
@@ -22335,6 +22789,9 @@ static void clif_parse_cz_req_style_change(int fd, struct map_session_data *sd)
static void clif_parse_cz_req_style_change2(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_cz_req_style_change2(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_REQ_STYLE_CHANGE2 *p = RP2PTR(fd);
if (p->HeadStyle > 0)
@@ -22397,6 +22854,9 @@ static void clif_parse_changeDress(int fd, struct map_session_data *sd) __attrib
/// 0ae8 <packet len>.W
static void clif_parse_changeDress(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const char commandname[] = "changedress";
char command[sizeof commandname + 3] = ""; // '@' command + ' ' + NUL
@@ -22421,6 +22881,9 @@ static void clif_party_dead_notification(struct map_session_data *sd)
static void clif_parse_memorial_dungeon_command(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
static void clif_parse_memorial_dungeon_command(int fd, struct map_session_data *sd)
{
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_MEMORIALDUNGEON_COMMAND *p = RP2PTR(fd);
switch (p->command) {
@@ -22461,6 +22924,9 @@ static void clif_parse_cameraInfo(int fd, struct map_session_data *sd) __attribu
static void clif_parse_cameraInfo(int fd, struct map_session_data *sd)
{
#if PACKETVER >= 20160525
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_CAMERA_INFO *const p = RFIFOP(fd, 0);
char command[100];
if (p->action == 1) {
@@ -22549,6 +23015,9 @@ static void clif_parse_NPCBarterPurchase(int fd, struct map_session_data *sd) __
static void clif_parse_NPCBarterPurchase(int fd, struct map_session_data *sd)
{
#if PACKETVER_MAIN_NUM >= 20190116 || PACKETVER_RE_NUM >= 20190116 || PACKETVER_ZERO_NUM >= 20181226
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
const struct PACKET_CZ_NPC_BARTER_PURCHASE *p = RP2PTR(fd);
int count = (p->packetLength - sizeof(struct PACKET_CZ_NPC_BARTER_PURCHASE)) / sizeof p->list[0];
struct barteritemlist item_list;
@@ -22652,6 +23121,9 @@ static void clif_parse_AddItemRefineryUI(int fd, struct map_session_data *sd) __
static void clif_parse_AddItemRefineryUI(int fd, struct map_session_data *sd)
{
#if PACKETVER_MAIN_NUM >= 20161005 || PACKETVER_RE_NUM >= 20161005 || defined(PACKETVER_ZERO)
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
if (battle_config.enable_refinery_ui == 0)
return;
@@ -22693,6 +23165,9 @@ static void clif_parse_RefineryUIRefine(int fd, struct map_session_data *sd) __a
static void clif_parse_RefineryUIRefine(int fd, struct map_session_data *sd)
{
#if PACKETVER_MAIN_NUM >= 20161005 || PACKETVER_RE_NUM >= 20161005 || defined(PACKETVER_ZERO)
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
if (battle_config.enable_refinery_ui == 0)
return;
@@ -22705,6 +23180,9 @@ static void clif_parse_RefineryUIClose(int fd, struct map_session_data *sd) __at
static void clif_parse_RefineryUIClose(int fd, struct map_session_data *sd)
{
#if PACKETVER_MAIN_NUM >= 20161130 || PACKETVER_RE_NUM >= 20161109 || defined(PACKETVER_ZERO)
+ if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd))
+ return;
+
if (battle_config.enable_refinery_ui == 0)
return;