[gnome-mud] A little patch



Is it ok if i submit some little patches here in the mailing list?
This one just adds a bit of code to support registered data out plugin functions, as well as adding a plugin_send_connection_data function (not much more than a macro). This patch works with anon CVS code (checked out today).
diff -u ./modules_api.c ../../gnome-mud-0.10.3-rheda/src/modules_api.c
--- ./modules_api.c	2003-09-12 12:41:02.000000000 +0200
+++ ../../gnome-mud-0.10.3-rheda/src/modules_api.c	2003-12-18 10:36:55.000000000 +0100
@@ -35,6 +35,19 @@
   popup_window (message);
 }
 
+void plugin_connection_send(CONNECTION_DATA *connection, gchar *text) {
+  gchar *s;
+
+  s=g_new(gchar,strlen(text)+2);
+  strcat(s,"\n");
+
+  //connection->connected checked inside
+  if(connection==NULL || connection->window==NULL)
+    connection_send(main_connection,s);
+  else
+    connection_send(connection,s);
+}
+
 void plugin_add_connection_text(CONNECTION_DATA *connection, gchar *message, gint color)
 {
   if (connection == NULL || connection->window == NULL)
diff -u ./modules_api.h ../../gnome-mud-0.10.3-rheda/src/modules_api.h
--- ./modules_api.h	2001-01-14 22:54:09.000000000 +0100
+++ ../../gnome-mud-0.10.3-rheda/src/modules_api.h	2003-12-18 10:15:01.000000000 +0100
@@ -28,6 +28,6 @@
 extern gboolean plugin_register_menu          (gint h, gchar *name, gchar *function );
 extern gboolean plugin_register_data_incoming (gint h, gchar *function              );
 extern gboolean plugin_register_data_outgoing (gint h, gchar *function              );
-
+extern void	plugin_connection_send        (gchar *text                          );
 
 #endif /* __MODULE__ */
diff -u ./net.c ../../gnome-mud-0.10.3-rheda/src/net.c
--- ./net.c	2003-07-14 08:31:12.000000000 +0200
+++ ../../gnome-mud-0.10.3-rheda/src/net.c	2003-12-18 10:33:33.000000000 +0100
@@ -115,9 +115,10 @@
 
 	a = g_strdup(alias->str);
 	g_string_free(alias, TRUE);
+	strcat(a,"\n"); // This way we avoid calling trigeer parsing functions twice (once with an empty parameter)
 	
-   	connection_send (connection, check_vars (connection->profile->variables, a));
-	connection_send (connection, "\n");
+	connection_send (connection, check_vars (connection->profile->variables, a));
+//	connection_send (connection, "\n");
 
 #ifndef WITHOUT_MAPPER	
 	for (puck = AutoMapList; puck!= NULL; puck = puck->next)
@@ -380,11 +381,24 @@
 
 void connection_send_data (CONNECTION_DATA *connection, gchar *message, int echo, gboolean secret)
 {
-    gint i;
-    gchar *sent;
+	gint i;
+	gchar *sent;
+	GList *t;
   
-    if (connection->connected)
-    {
+	for (t = g_list_first(Plugin_data_list); t != NULL; t = t->next) {
+		PLUGIN_DATA *pd;
+     
+		if (t->data != NULL)
+		{
+			pd = (PLUGIN_DATA *) t->data;
+			if (pd->plugin && pd->plugin->enabeled && (pd->dir == PLUGIN_DATA_OUT)) {
+				(* pd->datafunc) (pd->plugin, connection, message, GPOINTER_TO_INT(pd->plugin->handle));
+	    		}
+		}
+	}
+    
+	if (connection->connected)
+	{
 		sent = g_strdup (message);
 
 #ifdef USE_PYTHON


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]