summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-05-07 20:44:37 +0200
committerTor Andersson <tor@ccxvii.net>2023-05-24 21:06:18 +0200
commit26c2e43e5d784cfe344b70e91b5c2afda112ba70 (patch)
tree26f21248d90679444d0df3cb5085478f93e730a0
parent23bc441db1a06ba5caf3bd98bfab9929a8964180 (diff)
downloadred-flag-over-paris-26c2e43e5d784cfe344b70e91b5c2afda112ba70.tar.gz
Fix else.
-rw-r--r--rules.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/rules.js b/rules.js
index 0aac4cc..d293e17 100644
--- a/rules.js
+++ b/rules.js
@@ -2068,7 +2068,22 @@ function vm_if() {
}
function vm_else() {
- vm_goto(vm_endif, vm_if, 1, 1)
+ vm_jump(vm_endif, vm_if, 1, 1)
+}
+
+function vm_jump(op, nop, dir, step) {
+ let balance = 1
+ while (balance > 0) {
+ game.vm.ip += dir
+ if (vm_inst(0) === op)
+ --balance
+ if (vm_inst(0) === nop)
+ ++balance
+ if (game.vm.ip < 0 || game.vm.ip > CODE[game.vm.fp].length)
+ throw "ERROR"
+ }
+ game.vm.ip += step
+ vm_exec()
}
function vm_endif() {