summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorKonAki <konaki@anokonaki.org>2026-10-14 01:12:42 +0800
committerKonAki <konaki@anokonaki.org>2026-10-14 01:12:42 +0800
commit6754c66ba61e5145fc40049213ac8fd6182f74a8 (patch)
treef427c279c25d2dacd5b09658172ef7105a8a7f61 /tools
parent0815b5fc1f7e7b98e65499dbebc05034bec6dba0 (diff)
mzscript: skip calls to missing common events, build the converters
Diffstat (limited to 'tools')
-rw-r--r--tools/mzscript.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/mzscript.c b/tools/mzscript.c
index 53fcbff..f9371f6 100644
--- a/tools/mzscript.c
+++ b/tools/mzscript.c
@@ -279,7 +279,7 @@ typedef struct context {
buf_t *out;
const char *scope;
int counter;
- int scratchSwitch, scratchVar;
+ int scratchSwitch, scratchVar, maxCommon;
char labelNames[512][64];
char labelDone[512];
int labelCount;
@@ -582,6 +582,10 @@ static void convert(context_t *c, const kon_json_t *list)
put(out, "\treturn\n");
break;
case 117:
+ if (kon_jsonInt(kon_jsonAt(p, 0), 0) < 1 || kon_jsonInt(kon_jsonAt(p, 0), 0) > c->maxCommon) {
+ put(out, "\t# call of a common event that is not there\n");
+ break;
+ }
put(out, "\t%s common_%d\n", tailCall(list, i) ? "jump" : "call", kon_jsonInt(kon_jsonAt(p, 0), 0));
structured++;
break;
@@ -754,6 +758,7 @@ int main(int argc, char **argv)
json = load(argv[1], "CommonEvents.json");
if (json) {
maxCommon = kon_jsonCount(json) - 1;
+ c.maxCommon = maxCommon;
for (id = 1; id <= maxCommon; id++) {
const kon_json_t *event = kon_jsonAt(json, id);