From 6d6ee36ddea2465e34fcb67fc0fc8f37e9818df5 Mon Sep 17 00:00:00 2001 From: Fate Date: Sat, 12 Sep 2009 00:16:56 +0000 Subject: Implemented pDeaf property (70) which makes PCs ignore regular PC chat (except for GMs) --- src/map/clif.c | 43 ++++++++++++++++++++++++++++++++++++++++++- src/map/map.h | 2 ++ src/map/pc.c | 3 +++ 3 files changed, 47 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/map/clif.c b/src/map/clif.c index 70311e9..b9dc90c 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -49,6 +49,7 @@ #endif #define STATE_BLIND 0x10 +#define EMOTE_IGNORED 0x0e static const int packet_len_table[0x220] = { 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -207,6 +208,18 @@ int clif_foreachclient(int (*func)(struct map_session_data*, va_list),...) return 0; } +static int +is_deaf(struct block_list *bl) +{ + struct map_session_data *sd = (struct map_session_data *) bl; + if (!bl || bl->type != BL_PC) + return 0; + return sd->special_state.deaf; +} + +static void clif_emotion_towards(struct block_list *bl, struct block_list *target, int type); + + /*========================================== * clif_send��AREA*�w�莞�p *------------------------------------------ @@ -233,9 +246,17 @@ int clif_send_sub(struct block_list *bl, va_list ap) if (bl && bl == src_bl) return 0; break; + + case AREA_CHAT_WOC: + if (is_deaf (bl) && !(bl->type == BL_PC && pc_isGM((struct map_session_data *)src_bl))) { + clif_emotion_towards(src_bl, bl, EMOTE_IGNORED); + return 0; + } + /* fall through... */ case AREA_WOC: if ((sd && sd->chatID) || (bl && bl == src_bl)) return 0; + break; case AREA_WOSC: if ((sd) && sd->chatID && sd->chatID == ((struct map_session_data*)src_bl)->chatID) @@ -325,7 +346,7 @@ int clif_send(unsigned char *buf, int len, struct block_list *bl, int type) { map_foreachinarea(clif_send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE, BL_PC, buf, len, bl, type); break; case AREA_CHAT_WOC: - map_foreachinarea(clif_send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5), bl->x+(AREA_SIZE-5), bl->y+(AREA_SIZE-5), BL_PC, buf, len, bl, AREA_WOC); + map_foreachinarea(clif_send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5), bl->x+(AREA_SIZE-5), bl->y+(AREA_SIZE-5), BL_PC, buf, len, bl, AREA_CHAT_WOC); break; case CHAT: case CHAT_WOS: @@ -5878,6 +5899,26 @@ void clif_emotion(struct block_list *bl,int type) clif_send(buf,packet_len_table[0xc0],bl,AREA); } +static void clif_emotion_towards(struct block_list *bl, struct block_list *target, int type) +{ + unsigned char buf[8]; + int len = packet_len_table[0xc0]; + struct map_session_data *sd = (struct map_session_data *) target; + + nullpo_retv(bl); + nullpo_retv(target); + + if (target->type != BL_PC) + return; + + WBUFW(buf,0)=0xc0; + WBUFL(buf,2)=bl->id; + WBUFB(buf,6)=type; + + memcpy(WFIFOP(sd->fd,0), buf, len); + WFIFOSET(sd->fd,len); +} + /*========================================== * �g�[�L�[�{�b�N�X *------------------------------------------ diff --git a/src/map/map.h b/src/map/map.h index 71b091a..28729c6 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -184,6 +184,7 @@ struct map_session_data { unsigned unbreakable_weapon : 1; unsigned unbreakable_armor : 1; unsigned infinite_autospell : 1; + unsigned deaf : 1; } special_state; int char_id, login_id1, login_id2, sex; unsigned char tmw_version; // tmw client version @@ -581,6 +582,7 @@ enum { SP_28,SP_ATK1,SP_ATK2,SP_MATK1,SP_MATK2,SP_DEF1,SP_DEF2,SP_MDEF1, // 40-47 SP_MDEF2,SP_HIT,SP_FLEE1,SP_FLEE2,SP_CRITICAL,SP_ASPD,SP_36,SP_JOBLEVEL, // 48-55 SP_UPPER,SP_PARTNER,SP_CART,SP_FAME,SP_UNBREAKABLE, //56-58 + SP_DEAF=70, SP_CARTINFO=99, // 99 SP_GM=500, diff --git a/src/map/pc.c b/src/map/pc.c index 82c3584..d378f47 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2398,6 +2398,9 @@ int pc_bonus(struct map_session_data *sd,int type,int val) sd->unbreakable += val; } break; + case SP_DEAF: + sd->special_state.deaf = 1; + break; default: if(battle_config.error_log) printf("pc_bonus: unknown type %d %d !\n",type,val); -- cgit v1.2.3-70-g09d2