improve selectsave handling for Windows
If there were outdated savefiles encountered during startup, each individual one was getting a wait_synch that required a <return> even though a message window wasn't being used at that point. Allow suppression of the individual per-file wait_synch() calls on Windows, so that a single one can be done once the selectsave processing is overwith. This was a little messy because an indicator had to flow down through validate(), uptodate(), etc. There shouldn't be any change in how things behave on any non-Windows platforms.
This commit is contained in:
+2
-2
@@ -939,7 +939,7 @@ extern void paniclog(const char *, const char *);
|
|||||||
extern void testinglog(const char *, const char *, const char *);
|
extern void testinglog(const char *, const char *, const char *);
|
||||||
extern int validate_prefix_locations(char *);
|
extern int validate_prefix_locations(char *);
|
||||||
#ifdef SELECTSAVED
|
#ifdef SELECTSAVED
|
||||||
extern char *plname_from_file(const char *);
|
extern char *plname_from_file(const char *, boolean);
|
||||||
#endif
|
#endif
|
||||||
extern char **get_saved_games(void);
|
extern char **get_saved_games(void);
|
||||||
extern void free_saved_games(char **);
|
extern void free_saved_games(char **);
|
||||||
@@ -2421,7 +2421,7 @@ extern int restore_menu(winid);
|
|||||||
#endif
|
#endif
|
||||||
extern void minit(void);
|
extern void minit(void);
|
||||||
extern boolean lookup_id_mapping(unsigned, unsigned *);
|
extern boolean lookup_id_mapping(unsigned, unsigned *);
|
||||||
extern int validate(NHFILE *, const char *);
|
extern int validate(NHFILE *, const char *, boolean);
|
||||||
extern void reset_restpref(void);
|
extern void reset_restpref(void);
|
||||||
extern void set_restpref(const char *);
|
extern void set_restpref(const char *);
|
||||||
extern void set_savepref(const char *);
|
extern void set_savepref(const char *);
|
||||||
|
|||||||
@@ -830,6 +830,7 @@ typedef struct {
|
|||||||
#define UTD_CHECKFIELDCOUNTS 0x02
|
#define UTD_CHECKFIELDCOUNTS 0x02
|
||||||
#define UTD_SKIP_SANITY1 0x04
|
#define UTD_SKIP_SANITY1 0x04
|
||||||
#define UTD_SKIP_SAVEFILEINFO 0x08
|
#define UTD_SKIP_SAVEFILEINFO 0x08
|
||||||
|
#define UTD_WITHOUT_WAITSYNCH_PERFILE 0x10
|
||||||
|
|
||||||
#define ENTITIES 2
|
#define ENTITIES 2
|
||||||
struct valuable_data {
|
struct valuable_data {
|
||||||
|
|||||||
+1
-1
@@ -613,7 +613,7 @@ getbones(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validate(nhfp, gb.bones) != 0) {
|
if (validate(nhfp, gb.bones, FALSE) != 0) {
|
||||||
if (!wizard)
|
if (!wizard)
|
||||||
pline("Discarding unusable bones; no need to panic...");
|
pline("Discarding unusable bones; no need to panic...");
|
||||||
ok = FALSE;
|
ok = FALSE;
|
||||||
|
|||||||
+18
-8
@@ -1200,7 +1200,7 @@ restore_saved_game(void)
|
|||||||
|
|
||||||
nh_uncompress(fq_save);
|
nh_uncompress(fq_save);
|
||||||
if ((nhfp = open_savefile()) != 0) {
|
if ((nhfp = open_savefile()) != 0) {
|
||||||
if (validate(nhfp, fq_save) != 0) {
|
if (validate(nhfp, fq_save, FALSE) != 0) {
|
||||||
close_nhfile(nhfp);
|
close_nhfile(nhfp);
|
||||||
nhfp = (NHFILE *)0;
|
nhfp = (NHFILE *)0;
|
||||||
(void) delete_savefile();
|
(void) delete_savefile();
|
||||||
@@ -1210,8 +1210,9 @@ restore_saved_game(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SELECTSAVED)
|
#if defined(SELECTSAVED)
|
||||||
|
|
||||||
char *
|
char *
|
||||||
plname_from_file(const char *filename)
|
plname_from_file(const char *filename, boolean without_wait_synch_per_file)
|
||||||
{
|
{
|
||||||
NHFILE *nhfp = (NHFILE *) 0;
|
NHFILE *nhfp = (NHFILE *) 0;
|
||||||
char *result = 0;
|
char *result = 0;
|
||||||
@@ -1229,7 +1230,7 @@ plname_from_file(const char *filename)
|
|||||||
#endif
|
#endif
|
||||||
nh_uncompress(gs.SAVEF);
|
nh_uncompress(gs.SAVEF);
|
||||||
if ((nhfp = open_savefile()) != 0) {
|
if ((nhfp = open_savefile()) != 0) {
|
||||||
if (validate(nhfp, filename) == 0) {
|
if (validate(nhfp, filename, without_wait_synch_per_file) == 0) {
|
||||||
char tplname[PL_NSIZ];
|
char tplname[PL_NSIZ];
|
||||||
|
|
||||||
get_plname_from_file(nhfp, tplname);
|
get_plname_from_file(nhfp, tplname);
|
||||||
@@ -1272,6 +1273,9 @@ plname_from_file(const char *filename)
|
|||||||
}
|
}
|
||||||
#endif /* defined(SELECTSAVED) */
|
#endif /* defined(SELECTSAVED) */
|
||||||
|
|
||||||
|
#define SUPPRESS_WAITSYNCH_PERFILE TRUE
|
||||||
|
#define ALLOW_WAITSYNCH_PERFILE FALSE
|
||||||
|
|
||||||
char **
|
char **
|
||||||
get_saved_games(void)
|
get_saved_games(void)
|
||||||
{
|
{
|
||||||
@@ -1281,6 +1285,7 @@ get_saved_games(void)
|
|||||||
#endif
|
#endif
|
||||||
int j = 0;
|
int j = 0;
|
||||||
char **result = 0;
|
char **result = 0;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
{
|
{
|
||||||
char *foundfile;
|
char *foundfile;
|
||||||
@@ -1288,7 +1293,7 @@ get_saved_games(void)
|
|||||||
const char *fq_new_save;
|
const char *fq_new_save;
|
||||||
const char *fq_old_save;
|
const char *fq_old_save;
|
||||||
char **files = 0;
|
char **files = 0;
|
||||||
int i;
|
int i, count_failures = 0;
|
||||||
|
|
||||||
Strcpy(gp.plname, "*");
|
Strcpy(gp.plname, "*");
|
||||||
set_savefile_name(FALSE);
|
set_savefile_name(FALSE);
|
||||||
@@ -1321,10 +1326,9 @@ get_saved_games(void)
|
|||||||
(void) memset((genericptr_t) result, 0, (n + 1) * sizeof(char *));
|
(void) memset((genericptr_t) result, 0, (n + 1) * sizeof(char *));
|
||||||
for(i = 0; i < n; i++) {
|
for(i = 0; i < n; i++) {
|
||||||
char *r;
|
char *r;
|
||||||
r = plname_from_file(files[i]);
|
r = plname_from_file(files[i], SUPPRESS_WAITSYNCH_PERFILE);
|
||||||
|
|
||||||
if (r) {
|
if (r) {
|
||||||
|
|
||||||
/* rename file if it is not named as expected */
|
/* rename file if it is not named as expected */
|
||||||
Strcpy(gp.plname, r);
|
Strcpy(gp.plname, r);
|
||||||
set_savefile_name(TRUE);
|
set_savefile_name(TRUE);
|
||||||
@@ -1336,12 +1340,15 @@ get_saved_games(void)
|
|||||||
(void) rename(fq_old_save, fq_new_save);
|
(void) rename(fq_old_save, fq_new_save);
|
||||||
|
|
||||||
result[j++] = r;
|
result[j++] = r;
|
||||||
|
} else {
|
||||||
|
count_failures++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free_saved_games(files);
|
free_saved_games(files);
|
||||||
|
if (count_failures)
|
||||||
|
wait_synch();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
@@ -1373,7 +1380,7 @@ get_saved_games(void)
|
|||||||
char *r;
|
char *r;
|
||||||
|
|
||||||
Sprintf(filename, "save/%d%s", uid, name);
|
Sprintf(filename, "save/%d%s", uid, name);
|
||||||
r = plname_from_file(filename);
|
r = plname_from_file(filename, ALLOW_WAITSYNCH_PERFILE);
|
||||||
if (r)
|
if (r)
|
||||||
result[j++] = r;
|
result[j++] = r;
|
||||||
}
|
}
|
||||||
@@ -1398,8 +1405,11 @@ get_saved_games(void)
|
|||||||
free_saved_games(result);
|
free_saved_games(result);
|
||||||
}
|
}
|
||||||
#endif /* SELECTSAVED */
|
#endif /* SELECTSAVED */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#undef SUPPRESS_WAITSYNCH_PERFILE
|
||||||
|
#undef ALLOW_WAITSYNCH_PERFILE
|
||||||
|
|
||||||
void
|
void
|
||||||
free_saved_games(char **saved)
|
free_saved_games(char **saved)
|
||||||
|
|||||||
+4
-2
@@ -812,7 +812,7 @@ dorecover(NHFILE *nhfp)
|
|||||||
}
|
}
|
||||||
restoreinfo.mread_flags = 0;
|
restoreinfo.mread_flags = 0;
|
||||||
rewind_nhfile(nhfp); /* return to beginning of file */
|
rewind_nhfile(nhfp); /* return to beginning of file */
|
||||||
(void) validate(nhfp, (char *) 0);
|
(void) validate(nhfp, (char *) 0, FALSE);
|
||||||
get_plname_from_file(nhfp, gp.plname);
|
get_plname_from_file(nhfp, gp.plname);
|
||||||
|
|
||||||
getlev(nhfp, 0, (xint8) 0);
|
getlev(nhfp, 0, (xint8) 0);
|
||||||
@@ -1456,7 +1456,7 @@ restore_menu(
|
|||||||
#endif /* SELECTSAVED */
|
#endif /* SELECTSAVED */
|
||||||
|
|
||||||
int
|
int
|
||||||
validate(NHFILE *nhfp, const char *name)
|
validate(NHFILE *nhfp, const char *name, boolean without_waitsynch_perfile)
|
||||||
{
|
{
|
||||||
readLenType rlen = 0;
|
readLenType rlen = 0;
|
||||||
struct savefile_info sfi;
|
struct savefile_info sfi;
|
||||||
@@ -1465,6 +1465,8 @@ validate(NHFILE *nhfp, const char *name)
|
|||||||
|
|
||||||
if (nhfp->structlevel)
|
if (nhfp->structlevel)
|
||||||
utdflags |= UTD_CHECKSIZES;
|
utdflags |= UTD_CHECKSIZES;
|
||||||
|
if (without_waitsynch_perfile)
|
||||||
|
utdflags |= UTD_WITHOUT_WAITSYNCH_PERFILE;
|
||||||
if (!(reslt = uptodate(nhfp, name, utdflags)))
|
if (!(reslt = uptodate(nhfp, name, utdflags)))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|||||||
+8
-4
@@ -311,7 +311,8 @@ check_version(
|
|||||||
) {
|
) {
|
||||||
if (complain) {
|
if (complain) {
|
||||||
pline("Version mismatch for file \"%s\".", filename);
|
pline("Version mismatch for file \"%s\".", filename);
|
||||||
display_nhwindow(WIN_MESSAGE, TRUE);
|
if (WIN_MESSAGE != WIN_ERR)
|
||||||
|
display_nhwindow(WIN_MESSAGE, TRUE);
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (
|
} else if (
|
||||||
@@ -358,14 +359,17 @@ uptodate(NHFILE *nhfp, const char *name, unsigned long utdflags)
|
|||||||
if (rlen == 0) {
|
if (rlen == 0) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
pline("File \"%s\" is empty?", name);
|
pline("File \"%s\" is empty?", name);
|
||||||
wait_synch();
|
if ((utdflags & UTD_WITHOUT_WAITSYNCH_PERFILE) == 0)
|
||||||
|
wait_synch();
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!check_version(&vers_info, name, verbose, utdflags)) {
|
if (!check_version(&vers_info, name, verbose, utdflags)) {
|
||||||
if (verbose)
|
if (verbose) {
|
||||||
wait_synch();
|
if ((utdflags & UTD_WITHOUT_WAITSYNCH_PERFILE) == 0)
|
||||||
|
wait_synch();
|
||||||
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|||||||
@@ -34,44 +34,6 @@ static struct stat hbuf;
|
|||||||
static int eraseoldlocks(void);
|
static int eraseoldlocks(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
|
||||||
int
|
|
||||||
uptodate(int fd)
|
|
||||||
{
|
|
||||||
#ifdef WANT_GETHDATE
|
|
||||||
if(fstat(fd, &buf)) {
|
|
||||||
pline("Cannot get status of saved level? ");
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
if(buf.st_mtime < hbuf.st_mtime) {
|
|
||||||
pline("Saved level is out of date. ");
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#if (defined(MICRO)) && !defined(NO_FSTAT)
|
|
||||||
if(fstat(fd, &buf)) {
|
|
||||||
if(gm.moves > 1) pline("Cannot get status of saved level? ");
|
|
||||||
else pline("Cannot get status of saved game.");
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
if(comp_times(buf.st_mtime)) {
|
|
||||||
if(gm.moves > 1) pline("Saved level is out of date.");
|
|
||||||
else pline("Saved game is out of date. ");
|
|
||||||
/* This problem occurs enough times we need to give the player
|
|
||||||
* some more information about what causes it, and how to fix.
|
|
||||||
*/
|
|
||||||
#ifdef MSDOS
|
|
||||||
pline("Make sure that your system's date and time are correct.");
|
|
||||||
pline("They must be more current than NetHack.EXE's date/time stamp.");
|
|
||||||
#endif /* MSDOS */
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
#endif /* MICRO */
|
|
||||||
#endif /* WANT_GETHDATE */
|
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PC_LOCKING)
|
#if defined(PC_LOCKING)
|
||||||
#if !defined(SELF_RECOVER)
|
#if !defined(SELF_RECOVER)
|
||||||
static int
|
static int
|
||||||
|
|||||||
+1
-1
@@ -629,7 +629,7 @@ vms_get_saved_games(const char *savetemplate, /* wildcarded save file name in na
|
|||||||
if (filename[l - 1] != ' ')
|
if (filename[l - 1] != ' ')
|
||||||
break;
|
break;
|
||||||
filename[l] = '\0';
|
filename[l] = '\0';
|
||||||
if ((charname = plname_from_file(filename)) != 0)
|
if ((charname = plname_from_file(filename, FALSE)) != 0)
|
||||||
savefile(charname, count++, &asize, outarray);
|
savefile(charname, count++, &asize, outarray);
|
||||||
}
|
}
|
||||||
(void) lib$find_file_end(&context);
|
(void) lib$find_file_end(&context);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern boolean getreturn_enabled; /* from sys/share/pcsys.c */
|
extern boolean getreturn_enabled; /* from windmain.c */
|
||||||
extern int redirect_stdout;
|
extern int redirect_stdout;
|
||||||
|
|
||||||
#ifdef TTY_GRAPHICS
|
#ifdef TTY_GRAPHICS
|
||||||
|
|||||||
@@ -552,8 +552,8 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
|
|||||||
chdir(gf.fqn_prefix[HACKPREFIX]);
|
chdir(gf.fqn_prefix[HACKPREFIX]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (GUILaunched || IsDebuggerPresent())
|
/* if (GUILaunched || IsDebuggerPresent()) */
|
||||||
getreturn_enabled = TRUE;
|
getreturn_enabled = TRUE;
|
||||||
|
|
||||||
check_recordfile((char *) 0);
|
check_recordfile((char *) 0);
|
||||||
iflags.windowtype_deferred = TRUE;
|
iflags.windowtype_deferred = TRUE;
|
||||||
|
|||||||
@@ -491,7 +491,7 @@ nethack_exit(int code)
|
|||||||
/* use our custom version which works
|
/* use our custom version which works
|
||||||
a little cleaner than the stdio one */
|
a little cleaner than the stdio one */
|
||||||
windowprocs.win_nhgetch = windows_console_custom_nhgetch;
|
windowprocs.win_nhgetch = windows_console_custom_nhgetch;
|
||||||
}
|
} else
|
||||||
#endif
|
#endif
|
||||||
if (getreturn_enabled) {
|
if (getreturn_enabled) {
|
||||||
raw_print("\n");
|
raw_print("\n");
|
||||||
@@ -525,7 +525,8 @@ getreturn(const char *str)
|
|||||||
raw_print(buf);
|
raw_print(buf);
|
||||||
if (WINDOWPORT(tty))
|
if (WINDOWPORT(tty))
|
||||||
windows_console_custom_nhgetch();
|
windows_console_custom_nhgetch();
|
||||||
wait_synch();
|
else
|
||||||
|
wait_synch();
|
||||||
in_getreturn = FALSE;
|
in_getreturn = FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user