Added propagation of unsafe execution context to waiting command

Thanks Edward-san for pointing this out
This commit is contained in:
alexey.lysiuk 2018-01-08 10:41:31 +02:00
parent 059e40e2d5
commit b008426ed7

View file

@ -65,7 +65,7 @@ class DWaitingCommand : public DThinker
{
DECLARE_CLASS (DWaitingCommand, DThinker)
public:
DWaitingCommand (const char *cmd, int tics);
DWaitingCommand (const char *cmd, int tics, bool unsafe);
~DWaitingCommand ();
void Serialize(FSerializer &arc);
void Tick ();
@ -75,6 +75,7 @@ private:
char *Command;
int TicsLeft;
bool IsUnsafe;
};
class DStoredCommand : public DThinker
@ -203,12 +204,14 @@ DWaitingCommand::DWaitingCommand ()
{
Command = NULL;
TicsLeft = 1;
IsUnsafe = false;
}
DWaitingCommand::DWaitingCommand (const char *cmd, int tics)
DWaitingCommand::DWaitingCommand (const char *cmd, int tics, bool unsafe)
{
Command = copystring (cmd);
TicsLeft = tics+1;
IsUnsafe = unsafe;
}
DWaitingCommand::~DWaitingCommand ()
@ -223,7 +226,10 @@ void DWaitingCommand::Tick ()
{
if (--TicsLeft == 0)
{
const bool wasUnsafe = UnsafeExecutionContext;
UnsafeExecutionContext = IsUnsafe;
AddCommandString (Command);
UnsafeExecutionContext = wasUnsafe;
Destroy ();
}
}
@ -739,7 +745,7 @@ void AddCommandString (char *cmd, int keynum)
// Note that deferred commands lose track of which key
// (if any) they were pressed from.
*brkpt = ';';
Create<DWaitingCommand> (brkpt, tics);
Create<DWaitingCommand> (brkpt, tics, UnsafeExecutionContext);
}
return;
}