xrogue: initial support for the -n option.
The scorefile location is also configurable now.
This commit is contained in:
parent
dec970210b
commit
e35502804b
4 changed files with 39 additions and 2 deletions
|
|
@ -26,6 +26,9 @@
|
|||
#include "network.h"
|
||||
#include "rogue.h"
|
||||
|
||||
#define SCOREFILE "xrogue.scr"
|
||||
#define SAVEDIR "."
|
||||
|
||||
main(argc, argv, envp)
|
||||
char **argv;
|
||||
char **envp;
|
||||
|
|
@ -46,12 +49,33 @@ char **envp;
|
|||
strcat(file_name, "xrogue.sav");
|
||||
|
||||
/* Get default score file */
|
||||
#ifdef SCOREFILE
|
||||
strncpy(score_file, SCOREFILE, LINELEN);
|
||||
score_file[LINELEN-1] = '\0';
|
||||
#else
|
||||
strcpy(score_file, md_getroguedir());
|
||||
|
||||
if (*score_file)
|
||||
strcat(score_file,"/");
|
||||
|
||||
strcat(score_file, "xrogue.scr");
|
||||
#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.xrsav", SAVEDIR,
|
||||
md_getuid(), whoami))
|
||||
{
|
||||
strcpy(file_name, "xrogue.sav");
|
||||
use_savedir = FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((env = getenv("ROGUEOPTS")) != NULL)
|
||||
parse_opts(env);
|
||||
|
|
@ -121,6 +145,12 @@ char **envp;
|
|||
exit_game(0);
|
||||
}
|
||||
|
||||
if (use_savedir)
|
||||
{
|
||||
/* restore() will return TRUE if a new game should be started. */
|
||||
if (!restore(file_name, envp))
|
||||
exit_game(0);
|
||||
}
|
||||
if (argc == 2)
|
||||
if (!restore(argv[1], envp)) /* Note: restore will never return */
|
||||
exit_game(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue