<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40357 >

This patch fixes several buggy GGZ server event handlers:

* The spectator events are actually unused since we don't support 
spectators yet.  But they should all go to the spectator handler.

* The error event must be handled, by exiting the server properly.

This is a pretty severe error so I'll commit these immediately.

-jason

Index: server/ggzserver.c
===================================================================
--- server/ggzserver.c	(revision 14950)
+++ server/ggzserver.c	(working copy)
@@ -31,6 +31,7 @@
 #include "ggzserver.h"
 #include "score.h"
 #include "sernet.h"
+#include "srv_main.h"
 
 bool with_ggz = FALSE;
 
@@ -173,6 +174,19 @@
 }
 
 /****************************************************************************
+  Handles a ggzdmod error.  This simply exits the server with an error
+  message.
+****************************************************************************/
+static void handle_ggz_error(GGZdMod * ggz, GGZdModEvent event,
+			     const void *data)
+{
+  const char *err = data;
+
+  freelog(LOG_ERROR, "Error in ggz: %s", err);
+  server_quit();
+}
+
+/****************************************************************************
   Connect to the GGZ server, if GGZ is being used.
 ****************************************************************************/
 void ggz_initialize(void)
@@ -199,6 +213,12 @@
 			&handle_ggz_seat_event);
     ggzdmod_set_handler(ggzdmod, GGZDMOD_EVENT_SPECTATOR_JOIN,
 			&handle_ggz_spectator_seat_event);
+    ggzdmod_set_handler(ggzdmod, GGZDMOD_EVENT_SPECTATOR_LEAVE,
+			&handle_ggz_spectator_seat_event);
+    ggzdmod_set_handler(ggzdmod, GGZDMOD_EVENT_SPECTATOR_SEAT,
+			&handle_ggz_spectator_seat_event);
+    ggzdmod_set_handler(ggzdmod, GGZDMOD_EVENT_ERROR,
+    			&handle_ggz_error);
     if (ggzdmod_connect(ggzdmod) < 0) {
       exit(EXIT_FAILURE);
     }
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to