arogue7: implement the -n option.
This commit is contained in:
parent
7da765d616
commit
7824f79164
4 changed files with 43 additions and 1 deletions
|
|
@ -31,6 +31,8 @@ extern struct uwdata wdata, oldwin;
|
||||||
extern char oldtext[WTXTNUM][WTXTLEN];
|
extern char oldtext[WTXTNUM][WTXTLEN];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SAVEDIR "."
|
||||||
|
|
||||||
main(argc, argv, envp)
|
main(argc, argv, envp)
|
||||||
char **argv;
|
char **argv;
|
||||||
char **envp;
|
char **envp;
|
||||||
|
|
@ -67,6 +69,22 @@ char **envp;
|
||||||
strcat(score_file,"arogue77.scr");
|
strcat(score_file,"arogue77.scr");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SAVEDIR
|
||||||
|
/* Check for common save location */
|
||||||
|
if (argc >= 3 && strcmp(argv[1], "-n") == 0)
|
||||||
|
{
|
||||||
|
strncpy(whoami, argv[2], 79);
|
||||||
|
whoami[79] = '\0';
|
||||||
|
use_savedir = TRUE;
|
||||||
|
if (LINELEN <= snprintf(file_name, LINELEN, "%s/%d-%s.ar7sav", SAVEDIR,
|
||||||
|
md_getuid(), whoami))
|
||||||
|
{
|
||||||
|
strcpy(file_name, "xrogue.sav");
|
||||||
|
use_savedir = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((env = getenv("ROGUEOPTS")) != NULL)
|
if ((env = getenv("ROGUEOPTS")) != NULL)
|
||||||
parse_opts(env);
|
parse_opts(env);
|
||||||
|
|
||||||
|
|
@ -138,6 +156,11 @@ char **envp;
|
||||||
nice(19); /* nice the max amount */
|
nice(19); /* nice the max amount */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (use_savedir)
|
||||||
|
{
|
||||||
|
if (!restore(file_name, envp))
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
if (!restore(argv[1], envp)) /* Note: restore will never return */
|
if (!restore(argv[1], envp)) /* Note: restore will never return */
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,7 @@ bool firstmove = FALSE;
|
||||||
bool askme = FALSE;
|
bool askme = FALSE;
|
||||||
bool in_shell = FALSE;
|
bool in_shell = FALSE;
|
||||||
bool daytime = TRUE;
|
bool daytime = TRUE;
|
||||||
|
bool use_savedir = FALSE;
|
||||||
LEVTYPE levtype; /* type of level i'm on */
|
LEVTYPE levtype; /* type of level i'm on */
|
||||||
|
|
||||||
char *nothing = "Nothing seems to happen.";
|
char *nothing = "Nothing seems to happen.";
|
||||||
|
|
|
||||||
|
|
@ -1271,6 +1271,7 @@ extern bool slow_invent; /* Inventory one line at a time */
|
||||||
extern bool firstmove; /* First move after setting door_stop */
|
extern bool firstmove; /* First move after setting door_stop */
|
||||||
extern bool waswizard; /* Was a wizard sometime */
|
extern bool waswizard; /* Was a wizard sometime */
|
||||||
extern bool askme; /* Ask about unidentified things */
|
extern bool askme; /* Ask about unidentified things */
|
||||||
|
extern bool use_savedir; /* Are savefiles in SAVEDIR */
|
||||||
extern bool s_know[]; /* Does he know what a scroll does */
|
extern bool s_know[]; /* Does he know what a scroll does */
|
||||||
extern bool p_know[]; /* Does he know what a potion does */
|
extern bool p_know[]; /* Does he know what a potion does */
|
||||||
extern bool r_know[]; /* Does he know what a ring does */
|
extern bool r_know[]; /* Does he know what a ring does */
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,10 @@ save_game()
|
||||||
mpos = 0;
|
mpos = 0;
|
||||||
if (file_name[0] != '\0')
|
if (file_name[0] != '\0')
|
||||||
{
|
{
|
||||||
msg("Save file (%s)? ", file_name);
|
if (use_savedir)
|
||||||
|
msg("Save game? ");
|
||||||
|
else
|
||||||
|
msg("Save file (%s)? ", file_name);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
c = readchar();
|
c = readchar();
|
||||||
|
|
@ -77,6 +80,12 @@ save_game()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (use_savedir)
|
||||||
|
{
|
||||||
|
msg("");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
msg("File name: ");
|
msg("File name: ");
|
||||||
|
|
@ -90,7 +99,11 @@ save_game()
|
||||||
strcpy(file_name, buf);
|
strcpy(file_name, buf);
|
||||||
gotfile:
|
gotfile:
|
||||||
if ((savefd = open(file_name, O_WRONLY|O_CREAT|O_TRUNC,0666)) < 0)
|
if ((savefd = open(file_name, O_WRONLY|O_CREAT|O_TRUNC,0666)) < 0)
|
||||||
|
{
|
||||||
msg(strerror(errno)); /* fake perror() */
|
msg(strerror(errno)); /* fake perror() */
|
||||||
|
if (use_savedir)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
} while (savefd < 0);
|
} while (savefd < 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -168,6 +181,10 @@ char **envp;
|
||||||
file = file_name;
|
file = file_name;
|
||||||
if ((inf = open(file, 0)) < 0)
|
if ((inf = open(file, 0)) < 0)
|
||||||
{
|
{
|
||||||
|
if (use_savedir && errno == ENOENT)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
perror(file);
|
perror(file);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue