fix a tsc compiler bug where # in middle of event was interpreted as start of new one

This commit is contained in:
Alula 2021-04-19 21:14:52 +02:00
parent 662dc2adbf
commit 9a0009101f
No known key found for this signature in database
GPG Key ID: 3E00485503A1D8BA
1 changed files with 10 additions and 1 deletions

View File

@ -1736,10 +1736,11 @@ impl TextScript {
) -> GameResult<Vec<u8>> {
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();