]> skyeroc.xyz Git - dgamelaunch/commitdiff
Allow any number of different games per dgl installation without needing to recompile.
authorPasi Kallinen <paxed@alt.org>
Sat, 5 Apr 2008 22:55:46 +0000 (22:55 +0000)
committerPasi Kallinen <paxed@alt.org>
Sat, 5 Apr 2008 22:55:46 +0000 (22:55 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@437 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

config.y
configure.ac
dgamelaunch.h
dgl-common.c

index 3f272fa955a5ff0e0684d0715e55d53d0c5ed51d..dd3a62d150b70e12604d9e4606f82b7bf318d936 100644 (file)
--- a/config.y
+++ b/config.y
@@ -414,19 +414,25 @@ game_definitions : game_definition
 
 definegame : TYPE_DEFINE_GAME '{'
        {
-           if ((ncnf < 0) || (ncnf >= DIFF_GAMES)) {
-               fprintf(stderr, "%s:%d: too many games defined, bailing out\n",
+           struct dg_config **tmpconfig = NULL;
+
+           tmpconfig = calloc(ncnf + 1, sizeof(myconfig[0]));
+           if (!tmpconfig) {
+               fprintf(stderr, "%s:%d: could not allocate memory for config, bailing out\n",
                        config, line);
                exit(1);
            }
 
-           if (!myconfig) {
+           if (myconfig) {
                int tmp;
-               myconfig = calloc(DIFF_GAMES, sizeof(myconfig[0]));
-               for (tmp = 0; tmp < DIFF_GAMES; tmp++) {
-                   myconfig[tmp] = calloc(1, sizeof(struct dg_config));
+               for (tmp = 0; tmp < ncnf; tmp++) {
+                   tmpconfig[tmp] = myconfig[tmp];
                }
+               free(myconfig);
            }
+
+           tmpconfig[ncnf] = calloc(1, sizeof(struct dg_config));
+           myconfig = tmpconfig;
        }
        game_definitions '}'
        {
index 6d4d13f6ed4e268f2f4e6b2eb101b9ee12a9caf1..6081ad08f757ad1776d8328a72a652c5cb713fcf 100644 (file)
@@ -87,15 +87,6 @@ if test "$enable_sqlite" = yes; then
    AC_DEFINE_UNQUOTED(USE_SQLITE_DB, "$dgl_sqlite_db", [Path and filename of the SQLite database.])
 fi
 
-def_dgl_num_games=4
-
-AC_ARG_WITH(num-games,
-[AC_HELP_STRING([--num-games=INT], [Max. number of games this dgamelaunch supports per dgl installation.])],
-[dgl_num_games=$withval], [dgl_num_games=$def_dgl_num_games])
-
-AC_DEFINE_UNQUOTED(DIFF_GAMES, $dgl_num_games, [Max. number of games this dgamelaunch supports per dgl installation.])
-AC_MSG_RESULT([Number of games this dgamelaunch supports: $dgl_num_games]);
-
 AC_ARG_WITH(config-file,
 [AC_HELP_STRING([--with-config-file=PATH], [Define the path to the default configuration file.])],
 [configfile=$withval], [configfile="/etc/dgamelaunch.conf"])
index 3951bc335ff8cf7f4d65c31bc371b4d083735734..351ebcb26204bdabdbf9889e755d30a57f99a0c7 100644 (file)
@@ -14,9 +14,6 @@
 #endif
 
 
-/* max # of different games playable from within this dgl */
-/*#define DIFF_GAMES 4*/
-
 typedef enum
 {
     DGLTIME_DGLSTART = 0,      /* when someone telnets in */
index 5bade1128d18c011def2fa182517e8dd49080148..be04fc28c76f5fe20c0c558461c37d4ca1d9d5b9 100644 (file)
@@ -559,9 +559,8 @@ create_config ()
     }
 #else
     /*      fprintf(stderr, "NO DEFCONFIG\n");*/
-      myconfig = calloc(DIFF_GAMES, sizeof(myconfig[0]));
-    for (tmp = 0; tmp < DIFF_GAMES; tmp++)
-       myconfig[tmp] = NULL;
+    num_games = 0;
+    myconfig = calloc(1, sizeof(myconfig[0]));
     myconfig[0] = &defconfig;
     return;
 #endif
@@ -569,25 +568,8 @@ create_config ()
 
   if (!myconfig) /* a parse error occurred */
   {
-      /*      fprintf(stderr, "PARSE ERROR\n");*/
-      myconfig = calloc(DIFF_GAMES, sizeof(myconfig[0]));
-    for (tmp = 0; tmp < DIFF_GAMES; tmp++)
-       myconfig[tmp] = NULL;
-    myconfig[0] = &defconfig;
-    return;
-  }
-  /* Fill the rest with defaults */
-
-  for (tmp = 0; tmp < DIFF_GAMES; tmp++) {
-
-      if (!myconfig[tmp]->game_path) myconfig[tmp]->game_path = defconfig.game_path;
-      if (!myconfig[tmp]->game_name) myconfig[tmp]->game_name = defconfig.game_name;
-      if (!myconfig[tmp]->shortname) myconfig[tmp]->shortname = defconfig.shortname;
-      if (!myconfig[tmp]->rcfile) myconfig[tmp]->rcfile = defconfig.rcfile;
-      if (!myconfig[tmp]->spool) myconfig[tmp]->spool = defconfig.spool;
-      /*if (!myconfig[tmp]->savefilefmt) myconfig[tmp]->savefilefmt = defconfig.savefilefmt;*/
-      if (!myconfig[tmp]->inprogressdir) myconfig[tmp]->inprogressdir = defconfig.inprogressdir;
-
+      fprintf(stderr, "ERROR: configuration parsing failed\n");
+      graceful_exit(113);
   }
 
   if (!globalconfig.chroot) globalconfig.chroot = "/var/lib/dgamelaunch/";
@@ -617,8 +599,4 @@ create_config ()
                  globalconfig.shed_gid = 60; /* games gid in debian */
          }
 
-  for (tmp = 0; tmp < NUM_DGLTIMES; tmp++) {
-         globalconfig.cmdqueue[0] = NULL;
-  }
-
 }