Feature #2170 ยป 0056-Tiledef-Add-known-property.patch
| client/packhand.c | ||
|---|---|---|
|
extra_type_list_append(td->extras, pextra);
|
||
|
}
|
||
|
} extra_type_iterate_end;
|
||
|
td->known = p->known;
|
||
|
}
|
||
|
/************************************************************************//**
|
||
| common/networking/packets.def | ||
|---|---|---|
|
STRING rule_name[MAX_LEN_NAME];
|
||
|
BV_EXTRAS extras;
|
||
|
BOOL known;
|
||
|
end
|
||
|
/**************************************************************************
|
||
| common/requirements.c | ||
|---|---|---|
|
ptdef = req->source.value.tiledef;
|
||
|
if (ptdef->known && context->player == nullptr) {
|
||
|
return TRI_MAYBE;
|
||
|
}
|
||
|
switch (req->range) {
|
||
|
case REQ_RANGE_TILE:
|
||
|
/* The requirement is filled if the tile has tiledef of requested type. */
|
||
|
if (!context->tile) {
|
||
|
return TRI_MAYBE;
|
||
|
}
|
||
|
return BOOL_TO_TRISTATE(tile_matches_tiledef(ptdef, context->tile));
|
||
|
return BOOL_TO_TRISTATE(tile_matches_tiledef(ptdef, context->tile,
|
||
|
context->player));
|
||
|
case REQ_RANGE_CADJACENT:
|
||
|
if (!context->tile) {
|
||
|
return TRI_MAYBE;
|
||
|
}
|
||
|
return BOOL_TO_TRISTATE(tile_matches_tiledef(ptdef, context->tile)
|
||
|
|| is_tiledef_card_near(nmap, context->tile, ptdef));
|
||
|
return BOOL_TO_TRISTATE(tile_matches_tiledef(ptdef, context->tile,
|
||
|
context->player)
|
||
|
|| is_tiledef_card_near(nmap, context->tile, ptdef,
|
||
|
context->player));
|
||
|
case REQ_RANGE_ADJACENT:
|
||
|
if (!context->tile) {
|
||
|
return TRI_MAYBE;
|
||
|
}
|
||
|
return BOOL_TO_TRISTATE(tile_matches_tiledef(ptdef, context->tile)
|
||
|
|| is_tiledef_near_tile(nmap, context->tile, ptdef));
|
||
|
return BOOL_TO_TRISTATE(tile_matches_tiledef(ptdef, context->tile,
|
||
|
context->player)
|
||
|
|| is_tiledef_near_tile(nmap, context->tile, ptdef,
|
||
|
context->player));
|
||
|
case REQ_RANGE_CITY:
|
||
|
if (!context->city) {
|
||
|
return TRI_MAYBE;
|
||
|
}
|
||
|
city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
|
||
|
city_tile(context->city), ptile) {
|
||
|
if (tile_matches_tiledef(ptdef, ptile)) {
|
||
|
if (tile_matches_tiledef(ptdef, ptile, context->player)) {
|
||
|
return TRI_YES;
|
||
|
}
|
||
|
} city_tile_iterate_end;
|
||
| ... | ... | |
|
}
|
||
|
city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
|
||
|
city_tile(context->city), ptile) {
|
||
|
if (tile_matches_tiledef(ptdef, ptile)) {
|
||
|
if (tile_matches_tiledef(ptdef, ptile, context->player)) {
|
||
|
return TRI_YES;
|
||
|
}
|
||
|
} city_tile_iterate_end;
|
||
| ... | ... | |
|
} else {
|
||
|
city_tile_iterate(nmap, city_map_radius_sq_get(trade_partner),
|
||
|
city_tile(trade_partner), ptile) {
|
||
|
if (tile_matches_tiledef(ptdef, ptile)) {
|
||
|
if (tile_matches_tiledef(ptdef, ptile, context->player)) {
|
||
|
return TRI_YES;
|
||
|
}
|
||
|
} city_tile_iterate_end;
|
||
| common/tiledef.c | ||
|---|---|---|
|
/************************************************************************//**
|
||
|
Check if tile matches tiledef
|
||
|
****************************************************************************/
|
||
|
bool tile_matches_tiledef(const struct tiledef *td, const struct tile *ptile)
|
||
|
bool tile_matches_tiledef(const struct tiledef *td, const struct tile *ptile,
|
||
|
const struct player *pplayer)
|
||
|
{
|
||
|
if (terrain_flag_id_is_valid(td->terr_flag)) {
|
||
|
if (!terrain_has_flag(tile_terrain(ptile), td->terr_flag)) {
|
||
| ... | ... | |
|
}
|
||
|
} extra_type_list_iterate_end;
|
||
|
if (td->known && pplayer != nullptr
|
||
|
&& tile_get_known(ptile, pplayer) == TILE_UNKNOWN) {
|
||
|
return FALSE;
|
||
|
}
|
||
|
return TRUE;
|
||
|
}
|
||
| ... | ... | |
|
(Does not check ptile itself.)
|
||
|
****************************************************************************/
|
||
|
bool is_tiledef_card_near(const struct civ_map *nmap, const struct tile *ptile,
|
||
|
const struct tiledef *ptd)
|
||
|
const struct tiledef *ptd, const struct player *pplayer)
|
||
|
{
|
||
|
cardinal_adjc_iterate(nmap, ptile, adjc_tile) {
|
||
|
if (tile_matches_tiledef(ptd, adjc_tile)) {
|
||
|
if (tile_matches_tiledef(ptd, adjc_tile, pplayer)) {
|
||
|
return TRUE;
|
||
|
}
|
||
|
} cardinal_adjc_iterate_end;
|
||
| ... | ... | |
|
(Does not check ptile itself.)
|
||
|
****************************************************************************/
|
||
|
bool is_tiledef_near_tile(const struct civ_map *nmap, const struct tile *ptile,
|
||
|
const struct tiledef *ptd)
|
||
|
const struct tiledef *ptd, const struct player *pplayer)
|
||
|
{
|
||
|
adjc_iterate(nmap, ptile, adjc_tile) {
|
||
|
if (tile_matches_tiledef(ptd, adjc_tile)) {
|
||
|
if (tile_matches_tiledef(ptd, adjc_tile, pplayer)) {
|
||
|
return TRUE;
|
||
|
}
|
||
|
} adjc_iterate_end;
|
||
| common/tiledef.h | ||
|---|---|---|
|
enum terrain_flag_id terr_flag;
|
||
|
struct extra_type_list *extras;
|
||
|
bool known;
|
||
|
};
|
||
|
void tiledefs_init(void);
|
||
| ... | ... | |
|
} \
|
||
|
}
|
||
|
bool tile_matches_tiledef(const struct tiledef *td, const struct tile *ptile)
|
||
|
bool tile_matches_tiledef(const struct tiledef *td, const struct tile *ptile,
|
||
|
const struct player *pplayer)
|
||
|
fc__attribute((nonnull (1, 2)));
|
||
|
bool is_tiledef_card_near(const struct civ_map *nmap, const struct tile *ptile,
|
||
|
const struct tiledef *ptd);
|
||
|
const struct tiledef *ptd, const struct player *pplayer);
|
||
|
bool is_tiledef_near_tile(const struct civ_map *nmap, const struct tile *ptile,
|
||
|
const struct tiledef *ptd);
|
||
|
const struct tiledef *ptd, const struct player *pplayer);
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
| data/alien/terrain.ruleset | ||
|---|---|---|
|
; to satisfy tiledef requirements.
|
||
|
; extras = List of extras that the tile must have
|
||
|
; to satisfy tiledef requirements.
|
||
|
; known = Whether the target player must know the tile or not
|
||
|
;
|
||
|
; */ <-- avoid gettext warnings
|
||
| data/civ1/terrain.ruleset | ||
|---|---|---|
|
; to satisfy tiledef requirements.
|
||
|
; extras = List of extras that the tile must have
|
||
|
; to satisfy tiledef requirements.
|
||
|
; known = Whether the target player must know the tile or not
|
||
|
;
|
||
|
; */ <-- avoid gettext warnings
|
||
| data/civ2/terrain.ruleset | ||
|---|---|---|
|
; to satisfy tiledef requirements.
|
||
|
; extras = List of extras that the tile must have
|
||
|
; to satisfy tiledef requirements.
|
||
|
; known = Whether the target player must know the tile or not
|
||
|
;
|
||
|
; */ <-- avoid gettext warnings
|
||
| data/civ2civ3/terrain.ruleset | ||
|---|---|---|
|
; to satisfy tiledef requirements.
|
||
|
; extras = List of extras that the tile must have
|
||
|
; to satisfy tiledef requirements.
|
||
|
; known = Whether the target player must know the tile or not
|
||
|
;
|
||
|
; */ <-- avoid gettext warnings
|
||
| data/classic/terrain.ruleset | ||
|---|---|---|
|
; to satisfy tiledef requirements.
|
||
|
; extras = List of extras that the tile must have
|
||
|
; to satisfy tiledef requirements.
|
||
|
; known = Whether the target player must know the tile or not
|
||
|
;
|
||
|
; */ <-- avoid gettext warnings
|
||
| data/goldkeep/terrain.ruleset | ||
|---|---|---|
|
; to satisfy tiledef requirements.
|
||
|
; extras = List of extras that the tile must have
|
||
|
; to satisfy tiledef requirements.
|
||
|
; known = Whether the target player must know the tile or not
|
||
|
;
|
||
|
; */ <-- avoid gettext warnings
|
||
| data/granularity/terrain.ruleset | ||
|---|---|---|
|
; to satisfy tiledef requirements.
|
||
|
; extras = List of extras that the tile must have
|
||
|
; to satisfy tiledef requirements.
|
||
|
; known = Whether the target player must know the tile or not
|
||
|
;
|
||
|
; */ <-- avoid gettext warnings
|
||
| data/multiplayer/terrain.ruleset | ||
|---|---|---|
|
; to satisfy tiledef requirements.
|
||
|
; extras = List of extras that the tile must have
|
||
|
; to satisfy tiledef requirements.
|
||
|
; known = Whether the target player must know the tile or not
|
||
|
;
|
||
|
; */ <-- avoid gettext warnings
|
||
| data/ruledit/comments-3.4.txt | ||
|---|---|---|
|
; to satisfy tiledef requirements.\n\
|
||
|
; extras = List of extras that the tile must have\n\
|
||
|
; to satisfy tiledef requirements.\n\
|
||
|
; known = Whether the target player must know the tile or not\n\
|
||
|
;\n\
|
||
|
; */ <-- avoid gettext warnings\n\
|
||
|
"
|
||
| data/sandbox/terrain.ruleset | ||
|---|---|---|
|
; to satisfy tiledef requirements.
|
||
|
; extras = List of extras that the tile must have
|
||
|
; to satisfy tiledef requirements.
|
||
|
; known = Whether the target player must know the tile or not
|
||
|
;
|
||
|
; */ <-- avoid gettext warnings
|
||
| data/stub/terrain.ruleset | ||
|---|---|---|
|
; to satisfy tiledef requirements.
|
||
|
; extras = List of extras that the tile must have
|
||
|
; to satisfy tiledef requirements.
|
||
|
; known = Whether the target player must know the tile or not
|
||
|
;
|
||
|
; */ <-- avoid gettext warnings
|
||
| server/aahand.c | ||
|---|---|---|
|
pf_map_tiles_iterate(pfm, ptile, TRUE) {
|
||
|
if (ptile != nullptr) {
|
||
|
tiledef_iterate(td) {
|
||
|
if (tile_matches_tiledef(td, ptile)) {
|
||
|
if (tile_matches_tiledef(td, ptile, plr)) {
|
||
|
int tn = tiledef_number(td);
|
||
|
BV_SET(aarea->tiledefs, tn);
|
||
| server/ruleset/ruleload.c | ||
|---|---|---|
|
ok = FALSE;
|
||
|
}
|
||
|
if (ok) {
|
||
|
td->known = secfile_lookup_bool_default(file, FALSE,
|
||
|
"%s.known", section);
|
||
|
}
|
||
|
if (!ok) {
|
||
|
break;
|
||
|
}
|
||
| ... | ... | |
|
packet.extras = extras;
|
||
|
packet.known = td->known;
|
||
|
lsend_packet_ruleset_tiledef(dest, &packet);
|
||
|
} tiledef_iterate_end;
|
||
|
}
|
||
| tools/ruleutil/rulesave.c | ||
|---|---|---|
|
secfile_insert_str_vec(sfile, extra_names, set_count,
|
||
|
"%s.extras", path);
|
||
|
}
|
||
|
if (td->known) {
|
||
|
secfile_insert_bool(sfile, td->known, "%s.known", path);
|
||
|
}
|
||
|
} tiledef_iterate_end;
|
||
|
return save_ruleset_file(sfile, filename);
|
||