From 870fa2b6005efb046e12888eb2062a3ec611fe5a Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 07:34:49 +0200 Subject: Add state using_megaphone to struct map_session_data and implement its (un)setting --- src/map/itemdb.h | 1 + src/map/pc.c | 3 +++ src/map/pc.h | 1 + src/map/script.c | 2 ++ 4 files changed, 7 insertions(+) diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 4b06a21d6..39f0e7945 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -152,6 +152,7 @@ enum item_itemid { ITEMID_BUBBLE_GUM = 12210, ITEMID_GIANT_FLY_WING = 12212, ITEMID_NEURALIZER = 12213, + ITEMID_MEGAPHONE = 12221, ITEMID_M_CENTER_POTION = 12241, ITEMID_M_AWAKENING_POTION = 12242, ITEMID_M_BERSERK_POTION = 12243, diff --git a/src/map/pc.c b/src/map/pc.c index c1261c839..4c3f56280 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5320,6 +5320,9 @@ static int pc_useitem(struct map_session_data *sd, int n) // Update item use time. sd->canuseitem_tick = tick + battle_config.item_use_interval; + if (nameid == ITEMID_MEGAPHONE) + sd->state.using_megaphone = 1; + script->run_use_script(sd, sd->inventory_data[n], npc->fake_nd->bl.id); script->potion_flag = 0; diff --git a/src/map/pc.h b/src/map/pc.h index f2e911af3..074c01a13 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -224,6 +224,7 @@ struct map_session_data { unsigned int size :2; // for tiny/large types unsigned int night :1; //Holds whether or not the player currently has the SI_NIGHT effect on. [Skotlex] unsigned int using_fake_npc :1; + unsigned int using_megaphone : 1; //!< Whether the character is currently using a Megephone (ID=12221). unsigned int rewarp :1; //Signals that a player should warp as soon as he is done loading a map. [Skotlex] unsigned int killer : 1; unsigned int killable : 1; diff --git a/src/map/script.c b/src/map/script.c index 743a1779a..b79ac1603 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -12574,6 +12574,8 @@ static BUILDIN(loudhailer) clif->broadcast(&sd->bl, mes_formatted, (int)len_formatted, BC_MEGAPHONE, ALL_CLIENT); + sd->state.using_megaphone = 0; + return true; } -- cgit v1.2.3-70-g09d2 From 60332ab78298fd4408968deb34b0ce072385b91b Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 07:35:59 +0200 Subject: Don't show NPC speech bubble when opening input box by Megaphone --- src/map/clif.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index 649df3e33..b5c586db1 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2431,23 +2431,26 @@ static void clif_scriptinput(struct map_session_data *sd, int npcid) /// - close inputstr window static void clif_scriptinputstr(struct map_session_data *sd, int npcid) { - int fd; - struct block_list *bl = NULL; - nullpo_retv(sd); - if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = map->id2bl(npcid)) != NULL && (bl->m!=sd->bl.m || - bl->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || - bl->ybl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) + struct block_list *bl = map->id2bl(npcid); + int x1 = sd->bl.x - AREA_SIZE - 1; + int x2 = sd->bl.x + AREA_SIZE + 1; + int y1 = sd->bl.y - AREA_SIZE - 1; + int y2 = sd->bl.y + AREA_SIZE + 1; + bool out_of_sight = (bl != NULL && (bl->m != sd->bl.m || bl->x < x1 || bl->x > x2 || bl->y < y1 || bl->y > y2)); + + if (sd->state.using_fake_npc == 0 && sd->state.using_megaphone == 0 + && (npcid == npc->fake_nd->bl.id || out_of_sight)) { clif->sendfakenpc(sd, npcid); + } pc->update_idle_time(sd, BCIDLE_SCRIPT); - fd=sd->fd; - WFIFOHEAD(fd, packet_len(0x1d4)); - WFIFOW(fd,0)=0x1d4; - WFIFOL(fd,2)=npcid; - WFIFOSET(fd,packet_len(0x1d4)); + WFIFOHEAD(sd->fd, packet_len(0x1d4)); + WFIFOW(sd->fd, 0) = 0x1d4; + WFIFOL(sd->fd, 2) = (sd->state.using_megaphone == 0) ? npcid : 0; + WFIFOSET(sd->fd, packet_len(0x1d4)); } /// Marks a position on client's minimap (ZC_COMPASS). @@ -13334,7 +13337,7 @@ static void clif_parse_NpcStringInput(int fd, struct map_session_data *sd) if (len < 9) return; - npcid = RFIFOL(fd, 4); + npcid = (sd->state.using_megaphone == 0) ? RFIFOL(fd, 4) : sd->npc_id; message = RFIFOP(fd, 8); safestrncpy(sd->npc_str, message, min(message_len,CHATBOX_SIZE)); -- cgit v1.2.3-70-g09d2 From 43526bed2d926f1941504abd63e579e560c774f2 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 07:36:52 +0200 Subject: Add pc_istrading_except_npc() macro --- src/map/pc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/map/pc.h b/src/map/pc.h index 074c01a13..a6eeb5209 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -682,6 +682,7 @@ END_ZEROED_BLOCK; #define pc_issit(sd) ( (sd)->vd.dead_sit == 2 ) #define pc_isidle(sd) ( (sd)->chat_id != 0 || (sd)->state.vending || (sd)->state.buyingstore || DIFF_TICK(sockt->last_tick, (sd)->idletime) >= battle->bc->idle_no_share ) #define pc_istrading(sd) ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->state.trading ) +#define pc_istrading_except_npc(sd) ( (sd)->state.vending != 0 || (sd)->state.buyingstore != 0 || (sd)->state.trading != 0 ) #define pc_cant_act(sd) ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->chat_id != 0 || ((sd)->sc.opt1 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading || (sd)->state.storage_flag || (sd)->state.prevend || (sd)->state.refine_ui == 1 || (sd)->state.lapine_ui == 1) #define pc_cant_act_except_lapine(sd) ((sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->chat_id != 0 || ((sd)->sc.opt1 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading || (sd)->state.storage_flag || (sd)->state.prevend || (sd)->state.refine_ui == 1) #define pc_cant_act_except_npc(sd) ( (sd)->state.vending != 0 || (sd)->state.buyingstore != 0 || (sd)->chat_id != 0 || ((sd)->sc.opt1 != 0 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading != 0 || (sd)->state.storage_flag != 0 || (sd)->state.prevend != 0 || (sd)->state.refine_ui == 1 || (sd)->state.lapine_ui == 1) -- cgit v1.2.3-70-g09d2 From b36f4acb4ff6d5f2f701cdec83c96420959b27a0 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 07:40:57 +0200 Subject: Enable skill usage while Megaphone input box is present --- src/map/clif.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index b5c586db1..351637967 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12632,7 +12632,7 @@ static void clif_parse_ChangeCart(int fd, struct map_session_data *sd) if (pc->checkskill(sd, MC_CHANGECART) == 0) return; - if (sd->npc_id || sd->state.workinprogress & 1) { + if ((sd->npc_id != 0 && sd->state.using_megaphone == 0) || (sd->state.workinprogress & 1) != 0) { #if PACKETVER >= 20110308 clif->msgtable(sd, MSG_BUSY); #else @@ -12852,7 +12852,7 @@ static void clif_useSkillToIdReal(int fd, struct map_session_data *sd, int skill bool allow_self_skill = ((tmp & INF_SELF_SKILL) != 0 && (skill->get_nk(skill_id) & NK_NO_DAMAGE) != 0); allow_self_skill = (allow_self_skill && battle_config.skill_enabled_npc == SKILLENABLEDNPC_SELF); - if ((sd->npc_id != 0 && !allow_self_skill && battle_config.skill_enabled_npc != SKILLENABLEDNPC_ALL) + if ((sd->npc_id != 0 && sd->state.using_megaphone == 0 && !allow_self_skill && battle_config.skill_enabled_npc != SKILLENABLEDNPC_ALL) || (sd->state.workinprogress & 1) != 0) { #if PACKETVER >= 20110308 clif->msgtable(sd, MSG_BUSY); @@ -12999,7 +12999,7 @@ static void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uin return; } - if ((sd->npc_id != 0 && battle_config.skill_enabled_npc != SKILLENABLEDNPC_ALL) + if ((sd->npc_id != 0 && sd->state.using_megaphone == 0 && battle_config.skill_enabled_npc != SKILLENABLEDNPC_ALL) || (sd->state.workinprogress & 1) != 0) { #if PACKETVER >= 20110308 clif->msgtable(sd, MSG_BUSY); @@ -13121,7 +13121,7 @@ static void clif_parse_UseSkillMap(int fd, struct map_session_data *sd) // It is possible to use teleport with the storage window open issue:8027 if ((pc_cant_act_except_npc(sd) && sd->state.storage_flag == STORAGE_FLAG_CLOSED && skill_id != AL_TELEPORT) - || (sd->npc_id != 0 && battle_config.skill_enabled_npc != SKILLENABLEDNPC_ALL)) { + || (sd->npc_id != 0 && sd->state.using_megaphone == 0 && battle_config.skill_enabled_npc != SKILLENABLEDNPC_ALL)) { clif_menuskill_clear(sd); return; } @@ -13164,7 +13164,8 @@ static void clif_parse_ProduceMix(int fd, struct map_session_data *sd) default: return; } - if (pc_istrading(sd) || pc_isdead(sd) || pc_isvending(sd)) { + if (pc_istrading_except_npc(sd) || pc_isdead(sd) || pc_isvending(sd) + || (sd->npc_id != 0 && sd->state.using_megaphone == 0)) { //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); @@ -13195,7 +13196,8 @@ 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) || pc_isdead(sd) || pc_isvending(sd)) { + if (pc_istrading_except_npc(sd) || pc_isdead(sd) || pc_isvending(sd) + || (sd->npc_id != 0 && sd->state.using_megaphone == 0)) { //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); @@ -13215,7 +13217,8 @@ static void clif_parse_RepairItem(int fd, struct map_session_data *sd) if (sd->menuskill_id != BS_REPAIRWEAPON) return; - if (pc_istrading(sd) || pc_isdead(sd) || pc_isvending(sd)) { + if (pc_istrading_except_npc(sd) || pc_isdead(sd) || pc_isvending(sd) + || (sd->npc_id != 0 && sd->state.using_megaphone == 0)) { //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); @@ -13234,7 +13237,8 @@ static void clif_parse_WeaponRefine(int fd, struct map_session_data *sd) if (sd->menuskill_id != WS_WEAPONREFINE) //Packet exploit? return; - if (pc_istrading(sd) || pc_isdead(sd) || pc_isvending(sd)) { + if (pc_istrading_except_npc(sd) || pc_isdead(sd) || pc_isvending(sd) + || (sd->npc_id != 0 && sd->state.using_megaphone == 0)) { //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); @@ -13406,7 +13410,8 @@ 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) || pc_isdead(sd) || pc_isvending(sd)) { + if (pc_istrading_except_npc(sd) || pc_isdead(sd) || pc_isvending(sd) + || (sd->npc_id != 0 && sd->state.using_megaphone == 0)) { //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); @@ -20019,7 +20024,7 @@ static void clif_parse_SkillSelectMenu(int fd, struct map_session_data *sd) if (sd->menuskill_id != SC_AUTOSHADOWSPELL) return; - if (pc_istrading(sd) || sd->state.prevend) { + if (pc_istrading_except_npc(sd) || sd->state.prevend != 0 || (sd->npc_id != 0 && sd->state.using_megaphone == 0)) { clif->skill_fail(sd, sd->ud.skill_id, 0, 0, 0); clif_menuskill_clear(sd); return; -- cgit v1.2.3-70-g09d2 From c17eedc3e25b7fbd5beb051ae4b90bab65dd6eab Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 07:43:00 +0200 Subject: Enable item consumption while Megaphone input box is present --- src/map/pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/map/pc.c b/src/map/pc.c index 4c3f56280..bb7ace84f 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5163,7 +5163,7 @@ static int pc_useitem(struct map_session_data *sd, int n) nullpo_ret(sd); Assert_ret(n >= 0 && n < sd->status.inventorySize); - if ((sd->npc_id != 0 && (sd->npc_item_flag & ITEMENABLEDNPC_CONSUME) == 0) + if ((sd->npc_id != 0 && sd->state.using_megaphone == 0 && (sd->npc_item_flag & ITEMENABLEDNPC_CONSUME) == 0) || (sd->state.workinprogress & 1) != 0) { #if PACKETVER >= 20110308 clif->msgtable(sd, MSG_BUSY); -- cgit v1.2.3-70-g09d2 From 4562766f5fd87d9024b29098b8a1a47d8766ee8f Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 07:45:13 +0200 Subject: Enable changing equipment while Megaphone input box is present --- src/map/clif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index 351637967..ae03e6f4f 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12053,7 +12053,7 @@ static void clif_parse_EquipItem(int fd, struct map_session_data *sd) return; //Out of bounds check. if( sd->npc_id ) { - if ((sd->npc_item_flag & ITEMENABLEDNPC_EQUIP) == 0) + if ((sd->npc_item_flag & ITEMENABLEDNPC_EQUIP) == 0 && sd->state.using_megaphone == 0) return; } else if (sd->state.storage_flag != STORAGE_FLAG_CLOSED || sd->sc.opt1) ; //You can equip/unequip stuff while storage is open/under status changes @@ -12098,7 +12098,7 @@ static void clif_parse_UnequipItem(int fd, struct map_session_data *sd) } if( sd->npc_id ) { - if ((sd->npc_item_flag & ITEMENABLEDNPC_EQUIP) == 0) + if ((sd->npc_item_flag & ITEMENABLEDNPC_EQUIP) == 0 && sd->state.using_megaphone == 0) return; } else if (sd->state.storage_flag != STORAGE_FLAG_CLOSED || sd->sc.opt1) ; //You can equip/unequip stuff while storage is open/under status changes -- cgit v1.2.3-70-g09d2 From f60881dad234b44bbf6b6e49519b8acc05234e03 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 07:46:04 +0200 Subject: Enable walking while Megaphone input box is present --- src/map/clif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/map/clif.c b/src/map/clif.c index ae03e6f4f..f4b6e7505 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -11291,7 +11291,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) || pc_isvending(sd)) + else if (pc_cant_act_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; if(sd->sc.data[SC_RUN] || sd->sc.data[SC_WUGDASH]) -- cgit v1.2.3-70-g09d2 From 57731298a77bfcbce5f2839ed71bd50c0996af95 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 07:47:31 +0200 Subject: Enable attacking while Megaphone input box is present --- src/map/clif.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/map/clif.c b/src/map/clif.c index f4b6e7505..b025249e7 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -11653,8 +11653,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 || pc_isvending(sd)) + if (pc_cant_act_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) + || pc_issit(sd) || (sd->sc.option & OPTION_HIDE) != 0 || pc_isvending(sd)) { return; + } if (sd->sc.option & OPTION_COSTUME) return; -- cgit v1.2.3-70-g09d2 From dab76f21b45980eefc53b22fa9a950b4f57e54b0 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 07:53:56 +0200 Subject: Add pc_cant_act_except_npc_chat() macro --- src/map/pc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/map/pc.h b/src/map/pc.h index a6eeb5209..0334ff37c 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -686,6 +686,7 @@ END_ZEROED_BLOCK; #define pc_cant_act(sd) ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->chat_id != 0 || ((sd)->sc.opt1 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading || (sd)->state.storage_flag || (sd)->state.prevend || (sd)->state.refine_ui == 1 || (sd)->state.lapine_ui == 1) #define pc_cant_act_except_lapine(sd) ((sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->chat_id != 0 || ((sd)->sc.opt1 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading || (sd)->state.storage_flag || (sd)->state.prevend || (sd)->state.refine_ui == 1) #define pc_cant_act_except_npc(sd) ( (sd)->state.vending != 0 || (sd)->state.buyingstore != 0 || (sd)->chat_id != 0 || ((sd)->sc.opt1 != 0 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading != 0 || (sd)->state.storage_flag != 0 || (sd)->state.prevend != 0 || (sd)->state.refine_ui == 1 || (sd)->state.lapine_ui == 1) +#define pc_cant_act_except_npc_chat(sd) ( (sd)->state.vending != 0 || (sd)->state.buyingstore != 0 || ((sd)->sc.opt1 != 0 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading != 0 || (sd)->state.storage_flag != 0 || (sd)->state.prevend != 0 || (sd)->state.refine_ui == 1 || (sd)->state.lapine_ui == 1) /* equals pc_cant_act except it doesn't check for chat rooms */ #define pc_cant_act2(sd) ( (sd)->npc_id || (sd)->state.buyingstore || ((sd)->sc.opt1 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading || (sd)->state.storage_flag || (sd)->state.prevend || (sd)->state.refine_ui == 1 || (sd)->state.lapine_ui == 1) -- cgit v1.2.3-70-g09d2 From be04b21c5a00a025229dbec29e1fa8bdc7da11a8 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 07:57:19 +0200 Subject: Enable dropping items while Megaphone input box is present --- src/map/clif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/map/clif.c b/src/map/clif.c index b025249e7..f220e0e06 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -11982,7 +11982,7 @@ static void clif_parse_DropItem(int fd, struct map_session_data *sd) if (pc_isdead(sd)) break; - if ( pc_cant_act2(sd) || sd->state.vending ) + if (pc_cant_act_except_npc_chat(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0)) break; if (sd->sc.count && ( -- cgit v1.2.3-70-g09d2 From 7aa47a08bfdce1a6f65acaa86815b9d8a02e3a48 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 07:58:32 +0200 Subject: Enable picking up items while Megaphone input box is present --- src/map/clif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/map/clif.c b/src/map/clif.c index f220e0e06..db719256e 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -11956,7 +11956,7 @@ static void clif_parse_TakeItem(int fd, struct map_session_data *sd) ) ) break; - if (pc_cant_act(sd)) + if (pc_cant_act_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0)) break; if (!pc->takeitem(sd, fitem)) -- cgit v1.2.3-70-g09d2 From 7aacf9eed8162c18733364cc9b52f1b9358bc9db Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 08:00:37 +0200 Subject: Enable moving items between cart and inventory while Megaphone input box is present --- src/map/clif.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index db719256e..491e4f805 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12548,8 +12548,10 @@ static void clif_parse_PutItemToCart(int fd, struct map_session_data *sd) __attr static void clif_parse_PutItemToCart(int fd, struct map_session_data *sd) { int flag = 0; - if (pc_istrading(sd) || sd->state.prevend) + + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || sd->state.prevend != 0) return; + if (!pc_iscarton(sd)) return; if ( (flag = pc->putitemtocart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4))) ) { @@ -12563,8 +12565,9 @@ static void clif_parse_GetItemFromCart(int fd, struct map_session_data *sd) __at /// 0127 .W .L static void clif_parse_GetItemFromCart(int fd, struct map_session_data *sd) { - if (pc_istrading(sd) || sd->state.prevend) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || sd->state.prevend != 0) return; + if (!pc_iscarton(sd)) return; pc->getitemfromcart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4)); -- cgit v1.2.3-70-g09d2 From d6622f54398a780d9c007c75855971ebb2a19ea1 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 08:05:10 +0200 Subject: Enable trading while Megaphone input box is present --- src/map/clif.c | 4 ++-- src/map/trade.c | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index 491e4f805..deb53bccb 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12454,7 +12454,7 @@ static void clif_parse_TradeRequest(int fd, struct map_session_data *sd) struct map_session_data *t_sd = map->id2sd(RFIFOL(fd, 2)); - if (sd->chat_id == 0 && pc_cant_act(sd)) + if (pc_cant_act_except_npc_chat(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0)) return; //You can trade while in a chatroom. // @noask [LuzZza] @@ -13330,7 +13330,7 @@ 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)) + if ((sd->state.trading != 0 && sd->state.using_megaphone == 0) || pc_isdead(sd) || pc_isvending(sd)) return; int len = RFIFOW(fd, 2); diff --git a/src/map/trade.c b/src/map/trade.c index e727c3c70..31970fbf9 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -63,7 +63,7 @@ static void trade_traderequest(struct map_session_data *sd, struct map_session_d return; } - if (target_sd->npc_id) { + if (target_sd->npc_id != 0 && target_sd->state.using_megaphone == 0) { //Trade fails if you are using an NPC. clif->tradestart(sd, 2); return; @@ -166,9 +166,10 @@ static void trade_tradeack(struct map_session_data *sd, int type) } //Check if you can start trade. - if (sd->npc_id || sd->state.vending || sd->state.prevend || sd->state.buyingstore || sd->state.storage_flag != STORAGE_FLAG_CLOSED - || tsd->npc_id || tsd->state.vending || tsd->state.prevend || tsd->state.buyingstore || tsd->state.storage_flag != STORAGE_FLAG_CLOSED - ) { + if ((sd->npc_id != 0 && sd->state.using_megaphone == 0) || sd->state.vending != 0 || sd->state.prevend != 0 + || sd->state.buyingstore != 0 || sd->state.storage_flag != STORAGE_FLAG_CLOSED + || (tsd->npc_id != 0 && tsd->state.using_megaphone == 0) || tsd->state.vending != 0 || tsd->state.prevend != 0 + || tsd->state.buyingstore != 0 || tsd->state.storage_flag != STORAGE_FLAG_CLOSED) { //Fail clif->tradestart(sd, 2); clif->tradestart(tsd, 2); -- cgit v1.2.3-70-g09d2 From 7da438ed9885aa05f4d2748e655ad889b4d39c85 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 08:07:51 +0200 Subject: Enable vending shop features while Megaphone input box is present --- src/map/clif.c | 13 ++++++------- src/map/vending.c | 6 ++++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index deb53bccb..715e829f0 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -13330,7 +13330,7 @@ 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 != 0 && sd->state.using_megaphone == 0) || pc_isdead(sd) || pc_isvending(sd)) + if (((sd->state.trading != 0 || pc_isvending(sd)) && sd->state.using_megaphone == 0) || pc_isdead(sd)) return; int len = RFIFOW(fd, 2); @@ -14597,7 +14597,7 @@ 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 (sd->npc_id || sd->state.buyingstore || sd->state.trading) + if ((sd->npc_id != 0 && sd->state.using_megaphone == 0) || sd->state.buyingstore != 0 || sd->state.trading != 0) return; vending->close(sd); @@ -14608,12 +14608,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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isdead(sd)) return; - if( sd->npc_id ) {// using an NPC - return; - } vending->list(sd,RFIFOL(fd,2)); } @@ -14675,8 +14672,10 @@ 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) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) + || pc_isdead(sd) || sd->state.vending != 0 || sd->state.buyingstore != 0) { return; + } int len = (int)RFIFOW(fd, 2) - 85; diff --git a/src/map/vending.c b/src/map/vending.c index 4fd009025..9b3f48f38 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -251,8 +251,10 @@ static void vending_openvending(struct map_session_data *sd, const char *message int vending_skill_lvl; nullpo_retv(sd); - if ( pc_isdead(sd) || !sd->state.prevend || pc_istrading(sd)) - return; // can't open vendings lying dead || didn't use via the skill (wpe/hack) || can't have 2 shops at once + if (pc_isdead(sd) || sd->state.prevend == 0 || pc_istrading_except_npc(sd) + || (sd->npc_id != 0 && sd->state.using_megaphone == 0)) { + return; // Can't open vendings lying dead. || Didn't use via the skill. (wpe/hack) || Can't have 2 shops at once. + } vending_skill_lvl = pc->checkskill(sd, MC_VENDING); // skill level and cart check -- cgit v1.2.3-70-g09d2 From 0f11b668aebc5197281a4747b202cc9fa7549d72 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 08:09:10 +0200 Subject: Enable buying store features while Megaphone input box is present --- src/map/buyingstore.c | 13 +++++++------ src/map/clif.c | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 2c2fc13ae..fd6e6fd6e 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -91,8 +91,9 @@ static void buyingstore_create(struct map_session_data *sd, int zenylimit, unsig return; } - if( !battle_config.feature_buying_store || pc_istrading(sd) || sd->state.prevend || sd->buyingstore.slots == 0 || count > sd->buyingstore.slots || zenylimit <= 0 || zenylimit > sd->status.zeny || !storename[0] ) - {// disabled or invalid input + if (battle_config.feature_buying_store == 0 || pc_istrading_except_npc(sd) || sd->state.prevend != 0 + || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || sd->buyingstore.slots == 0 + || count > sd->buyingstore.slots || zenylimit <= 0 || zenylimit > sd->status.zeny || *storename == '\0') { // Disabled or invalid input. sd->buyingstore.slots = 0; clif->buyingstore_open_failed(sd, BUYINGSTORE_CREATE, 0); return; @@ -218,8 +219,8 @@ static void buyingstore_open(struct map_session_data *sd, int account_id) struct map_session_data* pl_sd; nullpo_retv(sd); - if (!battle_config.feature_buying_store || pc_istrading(sd) || sd->state.prevend) - {// not allowed to sell + if (battle_config.feature_buying_store == 0 || pc_istrading_except_npc(sd) || sd->state.prevend != 0 + || (sd->npc_id != 0 && sd->state.using_megaphone == 0)) { // Not allowed to sell. return; } @@ -255,8 +256,8 @@ static void buyingstore_trade(struct map_session_data* sd, int account_id, unsig return; } - if (!battle_config.feature_buying_store || pc_istrading(sd) || sd->state.prevend) - {// not allowed to sell + if (battle_config.feature_buying_store == 0 || pc_istrading_except_npc(sd) || sd->state.prevend != 0 + || (sd->npc_id != 0 && sd->state.using_megaphone == 0)) { // Not allowed to sell. clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, 0); return; } diff --git a/src/map/clif.c b/src/map/clif.c index 715e829f0..2b2865255 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -19190,7 +19190,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isdead(sd)) return; const unsigned int blocksize = sizeof(struct PACKET_CZ_REQ_OPEN_BUYING_STORE_sub); -- cgit v1.2.3-70-g09d2 From 43160bc727551e07252dfcb5dbcad183cc9308c9 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 08:10:39 +0200 Subject: Enable party features while Megaphone input box is present --- src/map/clif.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index 2b2865255..7a394f0ae 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -13702,7 +13702,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; char name[NAME_LENGTH]; @@ -13725,7 +13725,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; char name[NAME_LENGTH]; @@ -13753,7 +13753,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; struct map_session_data *t_sd; @@ -13777,7 +13777,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; struct map_session_data *t_sd; @@ -13810,7 +13810,7 @@ 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) { - if (pc_istrading(sd) || pc_isvending(sd)) { + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) { party->reply_invite(sd, RFIFOL(fd, 2), 0); return; } @@ -13821,7 +13821,7 @@ static void clif_parse_ReplyPartyInvite(int fd, struct map_session_data *sd) 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) { - if (pc_istrading(sd) || pc_isvending(sd)) { + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) { party->reply_invite(sd, RFIFOL(fd, 2), 0); return; } @@ -13834,7 +13834,7 @@ 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 (pc_istrading(sd) || pc_isvending(sd)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; if (map->list[sd->bl.m].flag.partylock) { @@ -13850,7 +13850,7 @@ 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 (pc_istrading(sd) || pc_isvending(sd)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; if (map->list[sd->bl.m].flag.partylock) { @@ -13867,7 +13867,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; struct party_data *p; @@ -13922,7 +13922,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; party->changeleader(sd, map->id2sd(RFIFOL(fd,2))); -- cgit v1.2.3-70-g09d2 From 1ae87bdd29223dd5983b92bbac54496e7277d98d Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 08:11:48 +0200 Subject: Enable party booking features while Megaphone input box is present --- src/map/clif.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index 7a394f0ae..96348d338 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -13937,7 +13937,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; short level = RFIFOW(fd,2); @@ -13982,7 +13982,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; short level = RFIFOW(fd,2); @@ -14036,7 +14036,7 @@ 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 (pc_istrading(sd) || pc_isvending(sd)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; if (party->booking_delete(sd)) @@ -14075,7 +14075,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; short job[PARTY_BOOKING_JOBS]; @@ -14094,7 +14094,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; int i; @@ -14165,7 +14165,7 @@ 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 - if (pc_istrading(sd) || pc_isvending(sd)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; short level = RFIFOW(fd, 2); @@ -14239,7 +14239,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; short level = RFIFOW(fd, 2); @@ -14259,7 +14259,7 @@ 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 (pc_istrading(sd) || pc_isvending(sd)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; if (party->booking_delete(sd)) @@ -14298,7 +14298,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; const char *notice = RFIFOP(fd, 2); @@ -14374,7 +14374,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; int index = RFIFOL(fd, 2); @@ -14391,7 +14391,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; int gid = RFIFOL(fd, 2); @@ -14408,7 +14408,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; int index = RFIFOL(fd, 2); @@ -14487,7 +14487,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; unsigned int aid = RFIFOL(fd, 2); @@ -14519,7 +14519,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; int index = RFIFOL(fd, 2); -- cgit v1.2.3-70-g09d2 From 90a72bc5eaae71d2ccdd4c1b6f859afb4c336fc6 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 08:14:57 +0200 Subject: Enable sending mails while Megaphone input box is present --- src/map/clif.c | 2 +- src/map/mail.c | 4 ++-- src/map/rodex.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index 96348d338..6b5e4a80e 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -22188,7 +22188,7 @@ static void clif_parse_rodex_open_write_mail(int fd, struct map_session_data *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; + int8 result = (rodex->isenabled() && (sd->npc_id == 0 || sd->state.using_megaphone != 0)) ? 1 : 0; clif->rodex_open_write_mail(fd, rPacket->receiveName, result); } diff --git a/src/map/mail.c b/src/map/mail.c index a1176e8fc..b862900c7 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -81,9 +81,9 @@ static int mail_removezeny(struct map_session_data *sd, short flag) static unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount) { - nullpo_retr(1, sd); - if( pc_istrading(sd) ) + + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0)) return 1; if( idx == 0 ) { // Zeny Transfer diff --git a/src/map/rodex.c b/src/map/rodex.c index 1ebed0623..998066eca 100644 --- a/src/map/rodex.c +++ b/src/map/rodex.c @@ -231,7 +231,7 @@ static int rodex_send_mail(struct map_session_data *sd, const char *receiver_nam nullpo_retr(RODEX_SEND_MAIL_FATAL_ERROR, body); nullpo_retr(RODEX_SEND_MAIL_FATAL_ERROR, title); - if (!rodex->isenabled() || sd->npc_id > 0) { + if (!rodex->isenabled() || (sd->npc_id != 0 && sd->state.using_megaphone == 0)) { rodex->clean(sd, 1); return RODEX_SEND_MAIL_FATAL_ERROR; } -- cgit v1.2.3-70-g09d2 From cc2dcda6c77936634cec00a56649c2898cafd4f1 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 08:16:14 +0200 Subject: Enable sending Megaphone message if character is dead --- src/map/clif.c | 2 +- src/map/pc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index 6b5e4a80e..b0c8fe027 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -13330,7 +13330,7 @@ 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 != 0 || pc_isvending(sd)) && sd->state.using_megaphone == 0) || pc_isdead(sd)) + if ((sd->state.trading != 0 || pc_isvending(sd) || pc_isdead(sd)) && sd->state.using_megaphone == 0) return; int len = RFIFOW(fd, 2); diff --git a/src/map/pc.c b/src/map/pc.c index bb7ace84f..085b7c6bb 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -8176,7 +8176,7 @@ static int pc_dead(struct map_session_data *sd, struct block_list *src) duel->reject(sd->duel_invite, sd); } - if (sd->npc_id != 0 && sd->st != NULL && sd->st->state != RUN) + if (sd->npc_id != 0 && sd->state.using_megaphone == 0 && sd->st != NULL && sd->st->state != RUN) npc->event_dequeue(sd); pc_setglobalreg(sd, script->add_variable("PC_DIE_COUNTER"), sd->die_counter + 1); @@ -8199,7 +8199,7 @@ static int pc_dead(struct map_session_data *sd, struct block_list *src) npc->script_event(sd, NPCE_DIE); // Clear anything NPC-related if character died while interacting with one. - if ((sd->npc_id != 0 || sd->npc_shopid != 0) && sd->state.dialog != 0) { + if (((sd->npc_id != 0 && sd->state.using_megaphone == 0) || sd->npc_shopid != 0) && sd->state.dialog != 0) { if (sd->state.using_fake_npc != 0) { clif->clearunit_single(sd->npc_id, CLR_OUTSIGHT, sd->fd); sd->state.using_fake_npc = 0; -- cgit v1.2.3-70-g09d2 From 87994df22212939fb9151160015953daccc289b6 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 08:17:06 +0200 Subject: Enable resurrection by Token of Siegfried while Megaphone input box is present --- src/map/clif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/map/clif.c b/src/map/clif.c index b0c8fe027..f347a379a 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -16762,7 +16762,7 @@ 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)) + if (pc_istrading_except_npc(sd) || (sd->npc_id != 0 && sd->state.using_megaphone == 0) || pc_isvending(sd)) return; if (!pc_isdead(sd)) -- cgit v1.2.3-70-g09d2 From 1ee5255bc81b5057dae57f4f1d91b7c70efeb143 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 08:20:50 +0200 Subject: Disable using Megaphone while Rodex send mail window is present This also fixes the issue where the client freezes when talking to a NPC while Rodex send mail window is present. --- src/map/clif.c | 3 +++ src/map/pc.c | 9 +++++++++ src/map/rodex.c | 1 + 3 files changed, 13 insertions(+) diff --git a/src/map/clif.c b/src/map/clif.c index f347a379a..fa01d31b5 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -22190,6 +22190,9 @@ static void clif_parse_rodex_open_write_mail(int fd, struct map_session_data *sd const struct PACKET_CZ_REQ_OPEN_WRITE_MAIL *rPacket = RFIFOP(fd, 0); int8 result = (rodex->isenabled() && (sd->npc_id == 0 || sd->state.using_megaphone != 0)) ? 1 : 0; + if (result == 1) + sd->state.workinprogress |= 2; + clif->rodex_open_write_mail(fd, rPacket->receiveName, result); } diff --git a/src/map/pc.c b/src/map/pc.c index 085b7c6bb..63d62467c 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5190,6 +5190,15 @@ static int pc_useitem(struct map_session_data *sd, int n) // Store information for later use before it is lost (via pc->delitem) [Paradox924X] nameid = sd->inventory_data[n]->nameid; + if (nameid == ITEMID_MEGAPHONE && (sd->state.workinprogress & 2) != 0) { +#if PACKETVER >= 20110308 + clif->msgtable(sd, MSG_BUSY); +#else + clif->messagecolor_self(sd->fd, COLOR_WHITE, msg_sd(sd, 48)); +#endif + return 0; + } + if (nameid != ITEMID_NAUTHIZ && sd->sc.opt1 > 0 && sd->sc.opt1 != OPT1_STONEWAIT && sd->sc.opt1 != OPT1_BURNING) return 0; diff --git a/src/map/rodex.c b/src/map/rodex.c index 998066eca..f2bb8a0d4 100644 --- a/src/map/rodex.c +++ b/src/map/rodex.c @@ -575,6 +575,7 @@ static void rodex_clean(struct map_session_data *sd, int8 flag) if (flag == 0) VECTOR_CLEAR(sd->rodex.messages); + sd->state.workinprogress &= ~2; memset(&sd->rodex.tmp, 0x0, sizeof(sd->rodex.tmp)); } -- cgit v1.2.3-70-g09d2 From e7f6a8ad0baefe9827b42a01d99ce2e507bf9284 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 08:21:57 +0200 Subject: Disable using Megaphone while Megaphone input box is present --- src/map/pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/map/pc.c b/src/map/pc.c index 63d62467c..ae746dab4 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5190,7 +5190,7 @@ static int pc_useitem(struct map_session_data *sd, int n) // Store information for later use before it is lost (via pc->delitem) [Paradox924X] nameid = sd->inventory_data[n]->nameid; - if (nameid == ITEMID_MEGAPHONE && (sd->state.workinprogress & 2) != 0) { + if (nameid == ITEMID_MEGAPHONE && ((sd->state.workinprogress & 2) != 0 || sd->state.using_megaphone != 0)) { #if PACKETVER >= 20110308 clif->msgtable(sd, MSG_BUSY); #else -- cgit v1.2.3-70-g09d2 From 736b288594003e1e6e4aabf8bc72f82d03143bb2 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Sun, 28 Jun 2020 02:08:49 +0200 Subject: Disable using Megaphone while interacting with NPCs regardless of item_enabled_npc battle flag --- src/map/pc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/map/pc.c b/src/map/pc.c index ae746dab4..6f3227ec9 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5190,7 +5190,8 @@ static int pc_useitem(struct map_session_data *sd, int n) // Store information for later use before it is lost (via pc->delitem) [Paradox924X] nameid = sd->inventory_data[n]->nameid; - if (nameid == ITEMID_MEGAPHONE && ((sd->state.workinprogress & 2) != 0 || sd->state.using_megaphone != 0)) { + if (nameid == ITEMID_MEGAPHONE && ((sd->state.workinprogress & 2) != 0 || sd->state.using_megaphone != 0 + || sd->npc_id != 0)) { #if PACKETVER >= 20110308 clif->msgtable(sd, MSG_BUSY); #else -- cgit v1.2.3-70-g09d2 From 1d00e2268b7a20077d9d61dc8989b9f770344e59 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Sun, 28 Jun 2020 02:19:38 +0200 Subject: Unset using_megaphone state in clif_parse_LoadEndAck() --- src/map/clif.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/map/clif.c b/src/map/clif.c index fa01d31b5..4febf9c84 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -10629,6 +10629,9 @@ static void clif_parse_WantToConnection(int fd, struct map_session_data *sd) static void clif_parse_LoadEndAck(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); static void clif_parse_LoadEndAck(int fd, struct map_session_data *sd) { + if (sd->state.using_megaphone != 0) + sd->state.using_megaphone = 0; + if (sd->bl.prev != NULL) return; -- cgit v1.2.3-70-g09d2