From 9a0009101fc6ffeb8fd02fb30078c8694f7b850e Mon Sep 17 00:00:00 2001 From: Alula <6276139+alula@users.noreply.github.com> Date: Mon, 19 Apr 2021 21:14:52 +0200 Subject: [PATCH] fix a tsc compiler bug where # in middle of event was interpreted as start of new one --- src/text_script.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/text_script.rs b/src/text_script.rs index 1bb9317..a3e6913 100644 --- a/src/text_script.rs +++ b/src/text_script.rs @@ -1736,10 +1736,11 @@ impl TextScript { ) -> GameResult> { let mut bytecode = Vec::new(); let mut char_buf = Vec::with_capacity(16); + let mut allow_next_event = false; while let Some(&chr) = iter.peek() { match chr { - b'#' => { + b'#' if allow_next_event => { if !char_buf.is_empty() { TextScript::put_string(&mut char_buf, &mut bytecode, encoding); } @@ -1749,6 +1750,7 @@ impl TextScript { break; } b'<' => { + allow_next_event = false; if !char_buf.is_empty() { TextScript::put_string(&mut char_buf, &mut bytecode, encoding); } @@ -1766,7 +1768,14 @@ impl TextScript { b'\r' => { iter.next(); } + b'\n' => { + allow_next_event = true; + char_buf.push(chr); + + iter.next(); + } _ => { + allow_next_event = false; char_buf.push(chr); iter.next();