diff options
author | Darshan Shaligram <dshaligram@users.sourceforge.net> | 2010-07-16 18:47:28 +0530 |
---|---|---|
committer | Darshan Shaligram <dshaligram@users.sourceforge.net> | 2010-07-16 19:04:00 +0530 |
commit | b7cedc63f4d463212bbf77c3708abd9faddd2b89 (patch) | |
tree | cddb8d2acdd1ad704551d85c039f2715f2f1831b /crawl-ref/source/macro.h | |
parent | 3a57810f6f89d315f9930f1d826b114bfba56c99 (diff) | |
download | crawl-ref-b7cedc63f4d463212bbf77c3708abd9faddd2b89.tar.gz crawl-ref-b7cedc63f4d463212bbf77c3708abd9faddd2b89.zip |
Fix Aliza's macro crash (!lm Aliza type=crash 1)
The game triggered an assert when
1. The keyboard buffer had several queued keystrokes (not macro-expanded)
2. The first keystroke triggered a Lua macro that added expanded keystrokes to
the *end* of the macro buffer -- adding expanded keys to the *front* of
the macro buffer was always safe.
3. The macro buffer ended up looking like this: <keys-waiting-macroexpansion>
<macroexpanded-keys>
(3) triggers the assert, since Crawl expects macroexpanded keys to always be at
the front of the macro buffer.
Fixed by using a secondary keybuffer to collect keys injected by Lua macros and
add them to the primary macro buffer only when it is empty.
Lua sendkeys and process_keys both add expanded keys to the end of the macro
buffer, which is probably not intended; they should presumably be adding keys
to the front of the macro buffer. This fix does not address that, however.
Also clear macro buffers when restarting after a game ends
(restart_after_game=yes)
Diffstat (limited to 'crawl-ref/source/macro.h')
-rw-r--r-- | crawl-ref/source/macro.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crawl-ref/source/macro.h b/crawl-ref/source/macro.h index 41da79d3a3..bba101ac68 100644 --- a/crawl-ref/source/macro.h +++ b/crawl-ref/source/macro.h @@ -46,8 +46,18 @@ void macro_add_query(); void macro_init(); void macro_save(); +void macro_clear_buffers(); + void macro_userfn(const char *keys, const char *registryname); +// Add macro-expanded keys to the end or start of the keyboard buffer. +void macro_sendkeys_end_add_expanded(int key); +void macro_sendkeys_start_add_expanded(int key); + +// [ds] Unless you know what you're doing, prefer macro_sendkeys_add_expanded +// to direct calls to macro_buf_add for pre-expanded key sequences. +// +// Crawl doesn't like holes in macro-expanded sequences in its main buffer. void macro_buf_add(int key, bool reverse = false, bool expanded = true); void macro_buf_add(const keyseq &actions, |