From a52d4270c6cb68e5797e1724954abf8a33a100ca Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Mon, 22 Apr 2024 13:35:23 +0300 Subject: [PATCH 01/11] Doom: first working implementation --- src/doom/m_menu.c | 32 +++++++++++++++++++++++++------- src/i_main.c | 4 ++++ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/doom/m_menu.c b/src/doom/m_menu.c index d9fcb93201..eef14273fd 100644 --- a/src/doom/m_menu.c +++ b/src/doom/m_menu.c @@ -20,6 +20,7 @@ #include #include +#include // [crispy] strftime, localtime #include "doomdef.h" @@ -854,22 +855,39 @@ void M_ReadSaveStrings(void) void M_DrawSaveLoadBottomLine(void) { char pagestr[16]; - const int y = LoadDef.y+LINEHEIGHT*load_end; // [crispy] force status bar refresh inhelpscreens = true; - M_DrawSaveLoadBorder(LoadDef.x,y); - dp_translation = cr[CR_GOLD]; if (savepage > 0) - M_WriteText(LoadDef.x, y, "< PGUP"); + M_WriteText(LoadDef.x, 152, "< PGUP"); if (savepage < savepage_max) - M_WriteText(LoadDef.x+(SAVESTRINGSIZE-6)*8, y, "PGDN >"); + M_WriteText(LoadDef.x+(SAVESTRINGSIZE-6)*8, 152, "PGDN >"); M_snprintf(pagestr, sizeof(pagestr), "page %d/%d", savepage + 1, savepage_max + 1); - M_WriteText(ORIGWIDTH/2-M_StringWidth(pagestr)/2, y, pagestr); + M_WriteText(ORIGWIDTH/2-M_StringWidth(pagestr)/2, 152, pagestr); + + // [crispy] print "modified" (or created initially) time of savegame file + if (LoadMenu[itemOn].status) + { + struct stat st; + char filedate[32]; + + stat(P_SaveGameFile(itemOn), &st); + +// [FG] suppress the most useless compiler warning ever +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-y2k" +#endif + strftime(filedate, sizeof(filedate), "%x %X", localtime(&st.st_mtime)); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + M_WriteText(ORIGWIDTH/2-M_StringWidth(filedate)/2, 160, filedate); + } dp_translation = NULL; } @@ -3457,7 +3475,7 @@ void M_Init (void) { LoadDef_y = vstep + captionheight - SHORT(patchl->height) + SHORT(patchl->topoffset); SaveDef_y = vstep + captionheight - SHORT(patchs->height) + SHORT(patchs->topoffset); - LoadDef.y = SaveDef.y = vstep + captionheight + vstep + SHORT(patchm->topoffset) - 7; // [crispy] see M_DrawSaveLoadBorder() + LoadDef.y = SaveDef.y = vstep + captionheight + vstep + SHORT(patchm->topoffset) - 15; // [crispy] see M_DrawSaveLoadBorder() MouseDef.y = LoadDef.y; } } diff --git a/src/i_main.c b/src/i_main.c index e1091d20b5..520952cc38 100644 --- a/src/i_main.c +++ b/src/i_main.c @@ -22,6 +22,7 @@ #include #include #include +#include // [crispy] setlocale #include "SDL.h" @@ -52,6 +53,9 @@ int main(int argc, char **argv) myargv[i] = M_StringDuplicate(argv[i]); } + // [crispy] Print date and time in the Load/Save Game menus in the current locale + setlocale(LC_TIME, ""); + //! // Print the program version and exit. // From 3d7169482f8c7e4af1825bf10ab1078b3b3a6fee Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Mon, 22 Apr 2024 14:04:09 +0300 Subject: [PATCH 02/11] Use parametrized y coord Co-Authored-By: Fabian Greffrath --- src/doom/m_menu.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/doom/m_menu.c b/src/doom/m_menu.c index eef14273fd..6a46df6f75 100644 --- a/src/doom/m_menu.c +++ b/src/doom/m_menu.c @@ -855,6 +855,7 @@ void M_ReadSaveStrings(void) void M_DrawSaveLoadBottomLine(void) { char pagestr[16]; + const int y = 152; // [crispy] force status bar refresh inhelpscreens = true; @@ -862,12 +863,12 @@ void M_DrawSaveLoadBottomLine(void) dp_translation = cr[CR_GOLD]; if (savepage > 0) - M_WriteText(LoadDef.x, 152, "< PGUP"); + M_WriteText(LoadDef.x, y, "< PGUP"); if (savepage < savepage_max) - M_WriteText(LoadDef.x+(SAVESTRINGSIZE-6)*8, 152, "PGDN >"); + M_WriteText(LoadDef.x+(SAVESTRINGSIZE-6)*8, y, "PGDN >"); M_snprintf(pagestr, sizeof(pagestr), "page %d/%d", savepage + 1, savepage_max + 1); - M_WriteText(ORIGWIDTH/2-M_StringWidth(pagestr)/2, 152, pagestr); + M_WriteText(ORIGWIDTH/2-M_StringWidth(pagestr)/2, y, pagestr); // [crispy] print "modified" (or created initially) time of savegame file if (LoadMenu[itemOn].status) @@ -886,7 +887,7 @@ void M_DrawSaveLoadBottomLine(void) #if defined(__GNUC__) #pragma GCC diagnostic pop #endif - M_WriteText(ORIGWIDTH/2-M_StringWidth(filedate)/2, 160, filedate); + M_WriteText(ORIGWIDTH/2-M_StringWidth(filedate)/2, y + 8, filedate); } dp_translation = NULL; From dab79ab6f7ae6854162080752d900eff1fe07297 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Mon, 22 Apr 2024 14:39:23 +0300 Subject: [PATCH 03/11] Correct comment Better do not remove it, so the purpose of "-15" will be clear. --- src/doom/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doom/m_menu.c b/src/doom/m_menu.c index 6a46df6f75..8cab0a1c80 100644 --- a/src/doom/m_menu.c +++ b/src/doom/m_menu.c @@ -3476,7 +3476,7 @@ void M_Init (void) { LoadDef_y = vstep + captionheight - SHORT(patchl->height) + SHORT(patchl->topoffset); SaveDef_y = vstep + captionheight - SHORT(patchs->height) + SHORT(patchs->topoffset); - LoadDef.y = SaveDef.y = vstep + captionheight + vstep + SHORT(patchm->topoffset) - 15; // [crispy] see M_DrawSaveLoadBorder() + LoadDef.y = SaveDef.y = vstep + captionheight + vstep + SHORT(patchm->topoffset) - 15; // [crispy] moved up, so savegame date/time may appear above status bar MouseDef.y = LoadDef.y; } } From 298f2987b8f6acae1f28ec8895ee8097d30b504b Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Mon, 22 Apr 2024 15:34:23 +0300 Subject: [PATCH 04/11] For Heretic --- src/heretic/mn_menu.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/heretic/mn_menu.c b/src/heretic/mn_menu.c index 665e3bb89b..dc7ea277ab 100644 --- a/src/heretic/mn_menu.c +++ b/src/heretic/mn_menu.c @@ -18,6 +18,7 @@ #include #include +#include // [crispy] strftime, localtime #include "deh_str.h" #include "doomdef.h" @@ -261,7 +262,7 @@ static MenuItem_t LoadItems[] = { }; static Menu_t LoadMenu = { - 70, 27, + 70, 27-9, // [crispy] moved up, so two lines of save pages and file date will fit DrawLoadMenu, SAVES_PER_PAGE, LoadItems, 0, @@ -278,7 +279,7 @@ static MenuItem_t SaveItems[] = { }; static Menu_t SaveMenu = { - 70, 27, + 70, 27-9, // [crispy] moved up, so two lines of save pages and file date will fit DrawSaveMenu, SAVES_PER_PAGE, SaveItems, 0, @@ -933,6 +934,25 @@ static void DrawSaveLoadBottomLine(const Menu_t *menu) M_snprintf(pagestr, sizeof(pagestr), "PAGE %d/%d", savepage + 1, SAVEPAGE_MAX + 1); MN_DrTextA(pagestr, ORIGWIDTH / 2 - MN_TextAWidth(pagestr) / 2, y); + // [crispy] print "modified" (or created initially) time of savegame file + if (SlotStatus[CurrentItPos] && !FileMenuKeySteal) + { + struct stat st; + char filedate[32]; + + stat(SV_Filename(CurrentItPos), &st); +// [FG] suppress the most useless compiler warning ever +#if defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wformat-y2k" +#endif + strftime(filedate, sizeof(filedate), "%x %X", localtime(&st.st_mtime)); +#if defined(__GNUC__) +# pragma GCC diagnostic pop +#endif + MN_DrTextA(filedate, ORIGWIDTH / 2 - MN_TextAWidth(pagestr), y + 10); + } + dp_translation = NULL; } @@ -948,12 +968,13 @@ static void DrawLoadMenu(void) title = DEH_String("LOAD GAME"); - MN_DrTextB(title, 160 - MN_TextBWidth(title) / 2, 7); if (!slottextloaded) { MN_LoadSlotText(); } DrawFileSlots(&LoadMenu); + // [crispy] moved here, draw title on top of file slots + MN_DrTextB(title, 160 - MN_TextBWidth(title) / 2, 1); DrawSaveLoadBottomLine(&LoadMenu); } @@ -969,12 +990,13 @@ static void DrawSaveMenu(void) title = DEH_String("SAVE GAME"); - MN_DrTextB(title, 160 - MN_TextBWidth(title) / 2, 7); if (!slottextloaded) { MN_LoadSlotText(); } DrawFileSlots(&SaveMenu); + // [crispy] moved here, draw title on top of file slots + MN_DrTextB(title, 160 - MN_TextBWidth(title) / 2, 1); DrawSaveLoadBottomLine(&SaveMenu); } From 24bb66189afdae8dc7b417c9dcbb26e129e6ed20 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Mon, 22 Apr 2024 16:16:06 +0300 Subject: [PATCH 05/11] For Hexen --- src/hexen/mn_menu.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/hexen/mn_menu.c b/src/hexen/mn_menu.c index b4f2d903bf..c4b00c5998 100644 --- a/src/hexen/mn_menu.c +++ b/src/hexen/mn_menu.c @@ -18,6 +18,7 @@ // HEADER FILES ------------------------------------------------------------ #include +#include // [crispy] strftime, localtime #include "h2def.h" #include "doomkeys.h" #include "i_input.h" @@ -263,7 +264,7 @@ static MenuItem_t LoadItems[] = { }; static Menu_t LoadMenu = { - 70, 27, + 70, 27-9, // [crispy] moved up, so two lines of save pages and file date will fit DrawLoadMenu, SAVES_PER_PAGE, LoadItems, 0, @@ -280,7 +281,7 @@ static MenuItem_t SaveItems[] = { }; static Menu_t SaveMenu = { - 70, 27, + 70, 27-9, // [crispy] moved up, so two lines of save pages and file date will fit DrawSaveMenu, SAVES_PER_PAGE, SaveItems, 0, @@ -907,6 +908,28 @@ static void DrawSaveLoadBottomLine(const Menu_t *menu) M_snprintf(pagestr, sizeof(pagestr), "PAGE %d/%d", savepage + 1, SAVEPAGE_MAX + 1); MN_DrTextA(pagestr, ORIGWIDTH / 2 - MN_TextAWidth(pagestr) / 2, y); + // [crispy] print "modified" (or created initially) time of savegame file + if (SlotStatus[CurrentItPos] && !FileMenuKeySteal) + { + struct stat st; + char filedate[32]; + char filename[100]; + + M_snprintf(filename, sizeof(filename), "%shex%d.hxs", SavePath, CurrentItPos + (savepage * 10)); + stat(filename, &st); +// [FG] suppress the most useless compiler warning ever +#if defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wformat-y2k" +#endif + strftime(filedate, sizeof(filedate), "%x %X", localtime(&st.st_mtime)); +#if defined(__GNUC__) +# pragma GCC diagnostic pop +#endif + //MN_DrTextACentered(filedate, y + 10, cr[CR_MENU_DARK4]); + MN_DrTextA(filedate, ORIGWIDTH / 2 - MN_TextAWidth(filedate) / 2, y + 10); + } + dp_translation = NULL; } @@ -918,12 +941,13 @@ static void DrawSaveLoadBottomLine(const Menu_t *menu) static void DrawLoadMenu(void) { - MN_DrTextB("LOAD GAME", 160 - MN_TextBWidth("LOAD GAME") / 2, 7); if (!slottextloaded) { MN_LoadSlotText(); } DrawFileSlots(&LoadMenu); + // [crispy] moved here, draw title on top of file slots + MN_DrTextB("LOAD GAME", 160 - MN_TextBWidth("LOAD GAME") / 2, 1); DrawSaveLoadBottomLine(&LoadMenu); } @@ -935,12 +959,13 @@ static void DrawLoadMenu(void) static void DrawSaveMenu(void) { - MN_DrTextB("SAVE GAME", 160 - MN_TextBWidth("SAVE GAME") / 2, 7); if (!slottextloaded) { MN_LoadSlotText(); } DrawFileSlots(&SaveMenu); + // [crispy] moved here, draw title on top of file slots + MN_DrTextB("SAVE GAME", 160 - MN_TextBWidth("SAVE GAME") / 2, 1); DrawSaveLoadBottomLine(&SaveMenu); } From 23eb6746032ea700fec1779361eaad8baee8fa8d Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Mon, 22 Apr 2024 17:33:52 +0300 Subject: [PATCH 06/11] For Strife (WIP) Working, but needs pixel perfection. --- src/strife/m_menu.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/strife/m_menu.c b/src/strife/m_menu.c index 29d4385bfe..a02c96e1a5 100644 --- a/src/strife/m_menu.c +++ b/src/strife/m_menu.c @@ -20,6 +20,7 @@ #include #include +#include // [crispy] strftime, localtime #include "doomdef.h" @@ -851,6 +852,40 @@ void M_DoNameChar(int choice) M_ClearMenus(0); } +// [crispy] print "modified" (or created initially) time of savegame file +// [JN] TODOs: +// - Move both Save and Load menus higher, so file date will be drawn +// one line above map name. +// - Possibly shift file date slightly right? So it will be centered +// by file slots, not by the center of the screen. +static void M_DrawSaveLoadBottomLine(void) +{ + const int y = 161; + + // [crispy] force status bar refresh + // [JN] TODO: probably not needed, we not drawing anything on status bar buffer. + inhelpscreens = true; + + if (LoadMenu[itemOn].status) + { + struct stat st; + char filedate[32]; + + stat(P_SaveGameFile(itemOn), &st); + +// [FG] suppress the most useless compiler warning ever +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-y2k" +#endif + strftime(filedate, sizeof(filedate), "%x %X", localtime(&st.st_mtime)); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + M_WriteText(ORIGWIDTH/2-M_StringWidth(filedate)/2, y, filedate); + } +} + // // M_LoadGame & Cie. // @@ -866,6 +901,8 @@ void M_DrawLoad(void) M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i); M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]); } + + M_DrawSaveLoadBottomLine(); } @@ -951,6 +988,8 @@ void M_DrawSave(void) i = M_StringWidth(savegamestrings[quickSaveSlot]); M_WriteText(LoadDef.x + i,LoadDef.y+LINEHEIGHT*quickSaveSlot,"_"); } + + M_DrawSaveLoadBottomLine(); } // From 484613f4c5451757a3bd32f2af75fa8516cf5632 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Mon, 22 Apr 2024 19:39:00 +0300 Subject: [PATCH 07/11] Doom: make M_DrawSaveLoadBottomLine static --- src/doom/m_menu.c | 2 +- src/i_main.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doom/m_menu.c b/src/doom/m_menu.c index 8cab0a1c80..f73b0536a7 100644 --- a/src/doom/m_menu.c +++ b/src/doom/m_menu.c @@ -852,7 +852,7 @@ void M_ReadSaveStrings(void) } // [FG] support up to 8 pages of savegames -void M_DrawSaveLoadBottomLine(void) +static void M_DrawSaveLoadBottomLine(void) { char pagestr[16]; const int y = 152; diff --git a/src/i_main.c b/src/i_main.c index 520952cc38..393721162d 100644 --- a/src/i_main.c +++ b/src/i_main.c @@ -53,8 +53,8 @@ int main(int argc, char **argv) myargv[i] = M_StringDuplicate(argv[i]); } - // [crispy] Print date and time in the Load/Save Game menus in the current locale - setlocale(LC_TIME, ""); + // [crispy] Print date and time in the Load/Save Game menus in the current locale + setlocale(LC_TIME, ""); //! // Print the program version and exit. From f44f1ef561baec2ef3dff32707b6d74bd57d98f1 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Mon, 22 Apr 2024 20:00:21 +0300 Subject: [PATCH 08/11] For Strife (done) Strife using spaces, not tabs. ;) --- src/strife/m_menu.c | 46 +++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/src/strife/m_menu.c b/src/strife/m_menu.c index a02c96e1a5..13676ee503 100644 --- a/src/strife/m_menu.c +++ b/src/strife/m_menu.c @@ -853,18 +853,9 @@ void M_DoNameChar(int choice) } // [crispy] print "modified" (or created initially) time of savegame file -// [JN] TODOs: -// - Move both Save and Load menus higher, so file date will be drawn -// one line above map name. -// - Possibly shift file date slightly right? So it will be centered -// by file slots, not by the center of the screen. static void M_DrawSaveLoadBottomLine(void) { - const int y = 161; - - // [crispy] force status bar refresh - // [JN] TODO: probably not needed, we not drawing anything on status bar buffer. - inhelpscreens = true; + const int y = 145; if (LoadMenu[itemOn].status) { @@ -889,11 +880,12 @@ static void M_DrawSaveLoadBottomLine(void) // // M_LoadGame & Cie. // +static int LoadDef_x = 80, LoadDef_y = 54; void M_DrawLoad(void) { int i; - V_DrawPatchDirect(72, 28, + V_DrawPatchDirect(LoadDef_x, LoadDef_y, W_CacheLumpName(DEH_String("M_LOADG"), PU_CACHE)); for (i = 0;i < load_end; i++) @@ -972,11 +964,12 @@ void M_LoadGame (int choice) // // M_SaveGame & Cie. // +static int SaveDef_x = 80, SaveDef_y = 54; void M_DrawSave(void) { int i; - V_DrawPatchDirect(72, 28, W_CacheLumpName(DEH_String("M_SAVEG"), PU_CACHE)); + V_DrawPatchDirect(SaveDef_x, SaveDef_y, W_CacheLumpName(DEH_String("M_SAVEG"), PU_CACHE)); for (i = 0;i < load_end; i++) { M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i); @@ -3189,6 +3182,35 @@ void M_Init (void) G_WriteSaveName(5, "ME"); ClearTmp(); + // [crispy] rearrange Load Game and Save Game menus + { + const patch_t *patchl, *patchs, *patchm; + short captionheight, vstep; + + patchl = W_CacheLumpName(DEH_String("M_LOADG"), PU_CACHE); + patchs = W_CacheLumpName(DEH_String("M_SAVEG"), PU_CACHE); + patchm = W_CacheLumpName(DEH_String("M_LSLEFT"), PU_CACHE); + + LoadDef_x = (ORIGWIDTH - SHORT(patchl->width)) / 2 + SHORT(patchl->leftoffset); + SaveDef_x = (ORIGWIDTH - SHORT(patchs->width)) / 2 + SHORT(patchs->leftoffset); + LoadDef.x = SaveDef.x = (ORIGWIDTH - 24 * 8) / 2 + SHORT(patchm->leftoffset); + + captionheight = MAX(SHORT(patchl->height), SHORT(patchs->height)); + + vstep = ORIGHEIGHT - 32; // [crispy] ST_HEIGHT + vstep -= captionheight; + vstep -= (load_end - 1) * LINEHEIGHT + SHORT(patchm->height); + vstep /= 3; + + if (vstep > 0) + { + LoadDef_y = vstep + captionheight - SHORT(patchl->height) + SHORT(patchl->topoffset); + SaveDef_y = vstep + captionheight - SHORT(patchs->height) + SHORT(patchs->topoffset); + LoadDef.y = SaveDef.y = vstep + captionheight + vstep + SHORT(patchm->topoffset) - 19; // [crispy] moved up, so savegame date/time may appear above status bar + MouseDef.y = LoadDef.y; + } + } + // Here we could catch other version dependencies, // like HELP1/2, and four episodes. } From d032b089b832ff9aa2f0ae1721e275205c32050c Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Mon, 22 Apr 2024 20:16:07 +0300 Subject: [PATCH 09/11] Doom: inhelpscreens no longer needed for M_DrawSaveLoadBottomLine Since everything is moved slightly up and no extra file slot is being drawed over status bar, "inhelpscreens" is now redundant. Save date should not appear on status bar, since it's using same Y-coords as KIS stats. Also, this making Save/Load menu slightly less expensive in terms of CPU usage, but fortunately, we are still on capped framerate while active menu. --- src/doom/m_menu.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/doom/m_menu.c b/src/doom/m_menu.c index f73b0536a7..601486c5d1 100644 --- a/src/doom/m_menu.c +++ b/src/doom/m_menu.c @@ -857,9 +857,6 @@ static void M_DrawSaveLoadBottomLine(void) char pagestr[16]; const int y = 152; - // [crispy] force status bar refresh - inhelpscreens = true; - dp_translation = cr[CR_GOLD]; if (savepage > 0) From e40efb21b0bbdadee37ca2b2424923ce5bf2699c Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Mon, 22 Apr 2024 20:31:03 +0300 Subject: [PATCH 10/11] Remove copy-pasta remaining from ID --- src/hexen/mn_menu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hexen/mn_menu.c b/src/hexen/mn_menu.c index c4b00c5998..1cd0c07ab8 100644 --- a/src/hexen/mn_menu.c +++ b/src/hexen/mn_menu.c @@ -926,7 +926,6 @@ static void DrawSaveLoadBottomLine(const Menu_t *menu) #if defined(__GNUC__) # pragma GCC diagnostic pop #endif - //MN_DrTextACentered(filedate, y + 10, cr[CR_MENU_DARK4]); MN_DrTextA(filedate, ORIGWIDTH / 2 - MN_TextAWidth(filedate) / 2, y + 10); } From ffab5c7eefb8cd0bc24d43a0a1549b59b19c9342 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Tue, 23 Apr 2024 14:20:29 +0300 Subject: [PATCH 11/11] Heretic & Hexen: fail-safe conditions for font drawing functions Co-Authored-By: Fabian Greffrath --- src/heretic/mn_menu.c | 8 ++++---- src/hexen/mn_menu.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/heretic/mn_menu.c b/src/heretic/mn_menu.c index dc7ea277ab..db8101bbb0 100644 --- a/src/heretic/mn_menu.c +++ b/src/heretic/mn_menu.c @@ -627,7 +627,7 @@ void MN_DrTextA(const char *text, int x, int y) while ((c = *text++) != 0) { - if (c < 33) + if (c < 33 || c > 91) // [crispy] fail-safe: draw patches above FONTA59 as spaces { x += 5; } @@ -657,7 +657,7 @@ int MN_TextAWidth(const char *text) width = 0; while ((c = *text++) != 0) { - if (c < 33) + if (c < 33 || c > 91) // [crispy] fail-safe: consider patches above FONTA59 as spaces { width += 5; } @@ -685,7 +685,7 @@ void MN_DrTextB(const char *text, int x, int y) while ((c = *text++) != 0) { - if (c < 33) + if (c < 33 || c > 90) // [crispy] fail-safe: draw patches above FONTB58 as spaces { x += 8; } @@ -715,7 +715,7 @@ int MN_TextBWidth(const char *text) width = 0; while ((c = *text++) != 0) { - if (c < 33) + if (c < 33 || c > 90) // [crispy] fail-safe: consider patches above FONTB58 as spaces { width += 5; } diff --git a/src/hexen/mn_menu.c b/src/hexen/mn_menu.c index 1cd0c07ab8..9d458084a6 100644 --- a/src/hexen/mn_menu.c +++ b/src/hexen/mn_menu.c @@ -558,7 +558,7 @@ void MN_DrTextA(const char *text, int x, int y) while ((c = *text++) != 0) { - if (c < 33) + if (c < 33 || c > 91) // [crispy] fail-safe: draw patches above FONTA59 as spaces { x += 5; } @@ -584,7 +584,7 @@ void MN_DrTextAYellow(const char *text, int x, int y) while ((c = *text++) != 0) { - if (c < 33) + if (c < 33 || c > 91) // [crispy] fail-safe: draw patches above FONTAY59 as spaces { x += 5; } @@ -614,7 +614,7 @@ int MN_TextAWidth(const char *text) width = 0; while ((c = *text++) != 0) { - if (c < 33) + if (c < 33 || c > 91) // [crispy] fail-safe: consider patches above FONTA(Y)59 as spaces { width += 5; } @@ -642,7 +642,7 @@ void MN_DrTextB(const char *text, int x, int y) while ((c = *text++) != 0) { - if (c < 33) + if (c < 33 || c > 90) // [crispy] fail-safe: draw patches above FONTB58 as spaces { x += 8; } @@ -672,7 +672,7 @@ int MN_TextBWidth(const char *text) width = 0; while ((c = *text++) != 0) { - if (c < 33) + if (c < 33 || c > 90) // [crispy] fail-safe: consider patches above FONTB58 as spaces { width += 5; }