Allow disabling savefile UID checking in sysconf

This commit is contained in:
Pasi Kallinen
2015-04-11 21:07:57 +03:00
parent 4771ce5499
commit eb77c57a6c
7 changed files with 22 additions and 1 deletions

View File

@@ -3007,6 +3007,9 @@ A string explaining how to recover a game on this system (no default value).
SEDUCE
0 or 1 to disable or enable, respectively, the SEDUCE option (see the source
for details on this function).
.lp
CHECK_SAVE_UID
0 or 1 to disable or enable, respectively, the UID checking for savefiles.
.pg
The following options affect the score file:
.pg

View File

@@ -3597,6 +3597,9 @@ A string explaining how to recover a game on this system (no default value).
\item[\ib{SEDUCE}]
0 or 1 to disable or enable, respectively, the SEDUCE option (see the source)
for details on this function.
%.lp
\item[\ib{CHECK\_SAVE\_UID}]
0 or 1 to disable or enable, respectively, the UID checking for savefiles.
\elist
%.pg

View File

@@ -35,6 +35,7 @@ struct sysopt {
# endif
#endif
int seduce;
int check_save_uid; /* restoring savefile checks UID? */
};
extern struct sysopt sysopt;

View File

@@ -2206,6 +2206,9 @@ int src;
} else if (src == SET_IN_SYS && match_varname(buf, "RECOVER", 7)) {
if (sysopt.recover) free(sysopt.recover);
sysopt.recover = dupstr(bufp);
} else if (src == SET_IN_SYS && match_varname(buf, "CHECK_SAVE_UID", 14)) {
n = atoi(bufp);
sysopt.check_save_uid = n;
} else if (match_varname(buf, "SEDUCE", 6)) {
n = !!atoi(bufp); /* XXX this could be tighter */
/* allow anyone to turn it off, but only sysconf to turn it on*/

View File

@@ -502,6 +502,13 @@ register struct obj *otmp;
else otmp->spe = fruitadd(oldf->fname, (struct fruit *)0);
}
#ifdef SYSCF
#define SYSOPT_CHECK_SAVE_UID sysopt.check_save_uid
#else
#define SYSOPT_CHECK_SAVE_UID TRUE
#endif
STATIC_OVL
boolean
restgamestate(fd, stuckid, steedid)
@@ -517,7 +524,7 @@ unsigned int *stuckid, *steedid;
unsigned long uid;
mread(fd, (genericptr_t) &uid, sizeof uid);
if (uid != (unsigned long)getuid()) { /* strange ... */
if (SYSOPT_CHECK_SAVE_UID && uid != (unsigned long)getuid()) { /* strange ... */
/* for wizard mode, issue a reminder; for others, treat it
as an attempt to cheat and refuse to restore this file */
pline("Saved game was not yours.");

View File

@@ -67,6 +67,7 @@ sys_early_init()
# endif
#endif
sysopt.check_save_uid = 1;
sysopt.seduce = 1; /* if it's compiled in, default to on */
sysopt_seduce_set(sysopt.seduce);
}

View File

@@ -35,6 +35,9 @@ MAXPLAYERS=10
# Uncomment the next line to disable the SEDUCE option.
#SEDUCE=0
# Uncomment to disable savefile UID checking.
#CHECK_SAVE_UID=0
# Record (high score) file options.
# CAUTION: changing these after people have started playing games can
# lead to lost high scores!