diff options
| author | KonAki <konaki@anokonaki.org> | 2026-10-15 05:40:42 +0800 |
|---|---|---|
| committer | KonAki <konaki@anokonaki.org> | 2026-10-15 05:40:42 +0800 |
| commit | 79957363275663e82900160b5a08aa56fc21086c (patch) | |
| tree | 1cf23e5497a8c82ff69c45c6bcefd69be0066434 /tools/mzscript.c | |
| parent | 60698e3006c88bc6b9eb4a851e21197c39e7a12d (diff) | |
find the data folder from the game folder in the converters
Diffstat (limited to 'tools/mzscript.c')
| -rw-r--r-- | tools/mzscript.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tools/mzscript.c b/tools/mzscript.c index 077efb2..38b2f6d 100644 --- a/tools/mzscript.c +++ b/tools/mzscript.c @@ -725,6 +725,27 @@ static void convert(context_t *c, const kon_json_t *list) /*** files ***/ +/* a game folder works too, the data is in data, or in www/data for MV */ +static int findData(char *out, size_t size, const char *folder) +{ + static const char *const where[] = {"", "/data", "/www/data"}; + char path[1100]; + FILE *f; + int i; + + for (i = 0; i < 3; i++) { + snprintf(path, sizeof path, "%s%s/System.json", folder, where[i]); + f = fopen(path, "rb"); + if (f) { + fclose(f); + snprintf(out, size, "%s%s", folder, where[i]); + return 1; + } + } + fprintf(stderr, "no System.json in %s, %s/data or %s/www/data\n", folder, folder, folder); + return 0; +} + static kon_json_t *load(const char *folder, const char *name) { char path[1024], error[120]; @@ -788,7 +809,7 @@ int main(int argc, char **argv) buf_t out; context_t c; kon_json_t *system, *json; - char scope[40], name[64] = "game", prefix[1024], error[200]; + char scope[40], name[64] = "game", prefix[1024], error[200], dataPath[1100]; const char *folder = NULL, *outFolder = NULL; int id, k, p, a, maxCommon = 0, entries = 0, split = 0, text = 0; konsc_result_t result; @@ -804,6 +825,8 @@ int main(int argc, char **argv) fprintf(stderr, "usage: mzscript [-n name] [-split rows] [-text] <data folder> <output folder>\n"); return 2; } + if (!findData(dataPath, sizeof dataPath, folder)) return 1; + folder = dataPath; snprintf(prefix, sizeof prefix, "%s/%s", outFolder, name); memset(&out, 0, sizeof out); |
