rogue5: add savedir, logfile, bugfixes
This commit is contained in:
parent
3741c4867d
commit
53a15a3e2e
13 changed files with 2124 additions and 1397 deletions
|
|
@ -42,21 +42,40 @@ main(int argc, char **argv)
|
|||
|
||||
#endif
|
||||
|
||||
/* Check to see if savefiles should be stored in the system location */
|
||||
#ifdef SAVEDIR
|
||||
if (argc >= 3 && !strcmp(argv[1], "-n"))
|
||||
{
|
||||
use_savedir = TRUE;
|
||||
strncpy(whoami, argv[2], MAXSTR);
|
||||
whoami[MAXSTR-1] = '\0';
|
||||
snprintf(file_name, MAXSTR, "%s/%d-%.10s.r5sav", SAVEDIR,
|
||||
md_getuid(), whoami);
|
||||
}
|
||||
#endif
|
||||
|
||||
open_score();
|
||||
open_log();
|
||||
|
||||
/*
|
||||
* get home and options from environment
|
||||
*/
|
||||
|
||||
strcpy(home, md_gethomedir());
|
||||
|
||||
if (strlen(home) > MAXSTR - strlen("rogue.save") - 1)
|
||||
if (strlen(home) > MAXSTR - strlen("rogue5.save") - 1)
|
||||
*home = 0;
|
||||
|
||||
strcpy(file_name, home);
|
||||
strcat(file_name, "rogue.save");
|
||||
if (!use_savedir)
|
||||
{
|
||||
md_normaluser();
|
||||
strcpy(file_name, home);
|
||||
strcat(file_name, "rogue5.save");
|
||||
}
|
||||
|
||||
if ((env = getenv("ROGUEOPTS")) != NULL)
|
||||
parse_opts(env);
|
||||
if (env == NULL || whoami[0] == '\0')
|
||||
if (!use_savedir && (env == NULL || whoami[0] == '\0'))
|
||||
strucpy(whoami, md_getusername(), strlen(md_getusername()));
|
||||
lowtime = time(NULL);
|
||||
if (getenv("SEED") != NULL)
|
||||
|
|
@ -68,20 +87,10 @@ main(int argc, char **argv)
|
|||
dnum = (unsigned int) lowtime + md_getpid();
|
||||
seed = dnum;
|
||||
|
||||
open_score();
|
||||
|
||||
/*
|
||||
* Drop setuid/setgid after opening the scoreboard file.
|
||||
*/
|
||||
|
||||
md_normaluser();
|
||||
|
||||
/*
|
||||
* check for print-score option
|
||||
*/
|
||||
|
||||
md_normaluser(); /* we drop any setgid/setuid priveldges here */
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
if (strcmp(argv[1], "-s") == 0)
|
||||
|
|
@ -105,15 +114,23 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
init_check(); /* check for legal startup */
|
||||
if (argc == 2)
|
||||
if (use_savedir)
|
||||
{
|
||||
/* If there is a saved game, restore() will not return. If it
|
||||
* returns 1, there isn't a game, so start one. If 0, there was
|
||||
* an error. */
|
||||
if (!restore(file_name))
|
||||
my_exit(1);
|
||||
}
|
||||
else if (argc == 2)
|
||||
if (!restore(argv[1])) /* Note: restore will never return */
|
||||
my_exit(1);
|
||||
#ifdef MASTER
|
||||
if (wizard)
|
||||
printf("Hello %s, welcome to dungeon #%d", whoami, dnum);
|
||||
printf("Hello %s, welcome to dungeon #%d\n", whoami, dnum);
|
||||
else
|
||||
#endif
|
||||
printf("Hello %s, just a moment while I dig the dungeon...", whoami);
|
||||
printf("Hello %s, just a moment while I dig the dungeon...\n", whoami);
|
||||
fflush(stdout);
|
||||
|
||||
initscr(); /* Start up cursor package */
|
||||
|
|
@ -235,6 +252,7 @@ tstp(int ignored)
|
|||
md_tstpresume();
|
||||
raw();
|
||||
noecho();
|
||||
nonl();
|
||||
keypad(stdscr,1);
|
||||
playltchars();
|
||||
clearok(curscr, TRUE);
|
||||
|
|
@ -311,6 +329,7 @@ quit(int sig)
|
|||
mvprintw(LINES - 2, 0, "You quit with %d gold pieces", purse);
|
||||
move(LINES - 1, 0);
|
||||
refresh();
|
||||
writelog(purse, 1, 0);
|
||||
score(purse, 1, 0);
|
||||
my_exit(0);
|
||||
}
|
||||
|
|
@ -377,6 +396,7 @@ shell(void)
|
|||
|
||||
noecho();
|
||||
raw();
|
||||
nonl();
|
||||
keypad(stdscr,1);
|
||||
playltchars();
|
||||
in_shell = FALSE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue