]> granicus.if.org Git - nethack/commitdiff
prevent Windows back_buffer_flip() early on
authornhmall <nhmall@nethack.org>
Sun, 6 Feb 2022 15:47:41 +0000 (10:47 -0500)
committernhmall <nhmall@nethack.org>
Sun, 6 Feb 2022 15:47:41 +0000 (10:47 -0500)
sys/windows/consoletty.c

index 47205ae09e57c906ba76641f85c0324a40f1eed3..391e9dc44b60387c9be24afb80ca5c4edc897776 100644 (file)
@@ -180,6 +180,7 @@ static COLORREF DefaultColors[CLR_MAX] = {
 };
 #endif
 struct console_t {
+    boolean is_ready;
     WORD background;
     WORD foreground;
     WORD attr;
@@ -217,6 +218,7 @@ struct console_t {
     DWORD out_cmode;
     long color24;
 } console = {
+    FALSE,
     (FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED), /* background */
     (FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED), /* foreground */
     0,                                                     /* attr */
@@ -718,6 +720,9 @@ back_buffer_flip(void)
     DWORD reserved;
     unsigned do_anything, did_anything;
 
+    if (!console.is_ready)
+        return;
+
     emit_hide_cursor();
     for (pos.Y = 0; pos.Y < console.height; pos.Y++) {
         for (pos.X = 0; pos.X < console.width; pos.X++) {
@@ -797,6 +802,9 @@ back_buffer_flip(void)
     COORD pos;
     DWORD unused;
 
+    if (!console.is_ready)
+        return;
+
     for (pos.Y = 0; pos.Y < console.height; pos.Y++) {
         for (pos.X = 0; pos.X < console.width; pos.X++) {
             if (back->attribute != front->attribute) {
@@ -2729,6 +2737,7 @@ void nethack_enter_consoletty(void)
     init_custom_colors();
 #endif /* VIRTUAL_TERMINAL_SEQUENCES */
     console.current_nhcolor = NO_COLOR;
+    console.is_ready = TRUE;
 }
 #endif /* TTY_GRAPHICS */