Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11620) Server ID for pubserver and metaserver
Home

[Freeciv-Dev] (PR#11620) Server ID for pubserver and metaserver

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11620) Server ID for pubserver and metaserver
From: "Paul Zastoupil" <paul@xxxxxxxxxxxxx>
Date: Mon, 20 Dec 2004 08:37:00 -0800
Reply-to: bugs@xxxxxxxxxxx

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

I was talking to Mike one day and we both thought it would be a nice
idea if you could tell the server its "id".  This would be reported to
the metaserver as well as in the server itself so that players could
tell what game they were playing on.

On pubserver this would let them know which number the game they were
connected to had.

Attached is a proof of concept, its not large.

This will require a change to the metaserver, which I can as well.  It
might also be nice to change the auth db to report the serverid, which I
haven't even looked at yet.

-- 
Paul Zastoupil
Index: server/civserver.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/civserver.c,v
retrieving revision 1.226
diff -u -r1.226 civserver.c
--- server/civserver.c  26 Nov 2004 22:28:43 -0000      1.226
+++ server/civserver.c  20 Dec 2004 16:30:37 -0000
@@ -126,6 +126,9 @@
        break;
       }
       free(option);
+    } else if ((option = get_option_malloc("--Serverid", argv, &inx, argc))) {
+      sz_strlcpy(srvarg.serverid, option);
+      free(option);
     } else if (is_option("--auth", argv[inx])) {
       srvarg.auth_enabled = TRUE;
     } else if (is_option("--Guests", argv[inx])) {
@@ -189,6 +192,8 @@
                      "When a game ends, exit instead of restarting\n"));
     fc_fprintf(stderr,
               _("  -s, --saves DIR\tSave games to directory DIR\n"));
+    fc_fprintf(stderr,
+              _("  -S, --Serverid ID\tSets the server id to ID\n"));
     fc_fprintf(stderr, _("  -r, --read FILE\tRead startup script FILE\n"));
     fc_fprintf(stderr, _("  -v, --version\t\tPrint the version number\n"));
     fc_fprintf(stderr, _("Report bugs to <%s>.\n"), BUG_EMAIL_ADDRESS);
Index: server/commands.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/commands.c,v
retrieving revision 1.4
diff -u -r1.4 commands.c
--- server/commands.c   22 Oct 2004 04:08:28 -0000      1.4
+++ server/commands.c   20 Dec 2004 16:30:37 -0000
@@ -356,6 +356,10 @@
   {"rfcstyle", ALLOW_HACK,
    "rfcstyle",
    N_("Switch server output between 'RFC-style' and normal style."), NULL
+  },
+  {"serverid", ALLOW_INFO,
+   N_("serverid"),
+   N_("Simply returns the id of the server."),
   }
 };
 
Index: server/commands.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/commands.h,v
retrieving revision 1.2
diff -u -r1.2 commands.h
--- server/commands.h   4 Oct 2004 04:37:33 -0000       1.2
+++ server/commands.h   20 Dec 2004 16:30:37 -0000
@@ -78,6 +78,7 @@
 
   /* undocumented */
   CMD_RFCSTYLE,
+  CMD_SRVID,
 
   /* pseudo-commands: */
   CMD_NUM,             /* the number of commands - for iterations */
Index: server/meta.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/meta.c,v
retrieving revision 1.65
diff -u -r1.65 meta.c
--- server/meta.c       12 Nov 2004 02:54:29 -0000      1.65
+++ server/meta.c       20 Dec 2004 16:30:37 -0000
@@ -244,6 +244,10 @@
                 my_url_encode(get_meta_topic_string()));
     s = end_of_strn(s, &rest);
 
+    my_snprintf(s, rest, "serverid=%s&",
+                my_url_encode(srvarg.serverid));
+    s = end_of_strn(s, &rest);
+
     my_snprintf(s, rest, "message=%s&",
                 my_url_encode(get_meta_message_string()));
     s = end_of_strn(s, &rest);
Index: server/srv_main.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.h,v
retrieving revision 1.25
diff -u -r1.25 srv_main.h
--- server/srv_main.h   18 Oct 2004 23:49:27 -0000      1.25
+++ server/srv_main.h   20 Dec 2004 16:30:37 -0000
@@ -38,6 +38,7 @@
   char load_filename[512]; /* FIXME: may not be long enough? use MAX_PATH? */
   char *script_filename;
   char *saves_pathname;
+  char serverid[256];
   /* quit if there no players after a given time interval */
   int quitidle;
   /* exit the server on game ending */
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.371
diff -u -r1.371 stdinhand.c
--- server/stdinhand.c  9 Dec 2004 16:38:35 -0000       1.371
+++ server/stdinhand.c  20 Dec 2004 16:30:37 -0000
@@ -647,6 +647,17 @@
   return TRUE;
 }
 
+/**************************************************************************
+ Returns the serverid 
+**************************************************************************/
+static bool show_serverid(struct connection *caller, char *arg)
+{
+  cmd_reply(CMD_SRVID, caller, C_COMMENT, _("Server id: %s"),srvarg.serverid);
+
+
+  return TRUE;
+}
+
 /***************************************************************
  This could be in common/player if the client ever gets
  told the ai player skill levels.
@@ -3379,6 +3390,8 @@
     return metaserver_command(caller, arg, check);
   case CMD_HELP:
     return show_help(caller, arg);
+  case CMD_SRVID:
+    return show_serverid(caller, arg);
   case CMD_LIST:
     return show_list(caller, arg);
   case CMD_AITOGGLE:

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#11620) Server ID for pubserver and metaserver, Paul Zastoupil <=