From a197c197420df6687a4be16f4945e9f01307fe80 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 10 Nov 2018 09:38:32 -0500 Subject: [PATCH] Prompt page string field length adjustment; check empty named tag before prompt search --- src/dehacked.c | 8 ++++---- src/doomstat.h | 4 ++-- src/f_finale.c | 11 +++++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 214d47a16..c3323a6af 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1641,11 +1641,11 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) // HACK: Add yellow control char now // so the drawing function doesn't call it repeatedly - char name[32]; + char name[34]; name[0] = '\x82'; // color yellow name[1] = 0; - strncat(name, word2, 31); - name[31] = 0; + strncat(name, word2, 33); + name[33] = 0; // Replace _ with ' ' for (i = 0; i < 32 && name[i]; i++) @@ -1728,7 +1728,7 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum) } } else if (fastcmp(word, "TAG")) - strncpy(textprompts[num]->page[pagenum].tag, word2, 25); + strncpy(textprompts[num]->page[pagenum].tag, word2, 33); else if (fastcmp(word, "NEXTPROMPT")) textprompts[num]->page[pagenum].nextprompt = usi; else if (fastcmp(word, "NEXTPAGE")) diff --git a/src/doomstat.h b/src/doomstat.h index eb4ed7066..432699d99 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -174,8 +174,8 @@ extern cutscene_t *cutscenes[128]; typedef struct { - char tag[25]; // page tag (24 chars due to texture concatenating) - char name[32]; // narrator name + char tag[33]; // page tag + char name[34]; // narrator name, extra char for color char iconname[8]; // narrator icon lump boolean rightside; // narrator side, false = left, true = right boolean iconflip; // narrator flip icon horizontally diff --git a/src/f_finale.c b/src/f_finale.c index 9217ced68..d706bf22e 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2236,14 +2236,17 @@ void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postex void F_StartTextPromptByNamedTag(char *tag, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime) { INT32 promptnum, pagenum; - char realtag[25]; + char realtag[33]; - strncpy(realtag, tag, 25); - realtag[24] = 0; + if (!tag || !tag[0]) + return; + + strncpy(realtag, tag, 33); + realtag[32] = 0; // \todo hardcoded tutorial mode behavior: concat control mode (fps, platform, custom) to end of input tag if (tutorialmode) - strncat(realtag, "FPS", 25); + strncat(realtag, "FPS", 33); for (promptnum = 0; promptnum < MAX_PROMPTS; promptnum++) {