some windows startup

noticed that "do you want to destroy the savefile" was not being
handled correctly in Windows startup.
This commit is contained in:
nhmall
2022-07-16 20:43:24 -04:00
parent 3fb45dfa4c
commit 0649783a6d
2 changed files with 16 additions and 7 deletions

View File

@@ -884,7 +884,8 @@ void buffer_fill_to_end(cell_t * buffer, cell_t * fill, int x, int y)
while (dst != sentinel) while (dst != sentinel)
*dst++ = *fill; *dst++ = *fill;
if (iflags.debug.immediateflips && buffer == console.back_buffer) if ((iflags.debug.immediateflips || !g.program_state.in_moveloop)
&& buffer == console.back_buffer)
back_buffer_flip(); back_buffer_flip();
} }
@@ -899,7 +900,7 @@ static void buffer_clear_to_end_of_line(cell_t * buffer, int x, int y)
while (dst != sentinel) while (dst != sentinel)
*dst++ = clear_cell; *dst++ = clear_cell;
if (iflags.debug.immediateflips) if (iflags.debug.immediateflips || !g.program_state.in_moveloop)
back_buffer_flip(); back_buffer_flip();
} }
@@ -911,7 +912,8 @@ void buffer_write(cell_t * buffer, cell_t * cell, COORD pos)
cell_t * dst = buffer + (console.width * pos.Y) + pos.X; cell_t * dst = buffer + (console.width * pos.Y) + pos.X;
*dst = *cell; *dst = *cell;
if (iflags.debug.immediateflips && buffer == console.back_buffer) if ((iflags.debug.immediateflips || !g.program_state.in_moveloop)
&& buffer == console.back_buffer)
back_buffer_flip(); back_buffer_flip();
} }

View File

@@ -36,6 +36,9 @@ extern void backsp(void);
#endif #endif
extern void clear_screen(void); extern void clear_screen(void);
#ifdef update_file
#undef update_file
#endif
#if defined(TERMLIB) || defined(CURSES_GRAPHICS) #if defined(TERMLIB) || defined(CURSES_GRAPHICS)
extern void (*decgraphics_mode_callback)(void); extern void (*decgraphics_mode_callback)(void);
#endif #endif
@@ -424,6 +427,7 @@ mingw_main(int argc, char *argv[])
char *windowtype = NULL; char *windowtype = NULL;
char fnamebuf[BUFSZ], encodedfnamebuf[BUFSZ]; char fnamebuf[BUFSZ], encodedfnamebuf[BUFSZ];
char failbuf[BUFSZ]; char failbuf[BUFSZ];
int getlock_result = 0;
#ifdef _MSC_VER #ifdef _MSC_VER
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
@@ -599,9 +603,12 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
fnamebuf, encodedfnamebuf, BUFSZ); fnamebuf, encodedfnamebuf, BUFSZ);
Sprintf(g.lock, "%s", encodedfnamebuf); Sprintf(g.lock, "%s", encodedfnamebuf);
/* regularize(lock); */ /* we encode now, rather than substitute */ /* regularize(lock); */ /* we encode now, rather than substitute */
if (getlock() == 0) if ((getlock_result = getlock()) == 0)
nethack_exit(EXIT_SUCCESS); nethack_exit(EXIT_SUCCESS);
if (getlock_result < 0) {
set_savefile_name(TRUE);
}
/* Set up level 0 file to keep the game state. /* Set up level 0 file to keep the game state.
*/ */
nhfp = create_levelfile(0, (char *) 0); nhfp = create_levelfile(0, (char *) 0);
@@ -623,7 +630,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
* We'll return here if new game player_selection() renames the hero. * We'll return here if new game player_selection() renames the hero.
*/ */
attempt_restore: attempt_restore:
if ((nhfp = restore_saved_game()) != 0) { if ((getlock_result != -1) && (nhfp = restore_saved_game()) != 0) {
#ifdef NEWS #ifdef NEWS
if (iflags.news) { if (iflags.news) {
display_file(NEWS, FALSE); display_file(NEWS, FALSE);
@@ -1145,7 +1152,7 @@ eraseoldlocks(void)
int int
getlock(void) getlock(void)
{ {
int fd, ern = 0, prompt_result = 0; int fd, ern = 0, prompt_result = 1;
int fcmask = FCMASK; int fcmask = FCMASK;
#ifndef SELF_RECOVER #ifndef SELF_RECOVER
char tbuf[BUFSZ]; char tbuf[BUFSZ];
@@ -1265,7 +1272,7 @@ gotlock:
error("cannot close lock (%s)", fq_lock); error("cannot close lock (%s)", fq_lock);
} }
} }
return 1; return prompt_result;
} }
#endif /* PC_LOCKING */ #endif /* PC_LOCKING */