summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/resources/map.c19
-rw-r--r--src/resources/map.h3
2 files changed, 19 insertions, 3 deletions
diff --git a/src/resources/map.c b/src/resources/map.c
index 667781d..0d65d57 100644
--- a/src/resources/map.c
+++ b/src/resources/map.c
@@ -146,7 +146,9 @@ map_add_tileset(struct map *m, struct tileset *t, Uint32 firstgid)
struct map_palette *
map_get_palette(struct map *m, const char *name)
{
- if (strcmp(name, "morn") == 0) {
+ if (strcmp(name, "default") == 0) {
+ return &m->palettes[MAP_PALETTE_DEFAULT];
+ } else if (strcmp(name, "morn") == 0) {
return &m->palettes[MAP_PALETTE_MORN];
} else if (strcmp(name, "day") == 0) {
return &m->palettes[MAP_PALETTE_DAY];
@@ -416,7 +418,20 @@ tmx_map_property_start(void *pv, const char *name, const char **attr)
if (xml_check_tag(name, "property")) {
xml_get_string_attr(p, attr, "name", &attr_name, 1);
xml_get_string_attr(p, attr, "value", &attr_value, 1);
- if (strncmp(attr_name, "palette-", 7) == 0) {
+ if (strcmp(attr_name, "palette-default") == 0) {
+ pal = map_get_palette(m, "default");
+ path = malloc(strlen(m->dirname) +
+ strlen(attr_value) + 2);
+ if (path == NULL) {
+ /* XXX: This won't run xml_node_push() and the
+ * stack will be corrupted. */
+ return;
+ }
+ sprintf(path, "%s/%s", m->dirname, attr_value);
+ pal->palette = palette_get(path);
+ pal->min = 0;
+ free(path);
+ } else if (strncmp(attr_name, "palette-", 7) == 0) {
pal = map_get_palette(m, attr_name + 8);
if (pal != NULL) {
/* Uint32 is overkill for pal_h and pal_m, but
diff --git a/src/resources/map.h b/src/resources/map.h
index 116300d..bac0cd5 100644
--- a/src/resources/map.h
+++ b/src/resources/map.h
@@ -7,7 +7,8 @@
#include "image.h"
enum map_palette_id {
- MAP_PALETTE_MORN = 0,
+ MAP_PALETTE_DEFAULT = 0,
+ MAP_PALETTE_MORN,
MAP_PALETTE_DAY,
MAP_PALETTE_EVE,
MAP_PALETTE_NIGHT,