[mw-devel] MW3 r1314 - trunk/src/webclient

arthur at sucs.org arthur at sucs.org
Tue Dec 11 22:01:07 GMT 2012


Author: arthur
Date: 2012-12-11 22:01:07 +0000 (Tue, 11 Dec 2012)
New Revision: 1314

Modified:
   trunk/src/webclient/comms.c
   trunk/src/webclient/import.c
   trunk/src/webclient/import.h
Log:
convert mwpoll to the new say message type too, 
copied function into import, should really get factored out.


Modified: trunk/src/webclient/comms.c
===================================================================
--- trunk/src/webclient/comms.c	2012-12-11 21:47:37 UTC (rev 1313)
+++ trunk/src/webclient/comms.c	2012-12-11 22:01:07 UTC (rev 1314)
@@ -433,17 +433,8 @@
                 return 1;			
 	}else
         if (co->authd && strncasecmp(buff, "emote ", 6)==0) {
-                struct filter_info f_info;
-                char line[8192];
-                memset(&f_info, 0, sizeof(f_info));
-                f_info.channel = user->room;
-                snprintf(line, sizeof line, "%s %s", user->name, &buff[6]);
+		talk_send_to_room(&buff[6], user->room, "say", -1);
 		mwlog("EMOTE %s", &buff[6]);
-                ipc_send_to_all(IPC_TEXT, line, send_filter_oneroom, &f_info);
-		//Strictly speaking, the following should check whether or not the room is hidden.
-		//If anyone cares about it enough to fix it, go right ahead
-        	snprintf(line, MAXTEXTLENGTH, "%d:%s %s", user->room, user->name, &buff[6]);
-        	ipc_send_to_all(IPC_TEXT, line, send_filter_global, &f_info);
                 snprintf(buff, sizeof buff, "{\"status\":\"Emote Sent to channel %d\"}", user->room);
                 send(co->fd, buff, strlen(buff), 0);
 		user->idletime = lastcomm;
@@ -524,17 +515,8 @@
 		return 1;
 	}else
 	if (co->authd && strncasecmp(buff, "say ", 4)==0) {
-		struct filter_info f_info;
-		char line[8192];
-		memset(&f_info, 0, sizeof(f_info));
-		f_info.channel = user->room;
-		snprintf(line, sizeof line, "%s: %s", user->name, &buff[4]);
+		talk_send_to_room(&buff[4], user->room, "say", -1);
 		mwlog("SAY %s", &buff[4]);
-		ipc_send_to_all(IPC_TEXT, line, send_filter_oneroom, &f_info);
-                //Strictly speaking, the following should check whether or not the room is hidden.
-                //If anyone cares about it enough to fix it, go right ahead
-                snprintf(line, MAXTEXTLENGTH, "%d:%s: %s", user->room, user->name, &buff[4]);
-                ipc_send_to_all(IPC_TEXT, line, send_filter_global, &f_info);
 		snprintf(buff, sizeof buff, "{\"status\":\"Message Sent to channel %d\"}", user->room);
 		send(co->fd, buff, strlen(buff), 0);
 		user->idletime = lastcomm;

Modified: trunk/src/webclient/import.c
===================================================================
--- trunk/src/webclient/import.c	2012-12-11 21:47:37 UTC (rev 1313)
+++ trunk/src/webclient/import.c	2012-12-11 22:01:07 UTC (rev 1314)
@@ -183,3 +183,15 @@
         close(file);
         return(found);
 }
+
+void talk_send_to_room(const char * text, int channel, const char * type, int plural) {
+	ipc_message_t * msg = ipcmsg_create(IPC_SAYTOROOM, getpid());
+	ipcmsg_destination(msg, channel);
+	json_t * j = json_init(NULL);
+	json_addstring(j, "text", text);
+	json_addstring(j, "type", type);
+	if (plural > -1) json_addint(j, "plural", plural);
+	ipcmsg_json_encode(msg, j);
+	json_decref(j);
+	ipcmsg_transmit(msg);
+}

Modified: trunk/src/webclient/import.h
===================================================================
--- trunk/src/webclient/import.h	2012-12-11 21:47:37 UTC (rev 1313)
+++ trunk/src/webclient/import.h	2012-12-11 22:01:07 UTC (rev 1314)
@@ -11,3 +11,4 @@
 void show_chatmodes(unsigned long cm, char *tmp, int flag);
 void show_chatprivs(unsigned long cp, char *tmp, int flag);
 char *remove_first_word(char *args) ;
+void talk_send_to_room(const char *text, int channel, const char *type, int plural);




More information about the mw-devel mailing list