- be more thorough with 'in menu' checks for certain protected functions.
They would also pass the test if a menu just was open but not the actual invoker. Also error out if this happens so that modders can see that they are doing unsupported things. Silent failure is not a good idea here.
This commit is contained in:
parent
53ee7cfc7b
commit
3046a7dd81
4 changed files with 48 additions and 4 deletions
|
|
@ -45,6 +45,7 @@
|
|||
#include "dobject.h"
|
||||
#include "vm.h"
|
||||
#include "i_time.h"
|
||||
#include "menu/menu.h"
|
||||
|
||||
const char *KeyNames[NUM_KEYS] =
|
||||
{
|
||||
|
|
@ -267,6 +268,14 @@ DEFINE_ACTION_FUNCTION(FKeyBindings, SetBind)
|
|||
PARAM_SELF_STRUCT_PROLOGUE(FKeyBindings);
|
||||
PARAM_INT(k);
|
||||
PARAM_STRING(cmd);
|
||||
|
||||
// Only menus are allowed to change bindings.
|
||||
if (DMenu::InMenu == 0)
|
||||
{
|
||||
I_FatalError("Attempt to change key bindings outside of menu code to '%s'", cmd.GetChars());
|
||||
}
|
||||
|
||||
|
||||
self->SetBind(k, cmd);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -506,6 +515,13 @@ DEFINE_ACTION_FUNCTION(FKeyBindings, UnbindACommand)
|
|||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(FKeyBindings);
|
||||
PARAM_STRING(cmd);
|
||||
|
||||
// Only menus are allowed to change bindings.
|
||||
if (DMenu::InMenu == 0)
|
||||
{
|
||||
I_FatalError("Attempt to unbind key bindings for '%s' outside of menu code", cmd.GetChars());
|
||||
}
|
||||
|
||||
self->UnbindACommand(cmd);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue