LibTMJ 2.0.0
A library for loading JSON Tiled maps
Loading...
Searching...
No Matches
tileset.c
Go to the documentation of this file.
1#include <string.h>
2
3#include <jansson.h>
4
5#include "log.h"
6#include "map.h"
7#include "tmj.h"
8
12
13int unpack_tileset(json_t* tileset, Tileset* ret) {
14 logmsg(TMJ_LOG_DEBUG, "Unpacking tileset");
15
16 if (tileset == NULL) {
17 return -1;
18 }
19
20 json_error_t error;
21
22 json_t* grid = NULL;
23 json_t* tileoffset = NULL;
24 json_t* transformations = NULL;
25 json_t* properties = NULL;
26 json_t* terrains = NULL;
27 json_t* tiles = NULL;
28
29 // Unpack scalar values
30 ret->fillmode = "stretch";
31 ret->objectalignment = "unspecified";
32 ret->tilerendersize = "tile";
33 int unpk = json_unpack_ex(tileset,
34 &error,
35 0,
36 "{"
37 "s?s, s?s, s?s, s?s, s:s, s?s, s?s, s?s, s?s, s?s, s?s, s?s,"
38 "s:i, s?i, s?i, s?i, s:i, s:i, s:i, s:i, s:i,"
39 "s?o, s?o, s?o, s?o, s?o, s?o"
40 "}",
41 "backgroundcolor",
42 &ret->backgroundcolor,
43 "class",
44 &ret->class_,
45 "fillmode",
46 &ret->fillmode,
47 "image",
48 &ret->image,
49 "name",
50 &ret->name,
51 "objectalignment",
52 &ret->objectalignment,
53 "source",
54 &ret->source,
55 "tiledversion",
56 &ret->tiledversion,
57 "tilerendersize",
58 &ret->tilerendersize,
59 "transparentcolor",
60 &ret->transparentcolor,
61 "type",
62 &ret->type,
63 "version",
64 &ret->version,
65 "columns",
66 &ret->columns,
67 "firstgid",
68 &ret->firstgid,
69 "imageheight",
70 &ret->imageheight,
71 "imagewidth",
72 &ret->imagewidth,
73 "margin",
74 &ret->margin,
75 "spacing",
76 &ret->spacing,
77 "tilecount",
78 &ret->tilecount,
79 "tileheight",
80 &ret->tileheight,
81 "tilewidth",
82 &ret->tilewidth,
83 "grid",
84 &grid,
85 "tileoffset",
86 &tileoffset,
87 "transformations",
88 &transformations,
89 "properties",
90 &properties,
91 "terrains",
92 &terrains,
93 "tiles",
94 &tiles);
95
96 if (unpk == -1) {
97 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset, %s at line %d column %d", error.text, error.line, error.column);
98
99 return -1;
100 }
101
102 // Unpack Grid
103 if (grid) {
104 ret->grid = calloc(1, sizeof(Grid));
105
106 if (ret->grid == NULL) {
107 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset[%s]->grid, the system is out of memory", ret->name);
108
109 return -1;
110 }
111
112 unpk = json_unpack_ex(
113 grid, &error, 0, "{s:i, s:s, s:i}", "height", &ret->grid->height, "orientation", &ret->grid->orientation, "width", &ret->grid->width);
114
115 if (unpk == -1) {
116 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset[%s]->grid, %s at line %d column %d", ret->name, error.text, error.line, error.column);
117
118 goto fail_grid;
119 }
120 }
121
122 // Unpack TileOffset
123 if (tileoffset) {
124 ret->tileoffset = calloc(1, sizeof(TileOffset));
125
126 if (ret->tileoffset == NULL) {
127 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset[%s]->tileoffset, the system is out of memory", ret->name);
128
129 goto fail_grid;
130 }
131
132 unpk = json_unpack_ex(tileoffset, &error, 0, "{s:i, s:i}", "x", &ret->tileoffset->x, "y", &ret->tileoffset->y);
133
134 if (unpk == -1) {
135 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset[%s]->tileoffset, %s at line %d column %d", ret->name, error.text, error.line, error.column);
136
137 goto fail_tileoffset;
138 }
139 }
140
141 // Unpack Transformations
142 if (transformations) {
143 ret->transformations = calloc(1, sizeof(Transformations));
144
145 if (ret->transformations == NULL) {
146 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset[%s]->transformations, the system is out of memory", ret->name);
147
148 goto fail_tileoffset;
149 }
150
151 int hflip = 0, vflip = 0, rotate = 0, preferuntransformed = 0;
152 unpk = json_unpack_ex(transformations,
153 &error,
154 0,
155 "{s:b, s:b, s:b, s:b}",
156 "hflip",
157 &hflip,
158 "vflip",
159 &vflip,
160 "rotate",
161 &rotate,
162 "preferuntransformed",
163 &preferuntransformed);
164
165 ret->transformations->hflip = hflip != 0;
166 ret->transformations->vflip = vflip != 0;
167 ret->transformations->rotate = rotate != 0;
168 ret->transformations->preferuntransformed = preferuntransformed != 0;
169
170 if (unpk == -1) {
172 "Unable to unpack tileset[%s]->transformations, %s at line %d column %d",
173 ret->name,
174 error.text,
175 error.line,
176 error.column);
177
178 goto fail_transformations;
179 }
180 }
181
182 // Unpack Properties
183 if (properties) {
184 if ((ret->properties = unpack_properties(properties)) == NULL) {
185 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset[%s]->properties", ret->name);
186
187 goto fail_transformations;
188 }
189
190 ret->property_count = json_array_size(properties);
191 }
192
193 // Unpack Terrains
194 if (terrains) {
195 if (!json_is_array(terrains)) {
196 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset[%s]->terrains, terrains must be an array of Terrains", ret->name);
197
198 goto fail_properties;
199 }
200
201 ret->terrain_count = json_array_size(terrains);
202
203 ret->terrains = calloc(ret->terrain_count, sizeof(Terrain));
204
205 if (ret->terrains == NULL) {
206 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset[%s]->terrains, the system is out of memory", ret->name);
207
208 goto fail_properties;
209 }
210
211 size_t idx;
212 json_t* terrain;
213
214 json_array_foreach(terrains, idx, terrain) {
215 properties = NULL;
216
217 unpk = json_unpack_ex(terrain,
218 &error,
219 0,
220 "{s:s, s:i, s?o}",
221 "name",
222 &ret->terrains[idx].name,
223 "tile",
224 &ret->terrains[idx].tile,
225 "properties",
226 &properties);
227
228 if (unpk == -1) {
230 "Unable to unpack tileset[%s]->terrains, %s at line %d column %d",
231 ret->name,
232 error.text,
233 error.line,
234 error.column);
235
236 goto fail_terrains;
237 }
238
239 if (properties) {
240 if ((ret->terrains[idx].properties = unpack_properties(properties)) == NULL) {
241 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset[%s]->terrain[%s]->properties", ret->name, ret->terrains[idx].name);
242
243 goto fail_terrains;
244 }
245
246 ret->terrains[idx].property_count = json_array_size(properties);
247 }
248 }
249 }
250
251 // Unpack Tiles
252 if (tiles) {
253 if (!json_is_array(tiles)) {
254 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset[%s]->tiles, tiles must be an array of Tiles", ret->name);
255
256 goto fail_terrains;
257 }
258
259 ret->tile_count = json_array_size(tiles);
260
261 ret->tiles = calloc(ret->tile_count, sizeof(Tile));
262
263 if (ret->tiles == NULL) {
264 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset[%s]->tiles, the system is out of memory", ret->name);
265
266 goto fail_terrains;
267 }
268
269 size_t idx = 0;
270 json_t* tile = NULL;
271
272 json_array_foreach(tiles, idx, tile) {
273 // Unpack Tile scalar values
274 json_t* animation = NULL;
275 json_t* objectgroup = NULL;
276 json_t* properties = NULL;
277 json_t* terrain = NULL;
278
279 ret->tiles[idx].probability = 1.0;
280 unpk = json_unpack_ex(tile,
281 &error,
282 0,
283 "{"
284 "s?s, s?s,"
285 "s:i, s?i, s?i, s?i, s?i, s?i, s?i,"
286 "s?F,"
287 "s?o, s?o, s?o, s?o"
288 "}",
289 "image",
290 &ret->tiles[idx].image,
291 "type",
292 &ret->tiles[idx].type,
293 "id",
294 &ret->tiles[idx].id,
295 "imageheight",
296 &ret->tiles[idx].imageheight,
297 "imagewidth",
298 &ret->tiles[idx].imagewidth,
299 "x",
300 &ret->tiles[idx].x,
301 "y",
302 &ret->tiles[idx].y,
303 "width",
304 &ret->tiles[idx].width,
305 "height",
306 &ret->tiles[idx].height,
307 "probability",
308 &ret->tiles[idx].probability,
309 "animation",
310 &animation,
311 "objectgroup",
312 &objectgroup,
313 "properties",
314 &properties,
315 "terrain",
316 &terrain);
317
318 if (ret->tiles[idx].width == 0) {
319 ret->tiles[idx].width = ret->tiles[idx].imagewidth;
320 }
321
322 if (ret->tiles[idx].height == 0) {
323 ret->tiles[idx].height = ret->tiles[idx].imageheight;
324 }
325
326 if (unpk == -1) {
327 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset[%s]->tiles, %s at line %d column %d", ret->name, error.text, error.line, error.column);
328
329 goto fail_tiles;
330 }
331
332 // Unpack Tile objectgroup
333 if (objectgroup) {
334 ret->tiles[idx].objectgroup = calloc(1, sizeof(Layer));
335
336 if (ret->tiles[idx].objectgroup == NULL) {
338 "Unable to unpack tileset[%s]->tiles[%d]->objectgroup, the system is out of memory",
339 ret->name,
340 ret->tiles[idx].id);
341
342 goto fail_tiles;
343 }
344
345 json_t* objects = NULL;
346 json_t* layer_properties = NULL;
347
348 int locked = 0, visible = 0;
349 ret->tiles[idx].objectgroup->parallaxx = 1.0;
350 ret->tiles[idx].objectgroup->parallaxy = 1.0;
351 unpk = json_unpack_ex(objectgroup,
352 &error,
353 0,
354 "{"
355 "s?b, s:b,"
356 "s?s, s?s, s:s, s?s, s:s,"
357 "s?i, s?i, s?i,"
358 "s?F, s?F, s:F, s?F, s?F,"
359 "s?o, s?o"
360 "}",
361 "locked",
362 &locked,
363 "visible",
364 &visible,
365 "class",
366 &ret->tiles[idx].objectgroup->class_,
367 "draworder",
368 &ret->tiles[idx].objectgroup->draworder,
369 "name",
370 &ret->tiles[idx].objectgroup->name,
371 "tintcolor",
372 &ret->tiles[idx].objectgroup->tintcolor,
373 "type",
374 &ret->tiles[idx].objectgroup->type,
375 "id",
376 &ret->tiles[idx].objectgroup->id,
377 "x",
378 &ret->tiles[idx].objectgroup->x,
379 "y",
380 &ret->tiles[idx].objectgroup->y,
381 "offsetx",
382 &ret->tiles[idx].objectgroup->offsetx,
383 "offsety",
384 &ret->tiles[idx].objectgroup->offsety,
385 "opacity",
386 &ret->tiles[idx].objectgroup->opacity,
387 "parallaxx",
388 &ret->tiles[idx].objectgroup->parallaxx,
389 "parallaxy",
390 &ret->tiles[idx].objectgroup->parallaxy,
391 "objects",
392 &objects,
393 "properties",
394 &layer_properties);
395
396 ret->tiles[idx].objectgroup->locked = locked != 0;
397 ret->tiles[idx].objectgroup->visible = visible != 0;
398
399 if (unpk == -1) {
401 "Unable to unpack tileset[%s]->tiles[%d]->objectgroup, %s at line %d column %d",
402 ret->name,
403 ret->tiles[idx].id,
404 error.text,
405 error.line,
406 error.column);
407
408 goto fail_tiles;
409 }
410
411 if (objects) {
412 ret->tiles[idx].objectgroup->objects = unpack_objects(objects);
413
414 if (ret->tiles[idx].objectgroup->objects == NULL) {
415 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset[%s]->tiles[%d]->objectgroup->objects", ret->name, ret->tiles[idx].id);
416
417 goto fail_tiles;
418 }
419
420 ret->tiles[idx].objectgroup->object_count = json_array_size(objects);
421 }
422
423 if (layer_properties) {
424 ret->tiles[idx].objectgroup->properties = unpack_properties(layer_properties);
425
426 if (ret->tiles[idx].objectgroup->properties == NULL) {
427 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset[%s]->tiles[%d]->objectgroup->properties", ret->name, ret->tiles[idx].id);
428
429 goto fail_tiles;
430 }
431
432 ret->tiles[idx].objectgroup->property_count = json_array_size(layer_properties);
433 }
434 }
435
436 // Unpack Tile animation
437 if (animation) {
438 if (!json_is_array(animation)) {
440 "Unable to unpack tileset[%s]->tiles[%d]->animation, animation must be an array of Frames",
441 ret->name,
442 ret->tiles[idx].id);
443
444 goto fail_tiles;
445 }
446
447 ret->tiles[idx].animation = calloc(json_array_size(animation), sizeof(Frame));
448
449 if (ret->tiles[idx].animation == NULL) {
451 "Unable to unpack tileset[%s]->tiles[%d]->animation, the system is out of memory",
452 ret->name,
453 ret->tiles[idx].id);
454
455 goto fail_tiles;
456 }
457
458 size_t idx2 = 0;
459 json_t* frame = NULL;
460
461 json_array_foreach(animation, idx2, frame) {
462 unpk = json_unpack_ex(frame,
463 &error,
464 0,
465 "{"
466 "s:i, s:i"
467 "}",
468 "duration",
469 &ret->tiles[idx].animation[idx2].duration,
470 "tileid",
471 &ret->tiles[idx].animation[idx2].tileid);
472
473 if (unpk == -1) {
475 "Unable to unpack tileset[%s]->tiles[%d]->animation, %s at line %d column %d",
476 ret->name,
477 ret->tiles[idx].id,
478 error.text,
479 error.line,
480 error.column);
481
482 goto fail_tiles;
483 }
484 }
485
486 ret->tiles[idx].animation_count = json_array_size(animation);
487 }
488
489 // Unpack Tile properties
490 if (properties) {
491 ret->tiles[idx].properties = unpack_properties(properties);
492
493 if (ret->tiles[idx].properties == NULL) {
494 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset[%s]->tiles[%d]->properties", ret->name, ret->tiles[idx].id);
495
496 goto fail_tiles;
497 }
498
499 ret->tiles[idx].property_count = json_array_size(properties);
500 }
501
502 // Unpack Tile terrain
503 if (terrain) {
504 if (!json_is_array(terrain)) {
506 "Unable to unpack tileset[%s]->tiles[%d]->terrain, terrain must be an array of terrain "
507 "indexes",
508 ret->name,
509 ret->tiles[idx].id);
510
511 goto fail_tiles;
512 }
513
514 if (json_array_size(terrain) > 4) {
516 "Unable to unpack tileset[%s]->tiles[%d]->terrain, terrain cannot be more than 4 elements",
517 ret->name,
518 ret->tiles[idx].id);
519
520 goto fail_tiles;
521 }
522
523 size_t idx2 = 0;
524 json_t* terrain_idx = NULL;
525
526 json_array_foreach(terrain, idx2, terrain_idx) {
527 if (!json_is_integer(terrain_idx)) {
529 "Unable to unpack tileset[%s]->tiles[%d]->terrain, terrain must be an array of "
530 "integers",
531 ret->name,
532 ret->tiles[idx].id);
533
534 goto fail_tiles;
535 }
536
537 ret->tiles[idx].terrain[idx2] = (int)json_integer_value(terrain_idx);
538 }
539 }
540 }
541 }
542
543 return 0;
544
545fail_tiles:
546 for (size_t i = 0; i < ret->tile_count; i++) {
547 free(ret->tiles[i].animation);
548
549 if (ret->tiles[i].objectgroup != NULL) {
550 free(ret->tiles[i].objectgroup->properties);
552 }
553
554 free(ret->tiles[i].objectgroup);
555 free(ret->tiles[i].properties);
556 }
557
558 free(ret->tiles);
559
560fail_terrains:
561 for (size_t i = 0; i < ret->terrain_count; i++) {
562 free(ret->terrains[i].properties);
563 }
564
565 free(ret->terrains);
566
567fail_properties:
568 free(ret->properties);
569
570fail_transformations:
571 free(ret->transformations);
572
573fail_tileoffset:
574 free(ret->tileoffset);
575
576fail_grid:
577 free(ret->grid);
578
579 return -1;
580}
581
585void tilesets_free(Tileset* tilesets, size_t tileset_count) {
586 for (size_t i = 0; i < tileset_count; i++) {
587 // Free tiles
588 if (tilesets[i].tiles) {
589 for (size_t j = 0; j < tilesets[i].tile_count; j++) {
590 free(tilesets[i].tiles[j].animation);
591 if (tilesets[i].tiles[j].objectgroup != NULL) {
592 free(tilesets[i].tiles[j].objectgroup->properties);
593 free_objects(tilesets[i].tiles[j].objectgroup->objects, tilesets[i].tiles[j].objectgroup->object_count);
594 }
595 free(tilesets[i].tiles[j].objectgroup);
596 free(tilesets[i].tiles[j].properties);
597 }
598
599 free(tilesets[i].tiles);
600 }
601
602 // Free terrains
603 if (tilesets[i].terrains) {
604 for (size_t j = 0; j < tilesets[i].terrain_count; j++) {
605 free(tilesets[i].terrains[j].properties);
606 }
607
608 free(tilesets[i].terrains);
609 }
610
611 // Free everything else
612 free(tilesets[i].properties);
613 free(tilesets[i].transformations);
614 free(tilesets[i].tileoffset);
615 free(tilesets[i].grid);
616
617 json_decref(tilesets[i].root);
618 }
619
620 free(tilesets);
621}
622
623Tileset* tmj_tileset_loadf(const char* path, bool check_extension) {
624 if (path == NULL) {
625 logmsg(TMJ_LOG_DEBUG, "Unable to load tileset with null path");
626
627 return NULL;
628 }
629
630 logmsg(TMJ_LOG_DEBUG, "Loading JSON tileset file '%s'", path);
631
632 char* ext = strrchr(path, '.');
633
634 if (check_extension) {
635 if (ext == NULL) {
636 logmsg(TMJ_LOG_ERR, "Tileset filename '%s' has no extension", path);
637
638 return NULL;
639 }
640
641 if (strcmp(ext, ".tsj") != 0 && strcmp(ext, ".json") != 0) {
642 logmsg(TMJ_LOG_ERR, "Tileset filename '%s' has unknown extension, '%s'", path, ext);
643 logmsg(TMJ_LOG_ERR, "Tileset filename '%s' must have '.tsj' or '.json' extension to be loaded", path);
644
645 return NULL;
646 }
647 }
648
649 json_error_t error;
650 json_t* root = json_load_file(path, JSON_REJECT_DUPLICATES, &error);
651
652 if (root == NULL) {
653 logmsg(TMJ_LOG_ERR, "Could not load tileset '%s', %s at line %d column %d", path, error.text, error.line, error.column);
654
655 return NULL;
656 }
657
658 Tileset* ret = calloc(1, sizeof(Tileset));
659
660 if (ret == NULL) {
661 logmsg(TMJ_LOG_ERR, "Unable to load tileset[%s], the system is out of memory", path);
662
663 json_decref(root);
664
665 return NULL;
666 }
667
668 if (unpack_tileset(root, ret) == -1) {
669 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset[%s]", path);
670
671 free(ret);
672 json_decref(root);
673
674 return NULL;
675 }
676
677 ret->root = root;
678
679 return ret;
680}
681
682Tileset* tmj_tileset_load(const char* tileset) {
683 logmsg(TMJ_LOG_DEBUG, "Loading JSON tileset from string");
684
685 json_error_t error;
686 json_t* root = json_loads(tileset, JSON_REJECT_DUPLICATES, &error);
687
688 if (root == NULL) {
689 logmsg(TMJ_LOG_ERR, "Could not load tileset, %s at line %d column %d", error.text, error.line, error.column);
690
691 return NULL;
692 }
693
694 Tileset* ret = calloc(1, sizeof(Tileset));
695
696 if (ret == NULL) {
697 logmsg(TMJ_LOG_ERR, "Unable to load tileset, the system is out of memory");
698
699 json_decref(root);
700
701 return NULL;
702 }
703
704 if (unpack_tileset(root, ret) == -1) {
705 logmsg(TMJ_LOG_ERR, "Unable to unpack tileset");
706
707 free(ret);
708 json_decref(root);
709
710 return NULL;
711 }
712
713 ret->root = root;
714
715 return ret;
716}
717
718void tmj_tileset_free(Tileset* tileset) {
719 if (tileset == NULL) {
720 logmsg(TMJ_LOG_ERR, "Unable to free null tileset");
721 }
722
723 tilesets_free(tileset, 1);
724}
void logmsg(tmj_log_priority priority, char *msg,...)
Processes log messages and passes them to the active logging callback, if there is one.
Definition log.c:23
Tileset * tmj_tileset_loadf(const char *path, bool check_extension)
Loads the Tiled tileset at the given path.
Definition tileset.c:623
void tmj_tileset_free(Tileset *tileset)
Frees the memory associated with the given tileset.
Definition tileset.c:718
Tileset * tmj_tileset_load(const char *tileset)
Loads the Tiled tileset from the given JSON object string.
Definition tileset.c:682
@ TMJ_LOG_ERR
Definition tmj.h:506
@ TMJ_LOG_DEBUG
Definition tmj.h:503
Object * unpack_objects(json_t *objects)
Definition map.c:269
void free_objects(Object *objects, size_t object_count)
Helper function to free Objects.
Definition map.c:439
Property * unpack_properties(json_t *properties)
Definition map.c:13
https://doc.mapeditor.org/en/stable/reference/json-map-format/#frame
Definition tmj.h:204
int tileid
Definition tmj.h:206
int duration
Definition tmj.h:205
https://doc.mapeditor.org/en/stable/reference/json-map-format/#grid
Definition tmj.h:285
int height
Definition tmj.h:288
int width
Definition tmj.h:289
char * orientation
Definition tmj.h:286
https://doc.mapeditor.org/en/stable/reference/json-map-format/#layer
Definition tmj.h:127
size_t property_count
Definition tmj.h:175
int x
Definition tmj.h:157
char * tintcolor
Definition tmj.h:139
char * draworder
Definition tmj.h:135
Property * properties
Definition tmj.h:176
double offsetx
Definition tmj.h:160
double parallaxy
Definition tmj.h:164
Object * objects
Definition tmj.h:173
double opacity
Definition tmj.h:162
double parallaxx
Definition tmj.h:163
char * class_
Definition tmj.h:133
char * type
Definition tmj.h:141
bool locked
Definition tmj.h:128
int y
Definition tmj.h:158
size_t object_count
Definition tmj.h:172
char * name
Definition tmj.h:138
int id
Definition tmj.h:151
double offsety
Definition tmj.h:161
bool visible
Definition tmj.h:131
https://doc.mapeditor.org/en/stable/reference/json-map-format/#terrain
Definition tmj.h:192
Property * properties
Definition tmj.h:198
char * name
Definition tmj.h:193
int tile
Definition tmj.h:195
size_t property_count
Definition tmj.h:197
https://doc.mapeditor.org/en/stable/reference/json-map-format/#tile-offset
Definition tmj.h:295
int y
Definition tmj.h:297
int x
Definition tmj.h:296
https://doc.mapeditor.org/en/stable/reference/json-map-format/#tile-definition
Definition tmj.h:212
Frame * animation
Definition tmj.h:227
int terrain[4]
Definition tmj.h:229
int height
Definition tmj.h:222
double probability
Definition tmj.h:224
int y
Definition tmj.h:220
int id
Definition tmj.h:216
char * image
Definition tmj.h:213
char * type
Definition tmj.h:214
int x
Definition tmj.h:219
size_t animation_count
Definition tmj.h:226
int imageheight
Definition tmj.h:217
Property * properties
Definition tmj.h:232
Layer * objectgroup
Definition tmj.h:234
int imagewidth
Definition tmj.h:218
size_t property_count
Definition tmj.h:231
int width
Definition tmj.h:221
https://doc.mapeditor.org/en/stable/reference/json-map-format/#tileset
Definition tmj.h:305
char * fillmode
Definition tmj.h:314
size_t tile_count
Definition tmj.h:341
char * transparentcolor
Definition tmj.h:321
int tileheight
Definition tmj.h:332
char * name
Definition tmj.h:316
char * image
Definition tmj.h:315
Grid * grid
Definition tmj.h:347
int imagewidth
Definition tmj.h:328
char * tiledversion
Definition tmj.h:319
char * objectalignment
Definition tmj.h:317
char * source
Definition tmj.h:318
int firstgid
Definition tmj.h:326
TileOffset * tileoffset
Definition tmj.h:349
int tilewidth
Definition tmj.h:333
char * tilerendersize
Definition tmj.h:320
size_t property_count
Definition tmj.h:335
size_t terrain_count
Definition tmj.h:338
int margin
Definition tmj.h:329
Property * properties
Definition tmj.h:336
json_t * root
The root object returned by jansson after parsing.
Definition tmj.h:310
char * class_
Definition tmj.h:313
int tilecount
Definition tmj.h:331
char * backgroundcolor
Definition tmj.h:312
int columns
Definition tmj.h:325
char * version
Definition tmj.h:323
Transformations * transformations
Definition tmj.h:351
Tile * tiles
Definition tmj.h:342
Terrain * terrains
Definition tmj.h:339
int spacing
Definition tmj.h:330
char * type
Definition tmj.h:322
int imageheight
Definition tmj.h:327
https://doc.mapeditor.org/en/stable/reference/json-map-format/#transformations
Definition tmj.h:182
bool preferuntransformed
Definition tmj.h:184
bool hflip
Definition tmj.h:183
bool rotate
Definition tmj.h:185
bool vflip
Definition tmj.h:186
int unpack_tileset(json_t *tileset, Tileset *ret)
Definition tileset.c:13
void tilesets_free(Tileset *tilesets, size_t tileset_count)
Helper function for freeing tilesets embedded in maps.
Definition tileset.c:585
The libtmj API.