- 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:
Christoph Oelckers 2018-09-15 12:30:05 +02:00
commit 3046a7dd81
4 changed files with 48 additions and 4 deletions

View file

@ -53,6 +53,7 @@
#include "events.h"
#include "scripting/types.h"
int DMenu::InMenu;
//
// Todo: Move these elsewhere
//
@ -190,7 +191,9 @@ bool DMenu::CallResponder(event_t *ev)
VMValue params[] = { (DObject*)this, &e };
int retval;
VMReturn ret(&retval);
InMenu++;
VMCall(func, params, 2, &ret, 1);
InMenu--;
return !!retval;
}
}
@ -202,7 +205,9 @@ bool DMenu::CallResponder(event_t *ev)
VMValue params[] = { (DObject*)this, &e };
int retval;
VMReturn ret(&retval);
InMenu++;
VMCall(func, params, 2, &ret, 1);
InMenu--;
return !!retval;
}
}
@ -222,7 +227,9 @@ bool DMenu::CallMenuEvent(int mkey, bool fromcontroller)
VMValue params[] = { (DObject*)this, mkey, fromcontroller };
int retval;
VMReturn ret(&retval);
InMenu++;
VMCall(func, params, 3, &ret, 1);
InMenu--;
return !!retval;
}
else return false;