summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map/clif.c114
-rw-r--r--src/map/clif.h8
2 files changed, 85 insertions, 37 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 ) {
diff --git a/src/map/clif.h b/src/map/clif.h
index 6808810c1..4e780f66d 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -373,6 +373,7 @@ void clif_misceffect(struct block_list* bl,int type); // area
void clif_changeoption(struct block_list* bl); // area
void clif_changeoption2(struct block_list* bl); // area
void clif_useitemack(struct map_session_data *sd,int index,int amount,bool ok); // self
+void clif_GlobalMessage(struct block_list* bl, const char* message);
void clif_createchat(struct map_session_data* sd, int flag); // self
void clif_dispchat(struct chat_data* cd, int fd); // area or fd
void clif_joinchatfail(struct map_session_data *sd,int flag); // self
@@ -568,11 +569,11 @@ void clif_instance_leave(int fd);
void clif_font(struct map_session_data *sd);
// atcommand
-void clif_notify_chat(struct block_list* bl, const char* message, send_target target);
void clif_displaymessage(const int fd, const char* mes);
void clif_disp_onlyself(struct map_session_data *sd, const char *mes, int len);
void clif_disp_message(struct block_list* src, const char* mes, int len, enum send_target target);
void clif_broadcast(struct block_list* bl, const char* mes, int len, int type, enum send_target target);
+void clif_MainChatMessage(const char* message);
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);
void clif_heal(int fd,int type,int val);
void clif_resurrection(struct block_list *bl,int type);
@@ -603,6 +604,7 @@ void clif_weather(int m); // [Valaris]
void clif_specialeffect(struct block_list* bl, int type, enum send_target target); // special effects [Valaris]
void clif_specialeffect_single(struct block_list* bl, int type, int fd);
void clif_messagecolor(struct block_list* bl, unsigned long color, const char* msg); // Mob/Npc color talk [SnakeDrak]
+void clif_message(struct block_list* bl, const char* msg);
void clif_specialeffect_value(struct block_list* bl, int effect_id, int num, send_target target);
void clif_GM_kickack(struct map_session_data *sd, int id);
@@ -767,8 +769,4 @@ int clif_colormes(struct map_session_data * sd, enum clif_colors color, const ch
#define clif_menuskill_clear(sd) (sd)->menuskill_id = (sd)->menuskill_val = (sd)->menuskill_val2 = 0;
-#define clif_GlobalMessage(bl,message) clif_notify_chat(bl, message, ALL_CLIENT)
-#define clif_MainChatMessage(message) clif_notify_chat(NULL, message, CHAT_MAINCHAT)
-#define clif_message(bl,msg) clif_notify_chat(bl, msg, AREA_CHAT_WOC)
-
#endif /* _CLIF_H_ */