[Freeciv-Dev] (PR#11208) get_tile_xxx_base
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=11208 >
This patch uses get_tile_xxx_base within base_get_xxx_tile. Nice names,
eh? Well for instance the code in get_tile_food_base is:
if (tile_has_special(ptile, S_SPECIAL_1))
return tile_types[ptile->terrain].special[0].food;
else if (tile_has_special(ptile, S_SPECIAL_2))
return tile_types[ptile->terrain].special[1].food;
else
return tile_types[ptile->terrain].food;
and in base_get_food_tile we have:
if (contains_special(tile.special, S_SPECIAL_1)) {
f = type->special[0].food;
} else if (contains_special(tile.special, S_SPECIAL_2)) {
f = type->special[1].food;
} else {
f = type->food;
}
so it's pretty easy to see that the two are the same. (Food is actually
more complicated than shields or trade because of auto-irrigation.
ptile->special is not necessarily the same as tile.special. However for
S_SPECIAL_1 and S_SPECIAL_2 this makes no difference.)
-jason
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.258
diff -u -r1.258 city.c
--- common/city.c 26 Nov 2004 09:49:11 -0000 1.258
+++ common/city.c 26 Nov 2004 10:01:26 -0000
@@ -582,15 +582,7 @@
{
enum tile_special_type spec_t = map_get_special(ptile);
Terrain_type_id tile_t = ptile->terrain;
- int s;
-
- if (contains_special(spec_t, S_SPECIAL_1)) {
- s = get_tile_type(tile_t)->special[0].shield;
- } else if (contains_special(spec_t, S_SPECIAL_2)) {
- s = get_tile_type(tile_t)->special[1].shield;
- } else {
- s = get_tile_type(tile_t)->shield;
- }
+ int s = get_tile_shield_base(ptile);
if (contains_special(spec_t, S_MINE)) {
s += get_tile_type(tile_t)->mining_shield_incr;
@@ -687,15 +679,7 @@
{
enum tile_special_type spec_t = map_get_special(ptile);
Terrain_type_id tile_t = ptile->terrain;
- int t;
-
- if (contains_special(spec_t, S_SPECIAL_1)) {
- t = get_tile_type(tile_t)->special[0].trade;
- } else if (contains_special(spec_t, S_SPECIAL_2)) {
- t = get_tile_type(tile_t)->special[1].trade;
- } else {
- t = get_tile_type(tile_t)->trade;
- }
+ int t = get_tile_trade_base(ptile);
if (contains_special(spec_t, S_RIVER) && !is_ocean(tile_t)) {
t += terrain_control.river_trade_incr;
@@ -798,7 +782,7 @@
const Terrain_type_id tile_t = ptile->terrain;
struct tile_type *type = get_tile_type(tile_t);
struct tile tile;
- int f;
+ int f = get_tile_food_base(ptile);
const bool auto_water = (pcity && is_city_center(city_x, city_y)
&& tile_t == type->irrigation_result
&& terrain_control.may_irrigate);
@@ -816,14 +800,6 @@
}
}
- if (contains_special(tile.special, S_SPECIAL_1)) {
- f = type->special[0].food;
- } else if (contains_special(tile.special, S_SPECIAL_2)) {
- f = type->special[1].food;
- } else {
- f = type->food;
- }
-
if (contains_special(tile.special, S_IRRIGATION)) {
f += type->irrigation_food_incr;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#11208) get_tile_xxx_base,
Jason Short <=
|
|