[Freeciv-Dev] (PR#12792) remove terr_gate/spec_gate
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12792 >
This is a preliminary patch to remove terr_gate/spec_gate:
1. The terr_gate/spec_gate values in the improvement struct are removed.
2. A little extra code is added to better support terrain and special
*requirements* for buildings.
3. The ruleset (default only, for now) is changed to use requirements
instead of terr_gate/spec_gate for these dependencies.
Behavior is basically unchanged. In particular, no AI code ever
considered these values so no changes are needed there.
An interesting new function is is_req_unchanging(). This returns TRUE
iff we can assume that if a requirement isn't met now it won't be met in
the future. This is clearly TRUE for nation reqs. I also returned TRUE
for terrain and special reqs here - although this isn't structly true,
it is so in most cases (ocean, river) and changing it would probably
confuse the AI (because can_eventually_build_improvement might return
TRUE prompting a city to try to meet one requirement, when a terrain
requirement is still unmet).
A rather crappy updated piece of code is in
city_landlocked_sell_coastal_improvements. This function is
historically called only when ocean is changed to land. The old
behavior - which is changed only slightly in the updated code - is to
sell buildings that require ocean, if there is no ocean. For any other
requirement that isn't met, it doesn't care. I think this needs to be
changed so that any building whose requirements aren't met is sold at
the end of each turn. However this is a rules question so for now I
left the behavior basically intact.
It's a preliminary patch; I haven't tested it much. Also the other
rulesets need updating.
-jason
Index: client/helpdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/helpdata.c,v
retrieving revision 1.101
diff -u -r1.101 helpdata.c
--- client/helpdata.c 14 Apr 2005 04:49:12 -0000 1.101
+++ client/helpdata.c 14 Apr 2005 06:55:27 -0000
@@ -203,7 +203,7 @@
static void insert_allows(struct req_source *psource,
char *buf, size_t bufsz)
{
- int r1, r2, i;
+ int r1, r2;
buf[0] = '\0';
@@ -234,14 +234,6 @@
}
}
- /* Append other co-reqs. */
- for (i = 0; building->terr_gate[i] != T_NONE; i++) {
- COREQ_APPEND(get_terrain_name(building->terr_gate[i]));
- }
- for (i = 0; building->spec_gate[i] != S_NO_SPECIAL; i++) {
- COREQ_APPEND(get_special_name(building->spec_gate[i]));
- }
-
if (coreq_buf[0] == '\0') {
cat_snprintf(buf, bufsz, _("Allows %s."), building->name);
} else {
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.490
diff -u -r1.490 packhand.c
--- client/packhand.c 14 Apr 2005 04:49:12 -0000 1.490
+++ client/packhand.c 14 Apr 2005 06:55:28 -0000
@@ -2239,34 +2239,12 @@
sz_strlcpy(b->soundtag, p->soundtag);
sz_strlcpy(b->soundtag_alt, p->soundtag_alt);
-#define T(elem,count,last) \
- b->elem = fc_malloc(sizeof(*b->elem) * (p->count + 1)); \
- for (i = 0; i < p->count; i++) { \
- b->elem[i] = p->elem[i]; \
- } \
- b->elem[p->count] = last;
-
- T(terr_gate, terr_gate_count, T_NONE);
- T(spec_gate, spec_gate_count, S_NO_SPECIAL);
-#undef T
-
#ifdef DEBUG
if(p->id == game.num_impr_types-1) {
impr_type_iterate(id) {
- int inx;
b = &improvement_types[id];
freelog(LOG_DEBUG, "Impr: %s...",
b->name);
- freelog(LOG_DEBUG, " terr_gate...");
- for (inx = 0; b->terr_gate[inx] != T_NONE; inx++) {
- freelog(LOG_DEBUG, " %2d/%s",
- b->terr_gate[inx], get_terrain_name(b->terr_gate[inx]));
- }
- freelog(LOG_DEBUG, " spec_gate...");
- for (inx = 0; b->spec_gate[inx] != S_NO_SPECIAL; inx++) {
- freelog(LOG_DEBUG, " %2d/%s",
- b->spec_gate[inx], get_special_name(b->spec_gate[inx]));
- }
if (tech_exists(b->obsolete_by)) {
freelog(LOG_DEBUG, " obsolete_by %2d/%s",
b->obsolete_by,
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.327
diff -u -r1.327 city.c
--- common/city.c 14 Apr 2005 04:49:13 -0000 1.327
+++ common/city.c 14 Apr 2005 06:55:28 -0000
@@ -497,42 +497,6 @@
}
/**************************************************************************
- Returns 1 if the given city is next to or on one of the given building's
- terr_gate (terrain) or spec_gate (specials), or if the building has no
- terrain/special requirements.
-**************************************************************************/
-bool city_has_terr_spec_gate(const struct city *pcity, Impr_Type_id id)
-{
- struct impr_type *impr;
- Terrain_type_id *terr_gate;
- enum tile_special_type *spec_gate;
-
- impr = get_improvement_type(id);
- spec_gate = impr->spec_gate;
- terr_gate = impr->terr_gate;
-
- if (*spec_gate == S_NO_SPECIAL && *terr_gate == T_NONE) {
- return TRUE;
- }
-
- for (;*spec_gate!=S_NO_SPECIAL;spec_gate++) {
- if (tile_has_special(pcity->tile, *spec_gate) ||
- is_special_near_tile(pcity->tile, *spec_gate)) {
- return TRUE;
- }
- }
-
- for (; *terr_gate != T_NONE; terr_gate++) {
- if (pcity->tile->terrain == *terr_gate
- || is_terrain_near_tile(pcity->tile, *terr_gate)) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-/**************************************************************************
Return whether given city can build given building, ignoring whether
it is obsolete.
**************************************************************************/
@@ -549,15 +513,11 @@
return FALSE;
}
- if (!city_has_terr_spec_gate(pcity, id)) {
- return FALSE;
- }
-
for (i = 0; i < MAX_NUM_REQS; i++) {
if (building->req[i].source.type == REQ_NONE) {
break;
}
- if (!is_req_active(city_owner(pcity), pcity, 0, NULL,
+ if (!is_req_active(city_owner(pcity), pcity, 0, pcity->tile,
&building->req[i])) {
return FALSE;
}
@@ -588,13 +548,26 @@
bool can_eventually_build_improvement(const struct city *pcity,
Impr_Type_id id)
{
+ int r;
+ struct impr_type *building;
+
/* Can the _player_ ever build this improvement? */
if (!can_player_eventually_build_improvement(city_owner(pcity), id)) {
return FALSE;
}
- if (!city_has_terr_spec_gate(pcity, id)) {
- return FALSE;
+ /* Check for requirements that aren't met and that are unchanging (so
+ * they can never be met). */
+ building = get_improvement_type(id);
+ for (r = 0; r < MAX_NUM_REQS; r++) {
+ if (building->req[r].source.type == REQ_NONE) {
+ break;
+ }
+ if (is_req_unchanging(&building->req[r])
+ && !is_req_active(city_owner(pcity), pcity, B_LAST, pcity->tile,
+ &building->req[r])) {
+ return FALSE;
+ }
}
return TRUE;
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.204
diff -u -r1.204 city.h
--- common/city.h 10 Apr 2005 21:53:30 -0000 1.204
+++ common/city.h 14 Apr 2005 06:55:28 -0000
@@ -378,7 +378,6 @@
/* city related improvement and unit functions */
-bool city_has_terr_spec_gate(const struct city *pcity, Impr_Type_id id);
int improvement_upkeep(const struct city *pcity, Impr_Type_id i);
bool can_build_improvement_direct(const struct city *pcity, Impr_Type_id id);
bool can_build_improvement(const struct city *pcity, Impr_Type_id id);
Index: common/fc_types.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/fc_types.h,v
retrieving revision 1.18
diff -u -r1.18 fc_types.h
--- common/fc_types.h 11 Apr 2005 22:42:06 -0000 1.18
+++ common/fc_types.h 14 Apr 2005 06:55:28 -0000
@@ -56,8 +56,9 @@
struct tile;
struct unit;
+/* Changing these will break network compatibility. */
#define SP_MAX 20
-#define MAX_NUM_REQS 2
+#define MAX_NUM_REQS 4
#define MAX_NUM_RULESETS 16
#define MAX_RULESET_NAME_LENGTH 64
Index: common/improvement.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/improvement.c,v
retrieving revision 1.54
diff -u -r1.54 improvement.c
--- common/improvement.c 14 Apr 2005 04:49:13 -0000 1.54
+++ common/improvement.c 14 Apr 2005 06:55:28 -0000
@@ -122,12 +122,6 @@
{
struct impr_type *p = get_improvement_type(id);
- free(p->terr_gate);
- p->terr_gate = NULL;
-
- free(p->spec_gate);
- p->spec_gate = NULL;
-
free(p->helptext);
p->helptext = NULL;
}
@@ -379,12 +373,32 @@
bool can_player_eventually_build_improvement(const struct player *p,
Impr_Type_id id)
{
+ int r;
+ struct impr_type *building;
+
if (!improvement_exists(id)) {
return FALSE;
}
if (improvement_obsolete(p, id)) {
return FALSE;
}
+
+ /* Check for requirements that aren't met and that are unchanging (so
+ * they can never be met). */
+ building = get_improvement_type(id);
+ for (r = 0; r < MAX_NUM_REQS; r++) {
+ if (building->req[r].source.type == REQ_NONE) {
+ break;
+ }
+ if (building->req[r].range >= REQ_RANGE_PLAYER
+ && is_req_unchanging(&building->req[r])
+ && !is_req_active(p, NULL, B_LAST, NULL, &building->req[r])) {
+ return FALSE;
+ }
+ }
+ /* FIXME: should check some "unchanging" reqs here - like if there's
+ * a nation requirement, we can go ahead and check it now. */
+
return TRUE;
}
Index: common/improvement.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/improvement.h,v
retrieving revision 1.43
diff -u -r1.43 improvement.h
--- common/improvement.h 14 Apr 2005 04:49:13 -0000 1.43
+++ common/improvement.h 14 Apr 2005 06:55:28 -0000
@@ -72,8 +72,6 @@
char graphic_str[MAX_LEN_NAME]; /* city icon of improv. */
char graphic_alt[MAX_LEN_NAME]; /* city icon of improv. */
struct requirement req[MAX_NUM_REQS];
- Terrain_type_id *terr_gate; /* list; T_NONE terminated */
- enum tile_special_type *spec_gate; /* list; S_NO_SPECIAL terminated */
Tech_Type_id obsolete_by; /* A_LAST = never obsolete */
Impr_Type_id replaced_by; /* B_LAST = never replaced */
int build_cost; /* Use wrappers to access this. */
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.105
diff -u -r1.105 packets.def
--- common/packets.def 14 Apr 2005 04:49:13 -0000 1.105
+++ common/packets.def 14 Apr 2005 06:55:29 -0000
@@ -1159,10 +1159,6 @@
STRING soundtag[MAX_LEN_NAME];
STRING soundtag_alt[MAX_LEN_NAME];
STRING helptext[MAX_LEN_PACKET];
- UINT8 terr_gate_count;
- TERRAIN terr_gate[255:terr_gate_count];
- UINT8 spec_gate_count;
- SPECIAL spec_gate[255:spec_gate_count];
end
PACKET_RULESET_TERRAIN=105;sc,lsend
Index: common/requirements.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/requirements.c,v
retrieving revision 1.12
diff -u -r1.12 requirements.c
--- common/requirements.c 14 Apr 2005 04:49:13 -0000 1.12
+++ common/requirements.c 14 Apr 2005 06:55:29 -0000
@@ -438,11 +438,11 @@
the number of available sources. However not all source caches exist: if
the cache doesn't exist then we return 0.
****************************************************************************/
-int count_buildings_in_range(const struct player *target_player,
- const struct city *target_city,
- Impr_Type_id target_building,
- enum req_range range, bool survives,
- Impr_Type_id source)
+static int count_buildings_in_range(const struct player *target_player,
+ const struct city *target_city,
+ Impr_Type_id target_building,
+ enum req_range range, bool survives,
+ Impr_Type_id source)
{
if (improvement_obsolete(target_player, source)) {
return 0;
@@ -525,16 +525,11 @@
enum tile_special_type special)
{
- /* The requirement is filled if the tile has the special. */
- if (!target_tile) {
- return FALSE;
- }
-
switch (range) {
case REQ_RANGE_LOCAL:
- return tile_has_special(target_tile, special);
+ return target_tile && tile_has_special(target_tile, special);
case REQ_RANGE_ADJACENT:
- return is_special_near_tile(target_tile, special);
+ return target_tile && is_special_near_tile(target_tile, special);
case REQ_RANGE_CITY:
case REQ_RANGE_CONTINENT:
case REQ_RANGE_PLAYER:
@@ -700,6 +695,39 @@
return TRUE;
}
+/****************************************************************************
+ Return TRUE if this is an "unchanging" requirement. This means that
+ if a target can't meet the requirement now, it probably won't ever be able
+ to do so later. This can be used to do requirement filtering when checking
+ if a target may "eventually" become available.
+
+ Note this isn't absolute. Returning TRUE here just means that the
+ requirement probably can't be met. In some cases (particularly terrains)
+ it may be wrong.
+*****************************************************************************/
+bool is_req_unchanging(const struct requirement *req)
+{
+ switch (req->source.type) {
+ case REQ_NATION:
+ case REQ_NONE:
+ return TRUE;
+ case REQ_TECH:
+ case REQ_GOV:
+ case REQ_BUILDING:
+ return FALSE;
+ case REQ_SPECIAL:
+ case REQ_TERRAIN:
+ /* Terrains and specials aren't really unchanging; in fact they're
+ * practically guaranteed to change. We return TRUE here for historical
+ * reasons and so that the AI doesn't get confused (since the AI
+ * doesn't know how to meet special and terrain requirements). */
+ return FALSE;
+ case REQ_LAST:
+ break;
+ }
+ assert(0);
+ return TRUE;
+}
/****************************************************************************
Return TRUE iff the two sources are equivalent. Note this isn't the
Index: common/requirements.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/requirements.h,v
retrieving revision 1.9
diff -u -r1.9 requirements.h
--- common/requirements.h 14 Apr 2005 04:49:14 -0000 1.9
+++ common/requirements.h 14 Apr 2005 06:55:29 -0000
@@ -105,11 +105,7 @@
const struct tile *target_tile,
const struct requirement *reqs, int num_reqs);
-int count_buildings_in_range(const struct player *target_player,
- const struct city *target_city,
- Impr_Type_id target_building,
- enum req_range range, bool survives,
- Impr_Type_id source);
+bool is_req_unchanging(const struct requirement *req);
/* Req-source helper functions. */
bool are_req_sources_equal(const struct req_source *psource1,
Index: data/default/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/buildings.ruleset,v
retrieving revision 1.69
diff -u -r1.69 buildings.ruleset
--- data/default/buildings.ruleset 14 Apr 2005 04:49:15 -0000 1.69
+++ data/default/buildings.ruleset 14 Apr 2005 06:55:29 -0000
@@ -32,16 +32,6 @@
; and README.effects for help on requirements)
; graphic = icon of improvement (used in city dialog)
; graphic_alt = alternate icon of improvement
-; terr_gate = list of terrain types, one of which on or adjacent
-; to city allows city to build improvement; empty
-; list means always allowed to build if nothing in spec_gate
-; is given (that means only if both terr_gate and spec_gate
-; are empty the building can be bulit everywhere)
-; spec_gate = list of special types, one of which on or adjacent
-; to city allows city to build improvement; empty
-; list means always allowed to build if nothing in terr_gate
-; is given (that means only if both terr_gate and spec_gate
-; are empty the building can be built everywhere)
; obsolete_by = advance which makes building obsolete; special
; value "None" means does not become obsolete
; build_cost = production shields required to build
@@ -59,8 +49,6 @@
}
graphic = "b.airport"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 120
upkeep = 3
@@ -87,8 +75,6 @@
}
graphic = "b.aqueduct"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 60
upkeep = 2
@@ -110,8 +96,6 @@
}
graphic = "b.bank"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 80
upkeep = 2
@@ -133,8 +117,6 @@
}
graphic = "b.barracks"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "Gunpowder"
replaced_by = "Barracks II"
build_cost = 30
@@ -159,8 +141,6 @@
}
graphic = "b.barracks"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "Mobile Warfare"
replaced_by = "Barracks III"
build_cost = 30
@@ -185,8 +165,6 @@
}
graphic = "b.barracks"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 30
upkeep = 1
@@ -211,8 +189,6 @@
}
graphic = "b.cathedral"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 80
upkeep = 3
@@ -237,8 +213,6 @@
}
graphic = "b.city_walls"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 60
upkeep = 0
@@ -259,11 +233,10 @@
reqs =
{ "type", "name", "range"
"Tech", "Metallurgy", "Player"
+ "Terrain", "Ocean", "Adjacent"
}
graphic = "b.coastal_defense"
graphic_alt = "-"
-terr_gate = "Ocean"
-;spec_gate =
obsolete_by = "None"
build_cost = 60
upkeep = 1
@@ -284,8 +257,6 @@
}
graphic = "b.colosseum"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 70
upkeep = 4
@@ -308,8 +279,6 @@
}
graphic = "b.courthouse"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 60
upkeep = 1
@@ -332,8 +301,6 @@
}
graphic = "b.factory"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 140
upkeep = 4
@@ -354,8 +321,6 @@
}
graphic = "b.granary"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 40
upkeep = 1
@@ -377,11 +342,10 @@
reqs =
{ "type", "name", "range"
"Tech", "Seafaring", "Player"
+ "Terrain", "Ocean", "Adjacent"
}
graphic = "b.harbour"
graphic_alt = "-"
-terr_gate = "Ocean"
-;spec_gate =
obsolete_by = "None"
build_cost = 40
upkeep = 1
@@ -400,11 +364,11 @@
{ "type", "name", "range"
"Tech", "Electronics", "Player"
"Building", "Factory", "City"
+ "Terrain", "Mountains", "Adjacent"
+ "Special", "River", "Adjacent"
}
graphic = "b.hydro_plant"
graphic_alt = "-"
-terr_gate = "Mountains"
-spec_gate = "River"
obsolete_by = "None"
build_cost = 180
upkeep = 4
@@ -438,8 +402,6 @@
}
graphic = "b.library"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 60
upkeep = 1
@@ -460,8 +422,6 @@
}
graphic = "b.marketplace"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 60
upkeep = 0
@@ -482,8 +442,6 @@
}
graphic = "b.mass_transit"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 120
upkeep = 4
@@ -506,8 +464,6 @@
}
graphic = "b.mfg_plant"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 220
upkeep = 6
@@ -530,8 +486,6 @@
}
graphic = "b.nuclear_plant"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 120
upkeep = 2
@@ -563,11 +517,10 @@
reqs =
{ "type", "name", "range"
"Tech", "Miniaturization", "Player"
+ "Terrain", "Ocean", "Adjacent"
}
graphic = "b.offshore_platform"
graphic_alt = "-"
-terr_gate = "Ocean"
-;spec_gate =
obsolete_by = "None"
build_cost = 120
upkeep = 3
@@ -588,8 +541,6 @@
}
graphic = "b.palace"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 70
upkeep = 0
@@ -618,8 +569,6 @@
}
graphic = "b.police_station"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 50
upkeep = 2
@@ -641,11 +590,10 @@
reqs =
{ "type", "name", "range"
"Tech", "Amphibious Warfare", "Player"
+ "Terrain", "Ocean", "Adjacent"
}
graphic = "b.port_facility"
graphic_alt = "-"
-terr_gate = "Ocean"
-;spec_gate =
obsolete_by = "None"
build_cost = 60
upkeep = 3
@@ -668,8 +616,6 @@
}
graphic = "b.power_plant"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 130
upkeep = 4
@@ -700,8 +646,6 @@
}
graphic = "b.recycling_center"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 140
upkeep = 2
@@ -724,8 +668,6 @@
}
graphic = "b.research_lab"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 120
upkeep = 3
@@ -748,8 +690,6 @@
}
graphic = "b.sam_battery"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 70
upkeep = 2
@@ -770,8 +710,6 @@
}
graphic = "b.sdi_defense"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 140
upkeep = 4
@@ -796,8 +734,6 @@
}
graphic = "b.sewer_system"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 80
upkeep = 2
@@ -819,8 +755,6 @@
}
graphic = "b.space_component"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 160
upkeep = 0
@@ -846,8 +780,6 @@
}
graphic = "b.space_modules"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 320
upkeep = 0
@@ -882,8 +814,6 @@
}
graphic = "b.space_structural"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 80
upkeep = 0
@@ -909,8 +839,6 @@
}
graphic = "b.stock_exchange"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 120
upkeep = 3
@@ -932,8 +860,6 @@
}
graphic = "b.super_highways"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 120
upkeep = 3
@@ -957,8 +883,6 @@
}
graphic = "b.supermarket"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 80
upkeep = 3
@@ -981,8 +905,6 @@
}
graphic = "b.temple"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 30
upkeep = 1
@@ -1005,8 +927,6 @@
}
graphic = "b.university"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 120
upkeep = 3
@@ -1028,8 +948,6 @@
}
graphic = "b.apollo_program"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 600
upkeep = 0
@@ -1051,8 +969,6 @@
}
graphic = "b.asmiths_trading_co"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 400
upkeep = 0
@@ -1073,8 +989,6 @@
}
graphic = "b.colossus"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "Flight"
build_cost = 100
upkeep = 0
@@ -1095,8 +1009,6 @@
}
graphic = "b.copernicus_observatory"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 200
upkeep = 0
@@ -1117,8 +1029,6 @@
}
graphic = "b.cure_for_cancer"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 600
upkeep = 0
@@ -1141,8 +1051,6 @@
}
graphic = "b.darwins_voyage"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 300
upkeep = 0
@@ -1164,8 +1072,6 @@
}
graphic = "b.eiffel_tower"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 100
upkeep = 0
@@ -1188,8 +1094,6 @@
}
graphic = "b.great_library"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "Electricity"
build_cost = 300
upkeep = 0
@@ -1210,8 +1114,6 @@
}
graphic = "b.great_wall"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "Metallurgy"
build_cost = 300
upkeep = 0
@@ -1234,8 +1136,6 @@
}
graphic = "b.hanging_gardens"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "Railroad"
build_cost = 200
upkeep = 0
@@ -1259,8 +1159,6 @@
}
graphic = "b.hoover_dam"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 600
upkeep = 0
@@ -1281,8 +1179,6 @@
}
graphic = "b.isaac_newtons_college"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 300
upkeep = 0
@@ -1304,8 +1200,6 @@
}
graphic = "b.js_bachs_cathedral"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 400
upkeep = 0
@@ -1325,8 +1219,6 @@
}
graphic = "b.king_richards_crusade"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "Robotics"
build_cost = 150
upkeep = 0
@@ -1347,8 +1239,6 @@
}
graphic = "b.leonardos_workshop"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "Automobile"
build_cost = 400
upkeep = 0
@@ -1368,8 +1258,6 @@
}
graphic = "b.lighthouse"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "Magnetism"
build_cost = 200
upkeep = 0
@@ -1391,8 +1279,6 @@
}
graphic = "b.magellans_expedition"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 400
upkeep = 0
@@ -1412,8 +1298,6 @@
}
graphic = "b.manhattan_project"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 600
upkeep = 0
@@ -1432,8 +1316,6 @@
}
graphic = "b.marco_polos_embassy"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "Communism"
build_cost = 200
upkeep = 0
@@ -1453,8 +1335,6 @@
}
graphic = "b.michelangelos_chapel"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 400
upkeep = 0
@@ -1479,8 +1359,6 @@
}
graphic = "b.oracle"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "Theology"
build_cost = 100
upkeep = 0
@@ -1500,8 +1378,6 @@
}
graphic = "b.pyramids"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 200
upkeep = 0
@@ -1523,8 +1399,6 @@
}
graphic = "b.seti_program"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 600
upkeep = 0
@@ -1544,8 +1418,6 @@
}
graphic = "b.shakespeares_theatre"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 200
upkeep = 0
@@ -1565,8 +1437,6 @@
}
graphic = "b.statue_of_liberty"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 400
upkeep = 0
@@ -1588,8 +1458,6 @@
}
graphic = "b.sun_tzus_war_academy"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "Mobile Warfare"
build_cost = 300
upkeep = 0
@@ -1611,8 +1479,6 @@
}
graphic = "b.united_nations"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 600
upkeep = 0
@@ -1640,8 +1506,6 @@
}
graphic = "b.womens_suffrage"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 600
upkeep = 0
@@ -1667,8 +1531,6 @@
}
graphic = "b.capitalization"
graphic_alt = "-"
-;terr_gate =
-;spec_gate =
obsolete_by = "None"
build_cost = 999
upkeep = 0
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.311
diff -u -r1.311 citytools.c
--- server/citytools.c 13 Apr 2005 18:41:11 -0000 1.311
+++ server/citytools.c 14 Apr 2005 06:55:30 -0000
@@ -2034,14 +2034,14 @@
}
/**************************************************************************
- For each city adjacent to (x,y), check if landlocked. If so, sell all
- improvements in the city that depend upon being next to an ocean tile.
- (Should be called after any ocean to land terrain changes.
- Assumes no city at (x,y).)
-
- N.B. Now uses info from buildings.ruleset to decide which buildings
- to sell. In theory this could (should?) be generalised to sell
- relevant buildings after any change of terrain/special type
+ For each city adjacent to ptile, check all the buildings in the city.
+ Any which have unmet terrain requirements will be sold. This is called
+ after any terrain changes (but this may be tied to the default ruleset).
+
+ FIXME: This function isn't very general. It would be better to check
+ each turn to make sure all requirements of all buildings of all cities
+ are met, and sell any buildings that can't be supported. Terrains aren't
+ the only requirement that may disappear.
**************************************************************************/
void city_landlocked_sell_coastal_improvements(struct tile *ptile)
{
@@ -2053,26 +2053,26 @@
/* Sell all buildings (but not Wonders) that must be next to the ocean */
built_impr_iterate(pcity, impr) {
- int i = 0;
+ int r;
if (!can_city_sell_building(pcity, impr)) {
continue;
}
- while (!is_ocean(improvement_types[impr].terr_gate[i])
- && improvement_types[impr].terr_gate[i] != T_NONE) {
- i++;
- }
+ for (r = 0; r < MAX_NUM_REQS; r++) {
+ struct requirement *req = &get_improvement_type(impr)->req[r];
- if (is_ocean(improvement_types[impr].terr_gate[i])
- && !city_has_terr_spec_gate(pcity, impr)) {
+ if (req->source.type == REQ_TERRAIN
+ && !is_req_active(city_owner(pcity), pcity, B_LAST, NULL,
+ req)) {
do_sell_building(pplayer, pcity, impr);
notify_player_ex(pplayer, tile1, E_IMP_SOLD,
_("You sell %s in %s (now landlocked)"
" for %d gold."),
get_improvement_name(impr), pcity->name,
impr_sell_gold(impr));
- }
+ }
+ }
} built_impr_iterate_end;
}
} adjc_iterate_end;
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.243
diff -u -r1.243 ruleset.c
--- server/ruleset.c 14 Apr 2005 04:49:15 -0000 1.243
+++ server/ruleset.c 14 Apr 2005 06:55:30 -0000
@@ -1247,8 +1247,8 @@
**************************************************************************/
static void load_ruleset_buildings(struct section_file *file)
{
- char **sec, *item, **list;
- int i, j, k, nval, count;
+ char **sec, *item;
+ int i, j, nval;
struct impr_type *b;
const char *filename = secfile_filename(file);
@@ -1279,38 +1279,6 @@
}
}
- list = secfile_lookup_str_vec(file, &count, "%s.terr_gate", sec[i]);
- b->terr_gate = fc_malloc((count + 1) * sizeof(b->terr_gate[0]));
- k = 0;
- for (j = 0; j < count; j++) {
- b->terr_gate[k] = get_terrain_by_name(list[j]);
- if (b->terr_gate[k] == T_UNKNOWN) {
- freelog(LOG_ERROR,
- "for %s terr_gate[%d] couldn't match terrain \"%s\" (%s)",
- b->name, j, list[j], filename);
- } else {
- k++;
- }
- }
- b->terr_gate[k] = T_NONE;
- free(list);
-
- list = secfile_lookup_str_vec(file, &count, "%s.spec_gate", sec[i]);
- b->spec_gate = fc_malloc((count + 1) * sizeof(b->spec_gate[0]));
- k = 0;
- for (j = 0; j < count; j++) {
- b->spec_gate[k] = get_special_by_name(list[j]);
- if (b->spec_gate[k] == S_NO_SPECIAL) {
- freelog(LOG_ERROR,
- "for %s spec_gate[%d] couldn't match special \"%s\" (%s)",
- b->name, j, list[j], filename);
- } else {
- k++;
- }
- }
- b->spec_gate[k] = S_NO_SPECIAL;
- free(list);
-
b->obsolete_by = lookup_tech(file, sec[i], "obsolete_by",
FALSE, filename, b->name);
if (b->obsolete_by == A_NONE || !tech_exists(b->obsolete_by)) {
@@ -2804,15 +2772,6 @@
packet.helptext[0] = '\0';
}
-#define T(elem,count,last) \
- for (packet.count = 0; b->elem[packet.count] != last; packet.count++) { \
- packet.elem[packet.count] = b->elem[packet.count]; \
- }
-
- T(terr_gate, terr_gate_count, T_NONE);
- T(spec_gate, spec_gate_count, S_NO_SPECIAL);
-#undef T
-
lsend_packet_ruleset_building(dest, &packet);
} impr_type_iterate_end;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12792) remove terr_gate/spec_gate,
Jason Short <=
|
|