From 8482653bbc800f4271b8c791a69bbd9c7243f19b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Jun 2017 08:52:04 +0200 Subject: [PATCH] Menu protection features - added a '-nocustommenu' command line options. This is for disabling user menus that intentionally or accidentally disable crucial menu features. - do not allow replacement of the main options menu. This menu contains engine-critical settings and may change at any time when new features get added. For now it will be the only one that gets protected but this may soon be extended to some of its submenus as well. --- src/menu/menudef.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index 37ca2fc0a..33645dd66 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -54,6 +54,7 @@ #include "vm.h" #include "types.h" #include "gameconfigfile.h" +#include "m_argv.h" @@ -520,6 +521,12 @@ static bool ReplaceMenu(FScanner &sc, DMenuDescriptor *desc) DMenuDescriptor **pOld = MenuDescriptors.CheckKey(desc->mMenuName); if (pOld != nullptr && *pOld != nullptr) { + if (desc->mMenuName == NAME_Optionsmenu) + { + sc.ScriptMessage("Cannot replace the main options menu!"); + return true; + } + if (!CheckCompatible(desc, *pOld)) { sc.ScriptMessage("Tried to replace menu '%s' with a menu of different type", desc->mMenuName.GetChars()); @@ -980,6 +987,7 @@ void M_ParseMenuDefs() sc.ScriptError("Unknown keyword '%s'", sc.String); } } + if (Args->CheckParm("-nocustommenu")) break; } DefaultListMenuClass = DefaultListMenuSettings->mClass; DefaultListMenuSettings = nullptr;