summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonAki <konaki@anokonaki.org>2026-10-16 07:06:23 +0800
committerKonAki <konaki@anokonaki.org>2026-10-16 07:06:23 +0800
commit85c684cefcb133ce5025f991077b2d9f9bc9ec64 (patch)
treef5e884cdc6171d17e05684d55e313b9b1d06b6b3
parentc821bab136a3fd46facf9a053359309ab2cc4d5c (diff)
mzscript: write the move route of command 205
-rw-r--r--tools/mzscript.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/tools/mzscript.c b/tools/mzscript.c
index a0d48d6..1ad1c6a 100644
--- a/tools/mzscript.c
+++ b/tools/mzscript.c
@@ -272,6 +272,43 @@ static void host(buf_t *out, int code, const kon_json_t *parameters)
freeTokens(&t);
}
+/* command 205: who, then the route as numbers, code count and the count numbers of each command, tab apart. what a command
+ has besides numbers (a character sheet, a script) is left out and its count is 0, the same as in the map's own routes */
+static void routeHost(buf_t *out, const kon_json_t *p)
+{
+ const kon_json_t *route = kon_jsonAt(p, 1);
+ const kon_json_t *list = kon_jsonGet(route, "list");
+ int flags = (kon_jsonBool(kon_jsonGet(route, "repeat"), 0) ? 1 : 0) | (kon_jsonBool(kon_jsonGet(route, "skippable"), 0) ? 2 : 0) | (kon_jsonBool(kon_jsonGet(route, "wait"), 0) ? 4 : 0);
+ buf_t text = {0};
+ int i, k, written = 0;
+
+ countHost(205);
+ for (i = 0; i < kon_jsonCount(list) && text.n < 3500; i++) {
+ const kon_json_t *command = kon_jsonAt(list, i);
+ const kon_json_t *params = kon_jsonGet(command, "parameters");
+ int code = kon_jsonInt(kon_jsonGet(command, "code"), 0), count = 0, allNumbers = 1;
+
+ if (code <= 0 || code > 1000) continue;
+ for (k = 0; k < kon_jsonCount(params) && k < 8; k++) {
+ const kon_json_t *q = kon_jsonAt(params, k);
+
+ if (!q || (q->type != KON_JSON_NUMBER && q->type != KON_JSON_BOOL)) allNumbers = 0;
+ }
+ if (allNumbers) count = kon_jsonCount(params) < 8 ? kon_jsonCount(params) : 8;
+ put(&text, "%s%d\t%d", written ? "\t" : "", code, count);
+ for (k = 0; k < count; k++) put(&text, "\t%d", kon_jsonInt(kon_jsonAt(params, k), 0));
+ written++;
+ }
+ put(out, "\thost 205 %d %d 0", kon_jsonInt(kon_jsonAt(p, 0), 0), flags);
+ if (written) {
+ text.p[text.n] = '\0';
+ put(out, " ");
+ putString(out, text.p);
+ }
+ put(out, "\n");
+ free(text.p);
+}
+
/*** one event list ***/
typedef struct frame {
@@ -698,7 +735,7 @@ static void convert(context_t *c, const kon_json_t *list)
break;
}
case 205:
- host(out, 205, p);
+ routeHost(out, p);
while (i + 1 < n && commandCode(list, i + 1) == 505) i++;
break;
case 357: