diff --git a/src/c_dispatch.cpp b/src/c_dispatch.cpp index 73d0d5d3e6..fa786b271b 100644 --- a/src/c_dispatch.cpp +++ b/src/c_dispatch.cpp @@ -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 (brkpt, tics); + Create (brkpt, tics, UnsafeExecutionContext); } return; }