Silence of the Robots
a patch against Teg v0.11.2
By Patrik Nilsson <blambi@chebab.com>

Notes:
This patch adds a function to check if a player is a human easily.
And a option to toggle if the player wish to hear the bots babble.

Also fixes the bug related to msg_show_colors.

diff -Nuar teg-0.11.2/client/gui-gnome/chatline.c teg-0.11.2-silence-of-the-robots/client/gui-gnome/chatline.c
--- teg-0.11.2/client/gui-gnome/chatline.c	2002-09-21 19:56:38.000000000 +0200
+++ teg-0.11.2-silence-of-the-robots/client/gui-gnome/chatline.c	2007-08-06 02:28:26.000000000 +0200
@@ -92,6 +92,9 @@
 	GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(main_message_area) );
 	gchar *ptr_name, *ptr_msg;
 
+	if( ! is_color_human(num) && ! gui_private.msg_show_robot )
+		return TEG_STATUS_SUCCESS; /* Silence of the evil machines */
+	
 	snprintf(name,sizeof(name)-1,"<%s>",n);
 	name[sizeof(name)-1] = 0;
 
@@ -136,6 +139,19 @@
 	gtk_text_buffer_set_text(buf, text, -1);
 }
 
+
+/* is color belonging to a human? */
+int * is_color_human( int color )
+{
+	PCPLAYER pJ;
+
+	if(player_whois(color,&pJ) != TEG_STATUS_SUCCESS) {
+		return FALSE;
+	}
+	
+	return pJ->human;
+}
+
 TEG_STATUS chatline_init()
 {
 	GtkTextBuffer *buffer;
diff -Nuar teg-0.11.2/client/gui-gnome/chatline.h teg-0.11.2-silence-of-the-robots/client/gui-gnome/chatline.h
--- teg-0.11.2/client/gui-gnome/chatline.h	2002-08-13 03:59:35.000000000 +0200
+++ teg-0.11.2-silence-of-the-robots/client/gui-gnome/chatline.h	2007-08-06 02:03:57.000000000 +0200
@@ -23,5 +23,6 @@
 TEG_STATUS gui_textmsg(char *astring);
 TEG_STATUS gui_textplayermsg(char *name, int nj, char *msg);
 TEG_STATUS chatline_init();
+int * is_color_human( int color );
 
 #endif  /* __TEG_GUI_GNOME_CHATLINE_H */
diff -Nuar teg-0.11.2/client/gui-gnome/gui.c teg-0.11.2-silence-of-the-robots/client/gui-gnome/gui.c
--- teg-0.11.2/client/gui-gnome/gui.c	2006-03-12 18:41:21.000000000 +0100
+++ teg-0.11.2-silence-of-the-robots/client/gui-gnome/gui.c	2007-08-06 10:45:45.000000000 +0200
@@ -270,6 +268,7 @@
 
 	g_game.msg_show = gconf_client_get_int( g_conf_client, "/apps/teg/msgshow",NULL);
 	gui_private.msg_show_colors =  gconf_client_get_bool( g_conf_client, "/apps/teg/msgshow_with_color",NULL);
+	gui_private.msg_show_robot =  gconf_client_get_bool( g_conf_client, "/apps/teg/msgshow_robot",NULL);
 	gui_private.dialog_show =  gconf_client_get_int( g_conf_client, "/apps/teg/dialog_show",NULL);
 	string = gconf_client_get_string( g_conf_client, "/apps/teg/theme",NULL);
 	if( string )
diff -Nuar teg-0.11.2/client/gui-gnome/preferences.c teg-0.11.2-silence-of-the-robots/client/gui-gnome/preferences.c
--- teg-0.11.2/client/gui-gnome/preferences.c	2002-10-08 06:35:57.000000000 +0200
+++ teg-0.11.2-silence-of-the-robots/client/gui-gnome/preferences.c	2007-08-06 02:22:50.000000000 +0200
@@ -43,6 +43,7 @@
 static GtkWidget	*conf_cb_showimp=NULL;
 static GtkWidget	*conf_cb_showmsg=NULL;
 static GtkWidget	*conf_cb_showmsgcolor=NULL;
+static GtkWidget	*conf_cb_showmsgrobot=NULL; /* NOTE: for silence... */
 static GtkWidget	*conf_cb_showinf=NULL;
 
 /** dialogs */
@@ -172,6 +173,12 @@
 		gui_private.msg_show_colors = 0;
 
 
+	if (GTK_TOGGLE_BUTTON( conf_cb_showmsgrobot )->active)
+		gui_private.msg_show_robot = 1;
+	else
+		gui_private.msg_show_robot = 0;
+
+
 	if (GTK_TOGGLE_BUTTON( conf_cb_showinf )->active)
 		g_game.msg_show |= M_INF;
 	else
@@ -243,6 +250,7 @@
 	/* save new configurations */
 	gconf_client_set_int( g_conf_client, "/apps/teg/msgshow",g_game.msg_show, NULL);
 	gconf_client_set_bool( g_conf_client, "/apps/teg/msgshow_with_color",gui_private.msg_show_colors, NULL);
+	gconf_client_set_bool( g_conf_client, "/apps/teg/msgshow_robot",gui_private.msg_show_robot, NULL);
 	gconf_client_set_int( g_conf_client, "/apps/teg/status_show",gui_private.status_show, NULL);
 	gconf_client_set_int( g_conf_client, "/apps/teg/dialog_show",gui_private.dialog_show, NULL);
 	gconf_client_set_bool( g_conf_client, "/apps/teg/robot_in_server",g_game.robot_in_server, NULL);
@@ -372,6 +380,12 @@
 	gtk_signal_connect (GTK_OBJECT (conf_cb_showmsgcolor), "clicked", GTK_SIGNAL_FUNC
 			(prop_box_changed_callback), NULL);
 
+	conf_cb_showmsgrobot = gtk_check_button_new_with_label(_("Show Robots Messages"));
+	GTK_TOGGLE_BUTTON(conf_cb_showmsgrobot)->active = (gui_private.msg_show_robot & 1) ?1:0;
+	gtk_box_pack_start( GTK_BOX( vbox ), conf_cb_showmsgrobot, FALSE, FALSE, 0);
+	gtk_signal_connect (GTK_OBJECT (conf_cb_showmsgrobot), "clicked", GTK_SIGNAL_FUNC
+			(prop_box_changed_callback), NULL);
+
 	conf_cb_showinf = gtk_check_button_new_with_label(_("Show Informative Messages"));
 	GTK_TOGGLE_BUTTON(conf_cb_showinf)->active = (g_game.msg_show & M_INF) ?1:0;
 	gtk_box_pack_start( GTK_BOX( vbox ), conf_cb_showinf, FALSE, FALSE, 0);
diff -Nuar teg-0.11.2/client/gui-gnome/priv.c teg-0.11.2-silence-of-the-robots/client/gui-gnome/priv.c
--- teg-0.11.2/client/gui-gnome/priv.c	2002-10-14 05:26:36.000000000 +0200
+++ teg-0.11.2-silence-of-the-robots/client/gui-gnome/priv.c	2007-08-06 10:45:06.000000000 +0200
@@ -39,7 +39,6 @@
 {
 	gui_private.tag = -1;
 	gui_private.tag_ggz = -1;
-	gui_private.msg_show_colors = 0;
 	gui_private.country_i_am = -1;
 
 	return TEG_STATUS_SUCCESS;
diff -Nuar teg-0.11.2/client/gui-gnome/priv.h teg-0.11.2-silence-of-the-robots/client/gui-gnome/priv.h
--- teg-0.11.2/client/gui-gnome/priv.h	2002-10-14 01:29:08.000000000 +0200
+++ teg-0.11.2-silence-of-the-robots/client/gui-gnome/priv.h	2007-08-06 02:14:29.000000000 +0200
@@ -35,6 +35,7 @@
 	int tag;
 	int tag_ggz;
 	BOOLEAN msg_show_colors;
+	BOOLEAN msg_show_robot; /* Show what the brainless robots say */
 	unsigned int status_show;	/* what columns to show in the status window */
 	unsigned int dialog_show;	/* what dialogs to show */
 	int country_i_am;		/* what country i'm pointing */
