[mw-devel] MW3 r1396 - in trunk/src: client server

arthur at sucs.org arthur at sucs.org
Tue Sep 29 16:28:37 BST 2015


Author: arthur
Date: 2015-09-29 16:28:37 +0100 (Tue, 29 Sep 2015)
New Revision: 1396

Modified:
   trunk/src/client/incoming.c
   trunk/src/server/servsock.c
Log:

Helps to display the event messages



Modified: trunk/src/client/incoming.c
===================================================================
--- trunk/src/client/incoming.c	2015-09-29 10:28:10 UTC (rev 1395)
+++ trunk/src/client/incoming.c	2015-09-29 15:28:37 UTC (rev 1396)
@@ -26,6 +26,7 @@
 #include "bb.h"
 #include "who.h"
 #include "user.h"
+#include "util.h"
 
 extern Alias rpc_list;
 extern Alias event_list;
@@ -632,6 +633,27 @@
 	
 		snprintf(tb, len, "%s shouts: %s", whom, text);
 		force_text(msg, buff, whom);
+	} else
+	if (msg->head.type == IPC_EVENT) {
+		const char * type = json_getstring(j, "type");
+		const char * text = json_getstring(j, "text");
+		const char * verbose = json_getstring(j, "verbose");
+		const char * reason = json_getstring(j, "reason");
+
+		if (verbose) force_text(msg, verbose, whom);
+		force_text(msg, text, whom);
+		if (reason) {
+			AUTOFREE_BUFFER excuse = NULL;
+			if (strcasecmp(type, "mrod")==0 || strcasecmp(type, "zod")==0) {
+				asprintf(&excuse, "Zebedee says \"%s\".", reason);
+			} else {
+				asprintf(&excuse, "%s gives the reason \"%s\".", whom, reason);
+			}
+			force_text(msg, excuse, whom);
+		} else {
+			force_text(msg, "They didn't say why...\n", whom);
+			printf("\n\nraw: %s\n\n", msg->body);
+		}
 	} else {
 		printf("Unknown message type %4.4s", (char *)&msg->head.type);
 	}
@@ -728,6 +750,7 @@
 		case IPC_SAYTOROOM:
 		case IPC_SAYTOUSER:
 		case IPC_SAYTOALL:
+		case IPC_EVENT:
 			display_content(msg);
 			break;
 		case IPC_TALKERROR:

Modified: trunk/src/server/servsock.c
===================================================================
--- trunk/src/server/servsock.c	2015-09-29 10:28:10 UTC (rev 1395)
+++ trunk/src/server/servsock.c	2015-09-29 15:28:37 UTC (rev 1396)
@@ -387,9 +387,17 @@
 		return;
 	}
 
+	if (msg->head.type == IPC_EVENT) {
+		printf("Event message\n");
+		msg_attach_to_all(msg);
+		return;
+	}
+
 	/* it was a broadcast message */
 	if (msg->head.dst == SYSTEM_USER) {
+		printf("Broadcast message to system user\n");
 		msg_attach_to_all(msg);
+		return;
 	}
 
 	/* otherwise redistribute this message to intended target */




More information about the mw-devel mailing list