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 "network.h"
|
||||||
#include "rogue.h"
|
#include "rogue.h"
|
||||||
|
|
||||||
|
#define SCOREFILE "xrogue.scr"
|
||||||
|
#define SAVEDIR "."
|
||||||
|
|
||||||
main(argc, argv, envp)
|
main(argc, argv, envp)
|
||||||
char **argv;
|
char **argv;
|
||||||
char **envp;
|
char **envp;
|
||||||
|
|
@ -46,12 +49,33 @@ char **envp;
|
||||||
strcat(file_name, "xrogue.sav");
|
strcat(file_name, "xrogue.sav");
|
||||||
|
|
||||||
/* Get default score file */
|
/* Get default score file */
|
||||||
|
#ifdef SCOREFILE
|
||||||
|
strncpy(score_file, SCOREFILE, LINELEN);
|
||||||
|
score_file[LINELEN-1] = '\0';
|
||||||
|
#else
|
||||||
strcpy(score_file, md_getroguedir());
|
strcpy(score_file, md_getroguedir());
|
||||||
|
|
||||||
if (*score_file)
|
if (*score_file)
|
||||||
strcat(score_file,"/");
|
strcat(score_file,"/");
|
||||||
|
|
||||||
strcat(score_file, "xrogue.scr");
|
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)
|
if ((env = getenv("ROGUEOPTS")) != NULL)
|
||||||
parse_opts(env);
|
parse_opts(env);
|
||||||
|
|
@ -121,6 +145,12 @@ char **envp;
|
||||||
exit_game(0);
|
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 (argc == 2)
|
||||||
if (!restore(argv[1], envp)) /* Note: restore will never return */
|
if (!restore(argv[1], envp)) /* Note: restore will never return */
|
||||||
exit_game(0);
|
exit_game(0);
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ WINDOW *msgw; /* Used to display messages */
|
||||||
bool pool_teleport = FALSE; /* just teleported from a pool */
|
bool pool_teleport = FALSE; /* just teleported from a pool */
|
||||||
bool inwhgt = FALSE; /* true if from wghtchk() */
|
bool inwhgt = FALSE; /* true if from wghtchk() */
|
||||||
bool after; /* True if we want after daemons */
|
bool after; /* True if we want after daemons */
|
||||||
|
bool use_savedir = FALSE; /* Use common save location? */
|
||||||
bool waswizard; /* Was a wizard sometime */
|
bool waswizard; /* Was a wizard sometime */
|
||||||
bool s_know[MAXSCROLLS]; /* Does he know what a scroll does */
|
bool s_know[MAXSCROLLS]; /* Does he know what a scroll does */
|
||||||
bool p_know[MAXPOTIONS]; /* Does he know what a potion does */
|
bool p_know[MAXPOTIONS]; /* Does he know what a potion does */
|
||||||
|
|
|
||||||
|
|
@ -1381,6 +1381,7 @@ extern bool def_attr; /* True for default attributes */
|
||||||
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; /* Use common save location */
|
||||||
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 */
|
||||||
|
|
|
||||||
|
|
@ -151,8 +151,13 @@ char **envp;
|
||||||
|
|
||||||
if ((inf = open(file, O_RDONLY)) < 0)
|
if ((inf = open(file, O_RDONLY)) < 0)
|
||||||
{
|
{
|
||||||
|
if (use_savedir && errno == ENOENT)
|
||||||
|
{
|
||||||
|
/* No game in progress, so one will be started. */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
perror(file);
|
perror(file);
|
||||||
return(-1);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
@ -222,7 +227,7 @@ char **envp;
|
||||||
playit();
|
playit();
|
||||||
|
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
return(1);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ENCWBSIZ 1024
|
#define ENCWBSIZ 1024
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue