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:
@@ -613,7 +613,7 @@ getbones(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (validate(nhfp, gb.bones) != 0) {
|
||||
if (validate(nhfp, gb.bones, FALSE) != 0) {
|
||||
if (!wizard)
|
||||
pline("Discarding unusable bones; no need to panic...");
|
||||
ok = FALSE;
|
||||
|
||||
26
src/files.c
26
src/files.c
@@ -1200,7 +1200,7 @@ restore_saved_game(void)
|
||||
|
||||
nh_uncompress(fq_save);
|
||||
if ((nhfp = open_savefile()) != 0) {
|
||||
if (validate(nhfp, fq_save) != 0) {
|
||||
if (validate(nhfp, fq_save, FALSE) != 0) {
|
||||
close_nhfile(nhfp);
|
||||
nhfp = (NHFILE *)0;
|
||||
(void) delete_savefile();
|
||||
@@ -1210,8 +1210,9 @@ restore_saved_game(void)
|
||||
}
|
||||
|
||||
#if defined(SELECTSAVED)
|
||||
|
||||
char *
|
||||
plname_from_file(const char *filename)
|
||||
plname_from_file(const char *filename, boolean without_wait_synch_per_file)
|
||||
{
|
||||
NHFILE *nhfp = (NHFILE *) 0;
|
||||
char *result = 0;
|
||||
@@ -1229,7 +1230,7 @@ plname_from_file(const char *filename)
|
||||
#endif
|
||||
nh_uncompress(gs.SAVEF);
|
||||
if ((nhfp = open_savefile()) != 0) {
|
||||
if (validate(nhfp, filename) == 0) {
|
||||
if (validate(nhfp, filename, without_wait_synch_per_file) == 0) {
|
||||
char tplname[PL_NSIZ];
|
||||
|
||||
get_plname_from_file(nhfp, tplname);
|
||||
@@ -1272,6 +1273,9 @@ plname_from_file(const char *filename)
|
||||
}
|
||||
#endif /* defined(SELECTSAVED) */
|
||||
|
||||
#define SUPPRESS_WAITSYNCH_PERFILE TRUE
|
||||
#define ALLOW_WAITSYNCH_PERFILE FALSE
|
||||
|
||||
char **
|
||||
get_saved_games(void)
|
||||
{
|
||||
@@ -1281,6 +1285,7 @@ get_saved_games(void)
|
||||
#endif
|
||||
int j = 0;
|
||||
char **result = 0;
|
||||
|
||||
#ifdef WIN32
|
||||
{
|
||||
char *foundfile;
|
||||
@@ -1288,7 +1293,7 @@ get_saved_games(void)
|
||||
const char *fq_new_save;
|
||||
const char *fq_old_save;
|
||||
char **files = 0;
|
||||
int i;
|
||||
int i, count_failures = 0;
|
||||
|
||||
Strcpy(gp.plname, "*");
|
||||
set_savefile_name(FALSE);
|
||||
@@ -1321,10 +1326,9 @@ get_saved_games(void)
|
||||
(void) memset((genericptr_t) result, 0, (n + 1) * sizeof(char *));
|
||||
for(i = 0; i < n; i++) {
|
||||
char *r;
|
||||
r = plname_from_file(files[i]);
|
||||
r = plname_from_file(files[i], SUPPRESS_WAITSYNCH_PERFILE);
|
||||
|
||||
if (r) {
|
||||
|
||||
/* rename file if it is not named as expected */
|
||||
Strcpy(gp.plname, r);
|
||||
set_savefile_name(TRUE);
|
||||
@@ -1336,12 +1340,15 @@ get_saved_games(void)
|
||||
(void) rename(fq_old_save, fq_new_save);
|
||||
|
||||
result[j++] = r;
|
||||
} else {
|
||||
count_failures++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free_saved_games(files);
|
||||
|
||||
if (count_failures)
|
||||
wait_synch();
|
||||
}
|
||||
#endif
|
||||
#ifdef UNIX
|
||||
@@ -1373,7 +1380,7 @@ get_saved_games(void)
|
||||
char *r;
|
||||
|
||||
Sprintf(filename, "save/%d%s", uid, name);
|
||||
r = plname_from_file(filename);
|
||||
r = plname_from_file(filename, ALLOW_WAITSYNCH_PERFILE);
|
||||
if (r)
|
||||
result[j++] = r;
|
||||
}
|
||||
@@ -1398,8 +1405,11 @@ get_saved_games(void)
|
||||
free_saved_games(result);
|
||||
}
|
||||
#endif /* SELECTSAVED */
|
||||
|
||||
return 0;
|
||||
}
|
||||
#undef SUPPRESS_WAITSYNCH_PERFILE
|
||||
#undef ALLOW_WAITSYNCH_PERFILE
|
||||
|
||||
void
|
||||
free_saved_games(char **saved)
|
||||
|
||||
@@ -812,7 +812,7 @@ dorecover(NHFILE *nhfp)
|
||||
}
|
||||
restoreinfo.mread_flags = 0;
|
||||
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);
|
||||
|
||||
getlev(nhfp, 0, (xint8) 0);
|
||||
@@ -1456,7 +1456,7 @@ restore_menu(
|
||||
#endif /* SELECTSAVED */
|
||||
|
||||
int
|
||||
validate(NHFILE *nhfp, const char *name)
|
||||
validate(NHFILE *nhfp, const char *name, boolean without_waitsynch_perfile)
|
||||
{
|
||||
readLenType rlen = 0;
|
||||
struct savefile_info sfi;
|
||||
@@ -1465,6 +1465,8 @@ validate(NHFILE *nhfp, const char *name)
|
||||
|
||||
if (nhfp->structlevel)
|
||||
utdflags |= UTD_CHECKSIZES;
|
||||
if (without_waitsynch_perfile)
|
||||
utdflags |= UTD_WITHOUT_WAITSYNCH_PERFILE;
|
||||
if (!(reslt = uptodate(nhfp, name, utdflags)))
|
||||
return 1;
|
||||
|
||||
|
||||
@@ -311,7 +311,8 @@ check_version(
|
||||
) {
|
||||
if (complain) {
|
||||
pline("Version mismatch for file \"%s\".", filename);
|
||||
display_nhwindow(WIN_MESSAGE, TRUE);
|
||||
if (WIN_MESSAGE != WIN_ERR)
|
||||
display_nhwindow(WIN_MESSAGE, TRUE);
|
||||
}
|
||||
return FALSE;
|
||||
} else if (
|
||||
@@ -358,14 +359,17 @@ uptodate(NHFILE *nhfp, const char *name, unsigned long utdflags)
|
||||
if (rlen == 0) {
|
||||
if (verbose) {
|
||||
pline("File \"%s\" is empty?", name);
|
||||
wait_synch();
|
||||
if ((utdflags & UTD_WITHOUT_WAITSYNCH_PERFILE) == 0)
|
||||
wait_synch();
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!check_version(&vers_info, name, verbose, utdflags)) {
|
||||
if (verbose)
|
||||
wait_synch();
|
||||
if (verbose) {
|
||||
if ((utdflags & UTD_WITHOUT_WAITSYNCH_PERFILE) == 0)
|
||||
wait_synch();
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
Reference in New Issue
Block a user