diff options
author | kdx <kikoodx@paranoici.org> | 2023-09-14 14:37:41 +0200 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-09-14 14:37:41 +0200 |
commit | 6e52997d0db19c557677adb8f5694e29437d027f (patch) | |
tree | b178134ee8098dee0437caacd21ba6698ad2e8b7 | |
parent | 7027243d1e97e361201ab3bfa62ec0610c6d26dd (diff) | |
download | tiled2c-6e52997d0db19c557677adb8f5694e29437d027f.tar.gz |
properly calculate object count
-rw-r--r-- | src/main.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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') |