From 68a29ad0dcd65af0e72249ad7af337e37d803a04 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Tue, 25 Mar 2025 23:25:31 +0100 Subject: [PATCH] Don't use K&R syntax for messagebox routines which was removed in C23 Yup, that's not just a function declaration thing... Starting to doubt if this is a net improvement --- src/m_menu.c | 20 ++++++++++++++------ src/m_menu.h | 4 +++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 946eaa9f4..0f6e1380e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -173,10 +173,15 @@ static INT16 itemOn = 1; // menu item skull is on, Hack by Tails 09-18-2002 static INT16 skullAnimCounter = 10; // skull animation counter static tic_t followertimer = 0; // Used for smooth follower floating -static struct { +static struct +{ boolean active; const char *text; - void (*routine)(); + union + { + void (*routine)(INT32 choice); // MM_YESNO + void (*handler)(event_t *ev); // MM_EVENTHANDLER + }; menumessagetype_t messagetype; INT16 x, y; INT16 numlines; @@ -1065,8 +1070,8 @@ boolean M_Responder(event_t *ev) else { // dirty hack: for customising controls, I want only buttons/keys/axes, not mouse - if (messagebox.routine && !(ev->type == ev_mouse || (ev->type == ev_joystick && messagebox.routine != M_ChangecontrolResponse))) - messagebox.routine(ev); + if (messagebox.handler && !(ev->type == ev_mouse || (ev->type == ev_joystick && messagebox.handler != M_ChangecontrolResponse))) + messagebox.handler(ev); } return true; } @@ -2623,7 +2628,7 @@ static INT32 M_GetFirstLevelInList(void) // ================================================== // MESSAGE BOX (aka: a hacked, cobbled together menu) // ================================================== -void M_StartMessage(const char *string, void (*routine)(), +void M_StartMessage2(const char *string, void (*routine)(void), menumessagetype_t itemtype) { size_t max = 0, start = 0, i, strlines; @@ -2669,7 +2674,10 @@ void M_StartMessage(const char *string, void (*routine)(), messagebox.text = message; messagebox.messagetype = itemtype; - messagebox.routine = routine; + if (itemtype == MM_EVENTHANDLER) + messagebox.handler = (void (*)(event_t *))routine; + else + messagebox.routine = (void (*)(INT32))routine; //added : 06-02-98: now draw a textbox around the message // compute lenght max and the numbers of lines diff --git a/src/m_menu.h b/src/m_menu.h index 592dea54d..e73f6f47b 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -139,7 +139,9 @@ typedef enum MM_EVENTHANDLER // the same of above but without 'y' or 'n' restriction // and routine is void routine(event_t *) (ex: set control) } menumessagetype_t; -void M_StartMessage(const char *string, void (*routine)(), menumessagetype_t itemtype); + +#define M_StartMessage(string, routine, itemtype) M_StartMessage2(string, (void (*)(void))routine, itemtype) +void M_StartMessage2(const char *string, void (*routine)(void), menumessagetype_t itemtype); typedef enum {