diff options
author | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-11-10 04:51:03 +0000 |
---|---|---|
committer | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-11-10 04:51:03 +0000 |
commit | 7726e501b5156319a2940601ea1ef3ccfd7326fc (patch) | |
tree | ff7cd83adc3158b854facd736f88ea6c9d4cfaa7 /src/map/clif.c | |
parent | a4a5d536b46215d8040b6ef40f4b5f5141e5b299 (diff) | |
download | hercules-7726e501b5156319a2940601ea1ef3ccfd7326fc.tar.gz hercules-7726e501b5156319a2940601ea1ef3ccfd7326fc.tar.bz2 hercules-7726e501b5156319a2940601ea1ef3ccfd7326fc.tar.xz hercules-7726e501b5156319a2940601ea1ef3ccfd7326fc.zip |
Fixed bugreport:6876 / Reverting r16891
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16896 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/clif.c')
-rw-r--r-- | src/map/clif.c | 114 |
1 files changed, 82 insertions, 32 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 26a5cdf8a..bed3a473f 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -5381,35 +5381,6 @@ void clif_status_change(struct block_list *bl,int type,int flag,int tick,int val clif_send(buf,packet_len(WBUFW(buf,0)),bl, (sd && sd->status.option&OPTION_INVISIBLE) ? SELF : AREA); } - -/// Notification about an another object's chat message (ZC_NOTIFY_CHAT). -/// 008d <packet len>.W <id>.L <message>.?B -void clif_notify_chat(struct block_list* bl, const char* message, send_target target) -{ - char buf[8+255+1]; - size_t length; - - if( !message[0] ) - {// empty message - return; - } - - length = strlen(message); - - if( length > sizeof(buf)-8 ) - { - ShowWarning("clif_notify_chat: Truncated message '%s' (len=%u, max=%u, id=%d, target=%d).\n", message, length, sizeof(buf)-8, bl ? bl->id : 0, target); - length = sizeof(buf)-8; - } - - WBUFW(buf,0) = 0x8d; - WBUFW(buf,2) = 8+length; - WBUFL(buf,4) = bl ? bl->id : 0; - safestrncpy((char*)WBUFP(buf,8), message, length+1); - clif_send(buf, WBUFW(buf,2), bl, target); -} - - /// Send message (modified by [Yor]) (ZC_NOTIFY_PLAYERCHAT). /// 008e <packet len>.W <message>.?B void clif_displaymessage(const int fd, const char* mes) @@ -5461,6 +5432,55 @@ void clif_broadcast(struct block_list* bl, const char* mes, int len, int type, e aFree(buf); } +/*========================================== + * Displays a message on a 'bl' to all it's nearby clients + * Used by npc_globalmessage + *------------------------------------------*/ +void clif_GlobalMessage(struct block_list* bl, const char* message) { + char buf[100]; + int len; + nullpo_retv(bl); + + if(!message) + return; + + len = strlen(message)+1; + + if( len > sizeof(buf)-8 ) { + ShowWarning("clif_GlobalMessage: Truncating too long message '%s' (len=%d).\n", message, len); + len = sizeof(buf)-8; + } + + WBUFW(buf,0)=0x8d; + WBUFW(buf,2)=len+8; + WBUFL(buf,4)=bl->id; + safestrncpy((char *) WBUFP(buf,8),message,len); + clif_send((unsigned char *) buf,WBUFW(buf,2),bl,ALL_CLIENT); + +} + +/*========================================== + * Send main chat message [LuzZza] + *------------------------------------------*/ +void clif_MainChatMessage(const char* message) { + uint8 buf[200]; + int len; + + if(!message) + return; + + len = strlen(message)+1; + if (len+8 > sizeof(buf)) { + ShowDebug("clif_MainChatMessage: Received message too long (len %d): %s\n", len, message); + len = sizeof(buf)-8; + } + WBUFW(buf,0)=0x8d; + WBUFW(buf,2)=len+8; + WBUFL(buf,4)=0; + safestrncpy((char *) WBUFP(buf,8),message,len); + clif_send(buf,WBUFW(buf,2),NULL,CHAT_MAINCHAT); +} + /// Send broadcast message with font formatting (ZC_BROADCAST2). /// 01c3 <packet len>.W <fontColor>.L <fontType>.W <fontSize>.W <fontAlign>.W <fontY>.W <message>.?B void clif_broadcast2(struct block_list* bl, const char* mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY, enum send_target target) @@ -8179,6 +8199,26 @@ void clif_messagecolor(struct block_list* bl, unsigned long color, const char* m clif_send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC); } +/// Public chat message [Valaris] (ZC_NOTIFY_CHAT). +/// 008d <packet len>.W <id>.L <message>.?B +void clif_message(struct block_list* bl, const char* msg) { + unsigned short msg_len = strlen(msg) + 1; + uint8 buf[256]; + nullpo_retv(bl); + + if( msg_len > sizeof(buf)-8 ) { + ShowWarning("clif_message: Truncating too long message '%s' (len=%u).\n", msg, msg_len); + msg_len = sizeof(buf)-8; + } + + WBUFW(buf,0) = 0x8d; + WBUFW(buf,2) = msg_len + 8; + WBUFL(buf,4) = bl->id; + safestrncpy((char*)WBUFP(buf,8), msg, msg_len); + + clif_send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC); +} + // refresh the client's screen, getting rid of any effects void clif_refresh(struct map_session_data *sd) { @@ -8469,7 +8509,11 @@ void clif_disp_overhead(struct map_session_data *sd, const char* mes) len_mes = sizeof(buf)-8; //Trunk it to avoid problems. } // send message to others - clif_notify_chat(&sd->bl, mes, AREA_CHAT_WOC); + WBUFW(buf,0) = 0x8d; + WBUFW(buf,2) = len_mes + 8; // len of message + 8 (command+len+id) + WBUFL(buf,4) = sd->bl.id; + safestrncpy((char*)WBUFP(buf,8), mes, len_mes); + clif_send(buf, WBUFW(buf,2), &sd->bl, AREA_CHAT_WOC); // send back message to the speaker WBUFW(buf,0) = 0x8e; @@ -9614,8 +9658,14 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) strcat(fakename, message); textlen = strlen(fakename) + 1; } - // send message to others - clif_notify_chat(&sd->bl, is_fake ? fakename : text, sd->chatID ? CHAT_WOS : AREA_CHAT_WOC); + // send message to others (using the send buffer for temp. storage) + WFIFOHEAD(fd, 8 + textlen); + WFIFOW(fd,0) = 0x8d; + WFIFOW(fd,2) = 8 + textlen; + WFIFOL(fd,4) = sd->bl.id; + safestrncpy((char*)WFIFOP(fd,8), is_fake ? fakename : text, textlen); + //FIXME: chat has range of 9 only + clif_send(WFIFOP(fd,0), WFIFOW(fd,2), &sd->bl, sd->chatID ? CHAT_WOS : AREA_CHAT_WOC); // send back message to the speaker if( is_fake ) { |