[mw-devel] MW3 r1359 - trunk/src/client

arthur at sucs.org arthur at sucs.org
Tue Nov 26 17:22:30 GMT 2013


Author: arthur
Date: 2013-11-26 17:22:29 +0000 (Tue, 26 Nov 2013)
New Revision: 1359

Modified:
   trunk/src/client/chattable.c
   trunk/src/client/incoming.c
   trunk/src/client/talker.c
   trunk/src/client/talker.h
Log:
Abstract out the common code to tell you the room topic, make it also tell you if the room is soundproof, call it after being summoned. add command to toggle soundproof


Modified: trunk/src/client/chattable.c
===================================================================
--- trunk/src/client/chattable.c	2013-11-07 15:15:23 UTC (rev 1358)
+++ trunk/src/client/chattable.c	2013-11-26 17:22:29 UTC (rev 1359)
@@ -66,6 +66,8 @@
 {"script"	,0x0200	,0, "Usage: script [function]", "List script functions, or source code for [function]", t_script, 1},
 {"shout"	,0x0000	,1, "Usage: shout <message>", "Send message to all rooms", t_shout, 1},
 {"spy"		,0x0100	,1, "Usage: spy <on|off>", "Spy mode - see who said what", t_spy, 1},
+{"sproof"	,0x0800	,0, "Usage: sproof <on|off>", "Sound Proof this room", t_sproof, 1},
+{"soundproof"	,0x0800	,0, "Usage: sproof <on|off>", "Sound Proof this room", t_sproof, 1},
 {"sticky"	,0x0000	,1, "Usage: sticky <on|off>", "Log back on to the room you logged off from", t_sticky, 1},
 {"summon"	,0x0080	,2, "Usage: summon <room> <user> [<user>...]", "Force user(s) to move into a room", t_summon, 1},
 {"tcunames"	,0x0000, 1, "Usage: tcunames <on|off>", "Allow tab-completion of username on talker", t_tcunames, 1},

Modified: trunk/src/client/incoming.c
===================================================================
--- trunk/src/client/incoming.c	2013-11-07 15:15:23 UTC (rev 1358)
+++ trunk/src/client/incoming.c	2013-11-26 17:22:29 UTC (rev 1359)
@@ -962,6 +962,7 @@
 			display_message(text, 1, 1);
 			set_talk_rights();
 			user->room=newroom;
+
 			snprintf(text,MAXTEXTLENGTH-1,"\03310%s has just been summoned into talker room %d by %s",user->name,newroom,from);
 			talk_send_rawbcast(text);
 			user->chatmode=cm_flags(user->chatmode,CM_ONCHAT,CM_MODE_SET);
@@ -979,6 +980,7 @@
 			/* give an entrance broadcast */
 			broadcast_onoffcode(1, 1, from, NULL);
 
+			enter_room(newroom);
 		}
 	}else
 	{
@@ -1003,6 +1005,7 @@
 			RoomDestroy(&myroom);
 			RoomInit(&myroom);
 			LoadRoom(&myroom, newroom);
+			enter_room(newroom);
 		}
 	}
 	disable_rl(1);

Modified: trunk/src/client/talker.c
===================================================================
--- trunk/src/client/talker.c	2013-11-07 15:15:23 UTC (rev 1358)
+++ trunk/src/client/talker.c	2013-11-26 17:22:29 UTC (rev 1359)
@@ -772,6 +772,46 @@
 	update_user(user,userposn);
 }
 
+void t_sproof(CommandList *cm, int argc, const char **argv, char *args)
+{
+	if(argc == 1) {
+		char * sproof = db_room_get(user->room, "soundproof");
+		if (sproof == NULL || sproof[0]!='1')
+			display_message("This room is not soundproof.", 0, 1);
+		else
+			display_message("This room is soundproof.", 0, 1);
+		if (sproof != NULL) free(sproof);
+
+		return;
+	}
+
+	int z=BoolOpt(argv[1]);
+	char * was = db_room_get(user->room, "soundproof");
+	if ( z == 1) {
+		if (was !=NULL && was[0] == '1') {
+			display_message("This room is already soundproof.", 0, 1);
+		} else {
+			db_room_set(user->room, "soundproof", "1");
+			char text[MAXTEXTLENGTH];
+			snprintf(text,MAXTEXTLENGTH-1,"\03315%s has just soundproofed this room.",user->name);
+			talk_send_raw(text,user->room);
+		}
+	} else
+	if (z == 0) {
+		if (was == NULL || was[0]!='1') {
+			display_message("This room was not soundproof.", 0, 1);
+		} else {
+			db_room_set(user->room, "soundproof", "0");
+			char text[MAXTEXTLENGTH];
+			snprintf(text,MAXTEXTLENGTH-1,"\03315%s has just removed the soundproofing for this room.",user->name);
+			talk_send_raw(text,user->room);
+		}
+	}
+	free(was);
+	//JSM
+}
+
+
 void t_protect(CommandList *cm, int argc, const char **argv, char *args)
 {
 	char text[MAXTEXTLENGTH];
@@ -1451,16 +1491,27 @@
 	/* give an entrance broadcast */
 	broadcast_onoffcode(1, 0, NULL, NULL);
 
-	char *topic = db_room_get(user->room, "topic");
-	if (topic == NULL)
-		return;
+	enter_room(user->room);
+}
 
-	if (*topic != 0) {
-		AUTOFREE_BUFFER buff=NULL;
-		asprintf(&buff, "Topic: %s\n", topic);
-		display_message(buff, 0, 1);
+void enter_room(int room)
+{
+	char *topic = db_room_get(room, "topic");
+	if (topic != NULL) {
+		if (*topic != 0) {
+			AUTOFREE_BUFFER buff=NULL;
+			asprintf(&buff, "Topic: %s\n", topic);
+			display_message(buff, 0, 1);
+		}
+		free(topic);
 	}
-	free(topic);
+	char * sproof = db_room_get(room, "soundproof");
+	if (sproof != NULL) {
+		if (strcasecmp(sproof, "1")==0) {
+			display_message("This room is soundproofed.\n", 0, 1);
+		}
+		free(sproof);
+	}
 }
 
 /**** actual talker utilities *****/
@@ -1718,15 +1769,7 @@
 			}
 			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);
-			}
+			enter_room(user->room);
 		}
 	}
 	else

Modified: trunk/src/client/talker.h
===================================================================
--- trunk/src/client/talker.h	2013-11-07 15:15:23 UTC (rev 1358)
+++ trunk/src/client/talker.h	2013-11-26 17:22:29 UTC (rev 1359)
@@ -55,6 +55,7 @@
 void t_sticky(CommandList *cm, int argc, const char **argv, char *args);
 void t_tcunames(CommandList *cm, int argc, const char **argv, char *args);
 void t_spy(CommandList *cm, int argc, const char **argv, char *args);
+void t_sproof(CommandList *cm, int argc, const char **argv, char *args);
 void t_showvars(CommandList *cm, int argc, const char **argv, char *args);
 void t_linewrap(CommandList *cm, int argc, const char **argv, char *args);
 void t_mwrc(CommandList *cm, int argc, const char **argv, char *args);
@@ -82,5 +83,6 @@
 void sendrpc(char *to, char *type, char *text, int broadcast);
 
 int ChangeRoom(char *room, int quiet);
+void enter_room(int room);
 
 #endif /* TALKER_H */




More information about the mw-devel mailing list