summaryrefslogtreecommitdiffstats
path: root/src/resources
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/resources
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/resources')
-rw-r--r--src/resources/map.c12
-rw-r--r--src/resources/map.h1
2 files changed, 11 insertions, 2 deletions
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
};