Allow any number of different games per dgl installation without needing to recompile.
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@437 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
parent
25d36a74f5
commit
2184a3609c
18
config.y
18
config.y
|
@ -414,19 +414,25 @@ game_definitions : game_definition
|
||||||
|
|
||||||
definegame : TYPE_DEFINE_GAME '{'
|
definegame : TYPE_DEFINE_GAME '{'
|
||||||
{
|
{
|
||||||
if ((ncnf < 0) || (ncnf >= DIFF_GAMES)) {
|
struct dg_config **tmpconfig = NULL;
|
||||||
fprintf(stderr, "%s:%d: too many games defined, bailing out\n",
|
|
||||||
|
tmpconfig = calloc(ncnf + 1, sizeof(myconfig[0]));
|
||||||
|
if (!tmpconfig) {
|
||||||
|
fprintf(stderr, "%s:%d: could not allocate memory for config, bailing out\n",
|
||||||
config, line);
|
config, line);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!myconfig) {
|
if (myconfig) {
|
||||||
int tmp;
|
int tmp;
|
||||||
myconfig = calloc(DIFF_GAMES, sizeof(myconfig[0]));
|
for (tmp = 0; tmp < ncnf; tmp++) {
|
||||||
for (tmp = 0; tmp < DIFF_GAMES; tmp++) {
|
tmpconfig[tmp] = myconfig[tmp];
|
||||||
myconfig[tmp] = calloc(1, sizeof(struct dg_config));
|
|
||||||
}
|
}
|
||||||
|
free(myconfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tmpconfig[ncnf] = calloc(1, sizeof(struct dg_config));
|
||||||
|
myconfig = tmpconfig;
|
||||||
}
|
}
|
||||||
game_definitions '}'
|
game_definitions '}'
|
||||||
{
|
{
|
||||||
|
|
|
@ -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.])
|
AC_DEFINE_UNQUOTED(USE_SQLITE_DB, "$dgl_sqlite_db", [Path and filename of the SQLite database.])
|
||||||
fi
|
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_ARG_WITH(config-file,
|
||||||
[AC_HELP_STRING([--with-config-file=PATH], [Define the path to the default configuration file.])],
|
[AC_HELP_STRING([--with-config-file=PATH], [Define the path to the default configuration file.])],
|
||||||
[configfile=$withval], [configfile="/etc/dgamelaunch.conf"])
|
[configfile=$withval], [configfile="/etc/dgamelaunch.conf"])
|
||||||
|
|
|
@ -14,9 +14,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* max # of different games playable from within this dgl */
|
|
||||||
/*#define DIFF_GAMES 4*/
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
DGLTIME_DGLSTART = 0, /* when someone telnets in */
|
DGLTIME_DGLSTART = 0, /* when someone telnets in */
|
||||||
|
|
30
dgl-common.c
30
dgl-common.c
|
@ -559,9 +559,8 @@ create_config ()
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* fprintf(stderr, "NO DEFCONFIG\n");*/
|
/* fprintf(stderr, "NO DEFCONFIG\n");*/
|
||||||
myconfig = calloc(DIFF_GAMES, sizeof(myconfig[0]));
|
num_games = 0;
|
||||||
for (tmp = 0; tmp < DIFF_GAMES; tmp++)
|
myconfig = calloc(1, sizeof(myconfig[0]));
|
||||||
myconfig[tmp] = NULL;
|
|
||||||
myconfig[0] = &defconfig;
|
myconfig[0] = &defconfig;
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
@ -569,25 +568,8 @@ create_config ()
|
||||||
|
|
||||||
if (!myconfig) /* a parse error occurred */
|
if (!myconfig) /* a parse error occurred */
|
||||||
{
|
{
|
||||||
/* fprintf(stderr, "PARSE ERROR\n");*/
|
fprintf(stderr, "ERROR: configuration parsing failed\n");
|
||||||
myconfig = calloc(DIFF_GAMES, sizeof(myconfig[0]));
|
graceful_exit(113);
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!globalconfig.chroot) globalconfig.chroot = "/var/lib/dgamelaunch/";
|
if (!globalconfig.chroot) globalconfig.chroot = "/var/lib/dgamelaunch/";
|
||||||
|
@ -617,8 +599,4 @@ create_config ()
|
||||||
globalconfig.shed_gid = 60; /* games gid in debian */
|
globalconfig.shed_gid = 60; /* games gid in debian */
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tmp = 0; tmp < NUM_DGLTIMES; tmp++) {
|
|
||||||
globalconfig.cmdqueue[0] = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue