Project

General

Profile

Feature #588 » 0010-Unhardcode-terrain-class-specific-border-claiming-ru.patch

main v5 - Alina Lenk, 05/24/2024 02:53 PM

View differences:

ai/default/daieffects.c
case EFT_UNIT_SHIELD_VALUE_PCT:
case EFT_NUKE_BLAST_RADIUS_1_SQ:
case EFT_HEAL_UNIT_PCT:
case EFT_TILE_CLAIMABLE:
break;
/* This has no effect for AI */
case EFT_VISIBLE_WALLS:
common/tech.h
/* Player can build air units */
#define SPECENUM_VALUE2 TF_BUILD_AIRBORNE
#define SPECENUM_VALUE2NAME N_("Build_Airborne")
/* Player can claim ocean tiles non-adjacent to border source */
#define SPECENUM_VALUE3 TF_CLAIM_OCEAN
#define SPECENUM_VALUE3NAME N_("Claim_Ocean")
/* Player can claim ocean tiles non-adjacent to border source as long
* as source is ocean tile */
#define SPECENUM_VALUE4 TF_CLAIM_OCEAN_LIMITED
#define SPECENUM_VALUE4NAME N_("Claim_Ocean_Limited")
#define SPECENUM_VALUE5 TECH_USER_1
#define SPECENUM_VALUE6 TECH_USER_2
#define SPECENUM_VALUE7 TECH_USER_3
#define SPECENUM_VALUE8 TECH_USER_4
#define SPECENUM_VALUE9 TECH_USER_5
#define SPECENUM_VALUE10 TECH_USER_6
#define SPECENUM_VALUE11 TECH_USER_7
#define SPECENUM_VALUE3 TECH_USER_1
#define SPECENUM_VALUE4 TECH_USER_2
#define SPECENUM_VALUE5 TECH_USER_3
#define SPECENUM_VALUE6 TECH_USER_4
#define SPECENUM_VALUE7 TECH_USER_5
#define SPECENUM_VALUE8 TECH_USER_6
#define SPECENUM_VALUE9 TECH_USER_7
#define SPECENUM_VALUE10 TECH_USER_8
#define SPECENUM_VALUE11 TECH_USER_9
#define SPECENUM_VALUE12 TECH_USER_LAST
/* Keep this last. */
#define SPECENUM_COUNT TF_COUNT
data/alien/effects.ruleset
{ "type", "name", "range", "present"
"Action", "Upgrade Unit", "Local", TRUE
}
[effect_claim_land]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
"TerrainClass", "Land", "Tile"
"TileRel", "Same Region", "Tile"
}
[effect_claim_ocean_adj]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
"TerrainClass", "Oceanic", "Tile"
"MaxDistanceSq", "2", "Tile"
}
[effect_claim_ocean_lake]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
"TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "20", "Continent"
"TileRel", "Region Surrounded", "Tile"
; implicit with Region Surrounded
; "TileRel", "Same Terrain Class", "Tile", FALSE
}
[effect_claim_ocean_from_land_bay]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range", "present"
"TerrainClass", "Oceanic", "Tile", TRUE
"TileRel", "Same Terrain Class", "Tile", FALSE
"MaxRegionTiles", "3", "Adjacent", TRUE
"TileRel", "Only Other Region", "Adjacent", TRUE
}
[effect_claim_ocean_tech]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
"TerrainClass", "Oceanic", "Tile"
"Tech", "Ocean Cities", "Player"
}
data/alien/techs.ruleset
; extra. See "bridged_over" extra property in
; terrain.ruleset.
; "Build_Airborne" = from now on can build air units (for use by AI)
; "Claim_Ocean" = Player claims ocean tiles even if they are not
; adjacent to border source
; "Claim_Ocean_Limited" = Oceanic border sources claim ocean tiles even if
; they are not adjacent to border source
;
; */ <-- avoid gettext warnings
......
name = _("Ocean Cities")
req1 = "Deneb Radar"
req2 = "Thermal Module"
flags = "Claim_Ocean"
flags = ""
graphic = "a.ocean_cities"
graphic_alt = "-"
helptext = _("Cities on ocean. Why not?")
data/civ1/effects.ruleset
{ "type", "name", "range", "present"
"Action", "Disband Unit Recover", "Local", TRUE
}
; Note: There are no oceanic border sources, so we don't need to check
; the tiles' terrain class
[effect_claim_land]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Land", "Tile"
"TileRel", "Same Region", "Tile"
}
[effect_claim_ocean_adj]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxDistanceSq", "2", "Tile"
}
[effect_claim_ocean_lake]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "20", "Continent"
"TileRel", "Region Surrounded", "Tile"
}
[effect_claim_ocean_bay]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "3", "Adjacent"
"TileRel", "Only Other Region", "Adjacent"
"TileRel", "Same Region", "Adjacent"
}
data/civ1/techs.ruleset
; extra. See "bridged_over" extra property in
; terrain.ruleset.
; "Build_Airborne" = from now on can build air units (for use by AI)
; "Claim_Ocean" = Player claims ocean tiles even if they are not
; adjacent to border source
; "Claim_Ocean_Limited" = Oceanic border sources claim ocean tiles even if
; they are not adjacent to border source
;
; */ <-- avoid gettext warnings
data/civ2/effects.ruleset
{ "type", "name", "range", "present"
"Action", "Upgrade Unit", "Local", TRUE
}
; Note: There are no oceanic border sources, so we don't need to check
; the tiles' terrain class
[effect_claim_land]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Land", "Tile"
"TileRel", "Same Region", "Tile"
}
[effect_claim_ocean_adj]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxDistanceSq", "2", "Tile"
}
[effect_claim_ocean_lake]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "20", "Continent"
"TileRel", "Region Surrounded", "Tile"
}
[effect_claim_ocean_bay]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "3", "Adjacent"
"TileRel", "Only Other Region", "Adjacent"
"TileRel", "Same Region", "Adjacent"
}
data/civ2/techs.ruleset
; extra. See "bridged_over" extra property in
; terrain.ruleset.
; "Build_Airborne" = from now on can build air units (for use by AI)
; "Claim_Ocean" = Player claims ocean tiles even if they are not
; adjacent to border source
; "Claim_Ocean_Limited" = Oceanic border sources claim ocean tiles even if
; they are not adjacent to border source
;
; */ <-- avoid gettext warnings
data/civ2civ3/effects.ruleset
{ "type", "name", "range", "present"
"Action", "Upgrade Unit", "Local", TRUE
}
; Note: There are no oceanic border sources, so we don't need to check
; the tiles' terrain class
[effect_claim_land]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Land", "Tile"
"TileRel", "Same Region", "Tile"
}
[effect_claim_ocean_adj]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxDistanceSq", "2", "Tile"
}
[effect_claim_ocean_lake]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "20", "Continent"
"TileRel", "Region Surrounded", "Tile"
}
[effect_claim_ocean_bay]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "3", "Adjacent"
"TileRel", "Only Other Region", "Adjacent"
"TileRel", "Same Region", "Adjacent"
}
data/civ2civ3/techs.ruleset
; extra. See "bridged_over" extra property in
; terrain.ruleset.
; "Build_Airborne" = from now on can build air units (for use by AI)
; "Claim_Ocean" = Player claims ocean tiles even if they are not
; adjacent to border source
; "Claim_Ocean_Limited" = Oceanic border sources claim ocean tiles even if
; they are not adjacent to border source
;
; */ <-- avoid gettext warnings
data/classic/effects.ruleset
{ "type", "name", "range", "present"
"Action", "Upgrade Unit", "Local", TRUE
}
; Note: There are no oceanic border sources, so we don't need to check
; the tiles' terrain class
[effect_claim_land]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Land", "Tile"
"TileRel", "Same Region", "Tile"
}
[effect_claim_ocean_adj]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxDistanceSq", "2", "Tile"
}
[effect_claim_ocean_lake]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "20", "Continent"
"TileRel", "Region Surrounded", "Tile"
}
[effect_claim_ocean_bay]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "3", "Adjacent"
"TileRel", "Only Other Region", "Adjacent"
"TileRel", "Same Region", "Adjacent"
}
data/classic/techs.ruleset
; extra. See "bridged_over" extra property in
; terrain.ruleset.
; "Build_Airborne" = from now on can build air units (for use by AI)
; "Claim_Ocean" = Player claims ocean tiles even if they are not
; adjacent to border source
; "Claim_Ocean_Limited" = Oceanic border sources claim ocean tiles even if
; they are not adjacent to border source
;
; */ <-- avoid gettext warnings
data/goldkeep/effects.ruleset
{ "type", "name", "range", "present"
"Action", "Upgrade Unit", "Local", TRUE
}
; Note: There are no oceanic border sources, so we don't need to check
; the tiles' terrain class
[effect_claim_land]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Land", "Tile"
"TileRel", "Same Region", "Tile"
}
[effect_claim_ocean_adj]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxDistanceSq", "2", "Tile"
}
[effect_claim_ocean_lake]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "20", "Continent"
"TileRel", "Region Surrounded", "Tile"
}
[effect_claim_ocean_bay]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "3", "Adjacent"
"TileRel", "Only Other Region", "Adjacent"
"TileRel", "Same Region", "Adjacent"
}
data/goldkeep/techs.ruleset
; extra. See "bridged_over" extra property in
; terrain.ruleset.
; "Build_Airborne" = from now on can build air units (for use by AI)
; "Claim_Ocean" = Player claims ocean tiles even if they are not
; adjacent to border source
; "Claim_Ocean_Limited" = Oceanic border sources claim ocean tiles even if
; they are not adjacent to border source
;
; */ <-- avoid gettext warnings
data/granularity/effects.ruleset
{ "type", "name", "range"
"Extra", "Mine", "Tile"
}
[effect_claim_land]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
"TerrainClass", "Land", "Tile"
"TileRel", "Same Region", "Tile"
}
[effect_claim_ocean_adj]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
"TerrainClass", "Oceanic", "Tile"
"MaxDistanceSq", "2", "Tile"
}
[effect_claim_ocean_lake]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
"TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "20", "Continent"
"TileRel", "Region Surrounded", "Tile"
; implicit with Region Surrounded
; "TileRel", "Same Terrain Class", "Tile", FALSE
}
[effect_claim_ocean_from_land_bay]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range", "present"
"TerrainClass", "Oceanic", "Tile", TRUE
"TileRel", "Same Terrain Class", "Tile", FALSE
"MaxRegionTiles", "3", "Adjacent", TRUE
"TileRel", "Only Other Region", "Adjacent", TRUE
}
data/granularity/techs.ruleset
; extra. See "bridged_over" extra property in
; terrain.ruleset.
; "Build_Airborne" = from now on can build air units (for use by AI)
; "Claim_Ocean" = Player claims ocean tiles even if they are not
; adjacent to border source
; "Claim_Ocean_Limited" = Oceanic border sources claim ocean tiles even if
; they are not adjacent to border source
;
; */ <-- avoid gettext warnings
data/multiplayer/effects.ruleset
{ "type", "name", "range", "present"
"Action", "Upgrade Unit", "Local", TRUE
}
; Note: There are no oceanic border sources, so we don't need to check
; the tiles' terrain class
[effect_claim_land]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Land", "Tile"
"TileRel", "Same Region", "Tile"
}
[effect_claim_ocean_adj]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxDistanceSq", "2", "Tile"
}
[effect_claim_ocean_lake]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "20", "Continent"
"TileRel", "Region Surrounded", "Tile"
}
[effect_claim_ocean_bay]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "3", "Adjacent"
"TileRel", "Only Other Region", "Adjacent"
"TileRel", "Same Region", "Adjacent"
}
data/multiplayer/techs.ruleset
; extra. See "bridged_over" extra property in
; terrain.ruleset.
; "Build_Airborne" = from now on can build air units (for use by AI)
; "Claim_Ocean" = Player claims ocean tiles even if they are not
; adjacent to border source
; "Claim_Ocean_Limited" = Oceanic border sources claim ocean tiles even if
; they are not adjacent to border source
;
; */ <-- avoid gettext warnings
data/ruledit/comments-3.3.txt
; extra. See \"bridged_over\" extra property in\n\
; terrain.ruleset.\n\
; \"Build_Airborne\" = from now on can build air units (for use by AI)\n\
; \"Claim_Ocean\" = Player claims ocean tiles even if they are not\n\
; adjacent to border source\n\
; \"Claim_Ocean_Limited\" = Oceanic border sources claim ocean tiles even if\n\
; they are not adjacent to border source\n\
;\n\
; */ <-- avoid gettext warnings\n\
"
data/sandbox/effects.ruleset
"Counter", "Turn_Owned2", "City", TRUE
"Counter", "Turn_of_Celebration", "City", TRUE
}
; Note: There are no oceanic border sources, so we don't need to check
; the tiles' terrain class
[effect_claim_land]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Land", "Tile"
"TileRel", "Same Region", "Tile"
}
[effect_claim_ocean_adj]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxDistanceSq", "2", "Tile"
}
[effect_claim_ocean_lake]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "20", "Continent"
"TileRel", "Region Surrounded", "Tile"
}
[effect_claim_ocean_bay]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "3", "Adjacent"
"TileRel", "Only Other Region", "Adjacent"
"TileRel", "Same Region", "Adjacent"
}
data/sandbox/techs.ruleset
; extra. See "bridged_over" extra property in
; terrain.ruleset.
; "Build_Airborne" = from now on can build air units (for use by AI)
; "Claim_Ocean" = Player claims ocean tiles even if they are not
; adjacent to border source
; "Claim_Ocean_Limited" = Oceanic border sources claim ocean tiles even if
; they are not adjacent to border source
;
; */ <-- avoid gettext warnings
data/stub/techs.ruleset
; extra. See "bridged_over" extra property in
; terrain.ruleset.
; "Build_Airborne" = from now on can build air units (for use by AI)
; "Claim_Ocean" = Player claims ocean tiles even if they are not
; adjacent to border source
; "Claim_Ocean_Limited" = Oceanic border sources claim ocean tiles even if
; they are not adjacent to border source
;
; */ <-- avoid gettext warnings
data/webperimental/effects.ruleset
{ "type", "name", "range", "present"
"Action", "Upgrade Unit", "Local", TRUE
}
; Note: There are no oceanic border sources, so we don't need to check
; the tiles' terrain class
[effect_claim_land]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Land", "Tile"
"TileRel", "Same Region", "Tile"
}
[effect_claim_ocean_adj]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxDistanceSq", "2", "Tile"
}
[effect_claim_ocean_lake]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "20", "Continent"
"TileRel", "Region Surrounded", "Tile"
}
[effect_claim_ocean_bay]
type = "Tile_Claimable"
value = 1
reqs =
{ "type", "name", "range"
; "TerrainClass", "Oceanic", "Tile"
"MaxRegionTiles", "3", "Adjacent"
"TileRel", "Only Other Region", "Adjacent"
"TileRel", "Same Region", "Adjacent"
}
data/webperimental/techs.ruleset
; extra. See "bridged_over" extra property in
; terrain.ruleset.
; "Build_Airborne" = from now on can build air units (for use by AI)
; "Claim_Ocean" = Player claims ocean tiles even if they are not
; adjacent to border source
; "Claim_Ocean_Limited" = Oceanic border sources claim ocean tiles even if
; they are not adjacent to border source
;
; */ <-- avoid gettext warnings
doc/README.effects
"Steal Gold Escape" actions that is lost before it reaches the player
ordering it. Evaluated against the actor unit.
Tile_Claimable
A positive value means national borders can expand to this tile from a
border source (city or base). The border source's tile is used as the
other tile for requirements that depend on two tiles.
Tile_Workable
If value > 0, city can work target tile.
gen_headers/enums/effects_enums.def
TECH_LEAKAGE "Tech_Leakage"
IMPR_UPKEEP_REDUCTION "Impr_Upkeep_Reduction"
CULTURE_PCT "Culture_Pct"
TILE_CLAIMABLE "Tile_Claimable"
USER_EFFECT_1 "User_Effect_1"
USER_EFFECT_2 "User_Effect_2"
USER_EFFECT_3 "User_Effect_3"
server/maphand.c
#include "maphand.h"
#define MAXIMUM_CLAIMED_OCEAN_SIZE (20)
/* Suppress send_tile_info() during game_load() */
static bool send_tile_suppressed = FALSE;
......
const struct player *pplayer,
enum vision_layer vlayer);
static bool is_claimable_ocean(struct tile *ptile, struct tile *source,
struct player *pplayer);
static bool is_tile_claimable(struct tile *ptile, struct tile *source,
struct player *pplayer);
/**********************************************************************//**
Used only in global_warming() and nuclear_winter() below.
......
claimer = tile_claimer(ptile);
if (claimer != NULL) {
/* Make sure map_claim_border() conditions are still satisfied */
if (is_ocean_tile(ptile)) {
/* Only certain water tiles are claimable */
if (!is_claimable_ocean(ptile, claimer, tile_owner(ptile))) {
map_clear_border(ptile);
}
} else {
/* Only land tiles on the same island as the border source
* are claimable */
if (tile_continent(ptile) != tile_continent(claimer)) {
map_clear_border(ptile);
}
if (!is_tile_claimable(ptile, claimer, tile_owner(ptile))) {
map_clear_border(ptile);
}
}
......
}
/**********************************************************************//**
Ocean tile can be claimed iff one of the following conditions stands:
a) it is an inland lake not larger than MAXIMUM_OCEAN_SIZE
b) it is adjacent to only one continent and not more than two ocean tiles
c) It is one tile away from a border source
d) Player knows tech with Claim_Ocean flag
e) Source itself is Oceanic tile and player knows tech with Claim_Ocean_Limited flag
The source which claims the ocean has to be placed on the correct continent.
in case a) The continent which surrounds the inland lake
in case b) The only continent which is adjacent to the tile
A tile can be claimed by a border source iff the tile itself is the
border source or the Tile_Claimable effect is positive
**************************************************************************/
static bool is_claimable_ocean(struct tile *ptile, struct tile *source,
struct player *pplayer)
static bool is_tile_claimable(struct tile *ptile, struct tile *source,
struct player *pplayer)
{
Continent_id cont = tile_continent(ptile);
Continent_id source_cont = tile_continent(source);
int ocean_tiles;
bool other_continent;
if (get_ocean_size(-cont) <= MAXIMUM_CLAIMED_OCEAN_SIZE
&& get_lake_surrounder(cont) == source_cont) {
return TRUE;
}
if (ptile == source) {
/* Source itself is always claimable. */
return TRUE;
}
if (num_known_tech_with_flag(pplayer, TF_CLAIM_OCEAN) > 0
|| (source_cont < 0 && num_known_tech_with_flag(pplayer, TF_CLAIM_OCEAN_LIMITED) > 0)) {
return TRUE;
}
ocean_tiles = 0;
other_continent = FALSE;
adjc_iterate(&(wld.map), ptile, adj_tile) {
Continent_id adj_cont = tile_continent(adj_tile);
if (adj_tile == source) {
/* Water next to border source is always claimable */
return TRUE;
}
if (adj_cont == cont) {
ocean_tiles++;
} else if (adj_cont != source_cont) {
/* This water is adjacent to a continent different from the one
* the border source is on */
other_continent = TRUE;
}
} adjc_iterate_end;
if (!other_continent && ocean_tiles <= 2) {
return TRUE;
} else {
return FALSE;
}
return 0 < get_target_bonus_effects(nullptr,
&(const struct req_context) {
.tile = ptile,
.player = pplayer,
},
&(const struct req_context) {
.tile = source,
},
EFT_TILE_CLAIMABLE);
}
/**********************************************************************//**
......
}
}
if (is_ocean_tile(dtile)) {
/* Only certain water tiles are claimable */
if (is_claimable_ocean(dtile, ptile, owner)) {
map_claim_ownership(dtile, owner, ptile, dr == 0);
}
} else {
/* Only land tiles on the same island as the border source
* are claimable */
if (tile_continent(dtile) == tile_continent(ptile)) {
map_claim_ownership(dtile, owner, ptile, dr == 0);
}
/* Only certain tiles are claimable */
if (is_tile_claimable(dtile, ptile, owner)) {
map_claim_ownership(dtile, owner, ptile, dr == 0);
}
} circle_dxyr_iterate_end;
}
server/ruleset/rscompat.c
#include "rscompat.h"
#define MAXIMUM_CLAIMED_OCEAN_SIZE_3_2 (20)
#define enough_new_user_flags(_new_flags_, _name_, \
_LAST_USER_FLAG_, _LAST_USER_FLAG_PREV_) \
FC_STATIC_ASSERT((ARRAY_SIZE(_new_flags_) \
......
not_enough_new_##_name_##_user_flags)
#define UTYF_LAST_USER_FLAG_3_2 UTYF_USER_FLAG_50
#define TECH_LAST_USER_FLAG_3_2 TECH_USER_7
static int first_free_unit_type_user_flag(void);
static int first_free_tech_user_flag(void);
/**********************************************************************//**
Initialize rscompat information structure
......
}
}
if (info->version < RSFORMAT_3_3) {
int first_free;
int i;
/* Some tech flags moved to the ruleset between 3.2 and 3.3.
* Add them back as user flags.
* XXX: ruleset might not need all of these, and may have enough
* flags of its own that these additional ones prevent conversion. */
const struct {
const char *name;
const char *helptxt;
} new_flags_33[] = {
{ N_("Claim_Ocean"),
N_("National borders expand freely into the ocean.") },
{ N_("Claim_Ocean_Limited"),
N_("National borders from oceanic sources expand freely.") },
};
enough_new_user_flags(new_flags_33, tech,
(TECH_USER_LAST - 1), TECH_LAST_USER_FLAG_3_2);
/* Tech flags. */
first_free = first_free_tech_user_flag() + TECH_USER_1;
for (i = 0; i < ARRAY_SIZE(new_flags_33); i++) {
if (TECH_USER_1 + MAX_NUM_USER_TECH_FLAGS <= first_free + i) {
/* Can't add the user unit type flags. */
ruleset_error(NULL, LOG_ERROR,
"Can't upgrade the ruleset. Not enough free tech "
"user flags to add user flags for the tech flags "
"that used to be hardcoded.");
return FALSE;
}
/* Shouldn't be possible for valid old ruleset to have flag names that
* clash with these ones */
if (tech_flag_id_by_name(new_flags_33[i].name, fc_strcasecmp)
!= tech_flag_id_invalid()) {
ruleset_error(NULL, LOG_ERROR,
"Ruleset had illegal user tech flag '%s'",
new_flags_33[i].name);
return FALSE;
}
set_user_tech_flag_name(first_free + i,
new_flags_33[i].name,
new_flags_33[i].helptxt);
}
}
/* No errors encountered. */
return TRUE;
}
......
void rscompat_postprocess(struct rscompat_info *info)
{
struct action_enabler *enabler;
struct effect *effect;
struct requirement e_req;
if (!info->compat_mode || info->version >= RSFORMAT_CURRENT) {
......
* thought limited by game.info.tech_leakage setting. */
effect_new(EFT_TECH_LEAKAGE, 1, nullptr);
/* Old behavior: Land tiles can be claimed by land border sources on the
* same continent. */
effect = effect_new(EFT_TILE_CLAIMABLE, 1, nullptr);
e_req = req_from_values(VUT_TERRAINCLASS, REQ_RANGE_TILE,
FALSE, TRUE, FALSE, TC_LAND);
effect_req_append(effect, e_req);
e_req = req_from_values(VUT_TILE_REL, REQ_RANGE_TILE,
FALSE, TRUE, FALSE, TREL_SAME_REGION);
effect_req_append(effect, e_req);
/* Tile-range TREL_SAME_REGION implies TREL_SAME_TCLASS */
/* Old behavior: Oceanic tiles can be claimed by adjacent border
* sources. */
effect = effect_new(EFT_TILE_CLAIMABLE, 1, nullptr);
e_req = req_from_values(VUT_TERRAINCLASS, REQ_RANGE_TILE,
FALSE, TRUE, FALSE, TC_OCEAN);
effect_req_append(effect, e_req);
e_req = req_from_values(VUT_MAX_DISTANCE_SQ, REQ_RANGE_TILE,
FALSE, TRUE, FALSE, 2);
effect_req_append(effect, e_req);
/* Old behavior: Oceanic tiles part of an ocean that is no larger than
* MAXIMUM_CLAIMED_OCEAN_SIZE tiles and that is adjacent to only one
* continent (i.e. surrounded by it) can be claimed by land border
* sources on that continent. */
effect = effect_new(EFT_TILE_CLAIMABLE, 1, nullptr);
e_req = req_from_values(VUT_TERRAINCLASS, REQ_RANGE_TILE,
FALSE, TRUE, FALSE, TC_OCEAN);
effect_req_append(effect, e_req);
e_req = req_from_values(VUT_MAX_REGION_TILES, REQ_RANGE_CONTINENT,
FALSE, TRUE, FALSE,
MAXIMUM_CLAIMED_OCEAN_SIZE_3_2);
effect_req_append(effect, e_req);
e_req = req_from_values(VUT_TILE_REL, REQ_RANGE_TILE,
FALSE, TRUE, FALSE, TREL_REGION_SURROUNDED);
effect_req_append(effect, e_req);
/* Tile-range TREL_REGION_SURROUNDED implies negated TREL_SAME_TCLASS */
/* Old behavior: Oceanic tiles adjacent to no more than two other oceanic
* tiles and (individually) adjacent to only a single continent can be
* claimed by land border sources on that continent. */
effect = effect_new(EFT_TILE_CLAIMABLE, 1, nullptr);
e_req = req_from_values(VUT_TERRAINCLASS, REQ_RANGE_TILE,
FALSE, TRUE, FALSE, TC_OCEAN);
effect_req_append(effect, e_req);
e_req = req_from_values(VUT_TILE_REL, REQ_RANGE_TILE,
FALSE, FALSE, FALSE, TREL_SAME_TCLASS);
effect_req_append(effect, e_req);
e_req = req_from_values(VUT_MAX_REGION_TILES, REQ_RANGE_ADJACENT,
FALSE, TRUE, FALSE, 2 + 1);
effect_req_append(effect, e_req);
e_req = req_from_values(VUT_TILE_REL, REQ_RANGE_ADJACENT,
FALSE, TRUE, FALSE, TREL_ONLY_OTHER_REGION);
effect_req_append(effect, e_req);
/* Old behavior: Oceanic tiles can be claimed by any oceanic border
* sources with the Claim_Ocean_Limited techflag. */
effect = effect_new(EFT_TILE_CLAIMABLE, 1, nullptr);
e_req = req_from_values(VUT_TERRAINCLASS, REQ_RANGE_TILE,
FALSE, TRUE, FALSE, TC_OCEAN);
effect_req_append(effect, e_req);
e_req = req_from_values(VUT_TILE_REL, REQ_RANGE_TILE,
FALSE, TRUE, FALSE, TREL_SAME_TCLASS);
effect_req_append(effect, e_req);
e_req = req_from_str("TechFlag", "Player", FALSE, TRUE, FALSE,
"Claim_Ocean_Limited");
effect_req_append(effect, e_req);
/* Old behavior: Oceanic tiles can be claimed by any border sources
* with the Claim_Ocean techflag. */
effect = effect_new(EFT_TILE_CLAIMABLE, 1, nullptr);
e_req = req_from_values(VUT_TERRAINCLASS, REQ_RANGE_TILE,
FALSE, TRUE, FALSE, TC_OCEAN);
effect_req_append(effect, e_req);
e_req = req_from_str("TechFlag", "Player", FALSE, TRUE, FALSE,
"Claim_Ocean");
effect_req_append(effect, e_req);
/* Make sure that all action enablers added or modified by the
* compatibility post processing fulfills all hard action requirements. */
rscompat_enablers_add_obligatory_hard_reqs();
......
return MAX_NUM_USER_UNIT_FLAGS;
}
/**********************************************************************//**
Find and return the first unused tech user flag. If all tech
user flags are taken MAX_NUM_USER_TECH_FLAGS is returned.
**************************************************************************/
static int first_free_tech_user_flag(void)
{
int flag;
/* Find the first unused user defined tech flag. */
for (flag = 0; flag < MAX_NUM_USER_TECH_FLAGS; flag++) {
if (tech_flag_id_name_cb(flag + TECH_USER_1) == nullptr) {
return flag;
}
}
/* All tech user flags are taken. */
return MAX_NUM_USER_TECH_FLAGS;
}
/**********************************************************************//**
Convert 3.2 unit type flag name to 3.3 one.
**************************************************************************/
(5-5/5)