From 564affea88cd7653b6e336501e123d863b6d07fe Mon Sep 17 00:00:00 2001 From: Ray Chason Date: Sun, 30 Aug 2026 15:52:15 -0400 Subject: [PATCH] Remove limit in size of widget_table It is difficult, but possible, to exceed 1024 widgets. One way is to set a very large Unicode symbol set, and then use #wizcustom. As there is no limit to how many objects can occupy a square, this limit is a possible hazard even to a normal game. --- win/X11/winlabel.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/win/X11/winlabel.c b/win/X11/winlabel.c index 2f9e5e68c..f8e99510c 100644 --- a/win/X11/winlabel.c +++ b/win/X11/winlabel.c @@ -610,9 +610,9 @@ typedef struct WidgetBucket { WidgetData *data; } WidgetBucket; -#define MAX_WIDGETS 1024 -static WidgetBucket widget_table[MAX_WIDGETS]; -static unsigned num_widgets; +static WidgetBucket *widget_table = NULL; +static unsigned num_widgets = 0; +static unsigned max_widgets = 0; /* bsearch compare function to search widget-table */ static int @@ -653,9 +653,12 @@ get_widget_data(Widget w) static WidgetData * add_widget(Widget w) { - /* Panic rather than overflow the array */ - if (num_widgets >= MAX_WIDGETS) { - panic("Widget table is full\n"); + /* If the array is full (or unallocated), add some new space to it */ + if (num_widgets >= max_widgets) { + max_widgets = num_widgets + 1024; + widget_table = (WidgetBucket *) re_alloc( + (long *) widget_table, + max_widgets * sizeof(widget_table[0])); } /* Insert the widget into the table, maintaining its order */ @@ -688,7 +691,7 @@ delete_widget(Widget w) /* Remove the widget from the table */ for (unsigned i = (unsigned)(bucket - widget_table); - i + 1 < MAX_WIDGETS; + i + 1 < num_widgets; ++i) { widget_table[i] = widget_table[i+1]; }