]> skyeroc.xyz Git - dgamelaunch/commitdiff
Make watching-screen default sortmode configurable
authorPasi Kallinen <paxed@alt.org>
Sun, 6 Apr 2008 09:13:50 +0000 (09:13 +0000)
committerPasi Kallinen <paxed@alt.org>
Sun, 6 Apr 2008 09:13:50 +0000 (09:13 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@441 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

TODO
config.l
config.y
dgamelaunch.c
dgamelaunch.h
dgl-common.c
examples/dgamelaunch.conf

diff --git a/TODO b/TODO
index 83bf3d88d1e5080c6942ac1d6e6c0c877e8afc1d..8366a9324283c85cd12b4766bcb1c060fa207160 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,5 +1,3 @@
--Update dgl-wall.c or fold the functionality into dgl itself.
- (see below)
 -BUG: cannot quit watching until caught up with the stream.
 -make default_fmode configurable, and add config
  file command "chmod file mode"
@@ -8,9 +6,6 @@
 -maybe allow changing the watching-screen &c layouts too?
 -add commandline parameters to dgamelaunch:
    dgamelaunch --chpasswd "nick" "newpass"
-   dgamelaunch --wall "message to mail everyone"
- these are obviously only for the server admin...
--allow setting the default watch-screen sortmode in config file.
 -some games (robotfindskitten?) are not worth saving into ttyrecs, make it configurable.
 -allow configuring ttyplay.c; some games may use different clear-screen
  commands. (see for example crawl)
index d688637f03cdebe4188dc13befd55371115afcec..f632c52e1e3f13ba1abd9066dc02c82b9b55da23 100644 (file)
--- a/config.l
+++ b/config.l
@@ -83,6 +83,7 @@ cursor                { return TYPE_CURSOR; }
 "inprogressdir" { return TYPE_PATH_INPROGRESS; }
 "game_args"    { return TYPE_GAME_ARGS; }
 "rc_fmt"       { return TYPE_RC_FMT; }
+sortmode       { return TYPE_WATCH_SORTMODE; }
 commands       { return TYPE_CMDQUEUE; }
 yes            { yylval.i = 1; return TYPE_BOOL; }
 no             { yylval.i = 0; return TYPE_BOOL; }
index dd3a62d150b70e12604d9e4606f82b7bf318d936..973b933cbe7838df952532ad54a087018c5dc41e 100644 (file)
--- a/config.y
+++ b/config.y
@@ -34,7 +34,7 @@ static const char* lookup_token (int t);
 }
 
 %token TYPE_SUSER TYPE_SGROUP TYPE_SGID TYPE_SUID TYPE_MAX TYPE_MAXNICKLEN
-%token TYPE_GAME_SHORT_NAME
+%token TYPE_GAME_SHORT_NAME TYPE_WATCH_SORTMODE
 %token TYPE_ALLOW_REGISTRATION
 %token TYPE_PATH_GAME TYPE_NAME_GAME TYPE_PATH_DGLDIR TYPE_PATH_SPOOL
 %token TYPE_PATH_BANNER TYPE_PATH_CANNED TYPE_PATH_CHROOT
@@ -155,7 +155,20 @@ KeyPair: TYPE_CMDQUEUE '[' TYPE_CMDQUEUENAME ']'
       globalconfig.chroot = strdup ($3);
       break;
 
+  case TYPE_WATCH_SORTMODE:
+      {
+         int tmpi, okay = 0;
 
+         for (tmpi = 0; tmpi < NUM_SORTMODES; tmpi++)
+             if (!strcasecmp(SORTMODE_NAME[tmpi], $3 )) {
+                 globalconfig.sortmode = tmpi;
+                 okay = 1;
+                 break;
+             }
+         if (!okay)
+             fprintf(stderr, "%s:%d: unknown sortmode '%s'\n", config, line, $3);
+      }
+      break;
 
     case TYPE_PATH_DGLDIR:
       if (globalconfig.dglroot) free(globalconfig.dglroot);
@@ -512,6 +525,7 @@ KeyType : TYPE_SUSER        { $$ = TYPE_SUSER; }
        | TYPE_PATH_LOCKFILE    { $$ = TYPE_PATH_LOCKFILE; }
        | TYPE_PATH_INPROGRESS  { $$ = TYPE_PATH_INPROGRESS; }
        | TYPE_RC_FMT           { $$ = TYPE_RC_FMT; }
+       | TYPE_WATCH_SORTMODE   { $$ = TYPE_WATCH_SORTMODE; }
        ;
 
 %%
@@ -538,6 +552,7 @@ const char* lookup_token (int t)
     case TYPE_PATH_INPROGRESS: return "inprogressdir";
     case TYPE_GAME_ARGS: return "game_args";
     case TYPE_RC_FMT: return "rc_fmt";
+    case TYPE_WATCH_SORTMODE: return "sortmode";
     default: abort();
   }
 }
index 57ddc7342002ba906fdb71b36a07d10e29c91381..20ca6e4e0cd74cc025f0a0ad0253520a989e3c3e 100644 (file)
@@ -355,13 +355,16 @@ void
 inprogressmenu (int gameid)
 {
   int i, menuchoice, len = 20, offset = 0, doresizewin = 0;
-  static dg_sortmode sortmode = SORTMODE_NONE;
+  static dg_sortmode sortmode = NUM_SORTMODES;
   time_t ctime;
   struct dg_game **games;
   char ttyrecname[130], *replacestr = NULL, gametype[10];
   int is_nhext[14];
   sigset_t oldmask, toblock;
 
+  if (sortmode == NUM_SORTMODES)
+      sortmode = globalconfig.sortmode;
+
   games = populate_games (gameid, &len);
   games = sort_games (games, len, sortmode);
 
index 351ebcb26204bdabdbf9889e755d30a57f99a0c7..8970919c302571604353a0d5faaadf3406805334 100644 (file)
@@ -110,6 +110,7 @@ struct dg_globalconfig
     char* passwd;
     char* lockfile;
     int allow_registration; /* allow registering new nicks */
+    int sortmode; /* default watching-screen sortmode */
 
     struct dg_cmdpart *cmdqueue[NUM_DGLTIMES];
 
@@ -146,11 +147,10 @@ typedef enum
     NUM_SORTMODES
 } dg_sortmode;
 
-static const char *SORTMODE_NAME[] = {
+static const char *SORTMODE_NAME[NUM_SORTMODES] = {
     "Unsorted",
     "Username",
-    "Idletime",
-    "",
+    "Idletime"
 };
 
 
index be04fc28c76f5fe20c0c558461c37d4ca1d9d5b9..efd648d3913e12726743bb7d60e3a72f71ebd720 100644 (file)
@@ -528,6 +528,8 @@ create_config ()
   if (!globalconfig.allow_registration) globalconfig.allow_registration = 1;
   globalconfig.menulist = NULL;
 
+  globalconfig.sortmode = SORTMODE_NONE;
+
   if (config)
   {
     if ((config_file = fopen(config, "r")) != NULL)
index 62fa1dfd65e96378e873c8ea261b8c66ba2f270a..d89a198faba29aeec9343f92d36f37bf81347227 100644 (file)
@@ -19,6 +19,10 @@ allow_new_nicks = yes
 # the record/logfile.
 maxnicklen = 10
 
+# Set the default watching-screen sorting mode. Can be one of
+# "unsorted", "username" or "idletime".  Unsorted is the default.
+#sortmode = "username"
+
 # Path to a prepared chroot jail.
 chroot_path = "/var/lib/dgamelaunch/"