Re: [Freeciv-Dev] (PR#40633) [Patch] Border radius property for bases
http://bugs.freeciv.org/Ticket/Display.html?id=40633 > 2009/1/7 Marko Lindqvist: > Attached patch replaces ClaimTerritory flag with border radius > property for each base. In the process civ1 & civ2 rulesets are fixed > so that their fortress has no territory claiming properties. Updated against svn. - ML diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c --- freeciv/client/packhand.c 2009-01-10 00:33:19.0 +0200 +++ freeciv/client/packhand.c 2009-01-11 18:55:11.0 +0200 @@ -2911,6 +2911,7 @@ pbase->gui_type = p->gui_type; pbase->build_time = p->build_time; + pbase->border_sq = p->border_sq; pbase->flags = p->flags; diff -Nurd -X.diff_ignore freeciv/common/base.c freeciv/common/base.c --- freeciv/common/base.c 2009-01-07 22:34:01.0 +0200 +++ freeciv/common/base.c 2009-01-11 18:55:11.0 +0200 @@ -32,7 +32,7 @@ static const char *base_type_flag_names[] = { "NoAggressive", "DefenseBonus", "NoStackDeath", - "ClaimTerritory", "DiplomatDefense", "ParadropFrom" + "DiplomatDefense", "ParadropFrom" }; /* This must correspond to enum base_gui_type in base.h */ @@ -302,3 +302,11 @@ return !BV_ISSET(base1->conflicts, base_index(base2)); } + +/** + Does this base type claim territory? +**/ +bool territory_claiming_base(const struct base_type *pbase) +{ + return pbase->border_sq >= 0; +} diff -Nurd -X.diff_ignore freeciv/common/base.h freeciv/common/base.h --- freeciv/common/base.h 2009-01-07 22:34:01.0 +0200 +++ freeciv/common/base.h 2009-01-11 18:55:11.0 +0200 @@ -29,7 +29,6 @@ * if base is close to city */ BF_DEFENSE_BONUS, /* Base provides defense bonus for units inside */ BF_NO_STACK_DEATH, /* Units inside will not die all at once */ - BF_CLAIM_TERRITORY,/* Base claims tile ownership */ BF_DIPLOMAT_DEFENSE, /* Base provides bonus for defending diplomat */ BF_PARADROP_FROM, /* Paratroopers can use base for paradrop */ BF_LAST/* This has to be last */ @@ -47,6 +46,7 @@ struct requirement_vector reqs; enum base_gui_type gui_type; int build_time; + int border_sq; bv_unit_classes native_to; bv_base_flags flags; @@ -91,6 +91,8 @@ bool can_bases_coexist(const struct base_type *base1, const struct base_type *base2); +bool territory_claiming_base(const struct base_type *pbase); + /* Initialization and iteration */ void base_types_init(void); void base_types_free(void); diff -Nurd -X.diff_ignore freeciv/common/borders.c freeciv/common/borders.c --- freeciv/common/borders.c2009-01-11 18:41:54.0 +0200 +++ freeciv/common/borders.c2009-01-11 18:55:11.0 +0200 @@ -47,8 +47,8 @@ radius_sq += pcity->size * game.info.border_size_effect; } else { base_type_iterate(pbase) { - if (tile_has_base(ptile, pbase) && base_has_flag(pbase, BF_CLAIM_TERRITORY)) { -radius_sq = 5; + if (tile_has_base(ptile, pbase) && territory_claiming_base(pbase)) { +radius_sq = pbase->border_sq; break; } } base_type_iterate_end; @@ -68,7 +68,7 @@ if (tile_owner(ptile) != NULL) { base_type_iterate(pbase) { - if (tile_has_base(ptile, pbase) && base_has_flag(pbase, BF_CLAIM_TERRITORY)) { + if (tile_has_base(ptile, pbase) && territory_claiming_base(pbase)) { return TRUE; } } base_type_iterate_end; diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def --- freeciv/common/packets.def 2009-01-11 18:41:54.0 +0200 +++ freeciv/common/packets.def 2009-01-11 18:55:11.0 +0200 @@ -1318,6 +1318,7 @@ BASE_GUI gui_type; BV_UNIT_CLASSES native_to; UINT8 build_time; + UINT8 border_sq; BV_BASE_FLAGS flags; end diff -Nurd -X.diff_ignore freeciv/common/tile.c freeciv/common/tile.c --- freeciv/common/tile.c 2009-01-09 20:41:54.0 +0200 +++ freeciv/common/tile.c 2009-01-11 18:55:11.0 +0200 @@ -231,6 +231,23 @@ } / + Check if tile contains base providing effect for unit +/ +bool tile_has_claimable_base(const struct tile *ptile, + const struct unit_type *punittype) +{ + base_type_iterate(pbase) { +if (tile_has_base(ptile, pbase) +&& territory_claiming_base(pbase) +&& is_native_base_to_uclass(pbase, utype_class(punittype))) { + return TRUE; +} + } base_type_iterate_end; + + return FALSE; +} + +/ Check if tile contains base native for unit **
Re: [Freeciv-Dev] (PR#40633) [Patch] Border radius property for bases
http://bugs.freeciv.org/Ticket/Display.html?id=40633 > 2009/1/7 Marko Lindqvist: > > Currently bases have only "ClaimTerritory" flag indicating if they > should claim territory or not. Hardcoded border radius of 5 is used > for all bases that do. > > Attached patch replaces ClaimTerritory flag with border radius > property for each base. In the process civ1 & civ2 rulesets are fixed > so that their fortress has no territory claiming properties. > > Applies on top of #40631 - Use value -1 instead of 0 to disable. This allows bases that claim only the tile they are on. - ML diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c --- freeciv/client/packhand.c 2009-01-07 18:17:49.0 +0200 +++ freeciv/client/packhand.c 2009-01-07 18:17:38.0 +0200 @@ -2909,6 +2909,7 @@ pbase->gui_type = p->gui_type; pbase->build_time = p->build_time; + pbase->border_sq = p->border_sq; pbase->flags = p->flags; diff -Nurd -X.diff_ignore freeciv/common/base.c freeciv/common/base.c --- freeciv/common/base.c 2009-01-07 17:59:59.0 +0200 +++ freeciv/common/base.c 2009-01-07 18:20:41.0 +0200 @@ -32,7 +32,7 @@ static const char *base_type_flag_names[] = { "NoAggressive", "DefenseBonus", "NoStackDeath", - "ClaimTerritory", "DiplomatDefense", "ParadropFrom" + "DiplomatDefense", "ParadropFrom" }; /* This must correspond to enum base_gui_type in base.h */ @@ -302,3 +302,11 @@ return !BV_ISSET(base1->conflicts, base_index(base2)); } + +/** + Does this base type claim territory? +**/ +bool territory_claiming_base(const struct base_type *pbase) +{ + return pbase->border_sq >= 0; +} diff -Nurd -X.diff_ignore freeciv/common/base.h freeciv/common/base.h --- freeciv/common/base.h 2009-01-07 17:59:59.0 +0200 +++ freeciv/common/base.h 2009-01-07 18:17:38.0 +0200 @@ -29,7 +29,6 @@ * if base is close to city */ BF_DEFENSE_BONUS, /* Base provides defense bonus for units inside */ BF_NO_STACK_DEATH, /* Units inside will not die all at once */ - BF_CLAIM_TERRITORY,/* Base claims tile ownership */ BF_DIPLOMAT_DEFENSE, /* Base provides bonus for defending diplomat */ BF_PARADROP_FROM, /* Paratroopers can use base for paradrop */ BF_LAST/* This has to be last */ @@ -47,6 +46,7 @@ struct requirement_vector reqs; enum base_gui_type gui_type; int build_time; + int border_sq; bv_unit_classes native_to; bv_base_flags flags; @@ -91,6 +91,8 @@ bool can_bases_coexist(const struct base_type *base1, const struct base_type *base2); +bool territory_claiming_base(const struct base_type *pbase); + /* Initialization and iteration */ void base_types_init(void); void base_types_free(void); diff -Nurd -X.diff_ignore freeciv/common/borders.c freeciv/common/borders.c --- freeciv/common/borders.c2009-01-07 18:17:54.0 +0200 +++ freeciv/common/borders.c2009-01-07 18:17:38.0 +0200 @@ -47,8 +47,8 @@ radius_sq += pcity->size * game.info.border_size_effect; } else { base_type_iterate(pbase) { - if (tile_has_base(ptile, pbase) && base_has_flag(pbase, BF_CLAIM_TERRITORY)) { -radius_sq = 5; + if (tile_has_base(ptile, pbase) && territory_claiming_base(pbase)) { +radius_sq = pbase->border_sq; break; } } base_type_iterate_end; @@ -68,7 +68,7 @@ if (tile_owner(ptile) != NULL) { base_type_iterate(pbase) { - if (tile_has_base(ptile, pbase) && base_has_flag(pbase, BF_CLAIM_TERRITORY)) { + if (tile_has_base(ptile, pbase) && territory_claiming_base(pbase)) { return TRUE; } } base_type_iterate_end; diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def --- freeciv/common/packets.def 2009-01-07 18:17:54.0 +0200 +++ freeciv/common/packets.def 2009-01-07 18:17:38.0 +0200 @@ -1318,6 +1318,7 @@ BASE_GUI gui_type; BV_UNIT_CLASSES native_to; UINT8 build_time; + UINT8 border_sq; BV_BASE_FLAGS flags; end diff -Nurd -X.diff_ignore freeciv/common/tile.c freeciv/common/tile.c --- freeciv/common/tile.c 2009-01-07 18:17:49.0 +0200 +++ freeciv/common/tile.c 2009-01-07 18:17:38.0 +0200 @@ -230,6 +230,23 @@ } / + Check if tile contains base providing effect for unit +/ +bool tile_has_claimable_base(const struct tile *ptile, + const struct unit_type *punittype) +{ + base_type_iterate(pbase) { +if (tile_has_base(ptile, pbase) +&& territory_claiming_base(pbase) +&& is_native_base_to_uclass(pbase, utype_class(punittype
[Freeciv-Dev] (PR#40633) [Patch] Border radius property for bases
http://bugs.freeciv.org/Ticket/Display.html?id=40633 > Currently bases have only "ClaimTerritory" flag indicating if they should claim territory or not. Hardcoded border radius of 5 is used for all bases that do. Attached patch replaces ClaimTerritory flag with border radius property for each base. In the process civ1 & civ2 rulesets are fixed so that their fortress has no territory claiming properties. Applies on top of #40631 - ML diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c --- freeciv/client/packhand.c 2009-01-07 15:45:57.0 +0200 +++ freeciv/client/packhand.c 2009-01-07 15:54:17.0 +0200 @@ -2909,6 +2909,7 @@ pbase->gui_type = p->gui_type; pbase->build_time = p->build_time; + pbase->border_sq = p->border_sq; pbase->flags = p->flags; diff -Nurd -X.diff_ignore freeciv/common/base.c freeciv/common/base.c --- freeciv/common/base.c 2008-10-27 04:13:30.0 +0200 +++ freeciv/common/base.c 2009-01-07 16:03:16.0 +0200 @@ -32,7 +32,7 @@ static const char *base_type_flag_names[] = { "NoAggressive", "DefenseBonus", "NoStackDeath", - "ClaimTerritory", "DiplomatDefense", "ParadropFrom" + "DiplomatDefense", "ParadropFrom" }; /* This must correspond to enum base_gui_type in base.h */ @@ -302,3 +302,11 @@ return !BV_ISSET(base1->conflicts, base_index(base2)); } + +/** + Does this base type claim territory? +**/ +bool territory_claiming_base(const struct base_type *pbase) +{ + return pbase->border_sq > 0; +} diff -Nurd -X.diff_ignore freeciv/common/base.h freeciv/common/base.h --- freeciv/common/base.h 2008-10-27 04:13:30.0 +0200 +++ freeciv/common/base.h 2009-01-07 16:03:31.0 +0200 @@ -29,7 +29,6 @@ * if base is close to city */ BF_DEFENSE_BONUS, /* Base provides defense bonus for units inside */ BF_NO_STACK_DEATH, /* Units inside will not die all at once */ - BF_CLAIM_TERRITORY,/* Base claims tile ownership */ BF_DIPLOMAT_DEFENSE, /* Base provides bonus for defending diplomat */ BF_PARADROP_FROM, /* Paratroopers can use base for paradrop */ BF_LAST/* This has to be last */ @@ -47,6 +46,7 @@ struct requirement_vector reqs; enum base_gui_type gui_type; int build_time; + int border_sq; bv_unit_classes native_to; bv_base_flags flags; @@ -91,6 +91,8 @@ bool can_bases_coexist(const struct base_type *base1, const struct base_type *base2); +bool territory_claiming_base(const struct base_type *pbase); + /* Initialization and iteration */ void base_types_init(void); void base_types_free(void); diff -Nurd -X.diff_ignore freeciv/common/borders.c freeciv/common/borders.c --- freeciv/common/borders.c2009-01-07 15:59:31.0 +0200 +++ freeciv/common/borders.c2009-01-07 16:04:50.0 +0200 @@ -47,8 +47,8 @@ radius_sq += pcity->size * game.info.border_size_effect; } else { base_type_iterate(pbase) { - if (tile_has_base(ptile, pbase) && base_has_flag(pbase, BF_CLAIM_TERRITORY)) { -radius_sq = 5; + if (tile_has_base(ptile, pbase) && territory_claiming_base(pbase)) { +radius_sq = pbase->border_sq; break; } } base_type_iterate_end; @@ -68,7 +68,7 @@ if (tile_owner(ptile) != NULL) { base_type_iterate(pbase) { - if (tile_has_base(ptile, pbase) && base_has_flag(pbase, BF_CLAIM_TERRITORY)) { + if (tile_has_base(ptile, pbase) && territory_claiming_base(pbase)) { return TRUE; } } base_type_iterate_end; diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def --- freeciv/common/packets.def 2009-01-07 15:59:31.0 +0200 +++ freeciv/common/packets.def 2009-01-07 15:53:54.0 +0200 @@ -1318,6 +1318,7 @@ BASE_GUI gui_type; BV_UNIT_CLASSES native_to; UINT8 build_time; + UINT8 border_sq; BV_BASE_FLAGS flags; end diff -Nurd -X.diff_ignore freeciv/common/tile.c freeciv/common/tile.c --- freeciv/common/tile.c 2009-01-07 15:45:57.0 +0200 +++ freeciv/common/tile.c 2009-01-07 16:09:56.0 +0200 @@ -230,6 +230,23 @@ } / + Check if tile contains base providing effect for unit +/ +bool tile_has_claimable_base(const struct tile *ptile, + const struct unit_type *punittype) +{ + base_type_iterate(pbase) { +if (tile_has_base(ptile, pbase) +&& territory_claiming_base(pbase) +&& is_native_base_to_uclass(pbase, utype_class(punittype))) { + return TRUE; +} + } base_type_iterate_end; + + return FALSE; +} + +/