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 '}'
{
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"])
#endif
-/* max # of different games playable from within this dgl */
-/*#define DIFF_GAMES 4*/
-
typedef enum
{
DGLTIME_DGLSTART = 0, /* when someone telnets in */
}
#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
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/";
globalconfig.shed_gid = 60; /* games gid in debian */
}
- for (tmp = 0; tmp < NUM_DGLTIMES; tmp++) {
- globalconfig.cmdqueue[0] = NULL;
- }
-
}