Skip to content

Commit

Permalink
- fixed: MENUDEF did not take recusive parsing into account when chec…
Browse files Browse the repository at this point in the history
…king the default scaling mode.
  • Loading branch information
coelckers committed Oct 26, 2020
1 parent 6a9bfa2 commit d850ca6
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/common/menu/menudef.cpp
Expand Up @@ -267,10 +267,8 @@ static bool CheckSkipOptionBlock(FScanner &sc)
//
//=============================================================================

static void ParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc)
static void ParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc, bool &sizeset, bool &sizecompatible)
{
bool sizeset = false;
bool sizecompatible = true;
sc.MustGetStringName("{");
while (!sc.CheckString("}"))
{
Expand All @@ -284,23 +282,23 @@ static void ParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc)
if (!CheckSkipGameBlock(sc))
{
// recursively parse sub-block
ParseListMenuBody(sc, desc);
ParseListMenuBody(sc, desc, sizeset, sizecompatible);
}
}
else if (sc.Compare("ifnotgame"))
{
if (!CheckSkipGameBlock(sc, false))
{
// recursively parse sub-block
ParseListMenuBody(sc, desc);
ParseListMenuBody(sc, desc, sizeset, sizecompatible);
}
}
else if (sc.Compare("ifoption"))
{
if (!CheckSkipOptionBlock(sc))
{
// recursively parse sub-block
ParseListMenuBody(sc, desc);
ParseListMenuBody(sc, desc, sizeset, sizecompatible);
}
}
else if (sc.Compare("Class"))
Expand Down Expand Up @@ -382,6 +380,7 @@ static void ParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc)
}
else if (sc.Compare("size"))
{
sizeset = true;
if (sc.CheckNumber())
{
desc->mVirtWidth = sc.Number;
Expand Down Expand Up @@ -544,10 +543,6 @@ static void ParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc)
}
}
}
if (!sizeset && sizecompatible) // allow unclean scaling on this menu
{
desc->mVirtWidth = -2;
}
for (auto &p : desc->mItems)
{
GC::WriteBarrier(p);
Expand Down Expand Up @@ -700,8 +695,16 @@ static void ParseListMenu(FScanner &sc)
desc->mWRight = 0;
desc->mCenter = false;
desc->mFromEngine = fileSystem.GetFileContainer(sc.LumpNum) == 0; // flags menu if the definition is from the IWAD.
desc->mVirtWidth = -2;

bool sizeset = false;
bool sizecompatible = true;
ParseListMenuBody(sc, desc, sizeset, sizecompatible);
if (!sizeset && sizecompatible) // allow unclean scaling on this menu
{
desc->mVirtWidth = -2;
}

ParseListMenuBody(sc, desc);
ReplaceMenu(sc, desc);
}

Expand Down Expand Up @@ -1296,7 +1299,8 @@ void M_ParseMenuDefs()
}
else if (sc.Compare("DEFAULTLISTMENU"))
{
ParseListMenuBody(sc, DefaultListMenuSettings);
bool s = false;
ParseListMenuBody(sc, DefaultListMenuSettings, s, s);
if (DefaultListMenuSettings->mItems.Size() > 0)
{
I_FatalError("You cannot add menu items to the menu default settings.");
Expand Down

0 comments on commit d850ca6

Please sign in to comment.