summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-02-17 20:44:32 (EST)
committer P. J. McDermott <pjm@nac.net>2013-02-17 20:44:32 (EST)
commitf158a79d0e8a2158f843ecfc5d7eaaa620828679 (patch)
treed433b0fad25700e76e8fbb1a806193f62226dd48 /src
parenteebb2788b04e7ad655338f515918f1ebc0ba05ab (diff)
downloadoverworld-rpg-f158a79d0e8a2158f843ecfc5d7eaaa620828679.zip
overworld-rpg-f158a79d0e8a2158f843ecfc5d7eaaa620828679.tar.gz
overworld-rpg-f158a79d0e8a2158f843ecfc5d7eaaa620828679.tar.bz2
Support collision and unknown map layers.
Diffstat (limited to 'src')
-rw-r--r--src/main.c2
-rw-r--r--src/resources/map.c12
-rw-r--r--src/resources/map.h1
3 files changed, 12 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 3512535..fa7c7f6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -15,7 +15,7 @@ main(void)
init();
- map = map_get("data/forest1.simple.tmx");
+ map = map_get("data/forest1.tmx");
debug("Map dimensions: %dx%d", map->width, map->height);
for (ts = map->tilesets_head; ts != NULL; ts = ts->next) {
debug("Tileset name: %s", ts->tileset->name);
diff --git a/src/resources/map.c b/src/resources/map.c
index 67b00cb..2cc2f2a 100644
--- a/src/resources/map.c
+++ b/src/resources/map.c
@@ -155,6 +155,8 @@ map_get_layer(struct map *m, const char *name)
return &m->layers[LAYER_CHAR_TOP];
} else if (strcmp(name, "obj-high") == 0) {
return &m->layers[LAYER_OBJ_HIGH];
+ } else if (strcmp(name, "collision") == 0) {
+ return &m->layers[LAYER_COLLISION];
} else if (strcmp(name, "weather") == 0) {
return &m->layers[LAYER_WEATHER];
} else {
@@ -355,8 +357,14 @@ tmx_map_el_start(void *pv, const char *name, const char **attr)
xml_get_string_attr(p, attr, "name", &ly_name, 1);
ly = map_get_layer(m, ly_name);
free(ly_name);
- ly->map = m;
- xml_node_push(p, ly, tmx_layer_el_start, tmx_layer_end, NULL);
+ if (ly != NULL) {
+ ly->map = m;
+ xml_node_push(p, ly, tmx_layer_el_start, tmx_layer_end,
+ NULL);
+ } else {
+ xml_node_push(p, NULL, tmx_unused_start, tmx_layer_end,
+ NULL);
+ }
} else if (xml_check_tag(name, "objectgroup")) {
xml_node_push(p, m, tmx_objectgroup_el_start,
tmx_objectgroup_end, NULL);
diff --git a/src/resources/map.h b/src/resources/map.h
index ba264de..02733bc 100644
--- a/src/resources/map.h
+++ b/src/resources/map.h
@@ -12,6 +12,7 @@ enum layer_id {
LAYER_OBJ_MID,
LAYER_CHAR_TOP,
LAYER_OBJ_HIGH,
+ LAYER_COLLISION,
LAYER_WEATHER,
LAYERS_MAX
};