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

tswsl1989 at sucs.org tswsl1989 at sucs.org
Sun Oct 10 16:44:38 BST 2010


Author: tswsl1989
Date: 2010-10-10 16:44:38 +0100 (Sun, 10 Oct 2010)
New Revision: 1217

Modified:
   trunk/src/webclient/comms.c
Log:
Improved rooms handling, with corrected message codes

Modified: trunk/src/webclient/comms.c
===================================================================
--- trunk/src/webclient/comms.c	2010-10-10 14:41:14 UTC (rev 1216)
+++ trunk/src/webclient/comms.c	2010-10-10 15:44:38 UTC (rev 1217)
@@ -381,15 +381,29 @@
 	if (strncasecmp(buff, "channel ", 8)==0) {
                 struct filter_info f_info;
                 char line[8192];
-		user->room = atoi(&buff[8]);
-                memset(&f_info, 0, sizeof(f_info));
-                f_info.channel = user->room;
-                snprintf(line, sizeof line, "\03312%s has just arrived in room %d", user->name, user->room);
-                ipc_send_to_all(IPC_TEXT, line, send_filter_oneroom, &f_info);
-		ipc_send_to_all(IPC_TEXT, line, send_filter_global, &f_info);
-		snprintf(buff, sizeof buff, "{\"channel\":%d}", user->room);
-		send(co->fd, buff, strlen(buff), 0);
-		return 0; // dont close
+		int oldroom;
+		int newroom;
+		oldroom = user->room;
+		newroom = atoi(&buff[8]);
+		if (newroom == oldroom) {
+			return 1;
+		}else{
+	                memset(&f_info, 0, sizeof(f_info));
+			f_info.channel = oldroom;
+			user->room = newroom;
+			snprintf(line, sizeof line, "\03313%s has left to room %d", user->name, newroom);
+			ipc_send_to_all(IPC_TEXT, line, send_filter_oneroom, &f_info);
+                	f_info.channel = user->room;
+                        snprintf(line, sizeof line, "\03314Leaving room %d for room %d",oldroom,newroom);
+                        ipc_send_to_username(user->name,IPC_TEXT,line);
+	                snprintf(line, sizeof line, "\03312%s has just arrived in room %d", user->name, user->room);
+        	        ipc_send_to_all(IPC_TEXT, line, send_filter_oneroom, &f_info);
+			ipc_send_to_all(IPC_TEXT, line, send_filter_global, &f_info);
+			//(asprintf(&buff, "Leaving room %d for room %d", oldroom, user->room)
+			snprintf(buff, sizeof buff, "{\"channel\":%d}", user->room);
+			send(co->fd, buff, strlen(buff), 0);
+			return 1; // dont close
+		}
 	}else
 	if (co->authd && strncasecmp(buff, "sayto ", 6)==0) {
 		char *tmp;




More information about the mw-devel mailing list