From 3cbbcfd2531e231554ff241f1c23358ffd37f649 Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 17 Jun 2023 00:51:04 +0100 Subject: [PATCH] M_StringHeight: Guarantee that there will be enough vertical space in a Menu Message for the relevant lines --- src/menus/transient/message-box.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/menus/transient/message-box.c b/src/menus/transient/message-box.c index f677ba992..f463bfcef 100644 --- a/src/menus/transient/message-box.c +++ b/src/menus/transient/message-box.c @@ -14,11 +14,14 @@ struct menumessage_s menumessage; // static inline size_t M_StringHeight(const char *string) { - size_t h = 8, i; + size_t h = 8, i, len = strlen(string); - for (i = 0; i < strlen(string); i++) - if (string[i] == '\n') - h += 8; + for (i = 0; i < len; i++) + { + if (string[i] != '\n' && i != len-1) + continue; + h += 8; + } return h; }