Browse Source

- Merged main-chat message handling (as requested/enforced by trojal <3)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15816 54d463be-8e91-2dee-dedb-b68131a5f0ec
epoque11 13 years ago
parent
commit
1ce49ea08e
4 changed files with 27 additions and 14 deletions
  1. 3 8
      src/map/atcommand.c
  2. 2 6
      src/map/clif.c
  3. 21 0
      src/map/intif.c
  4. 1 0
      src/map/intif.h

+ 3 - 8
src/map/atcommand.c

@@ -7790,14 +7790,9 @@ ACMD_FUNC(main)
 				clif_displaymessage(fd, msg_txt(387));
 				return -1;
 			}
-			sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
-			// I use 0xFE000000 color for signalizing that this message is
-			// main chat message. 0xFE000000 is invalid color, same using
-			// 0xFF000000 for simple (not colored) GM messages. [LuzZza]
-			intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0, 0, 0, 0);
-
-			// Chat logging type 'M' / Main Chat
-			log_chat(LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
+
+			// send the message using inter-server system
+			intif_main_message( sd, message );
 		}
 		
 	} else {

+ 2 - 6
src/map/clif.c

@@ -9827,14 +9827,10 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
 		if(!sd->state.mainchat)
 			clif_displaymessage(fd, msg_txt(388)); // You should enable main chat with "@main on" command.
 		else {
-			char output[256];
-			snprintf(output, ARRAYLENGTH(output), msg_txt(386), sd->status.name, message);
-			intif_broadcast2(output, strlen(output) + 1, 0xFE000000, 0, 0, 0, 0);
+			// send the main message using inter-server system
+			intif_main_message( sd, message );
 		}
 
-		// Chat logging type 'M' / Main Chat
-		log_chat(LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
-
 		return;
 	}
 

+ 21 - 0
src/map/intif.c

@@ -192,6 +192,27 @@ int intif_broadcast2(const char* mes, int len, unsigned long fontColor, short fo
 	return 0;
 }
 
+/// send a message using the main chat system
+/// <sd>         the source of message
+/// <message>    the message that was sent
+int intif_main_message(struct map_session_data* sd, const char* message)
+{
+	char output[256];
+
+	nullpo_retv(sd);
+
+	// format the message for main broadcasting
+	snprintf( output, sizeof(output), msg_txt(386), sd->status.name, message );
+
+	// send the message using the inter-server broadcast service
+	intif_broadcast2( output, strlen(output) + 1, 0xFE000000, 0, 0, 0, 0 );
+
+	// log the chat message
+	log_chat( LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message );
+
+	return 0;
+}
+
 // The transmission of Wisp/Page to inter-server (player not found on this server)
 int intif_wis_message(struct map_session_data *sd, char *nick, char *mes, int mes_len)
 {

+ 1 - 0
src/map/intif.h

@@ -18,6 +18,7 @@ int intif_parse(int fd);
 
 int intif_broadcast(const char* mes, int len, int type);
 int intif_broadcast2(const char* mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY);
+int intif_main_message(struct map_session_data* sd, const char* message);
 
 int intif_wis_message(struct map_session_data *sd,char *nick,char *mes,int mes_len);
 int intif_wis_message_to_gm(char *Wisp_name, int permission, char *mes);