summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-09-14 14:37:41 +0200
committerkdx <kikoodx@paranoici.org>2023-09-14 14:37:41 +0200
commit6e52997d0db19c557677adb8f5694e29437d027f (patch)
treeb178134ee8098dee0437caacd21ba6698ad2e8b7
parent7027243d1e97e361201ab3bfa62ec0610c6d26dd (diff)
downloadtiled2c-6e52997d0db19c557677adb8f5694e29437d027f.tar.gz
properly calculate object count
-rw-r--r--src/main.c10
1 files changed, 9 insertions, 1 deletions
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')