~cadence/PE-DIA

7d763a1cd32fa3b190be33c1104e7080e1fcacc4 — Cadence Ember 2 years ago de9ca01
Fix infinite loops

- Interchange text without replies
- Mismatched square bracket text effects
2 files changed, 7 insertions(+), 3 deletions(-)

M parser.js
M processor.js
M parser.js => parser.js +3 -2
@@ 72,8 72,9 @@ export class Parser {
	 * @param {number} level Number of brackets that are currently open
	 */
	getBrackets(open, close, level = 0) {
		let start, end
		while (true) {
		let start
		let end = this.cursor
		while (this.hasRemaining()) {
			const char = this.slice(1, true)
			if (char === open) {
				level++

M processor.js => processor.js +4 -1
@@ 175,7 175,7 @@ class Interchange {
			const myEffectName = parser.get({split: " "})
			const formalEffectName = formalEffects.get(myEffectName)
			if (!formalEffectName) {
				throw new Error(`No text effect named ${myEffectName}`)
				throw new Error(`No text effect named '${myEffectName}'`)
			}
			openEffects.push({effect: formalEffectName, start: noEffectText.length})
			// console.error(`effect ${effect} started. open effects:`, openEffects)


@@ 197,6 197,9 @@ class Interchange {
			if (parser.slice(2) === "* ") {
				break
			}
			if (!parser.hasRemaining()) {
				return
			}
		}

		let effects