Fix for #114: unneccesary newline printed every time a "direct call" made.
authorDavid Griffith <dave@661.org>
Sat, 18 May 2019 03:13:47 +0000 (20:13 -0700)
committerDavid Griffith <dave@661.org>
Sat, 18 May 2019 05:29:44 +0000 (22:29 -0700)
My fix for #84 (cfec4f1ed81a8e733effbaa93acd917e7f6bded0) neglected to
take into account the fact that interpret() would be called before the
game ends under certain rare circumstances. Therefore, I've added a
reset_screen() to main() which contains the final call to new_line().

src/common/main.c
src/common/process.c
src/common/screen.c

index 22e19e3663cd7e4f8ccec103023e6bae03e4ab77..cd96b667de3b1d6a436671489d9a46a7076e3ed1 100644 (file)
@@ -33,6 +33,7 @@
 extern void interpret (void);
 extern void init_memory (void);
 extern void init_undo (void);
+extern void reset_screen (void);
 extern void reset_memory (void);
 
 bool need_newline_at_exit = FALSE;
@@ -168,6 +169,8 @@ int cdecl main (int argc, char *argv[])
 
     interpret ();
 
+    reset_screen ();
+
     reset_memory ();
 
     os_reset_screen ();
index 635947e23e15226f0c6fa0a9df3631ca5483530d..9187b0bbd293b3514dbf76a8f8de20d795576208 100644 (file)
@@ -313,9 +313,6 @@ void interpret (void)
         os_tick();
     } while (finished == 0);
 
-    if (need_newline_at_exit)
-       new_line();
-
     finished--;
 
 }/* interpret */
index 313b415362a244c275130f2dd0e95fddc1a6ee71..0e1e1188afe62da9b25f43f40354d90d000fc020 100644 (file)
@@ -133,6 +133,19 @@ static void reset_cursor (zword win)
 }/* reset_cursor */
 
 
+/*
+ * reset_screen
+ *
+ * Do any interface-independent screen cleanup prior to exiting the game.
+ *
+ */
+void reset_screen (void)
+{
+    if (need_newline_at_exit)
+       new_line();
+
+}/* reset_screen */
+
 /*
  * set_more_prompts
  *