mirror of
https://github.com/evennia/evennia.git
synced 2026-04-01 05:27:17 +02:00
Make at_post_cmd() run after func() also for delayed commands. Resolve #2179
This commit is contained in:
parent
29b381fbe6
commit
4ba2f444ff
2 changed files with 23 additions and 10 deletions
|
|
@ -70,6 +70,8 @@ without arguments starts a full interactive Python console.
|
|||
- Make `INLINEFUNC_STACK_MAXSIZE` default visible in `settings_default.py`.
|
||||
- Change how `ic` finds puppets; non-priveleged users will use `_playable_characters` list as
|
||||
candidates, Builders+ will use list, local search and only global search if no match found.
|
||||
- Make `cmd.at_post_cmd()` always run after `cmd.func()`, even when the latter uses delays
|
||||
with yield.
|
||||
|
||||
|
||||
## Evennia 0.9 (2018-2019)
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ def _progressive_cmd_run(cmd, generator, response=None):
|
|||
else:
|
||||
value = generator.send(response)
|
||||
except StopIteration:
|
||||
pass
|
||||
raise
|
||||
else:
|
||||
if isinstance(value, (int, float)):
|
||||
utils.delay(value, _progressive_cmd_run, cmd, generator)
|
||||
|
|
@ -631,20 +631,31 @@ def cmdhandler(
|
|||
ret = cmd.func()
|
||||
if isinstance(ret, types.GeneratorType):
|
||||
# cmd.func() is a generator, execute progressively
|
||||
_progressive_cmd_run(cmd, ret)
|
||||
in_generator = True
|
||||
try:
|
||||
_progressive_cmd_run(cmd, ret)
|
||||
except StopIteration:
|
||||
# this means func() has run its course
|
||||
in_generator = False
|
||||
yield None
|
||||
else:
|
||||
in_generator = False
|
||||
ret = yield ret
|
||||
|
||||
# post-command hook
|
||||
yield cmd.at_post_cmd()
|
||||
if not in_generator:
|
||||
# this will only run if we are out of the generator for this
|
||||
# cmd, otherwise we would have at_post_cmd run before a delayed
|
||||
# func() finished
|
||||
|
||||
if cmd.save_for_next:
|
||||
# store a reference to this command, possibly
|
||||
# accessible by the next command.
|
||||
caller.ndb.last_cmd = yield copy(cmd)
|
||||
else:
|
||||
caller.ndb.last_cmd = None
|
||||
# post-command hook
|
||||
yield cmd.at_post_cmd()
|
||||
|
||||
if cmd.save_for_next:
|
||||
# store a reference to this command, possibly
|
||||
# accessible by the next command.
|
||||
caller.ndb.last_cmd = yield copy(cmd)
|
||||
else:
|
||||
caller.ndb.last_cmd = None
|
||||
|
||||
# return result to the deferred
|
||||
returnValue(ret)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue