Project

General

Profile

Feature #652 » 0006-Support-MaxRegionTiles-at-C-Adjacent-ranges.patch

main v3 - Alina Lenk, 05/22/2024 01:50 AM

View differences:

common/metaknowledge.c
return TRUE;
}
if (req->source.kind == VUT_MAX_REGION_TILES) {
if (context->tile == NULL) {
/* The tile may exist but not be passed when the problem type is
* RPT_POSSIBLE. */
return prob_type == RPT_CERTAIN;
}
switch (req->range) {
case REQ_RANGE_CADJACENT:
case REQ_RANGE_ADJACENT:
/* TODO: Known tiles might be enough to determine the answer already;
* should we check on an individual requirement basis? */
if (tile_get_known(context->tile, pov_player) == TILE_UNKNOWN) {
return FALSE;
}
range_adjc_iterate(&(wld.map), context->tile, req->range, adj_tile) {
if (tile_get_known(adj_tile, pov_player) == TILE_UNKNOWN) {
return FALSE;
}
} range_adjc_iterate_end;
return TRUE;
case REQ_RANGE_CONTINENT:
/* Too complicated to figure out */
return FALSE;
case REQ_RANGE_CITY:
case REQ_RANGE_TRADE_ROUTE:
case REQ_RANGE_PLAYER:
case REQ_RANGE_ALLIANCE:
case REQ_RANGE_TEAM:
case REQ_RANGE_WORLD:
case REQ_RANGE_LOCAL:
case REQ_RANGE_TILE:
case REQ_RANGE_COUNT:
/* Non existing range for requirement types. */
return FALSE;
}
}
if (req->source.kind == VUT_ACTION
|| req->source.kind == VUT_OTYPE) {
/* This requirement type is intended to specify the situation. */
common/reqtext.c
case VUT_MAX_REGION_TILES:
switch (preq->range) {
case REQ_RANGE_CADJACENT:
fc_strlcat(buf, prefix, bufsz);
/* Off-by-one: The requirement counts the tile itself, we're phrasing
* the helptext in terms of *other* tiles only. */
if (preq->present) {
if (preq->source.value.region_tiles == 1) {
/* Special case for zero */
fc_strlcat(buf,
_("No other cardinally adjacent tile may be part of "
"the same continent or ocean."),
bufsz);
} else {
cat_snprintf(buf, bufsz,
PL_("No more than %d other cardinally adjacent tile "
"may be part of the same continent or ocean.",
"No more than %d other cardinally adjacent tiles "
"may be part of the same continent or ocean.",
preq->source.value.region_tiles - 1),
preq->source.value.region_tiles - 1);
}
} else {
cat_snprintf(buf, bufsz,
PL_("Requires at least %d other cardinally adjacent "
"tile of the same continent or ocean.",
"Requires at least %d other cardinally adjacent "
"tiles of the same continent or ocean.",
preq->source.value.region_tiles),
preq->source.value.region_tiles);
}
return TRUE;
case REQ_RANGE_ADJACENT:
fc_strlcat(buf, prefix, bufsz);
/* Off-by-one: The requirement counts the tile itself, we're phrasing
* the helptext in terms of *other* tiles only. */
if (preq->present) {
if (preq->source.value.region_tiles == 1) {
/* Special case for zero */
fc_strlcat(buf,
_("No other adjacent tile may be part of the same "
"continent or ocean."),
bufsz);
} else {
cat_snprintf(buf, bufsz,
PL_("No more than %d other adjacent tile may be "
"part of the same continent or ocean.",
"No more than %d other adjacent tiles may be "
"part of the same continent or ocean.",
preq->source.value.region_tiles - 1),
preq->source.value.region_tiles - 1);
}
} else {
cat_snprintf(buf, bufsz,
PL_("Requires at least %d other adjacent tile of the "
"same continent or ocean.",
"Requires at least %d other adjacent tiles of the "
"same continent or ocean.",
preq->source.value.region_tiles),
preq->source.value.region_tiles);
}
return TRUE;
case REQ_RANGE_CONTINENT:
fc_strlcat(buf, prefix, bufsz);
if (preq->present) {
......
case REQ_RANGE_WORLD:
case REQ_RANGE_LOCAL:
case REQ_RANGE_TILE:
case REQ_RANGE_CADJACENT:
case REQ_RANGE_ADJACENT:
case REQ_RANGE_CITY:
case REQ_RANGE_TRADE_ROUTE:
case REQ_RANGE_COUNT:
common/requirements.c
invalid = (req.range != REQ_RANGE_PLAYER);
break;
case VUT_MAX_REGION_TILES:
invalid = (req.range != REQ_RANGE_CONTINENT);
invalid = (req.range != REQ_RANGE_CONTINENT
&& req.range != REQ_RANGE_CADJACENT
&& req.range != REQ_RANGE_ADJACENT);
break;
case VUT_IMPROVEMENT:
/* Valid ranges depend on the building genus (wonder/improvement),
......
/* Finding contradictions across requirement kinds isn't supported
* for MaxRegionTiles requirements. */
return FALSE;
} else if (req1->range != req2->range) {
/* FIXME: Finding contradictions across ranges not yet supported.
* In particular, a max at a small range and a min at a larger range
* needs extra work to figure out. */
return FALSE;
}
return are_bounds_contradictions(
req1->source.value.region_tiles, req1->present,
......
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_MAX_REGION_TILES);
switch (req->range) {
case REQ_RANGE_CADJACENT:
case REQ_RANGE_ADJACENT:
if (context->tile == nullptr) {
/* The tile itself is included in the range */
max_tiles = 1 + ((req->range == REQ_RANGE_CADJACENT)
? nmap->num_cardinal_dirs
: nmap->num_valid_dirs);
break;
} else {
Continent_id cont = tile_continent(context->tile);
/* Count how many adjacent tiles there actually are as we go along */
max_tiles = 1;
range_adjc_iterate(nmap, context->tile, req->range, adj_tile) {
Continent_id adj_cont = tile_continent(adj_tile);
if (adj_cont == 0 || cont == 0) {
max_tiles++;
} else if (adj_cont == cont) {
min_tiles++;
max_tiles++;
}
} range_adjc_iterate_end;
}
break;
case REQ_RANGE_CONTINENT:
{
Continent_id cont = context->tile ? tile_continent(context->tile) : 0;
doc/README.effects
MinVeteran: Local
MinHitPoints: Local
MaxDistanceSq: Tile
MaxRegionTiles: Continent
MaxRegionTiles: Continent, Adjacent, CAdjacent
MinSize is the minimum size of a city required.
......
MaxDistanceSq is about the (squared) distance between two tiles; currently
only available for action enablers (see also README.actions) and a select
few effects.
MaxRegionTiles is continent or ocean size (number of tiles).
MaxRegionTiles is about the number of tiles of the same continent or ocean as
the target tile in the given range (including the tile itself). At "Continent"
range this is just the full continent/ocean size.
CityStatus is "OwnedByOriginal", "Transferred", "Starved",
"Disorder", or "Celebration"
The difference between "OwnedByOriginal" and "Transferred" is that
server/ruleset/rssanity.c
case VUT_ORIGINAL_OWNER: /* City range -> only one original owner */
case VUT_FORM_AGE:
case VUT_MAX_DISTANCE_SQ: /* Breaks nothing, but has no sense either */
case VUT_MAX_REGION_TILES: /* Breaks nothing, but has no sense either */
/* There can be only one requirement of these types (with current
* range limitations)
* Requirements might be identical, but we consider multiple
......
/* Can have multiple requirements of these types */
case VUT_MINLATITUDE:
case VUT_MAXLATITUDE:
case VUT_MAX_REGION_TILES:
/* Can have multiple requirements at different ranges.
* TODO: Compare to number of legal ranges? */
break;
(3-3/3)