Fixed brain-dead handling of undo slots.
authorDavid Griffith <dave@661.org>
Tue, 23 May 2023 07:00:02 +0000 (00:00 -0700)
committerDavid Griffith <dave@661.org>
Tue, 23 May 2023 23:08:35 +0000 (16:08 -0700)
The manpages have always mentioned a default number of undo slots as
being 20 (curses interface) or 25 (X11 interface).  The problem is that
nowhere is this actually set.  This commit makes the Frotz core actually
set a default of 25.  There is no need to involve the interface code.

ChangeLog
doc/frotz.6
src/common/fastmem.c
src/common/frotz.h

index c63d188aef591875242c9d643131683d1c974937..c60855b4ead0f581f69199c73953de50f0bb9968 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,8 @@ NEW FEATURES
 
 BUG FIXES
 
+- Fixed brain-dead handling of undo slots.
+
 - Fixed a segfault when xfrotz detects a fatal error.
 
 - Fixed compile failure of the SDL interface for GCC 12 and maybe GCC 11.
index 91310fc7caa3e470a57375993d76175f25b789c4..f0b0e00cf8d37176a9e0eaf8cf8462d663b941e4 100644 (file)
@@ -205,7 +205,7 @@ toned down.
 .TP
 .B \-u N
 Sets the number of slots available for Frotz's multiple undo hotkey (see
-below).  This defaults to twenty, which should be sufficient for most
+below).  This defaults to 25, which should be sufficient for most
 purposes.  Setting too high a number here may be dangerous on machines
 with limited memory.
 .TP
index ede1330dcb4a89bbcd08f9c0eb63e00f76796b9c..c73ef989f67ab40074f9b3edc438bb6b480574ed 100644 (file)
@@ -256,7 +256,7 @@ void init_header(void)
 void init_setup(void)
 {
        memset(&f_setup, 0, sizeof(f_setup));
-       f_setup.undo_slots = MAX_UNDO_SLOTS;
+       f_setup.undo_slots = DEFAULT_UNDO_SLOTS;
        f_setup.script_cols = 80;
        f_setup.err_report_mode = ERR_DEFAULT_REPORT_MODE;
        f_setup.blorb_file = NULL;
@@ -289,6 +289,7 @@ void init_memory(void)
        zword addr;
        unsigned n;
        int i, j;
+       char errorstring[81];
 
 #ifdef TOPS20
        zword checksum = 0;
@@ -458,6 +459,12 @@ void init_memory(void)
        };
        /* INDENT-ON */
 
+       /* Ensure undo slots don't exceed maximum */
+       if (f_setup.undo_slots > MAX_UNDO_SLOTS) {
+               snprintf(errorstring, 80, "Maxmimum undo slots is %d", MAX_UNDO_SLOTS);
+               os_fatal(errorstring);
+       }
+
        /* Open story file */
        if ((story_fp = os_load_story()) == NULL)
                os_fatal("Cannot open story file");
index 9407367397b5a8ac2a1c2a4ade833fca905f226b..9abae04b8fe9c58258a9c6331794f7c26d06db44 100644 (file)
@@ -170,6 +170,9 @@ typedef struct {
 #include "unused.h"
 
 /*** Constants that may be set at compile time ***/
+#ifndef DEFAULT_UNDO_SLOTS
+#define DEFAULT_UNDO_SLOTS 25
+#endif
 #ifndef MAX_UNDO_SLOTS
 #define MAX_UNDO_SLOTS 500
 #endif