[mw-devel] MW3 r1319 - in trunk/src: . server

arthur at sucs.org arthur at sucs.org
Sun Dec 30 17:11:57 GMT 2012


Author: arthur
Date: 2012-12-30 17:11:56 +0000 (Sun, 30 Dec 2012)
New Revision: 1319

Modified:
   trunk/src/rooms.c
   trunk/src/rooms.h
   trunk/src/server/Makefile
   trunk/src/server/servsock.c
   trunk/src/talker.c
   trunk/src/talker.h
Log:
Forgot to impliment global mode on SAYTOROOM


Modified: trunk/src/rooms.c
===================================================================
--- trunk/src/rooms.c	2012-12-30 15:56:36 UTC (rev 1318)
+++ trunk/src/rooms.c	2012-12-30 17:11:56 UTC (rev 1319)
@@ -9,15 +9,6 @@
 #include "rooms.h"
 #include "util.h"
 
-extern unsigned long rights;
-#define MAX_ARGC 128
-
-extern CommandList chattable[];
-extern struct person *user;
-extern long userposn;
-extern unsigned long rights;
-extern int busy;
-
 struct room myroom;
 
 int isanum(char *a, int *result, int onlydecimal);
@@ -66,102 +57,3 @@
 
 	return 1;
 }
-
-/* changes room, returning error code on failure
- * 0 - ok
- * 1 - hidden/locked
- * 2 - frozen
- * 3 - invalid direction/room
- * 4 - invalid number
- * 5 - OOM
- */
-int ChangeRoom(char *room, int quiet)
-{
-	struct room tmp;
-	int i;
-	unsigned short oldroom = user->room;
-	AUTOFREE_BUFFER buff=NULL;
-
-	if (cm_flags(user->chatmode,CM_FROZEN,CM_MODE_ANY))
-	{
-		return(2);
-	}
-
-	i = 0;
-	if (isanum(room, &i, 1))
-	{
-		if (i>=0 && i<=65535)
-		{
-			RoomInit(&tmp);
-			if (LoadRoom(&tmp, i))
-			{
-				int found = 1;
-
-				if (tmp.locked>0) found = 0;
-
-				if (!found)
-				{
-					RoomDestroy(&tmp);
-					return(1);
-				}
-			}
-			else
-			{
-				user->room=i;
-			}
-			RoomDestroy(&tmp);
-		}
-		else
-		{
- 			return(4);
-		}
-
-		if (i==oldroom)
-		{
-			if (!quiet) printf("You are already in room %d\n", i);
-		}
-		else
-		{
-			if (asprintf(&buff, "\03312%s has just arrived in room %d", user->name, i) < 0)
-			{
-				return 5;
-			}
-			if (!quiet) talk_send_raw(buff, i);
-			user->room = i;
-			update_user(user, userposn);
-
-			RoomDestroy(&myroom);
-			RoomInit(&myroom);
-			LoadRoom(&myroom, user->room);
-
-			SAFE_FREE(buff);
-			if (asprintf(&buff, "\03313%s has left to room %d", user->name, i) < 0)
-			{
-				return 5;
-			}
-			if (!quiet) talk_send_raw(buff, oldroom);
-			SAFE_FREE(buff);
-			if (asprintf(&buff, "Leaving room %d for room %d", oldroom, user->room) < 0)
-			{
-				return 5;
-			}
-			if (!quiet) display_message(buff, 1, 1);
-
-			{
-				char *topic = db_room_get(user->room, "topic");
-				if (topic != NULL && *topic != 0) {
-					SAFE_FREE(buff);
-					asprintf(&buff, "Topic: %s\n", topic);
-					display_message(buff, 1, 1);
-				}
-				if (topic != NULL) free(topic);
-			}
-		}
-	}
-	else
-	{
-		return(4);
-	}
-
-	return(0);
-}

Modified: trunk/src/rooms.h
===================================================================
--- trunk/src/rooms.h	2012-12-30 15:56:36 UTC (rev 1318)
+++ trunk/src/rooms.h	2012-12-30 17:11:56 UTC (rev 1319)
@@ -17,6 +17,5 @@
 void RoomInit(struct room *room);
 void RoomDestroy(struct room *room);
 int LoadRoom(struct room *room, int num);
-int ChangeRoom(char *room, int quiet);
 
 #endif /* ROOMS_H */

Modified: trunk/src/server/Makefile
===================================================================
--- trunk/src/server/Makefile	2012-12-30 15:56:36 UTC (rev 1318)
+++ trunk/src/server/Makefile	2012-12-30 17:11:56 UTC (rev 1319)
@@ -23,7 +23,7 @@
 DEFS+= -DMSGDIR=\"$(MSGDIR)\"
 
 ### uncomment for gdb debugging
-LDFLAGS+= -ggdb -g -lcrypt -lpq -ljansson
+LDFLAGS+= -ggdb -g -lcrypt -lpq -ljansson -lsqlite3
 CFLAGS+= -ggdb -g -D__NO_STRING_INLINE -fstack-protector-all
 
 ### Optimisation - uncomment for release & extra testing
@@ -46,7 +46,7 @@
 
 .PHONY: build install clean test
 
-mwserv: mwserv.o servsock.o ../socket.o ../files.o ../strings.o ../ipc.o ../iconv.o ../nonce.o
+mwserv: mwserv.o servsock.o ../socket.o ../files.o ../strings.o ../ipc.o ../iconv.o ../nonce.o ../rooms.o ../sqlite.o
 	$(CC) $(LDFLAGS) $(LDLIBS) -o $@ $^
 
 clean:

Modified: trunk/src/server/servsock.c
===================================================================
--- trunk/src/server/servsock.c	2012-12-30 15:56:36 UTC (rev 1318)
+++ trunk/src/server/servsock.c	2012-12-30 17:11:56 UTC (rev 1319)
@@ -18,6 +18,8 @@
 #include "../nonce.h"
 #include "../util.h"
 #include "../who.h"
+#include "../rooms.h"
+#include "../talker_privs.h"
 
 struct list_head connection_list;
 
@@ -307,6 +309,10 @@
 
 		const char * exclude = json_getstring(j, "exclude");
 
+		struct room room;
+		RoomInit(&room);
+		LoadRoom(&room, msg->head.dst);
+
 		while (read(who_fd, &who, sizeof(who)) > 0) {
 			if (who.posn < 0) continue;
 			if (who.pid <= 0) continue;
@@ -320,8 +326,13 @@
 			/* room matches, send them a copy */
 			if (user.room == msg->head.dst) {
 				msg_attach_to(msg, who.pid);
+			} else
+			/* room not soundproof, and user has global on */
+			if (room.sproof == 0 && (user.chatmode & CM_GLOBAL)) {
+				msg_attach_to(msg, who.pid);
 			}
 		}
+		RoomDestroy(&room);
 		json_decref(j);
 		close(who_fd);
 		close(users_fd);

Modified: trunk/src/talker.c
===================================================================
--- trunk/src/talker.c	2012-12-30 15:56:36 UTC (rev 1318)
+++ trunk/src/talker.c	2012-12-30 17:11:56 UTC (rev 1319)
@@ -1638,3 +1638,102 @@
 		if (!found) printf("Sorry, no help available on that subject.\n");
 	}
 }
+
+/* changes room, returning error code on failure
+ * 0 - ok
+ * 1 - hidden/locked
+ * 2 - frozen
+ * 3 - invalid direction/room
+ * 4 - invalid number
+ * 5 - OOM
+ */
+int ChangeRoom(char *room, int quiet)
+{
+	struct room tmp;
+	int i;
+	unsigned short oldroom = user->room;
+	AUTOFREE_BUFFER buff=NULL;
+
+	if (cm_flags(user->chatmode,CM_FROZEN,CM_MODE_ANY))
+	{
+		return(2);
+	}
+
+	i = 0;
+	if (isanum(room, &i, 1))
+	{
+		if (i>=0 && i<=65535)
+		{
+			RoomInit(&tmp);
+			if (LoadRoom(&tmp, i))
+			{
+				int found = 1;
+
+				if (tmp.locked>0) found = 0;
+
+				if (!found)
+				{
+					RoomDestroy(&tmp);
+					return(1);
+				}
+			}
+			else
+			{
+				user->room=i;
+			}
+			RoomDestroy(&tmp);
+		}
+		else
+		{
+ 			return(4);
+		}
+
+		if (i==oldroom)
+		{
+			if (!quiet) printf("You are already in room %d\n", i);
+		}
+		else
+		{
+			if (asprintf(&buff, "\03312%s has just arrived in room %d", user->name, i) < 0)
+			{
+				return 5;
+			}
+			if (!quiet) talk_send_raw(buff, i);
+			user->room = i;
+			update_user(user, userposn);
+
+			RoomDestroy(&myroom);
+			RoomInit(&myroom);
+			LoadRoom(&myroom, user->room);
+
+			SAFE_FREE(buff);
+			if (asprintf(&buff, "\03313%s has left to room %d", user->name, i) < 0)
+			{
+				return 5;
+			}
+			if (!quiet) talk_send_raw(buff, oldroom);
+			SAFE_FREE(buff);
+			if (asprintf(&buff, "Leaving room %d for room %d", oldroom, user->room) < 0)
+			{
+				return 5;
+			}
+			if (!quiet) display_message(buff, 1, 1);
+
+			{
+				char *topic = db_room_get(user->room, "topic");
+				if (topic != NULL && *topic != 0) {
+					SAFE_FREE(buff);
+					asprintf(&buff, "Topic: %s\n", topic);
+					display_message(buff, 1, 1);
+				}
+				if (topic != NULL) free(topic);
+			}
+		}
+	}
+	else
+	{
+		return(4);
+	}
+
+	return(0);
+}

Modified: trunk/src/talker.h
===================================================================
--- trunk/src/talker.h	2012-12-30 15:56:36 UTC (rev 1318)
+++ trunk/src/talker.h	2012-12-30 17:11:56 UTC (rev 1319)
@@ -81,4 +81,6 @@
 void sendipc(char *to, char *text, int broadcast);
 void sendrpc(char *to, char *type, char *text, int broadcast);
 
+int ChangeRoom(char *room, int quiet);
+
 #endif /* TALKER_H */




More information about the mw-devel mailing list