Return to dgamelaunch after the game ends.
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@420 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
parent
0ee48979db
commit
2b909a3610
|
@ -2060,6 +2060,7 @@ main (int argc, char** argv)
|
|||
}
|
||||
}
|
||||
|
||||
while (1) {
|
||||
initcurses ();
|
||||
|
||||
userchoice = menuloop();
|
||||
|
@ -2091,36 +2092,6 @@ main (int argc, char** argv)
|
|||
/* then run the game-specific commands */
|
||||
dgl_exec_cmdqueue(myconfig[userchoice]->cmdqueue, userchoice, me);
|
||||
|
||||
/*
|
||||
if (!backup_savefile (userchoice))
|
||||
graceful_exit (5);
|
||||
*/
|
||||
|
||||
/* environment */
|
||||
/*
|
||||
if (myconfig[userchoice]->rcfile) {
|
||||
snprintf (atrcfilename, 81, "@%s", dgl_format_str(userchoice, me, myconfig[userchoice]->rc_fmt));
|
||||
mysetenv ("NETHACKOPTIONS", atrcfilename, 1);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
len = strlen(myconfig[userchoice]->spool) + strlen (me->username) + 1;
|
||||
spool = malloc (len + 1);
|
||||
snprintf (spool, len + 1, "%s/%s", myconfig[userchoice]->spool, me->username);
|
||||
|
||||
mysetenv ("MAIL", spool, 1);
|
||||
mysetenv ("SIMPLEMAIL", "1", 1);
|
||||
*/
|
||||
|
||||
/* don't let the mail file grow */
|
||||
/*
|
||||
if (access (spool, F_OK) == 0)
|
||||
unlink (spool);
|
||||
|
||||
free (spool);
|
||||
*/
|
||||
|
||||
/* fix the variables in the arguments */
|
||||
for (i = 0; i < myconfig[userchoice]->num_args; i++) {
|
||||
tmp = strdup(dgl_format_str(userchoice, me, myconfig[userchoice]->bin_args[i]));
|
||||
|
@ -2131,31 +2102,15 @@ main (int argc, char** argv)
|
|||
/* launch program */
|
||||
ttyrec_main (userchoice, me->username, gen_ttyrec_filename());
|
||||
|
||||
setproctitle ("%s", me->username);
|
||||
}
|
||||
|
||||
/* NOW we can safely kill this */
|
||||
freefile ();
|
||||
|
||||
/*
|
||||
printf("config:'%s'\n", config);
|
||||
|
||||
printf("chroot:'%s'\n", globalconfig.chroot);
|
||||
printf("gamepath:'%s'\n", myconfig[userchoice]->game_path);
|
||||
printf("game:'%s'\n", myconfig[userchoice]->game_name);
|
||||
printf("dglroot:'%s'\n", globalconfig.dglroot);
|
||||
printf("lockfile:'%s'\n", globalconfig.lockfile);
|
||||
printf("passwd:'%s'\n", globalconfig.passwd);
|
||||
printf("banner:'%s'\n", globalconfig.banner);
|
||||
printf("rcfile:'%s'\n", myconfig[userchoice]->rcfile);
|
||||
printf("spool:'%s'\n", myconfig[userchoice]->spool);
|
||||
printf("savefilefmt:'%s'\n", myconfig[userchoice]->savefilefmt);
|
||||
printf("dgl_format_str(savefilefmt):'%s'\n", dgl_format_str(userchoice, myconfig[userchoice]->savefilefmt));
|
||||
printf("inprogressdir:'%s'\n", myconfig[userchoice]->inprogressdir);
|
||||
*/
|
||||
|
||||
if (me)
|
||||
free (me);
|
||||
|
||||
/* FIXME: free data in globalconfig */
|
||||
|
||||
graceful_exit (1);
|
||||
|
||||
return 1;
|
||||
|
|
32
ttyrec.c
32
ttyrec.c
|
@ -72,8 +72,11 @@
|
|||
|
||||
int slave;
|
||||
pid_t child, subchild;
|
||||
pid_t input_child;
|
||||
char* ipfile = NULL;
|
||||
|
||||
volatile int wait_for_menu = 0;
|
||||
|
||||
FILE *fscript;
|
||||
int master;
|
||||
|
||||
|
@ -86,6 +89,8 @@ ttyrec_main (int game, char *username, char* ttyrec_filename)
|
|||
{
|
||||
char dirname[100];
|
||||
|
||||
child = subchild = input_child = 0;
|
||||
|
||||
snprintf (dirname, 100, "%sttyrec/%s/%s", globalconfig.dglroot, username,
|
||||
ttyrec_filename);
|
||||
|
||||
|
@ -123,7 +128,23 @@ ttyrec_main (int game, char *username, char* ttyrec_filename)
|
|||
else
|
||||
doshell (game, username);
|
||||
}
|
||||
|
||||
(void) fclose (fscript);
|
||||
|
||||
wait_for_menu = 1;
|
||||
input_child = fork();
|
||||
if (input_child < 0)
|
||||
{
|
||||
perror ("fork2");
|
||||
fail ();
|
||||
}
|
||||
if (!input_child)
|
||||
doinput ();
|
||||
else
|
||||
{
|
||||
while (wait_for_menu)
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
unlink (ipfile);
|
||||
|
||||
|
@ -136,7 +157,6 @@ doinput ()
|
|||
register int cc;
|
||||
char ibuf[BUFSIZ];
|
||||
|
||||
(void) fclose (fscript);
|
||||
while ((cc = read (0, ibuf, BUFSIZ)) > 0)
|
||||
(void) write (master, ibuf, cc);
|
||||
done ();
|
||||
|
@ -158,8 +178,18 @@ finish (int sig)
|
|||
}
|
||||
|
||||
if (die)
|
||||
{
|
||||
if (wait_for_menu && input_child)
|
||||
{
|
||||
// Need to kill the child that's writing input to pty.
|
||||
kill(input_child, SIGTERM);
|
||||
while ((pid = wait3(&status, WNOHANG, 0)) > 0);
|
||||
wait_for_menu = 0;
|
||||
}
|
||||
else
|
||||
done ();
|
||||
}
|
||||
}
|
||||
|
||||
struct linebuf
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue