diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-05-07 20:44:37 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-05-24 21:06:18 +0200 |
commit | 26c2e43e5d784cfe344b70e91b5c2afda112ba70 (patch) | |
tree | 26f21248d90679444d0df3cb5085478f93e730a0 | |
parent | 23bc441db1a06ba5caf3bd98bfab9929a8964180 (diff) | |
download | red-flag-over-paris-26c2e43e5d784cfe344b70e91b5c2afda112ba70.tar.gz |
Fix else.
-rw-r--r-- | rules.js | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -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() { |