mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-27 14:22:13 +00:00
- added a check to the MENUDEF parser to prevent special menus from being replaced by something non-functional to counter attempts to cripple the engine's functionality.
SVN r3682 (trunk)
This commit is contained in:
parent
086d0a797e
commit
18839acddb
2 changed files with 36 additions and 11 deletions
|
@ -86,6 +86,7 @@ struct FMenuDescriptor
|
|||
FName mMenuName;
|
||||
FString mNetgameMessage;
|
||||
int mType;
|
||||
const PClass *mClass;
|
||||
|
||||
virtual ~FMenuDescriptor() {}
|
||||
};
|
||||
|
@ -108,7 +109,6 @@ struct FListMenuDescriptor : public FMenuDescriptor
|
|||
FFont *mFont;
|
||||
EColorRange mFontColor;
|
||||
EColorRange mFontColor2;
|
||||
const PClass *mClass;
|
||||
FMenuDescriptor *mRedirect; // used to redirect overlong skill and episode menus to option menu based alternatives
|
||||
bool mCenter;
|
||||
|
||||
|
@ -153,7 +153,6 @@ struct FOptionMenuDescriptor : public FMenuDescriptor
|
|||
int mIndent;
|
||||
int mPosition;
|
||||
bool mDontDim;
|
||||
const PClass *mClass;
|
||||
|
||||
void CalcIndent();
|
||||
FOptionMenuItem *GetItem(FName name);
|
||||
|
|
|
@ -450,6 +450,37 @@ static void ParseListMenuBody(FScanner &sc, FListMenuDescriptor *desc)
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
static bool CheckCompatible(FMenuDescriptor *newd, FMenuDescriptor *oldd)
|
||||
{
|
||||
if (oldd->mClass == NULL) return true;
|
||||
return oldd->mClass == newd->mClass;
|
||||
}
|
||||
|
||||
static bool ReplaceMenu(FScanner &sc, FMenuDescriptor *desc)
|
||||
{
|
||||
FMenuDescriptor **pOld = MenuDescriptors.CheckKey(desc->mMenuName);
|
||||
if (pOld != NULL && *pOld != NULL)
|
||||
{
|
||||
if (CheckCompatible(desc, *pOld))
|
||||
{
|
||||
delete *pOld;
|
||||
}
|
||||
else
|
||||
{
|
||||
sc.ScriptMessage("Tried to replace menu '%s' with a menu of different type", desc->mMenuName.GetChars());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
MenuDescriptors[desc->mMenuName] = desc;
|
||||
return false;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
static void ParseListMenu(FScanner &sc)
|
||||
{
|
||||
sc.MustGetString();
|
||||
|
@ -476,11 +507,9 @@ static void ParseListMenu(FScanner &sc)
|
|||
desc->mWRight = 0;
|
||||
desc->mCenter = false;
|
||||
|
||||
FMenuDescriptor **pOld = MenuDescriptors.CheckKey(desc->mMenuName);
|
||||
if (pOld != NULL && *pOld != NULL) delete *pOld;
|
||||
MenuDescriptors[desc->mMenuName] = desc;
|
||||
|
||||
ParseListMenuBody(sc, desc);
|
||||
bool scratch = ReplaceMenu(sc, desc);
|
||||
if (scratch) delete desc;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -810,13 +839,10 @@ static void ParseOptionMenu(FScanner &sc)
|
|||
desc->mIndent = DefaultOptionMenuSettings.mIndent;
|
||||
desc->mDontDim = DefaultOptionMenuSettings.mDontDim;
|
||||
|
||||
FMenuDescriptor **pOld = MenuDescriptors.CheckKey(desc->mMenuName);
|
||||
if (pOld != NULL && *pOld != NULL) delete *pOld;
|
||||
MenuDescriptors[desc->mMenuName] = desc;
|
||||
|
||||
ParseOptionMenuBody(sc, desc);
|
||||
|
||||
bool scratch = ReplaceMenu(sc, desc);
|
||||
if (desc->mIndent == 0) desc->CalcIndent();
|
||||
if (scratch) delete desc;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue