Project

General

Profile

Feature #1938 ยป 0042-Add-Terrain-flag-for-Tiledef.patch

Marko Lindqvist, 02/08/2026 09:18 AM

View differences:

common/tiledef.c
****************************************************************************/
bool tile_matches_tiledef(const struct tiledef *td, const struct tile *ptile)
{
if (terrain_flag_id_is_valid(td->terr_flag)) {
if (!terrain_has_flag(tile_terrain(ptile), td->terr_flag)) {
return FALSE;
}
}
extra_type_list_iterate(td->extras, pextra) {
if (!tile_has_extra(ptile, pextra)) {
return FALSE;
common/tiledef.h
/* common */
#include "extras.h"
#include "terrain.h"
struct tiledef
{
int id;
struct name_translation name;
enum terrain_flag_id terr_flag;
struct extra_type_list *extras;
};
data/alien/terrain.ruleset
; not change, if you want to rename an item after a
; ruleset has been released, you should set
; "rule_name" to the original value of "name".
; terrain_flag = Flag that terrain on the tile must have
; to satisfy tiledef requirements.
; extras = List of extras that the tile must have
; to satisfy tiledef requirements.
;
data/civ1/terrain.ruleset
; not change, if you want to rename an item after a
; ruleset has been released, you should set
; "rule_name" to the original value of "name".
; terrain_flag = Flag that terrain on the tile must have
; to satisfy tiledef requirements.
; extras = List of extras that the tile must have
; to satisfy tiledef requirements.
;
data/civ2/terrain.ruleset
; not change, if you want to rename an item after a
; ruleset has been released, you should set
; "rule_name" to the original value of "name".
; terrain_flag = Flag that terrain on the tile must have
; to satisfy tiledef requirements.
; extras = List of extras that the tile must have
; to satisfy tiledef requirements.
;
data/civ2civ3/terrain.ruleset
; not change, if you want to rename an item after a
; ruleset has been released, you should set
; "rule_name" to the original value of "name".
; terrain_flag = Flag that terrain on the tile must have
; to satisfy tiledef requirements.
; extras = List of extras that the tile must have
; to satisfy tiledef requirements.
;
data/classic/terrain.ruleset
; not change, if you want to rename an item after a
; ruleset has been released, you should set
; "rule_name" to the original value of "name".
; terrain_flag = Flag that terrain on the tile must have
; to satisfy tiledef requirements.
; extras = List of extras that the tile must have
; to satisfy tiledef requirements.
;
data/goldkeep/terrain.ruleset
; not change, if you want to rename an item after a
; ruleset has been released, you should set
; "rule_name" to the original value of "name".
; terrain_flag = Flag that terrain on the tile must have
; to satisfy tiledef requirements.
; extras = List of extras that the tile must have
; to satisfy tiledef requirements.
;
data/granularity/terrain.ruleset
; not change, if you want to rename an item after a
; ruleset has been released, you should set
; "rule_name" to the original value of "name".
; terrain_flag = Flag that terrain on the tile must have
; to satisfy tiledef requirements.
; extras = List of extras that the tile must have
; to satisfy tiledef requirements.
;
data/multiplayer/terrain.ruleset
; not change, if you want to rename an item after a
; ruleset has been released, you should set
; "rule_name" to the original value of "name".
; terrain_flag = Flag that terrain on the tile must have
; to satisfy tiledef requirements.
; extras = List of extras that the tile must have
; to satisfy tiledef requirements.
;
data/ruledit/comments-3.4.txt
; not change, if you want to rename an item after\n\
; a ruleset has been released, you should set\n\
; \"rule_name\" to the original value of \"name\".\n\
; terrain_flag = Flag that terrain on the tile must have\n\
; to satisfy tiledef requirements.\n\
; extras = List of extras that the tile must have\n\
; to satisfy tiledef requirements.\n\
;\n\
data/sandbox/terrain.ruleset
; not change, if you want to rename an item after a
; ruleset has been released, you should set
; "rule_name" to the original value of "name".
; terrain_flag = Flag that terrain on the tile must have
; to satisfy tiledef requirements.
; extras = List of extras that the tile must have
; to satisfy tiledef requirements.
;
data/stub/terrain.ruleset
; not change, if you want to rename an item after a
; ruleset has been released, you should set
; "rule_name" to the original value of "name".
; terrain_flag = Flag that terrain on the tile must have
; to satisfy tiledef requirements.
; extras = List of extras that the tile must have
; to satisfy tiledef requirements.
;
server/ruleset/ruleload.c
const char *section = &tiledef_sections[tdidx * MAX_SECTION_LABEL];
const char **slist;
int ej;
const char *flag_name;
flag_name = secfile_lookup_str_default(file, nullptr,
"%s.terrain_flag", section);
if (flag_name == nullptr) {
td->terr_flag = terrain_flag_id_invalid();
} else {
td->terr_flag = terrain_flag_id_by_name(flag_name, fc_strcasecmp);
if (!terrain_flag_id_is_valid(td->terr_flag)) {
ruleset_error(nullptr, LOG_ERROR,
"%s: Invalid terrain flag %s.",
section, flag_name);
ok = FALSE;
break;
}
}
slist = secfile_lookup_str_vec(file, &nval, "%s.extras", section);
for (ej = 0; ej < nval; ej++) {
    (1-1/1)