break quit messages after at most 42 chars

if they do not contain explicit line breaks themselves

Fixes #2263
This commit is contained in:
Fabian Greffrath 2025-05-13 14:02:35 +02:00
parent 7530deae79
commit 751cecb4e2

View File

@ -2255,6 +2255,36 @@ void M_ResetAutoSave(void)
// M_Init
//
#define MAX_STRLEN 42
static void AddLineBreaks(char *string)
{
char *start = string;
char *p = start;
while (strlen(p) > MAX_STRLEN)
{
start = p;
p += MAX_STRLEN;
do
{
if (*p == ' ')
{
*p++ = '\n';
break;
}
} while (--p > start);
if (p == start)
{
break;
}
}
}
#undef MAX_STRLEN
void M_Init(void)
{
MN_InitDefaults(); // killough 11/98
@ -2360,6 +2390,16 @@ void M_Init(void)
free(replace);
*endmsg[9] = string;
}
for (int i = 0; i < NUM_QUITMESSAGES; i++)
{
char *const msg = *endmsg[i];
if (strchr(msg, '\n') == NULL)
{
AddLineBreaks(*endmsg[i]);
}
}
}
/////////////////////////////