From 4e9d070b6421fe4641c414ce69a3a5f39c507e4d Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 1 Oct 2016 15:41:10 +0200 Subject: [PATCH] Save the cmdset stack before entering batchcommands in order to properly re-establiish the stack after batch runs instead of simply clearing it. Resolves #1085. --- evennia/commands/default/batchprocess.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/evennia/commands/default/batchprocess.py b/evennia/commands/default/batchprocess.py index 583ac6e8c3..38518e837d 100644 --- a/evennia/commands/default/batchprocess.py +++ b/evennia/commands/default/batchprocess.py @@ -205,9 +205,15 @@ def purge_processor(caller): del caller.ndb.batch_batchmode except: pass - # clear everything but the default cmdset. - caller.cmdset.delete(BatchSafeCmdSet) - caller.cmdset.clear() + # clear everything back to the state before the batch call + if caller.ndb.batch_cmdset_backup: + caller.cmdset.cmdset_stack = caller.ndb.batch_cmdset_backup + caller.cmdset.update() + del caller.ndb.batch_cmdset_backup + else: + # something went wrong. Purge cmdset except default + caller.cmdset.clear() + caller.scripts.validate() # this will purge interactive mode #------------------------------------------------------------ @@ -269,6 +275,8 @@ class CmdBatchCommands(_COMMAND_DEFAULT_CLASS): caller.ndb.batch_stackptr = 0 caller.ndb.batch_pythonpath = python_path caller.ndb.batch_batchmode = "batch_commands" + # we use list() here to create a new copy of the cmdset stack + caller.ndb.batch_cmdset_backup = list(caller.cmdset.cmdset_stack) caller.cmdset.add(BatchSafeCmdSet) if 'inter' in switches or 'interactive' in switches: @@ -377,6 +385,8 @@ class CmdBatchCode(_COMMAND_DEFAULT_CLASS): caller.ndb.batch_pythonpath = python_path caller.ndb.batch_batchmode = "batch_code" caller.ndb.batch_debug = debug + # we use list() here to create a new copy of cmdset_stack + caller.ndb.batch_cmdset_backup = list(caller.cmdset.cmdset_stack) caller.cmdset.add(BatchSafeCmdSet) if 'inter' in switches or 'interactive'in switches: @@ -696,10 +706,7 @@ class CmdStateCC(_COMMAND_DEFAULT_CLASS): step_pointer(caller, 1) show_curr(caller) - del caller.ndb.batch_stack - del caller.ndb.batch_stackptr - del caller.ndb.batch_pythonpath - del caller.ndb.batch_batchmode + purge_processor(self) caller.msg(format_code("Finished processing batch file."))