Update of /cvsroot/netrek/server/Vanilla/tools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1346/tools

Modified Files:
	Makefile.in players.c 
Log Message:
multicast server discovery


Index: Makefile.in
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/tools/Makefile.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Makefile.in	14 Jan 2006 00:48:08 -0000	1.3
+++ Makefile.in	22 Feb 2006 09:18:30 -0000	1.4
@@ -88,7 +88,7 @@
 	$(INSTALLPROG) $(INSTALLOPTS) ltd_dump $(DESTDIR)$(LIBDIR)/tools/ltd_dump
 	$(INSTALLPROG) $(INSTALLOPTS) updated $(DESTDIR)$(LIBDIR)/updated
 	$(INSTALLPROG) $(INSTALLOPTS) cambot $(DESTDIR)$(LIBDIR)/cambot
-	$(INSTALLPROG) $(INSTALLOPTS) metaget $(DESTDIR)$(LIBDIR)/metaget
+	$(INSTALLPROG) $(INSTALLOPTS) metaget $(DESTDIR)$(LIBDIR)/tools/metaget
 
 # cb_sock.o: packets.h ../ntserv/socket.c
 #	$(CC) -o ./cb_sock.o -g $(CFLAGS) -DCAMBOT -c ../ntserv/socket.c
@@ -176,12 +176,13 @@
 conq_vert: conq_vert.o
 	$(CC) -o $@ $(CFLAGS) ${LDFLAGS} conq_vert.o
 
+metaget: metaget.o
+	$(CC) -o $@ $(CFLAGS) ${LDFLAGS} metaget.o
+
 trekon: ${srcdir}/mktrekon ${srcdir}/trekon.bitmap ${srcdir}/trekoff.bitmap
 	${srcdir}/mktrekon $(LIBDIR)
 	chmod a+x trekon
 
-metaget: metaget.c
-
 installtrekon: trekon
 	@if [ -f $(DESTDIR)$(LIBDIR)/trekon ]; then touch $(DESTDIR)$(LIBDIR)/trekon; \
 	 else cp trekon $(DESTDIR)$(LIBDIR)/trekon; \

Index: players.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/tools/players.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- players.c	2 Jan 2006 08:07:05 -0000	1.2
+++ players.c	22 Feb 2006 09:18:30 -0000	1.3
@@ -183,6 +183,21 @@
     return 0;		/* satisfy lint */
 }
 
+/* server comment */
+static char *comment() {
+#define MAXPATH 256
+  char name[MAXPATH];
+  snprintf(name, MAXPATH, "%s/%s", SYSCONFDIR, "comment");
+  FILE *file = fopen(name, "r");
+  if (file == NULL) return "";
+  static char text[80];
+  char *res = fgets(text, 80, file);
+  fclose(file);
+  if (res == NULL) return "";
+  res[strlen(res)-1] = '\0';
+  return res;
+}
+
 /* player count on a queue */
 static int pc(int queue) {
   int j, n = 0;
@@ -215,21 +230,19 @@
   /* compose a reply packet */
   char packet[128];
   
+  /* s,type,comment,ports,port,players,queue[,port,players,queue] */
   /* if server isn't running, send simple reply */
   if (!openmem(-1)) {
-    // s,type,port,players,queue[,port,players,queue]
-    sprintf(packet, "s,B,1,2592,%d,%d\n", 0, 0);
+    sprintf(packet, "s,B,%s,1,2592,%d,%d\n", comment(), 0, 0);
   } else {
     if (status->gameup & GU_INROBOT) {
-      int q = QU_PICKUP;
-      // s,type,port,players,queue[,port,players,queue]
-      sprintf(packet, "s,B,1,2592,%d,%d\n", pc(q), ql(q));
-    } else {
       int q1 = QU_HOME;
       int q2 = QU_AWAY;
-      // s,type,port,players,queue[,port,players,queue]
-      sprintf(packet, "s,B,2,4566,%d,%d,4577,%d,%d\n", 
-	      pc(q1), ql(q1), pc(q2), ql(q2));
+      sprintf(packet, "s,B,%s,2,4566,%d,%d,4577,%d,%d\n", 
+	      comment(), pc(q1), ql(q1), pc(q2), ql(q2));
+    } else {
+      int q = QU_PICKUP;
+      sprintf(packet, "s,B,%s,1,2592,%d,%d\n", comment(), pc(q), ql(q));
     }
   }