LibTMJ  1.0.0
A library for loading JSON Tiled maps
Functions
map.c File Reference
#include <string.h>
#include <jansson.h>
#include "log.h"
#include "tileset.h"
#include "tmj.h"
Include dependency graph for map.c:

Go to the source code of this file.

Functions

Propertyunpack_properties (json_t *properties)
 
Pointunpack_points (json_t *points)
 Unpacks an array of points. More...
 
Textunpack_text (json_t *text)
 Unpacks a text object. More...
 
Objectunpack_objects (json_t *objects)
 
void free_objects (Object *objects, size_t object_count)
 Helper function to free Objects. More...
 
Chunkunpack_chunks (json_t *chunks)
 
void free_chunks (Chunk *chunks, size_t chunk_count)
 
Layerunpack_layers (json_t *layers)
 Loads map layers recursively. More...
 
void layers_free (Layer *layers, size_t layer_count)
 Helper function for freeing layer tree associated with a map. More...
 
Mapmap_load_json (json_t *root, const char *path)
 
Maptmj_map_loadf (const char *path, bool check_extension)
 Loads the Tiled map from the file at the given path. More...
 
Maptmj_map_load (const char *map, const char *name)
 Loads the Tiled map from the given JSON object string. More...
 
void tmj_map_free (Map *map)
 Frees the memory associated with the given map. More...
 

Function Documentation

◆ unpack_properties()

Property* unpack_properties ( json_t *  properties)

Definition at line 13 of file map.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unpack_points()

Point* unpack_points ( json_t *  points)

Unpacks an array of points.

The returned array must be freed by the caller.

Definition at line 155 of file map.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unpack_text()

Text* unpack_text ( json_t *  text)

Unpacks a text object.

The returned object must be freed by the caller.

Definition at line 199 of file map.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unpack_objects()

Object* unpack_objects ( json_t *  objects)

Definition at line 257 of file map.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_objects()

void free_objects ( Object objects,
size_t  object_count 
)

Helper function to free Objects.

May cause undefined behavior if the objects were modified by the caller of map_load().

Definition at line 423 of file map.c.

Here is the caller graph for this function:

◆ unpack_chunks()

Chunk* unpack_chunks ( json_t *  chunks)

Definition at line 434 of file map.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_chunks()

void free_chunks ( Chunk chunks,
size_t  chunk_count 
)

Definition at line 543 of file map.c.

Here is the caller graph for this function:

◆ unpack_layers()

Layer* unpack_layers ( json_t *  layers)

Loads map layers recursively.

Definition at line 556 of file map.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ layers_free()

void layers_free ( Layer layers,
size_t  layer_count 
)

Helper function for freeing layer tree associated with a map.

May result in undefined behavior if the layer objects were modified by the caller of map_load().

Definition at line 874 of file map.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ map_load_json()

Map* map_load_json ( json_t *  root,
const char *  path 
)

Definition at line 887 of file map.c.

Here is the call graph for this function:
Here is the caller graph for this function: