Skip to content

Commit

Permalink
Add safe FontA access
Browse files Browse the repository at this point in the history
  • Loading branch information
kraflab committed Jul 20, 2024
1 parent 22e6580 commit 9502055
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions prboom2/src/heretic/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ static int MenuTime;

dboolean mn_SuicideConsole;

static int MN_SafeFontALump(int offset)
{
if (offset > 58)
return FontABaseLump;

return FontABaseLump + offset;
}

static void MN_InitFonts(void)
{
FontABaseLump = W_GetNumForName("FONTA_S") + 1;
Expand Down Expand Up @@ -422,7 +430,7 @@ void MN_DrTextA(const char *text, int x, int y)
}
else
{
lump = FontABaseLump + c - 33;
lump = MN_SafeFontALump(c - 33);
V_DrawNumPatch(x, y, 0, lump, CR_DEFAULT, VPT_STRETCH);
x += R_NumPatchWidth(lump) - 1;
}
Expand Down Expand Up @@ -458,7 +466,7 @@ int MN_TextAWidth(const char *text)
}
else
{
lump = FontABaseLump + c - 33;
lump = MN_SafeFontALump(c - 33);
width += R_NumPatchWidth(lump) - 1;
}
}
Expand Down

0 comments on commit 9502055

Please sign in to comment.