From 6e52997d0db19c557677adb8f5694e29437d027f Mon Sep 17 00:00:00 2001 From: kdx Date: Thu, 14 Sep 2023 14:37:41 +0200 Subject: properly calculate object count --- src/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 21fdd75..176af47 100644 --- a/src/main.c +++ b/src/main.c @@ -171,7 +171,15 @@ process_map(const char *word, const char *path, cJSON *json) return -1; } } - printf("},%d,(const Tiled2cObject[]){", cJSON_GetArraySize(layers)); + int numobjects = 0; + cJSON_ArrayForEach(layer, layers) { + JSON_GET_STRING(layer, type); + if (type->valuestring[0] != 'o') + continue; + JSON_GET_ARRAY(layer, objects); + numobjects += cJSON_GetArraySize(objects); + } + printf("},%d,(const Tiled2cObject[]){", numobjects); cJSON_ArrayForEach(layer, layers) { JSON_GET_STRING(layer, type); if (type->valuestring[0] != 'o') -- cgit v1.2.3