Skip to content

Commit

Permalink
Added terrain tag as separate field to [tile_...] sections instead of…
Browse files Browse the repository at this point in the history
… using section name

itself.

See bug #21123

[[originally from svn r29547]]
  • Loading branch information
cazfi committed Aug 16, 2015
1 parent eb0317a commit 132b397
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 10 deletions.
26 changes: 20 additions & 6 deletions client/tilespec.c
Expand Up @@ -578,11 +578,12 @@ void tileset_error(enum log_level level, const char *format, ...)
/****************************************************************************
Create a new drawing data.
****************************************************************************/
static struct drawing_data *drawing_data_new(const char *name)
static struct drawing_data *drawing_data_new(void)
{
struct drawing_data *draw = fc_calloc(1, sizeof(*draw));

draw->name = fc_strdup(name);
draw->name = NULL;

return draw;
}

Expand All @@ -595,7 +596,9 @@ static void drawing_data_destroy(struct drawing_data *draw)

fc_assert_ret(NULL != draw);

free(draw->name);
if (draw->name != NULL) {
free(draw->name);
}
for (i = 0; i < 4; i++) {
if (draw->blend[i]) {
free_sprite(draw->blend[i]);
Expand Down Expand Up @@ -1506,7 +1509,6 @@ struct tileset *tileset_read_toplevel(const char *tileset_name, bool verbose)
const char *file_capstr;
bool duplicates_ok, is_hex;
enum direction8 dir;
const int spl = strlen(TILE_SECTION_PREFIX);
struct tileset *t = NULL;
const char *extraname;
const char *tstr;
Expand Down Expand Up @@ -1757,9 +1759,20 @@ struct tileset *tileset_read_toplevel(const char *tileset_name, bool verbose)

section_list_iterate(sections, psection) {
const char *sec_name = section_name(psection);
struct drawing_data *draw = drawing_data_new(sec_name + spl);
struct drawing_data *draw = drawing_data_new();
const char *sprite_type;
int l;
const char *terrain_name;

terrain_name = secfile_lookup_str(file, "%s.tag", sec_name);

if (terrain_name != NULL) {
draw->name = fc_strdup(terrain_name);
} else {
tileset_error(LOG_ERROR, _("No terrain tag given on \"%s\"."), sec_name);
drawing_data_destroy(draw);
goto ON_ERROR;
}

draw->blending = secfile_lookup_int_default(file, 0, "%s.blend_layer",
sec_name);
Expand Down Expand Up @@ -1902,7 +1915,8 @@ struct tileset *tileset_read_toplevel(const char *tileset_name, bool verbose)
}

if (!drawing_hash_insert(t->tile_hash, draw->name, draw)) {
log_error("warning: duplicate tilespec entry [%s].", sec_name);
log_error("warning: multiple tile sections containing terrain tag \"%s\".",
draw->name);
goto ON_ERROR;
}
} section_list_iterate_end;
Expand Down
14 changes: 14 additions & 0 deletions data/alio.tilespec
Expand Up @@ -143,6 +143,7 @@ match_types = "hills", "foliage"
;

[tile_lake]
tag = "lake"
blend_layer = 2
num_layers = 2
layer0_match_type = "lake"
Expand All @@ -153,6 +154,7 @@ layer1_match_with = "water"
layer1_sprite_type = "corner"

[tile_coast]
tag = "coast"
blend_layer = 2
num_layers = 2
layer0_match_type = "coast"
Expand All @@ -161,6 +163,7 @@ layer1_match_with = "water"
layer1_sprite_type = "corner"

[tile_floor]
tag = "floor"
blend_layer = 2
num_layers = 2
layer0_match_type = "floor"
Expand All @@ -171,6 +174,7 @@ layer1_match_with = "water"
layer1_sprite_type = "corner"

[tile_inaccessible]
tag = "inaccessible"
blend_layer = 0
num_layers = 2
layer0_match_type = "floor"
Expand All @@ -180,60 +184,70 @@ layer1_match_type = "land"
;

[tile_arctic]
tag = "arctic"
blend_layer = 0
num_layers = 2
layer0_match_type = "lake"
layer1_match_type = "water"

[tile_desert]
tag = "desert"
blend_layer = 1
num_layers = 2
layer1_match_type = "land"

[tile_forest]
tag = "forest"
blend_layer = 1
num_layers = 3
layer1_match_type = "land"
layer2_match_type = "foliage"
layer2_match_with = "foliage"

[tile_grassland]
tag = "grassland"
blend_layer = 1
num_layers = 2
layer1_match_type = "land"

[tile_hills]
tag = "hills"
blend_layer = 1
num_layers = 3
layer1_match_type = "land"
layer2_match_type = "hills"
layer2_match_with = "hills"

[tile_jungle]
tag = "jungle"
blend_layer = 1
num_layers = 3
layer1_match_type = "land"
layer2_match_type = "foliage"
layer2_match_with = "foliage"

[tile_mountains]
tag = "mountains"
blend_layer = 1
num_layers = 3
layer1_match_type = "land"
layer2_match_type = "hills"
layer2_match_with = "hills"

[tile_plains]
tag = "plains"
blend_layer = 1
num_layers = 2
layer1_match_type = "land"

[tile_swamp]
tag = "swamp"
blend_layer = 1
num_layers = 2
layer1_match_type = "land"

[tile_tundra]
tag = "tundra"
blend_layer = 1
num_layers = 2
layer1_match_type = "land"
Expand Down
13 changes: 13 additions & 0 deletions data/amplio.tilespec
Expand Up @@ -119,13 +119,15 @@ match_types = "water", "ice"
; Water graphics referenced by terrain.ruleset
;
[tile_lake]
tag = "lake"
blend_layer = 1
num_layers = 1
layer0_match_type = "shallow"
layer0_match_with = "land"
layer0_sprite_type = "corner"

[tile_coast]
tag = "coast"
blend_layer = 1
num_layers = 2
layer0_match_type = "shallow"
Expand All @@ -136,6 +138,7 @@ layer1_match_with = "ice"
layer1_sprite_type = "corner"

[tile_floor]
tag = "floor"
blend_layer = 0
num_layers = 2
layer0_match_type = "deep"
Expand All @@ -148,6 +151,7 @@ layer1_sprite_type = "corner"
; Land graphics referenced by terrain.ruleset
;
[tile_arctic]
tag = "arctic"
; treated as water for ice cliffs
blend_layer = 0
num_layers = 3
Expand All @@ -156,52 +160,61 @@ layer1_match_type = "ice"
layer2_match_type = "ice"

[tile_desert]
tag = "desert"
blend_layer = 1
num_layers = 1
layer0_match_type = "land"

[tile_forest]
tag = "forest"
blend_layer = 1
num_layers = 2
layer0_match_type = "land"
layer1_match_type = "forest"
layer1_match_with = "forest"

[tile_grassland]
tag = "grassland"
blend_layer = 1
num_layers = 1
layer0_match_type = "land"

[tile_hills]
tag = "hills"
blend_layer = 1
num_layers = 2
layer0_match_type = "land"
layer1_match_type = "hills"
layer1_match_with = "hills"

[tile_jungle]
tag = "jungle"
blend_layer = 1
num_layers = 1
layer0_match_type = "land"

[tile_mountains]
tag = "mountains"
blend_layer = 1
num_layers = 2
layer0_match_type = "land"
layer1_match_type = "mountains"
layer1_match_with = "mountains"

[tile_plains]
tag = "plains"
blend_layer = 1
num_layers = 1
layer0_match_type = "land"

[tile_swamp]
tag = "swamp"
blend_layer = 1
num_layers = 1
layer0_match_type = "land"

[tile_tundra]
tag = "tundra"
blend_layer = 1
num_layers = 1
layer0_match_type = "land"
Expand Down
14 changes: 14 additions & 0 deletions data/amplio2.tilespec
Expand Up @@ -124,13 +124,15 @@ match_types = "water", "ice"
; Water graphics referenced by terrain.ruleset
;
[tile_lake]
tag = "lake"
blend_layer = 1
num_layers = 1
layer0_match_type = "shallow"
layer0_match_with = "land"
layer0_sprite_type = "corner"

[tile_coast]
tag = "coast"
blend_layer = 1
num_layers = 2
layer0_match_type = "shallow"
Expand All @@ -141,6 +143,7 @@ layer1_match_with = "ice"
layer1_sprite_type = "corner"

[tile_floor]
tag = "floor"
blend_layer = 0
num_layers = 2
layer0_match_type = "deep"
Expand All @@ -153,6 +156,7 @@ layer1_sprite_type = "corner"
; Land graphics referenced by terrain.ruleset
;
[tile_arctic]
tag = "arctic"
; treated as water for ice cliffs
blend_layer = 0
num_layers = 3
Expand All @@ -161,37 +165,43 @@ layer1_match_type = "ice"
layer2_match_type = "ice"

[tile_desert]
tag = "desert"
blend_layer = 1
num_layers = 1
layer0_match_type = "land"

[tile_forest]
tag = "forest"
blend_layer = 1
num_layers = 2
layer0_match_type = "land"
layer1_match_type = "forest"
layer1_match_with = "forest"

[tile_grassland]
tag = "grassland"
blend_layer = 1
num_layers = 1
layer0_match_type = "land"

[tile_hills]
tag = "hills"
blend_layer = 1
num_layers = 2
layer0_match_type = "land"
layer1_match_type = "hills"
layer1_match_with = "hills"

[tile_jungle]
tag = "jungle"
blend_layer = 1
num_layers = 2
layer0_match_type = "land"
layer1_match_type = "forest"
layer1_match_with = "forest"

[tile_mountains]
tag = "mountains"
blend_layer = 1
num_layers = 2
layer0_match_type = "land"
Expand All @@ -201,21 +211,25 @@ layer1_is_tall = TRUE
layer1_offset_y = 6

[tile_plains]
tag = "plains"
blend_layer = 1
num_layers = 1
layer0_match_type = "land"

[tile_swamp]
tag = "swamp"
blend_layer = 1
num_layers = 1
layer0_match_type = "land"

[tile_tundra]
tag = "tundra"
blend_layer = 1
num_layers = 1
layer0_match_type = "land"

[tile_inaccessible]
tag = "inaccessible"
blend_layer = 0
num_layers = 1
layer0_match_type = "land"
Expand Down

0 comments on commit 132b397

Please sign in to comment.