LibTMJ 2.0.0
A library for loading JSON Tiled maps
Loading...
Searching...
No Matches
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

Property * unpack_properties (json_t *properties)
Point * unpack_points (json_t *points)
 Unpacks an array of points.
Text * unpack_text (json_t *text)
 Unpacks a text object.
Object * unpack_objects (json_t *objects)
void free_objects (Object *objects, size_t object_count)
 Helper function to free Objects.
Chunk * unpack_chunks (json_t *chunks, size_t *chunk_count)
void free_chunks (Chunk *chunks, size_t chunk_count)
Layer * unpack_layers (json_t *layers)
 Loads map layers recursively.
void layers_free (Layer *layers, size_t layer_count)
 Helper function for freeing layer tree associated with a map.
Map * map_load_json (json_t *root, const char *path)
Map * tmj_map_loadf (const char *path, bool check_extension)
 Loads the Tiled map from the file at the given path.
Map * tmj_map_load (const char *map, const char *name)
 Loads the Tiled map from the given JSON object string.
void tmj_map_free (Map *map)
 Frees the memory associated with the given map.

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 154 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 198 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 269 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 439 of file map.c.

Here is the caller graph for this function:

◆ unpack_chunks()

Chunk * unpack_chunks ( json_t * chunks,
size_t * chunk_count )

Definition at line 450 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 559 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 572 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 919 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 934 of file map.c.

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