diff options
Diffstat (limited to 'tools/mzsurvey.c')
| -rw-r--r-- | tools/mzsurvey.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/tools/mzsurvey.c b/tools/mzsurvey.c index 61253a6..92995f4 100644 --- a/tools/mzsurvey.c +++ b/tools/mzsurvey.c @@ -380,21 +380,43 @@ static void plugins(const char *path) free(text); } +/* 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; +} + int main(int argc, char **argv) { - char path[1024]; + char path[1024], dataPath[1000]; if (argc < 2) { fprintf(stderr, "usage: mzsurvey <data folder> [plugins.js]\n"); return 2; } - if (survey(argv[1])) return 1; + if (!findData(dataPath, sizeof dataPath, argv[1])) return 1; + if (survey(dataPath)) return 1; commandReport(); show(&pluginCommands, "plugin commands", 40); show(&scriptCalls, "script calls", 25); show(¬eTags, "note tags", 40); show(&tilesets, "tilesets used by maps", 20); - snprintf(path, sizeof path, "%s/../js/plugins.js", argv[1]); + snprintf(path, sizeof path, "%s/../js/plugins.js", dataPath); plugins(argc > 2 ? argv[2] : path); return 0; } |
