[Freeciv-Dev] (PR#11717) new function get_output_tile
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11717 >
This patch merges get_food_tile, get_shields_tile, and get_trade_tile
into a single function get_output_tile. It's pretty straightforward.
-jason
? diff
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.296
diff -u -r1.296 city.c
--- common/city.c 28 Dec 2004 19:09:27 -0000 1.296
+++ common/city.c 28 Dec 2004 19:36:52 -0000
@@ -692,12 +692,13 @@
}
/**************************************************************************
- Calculate the shields produced by the tile. This obviously won't take
- into account any city or government bonuses.
+ Calculate the production output produced by the tile. This obviously
+ won't take into account any city or government bonuses. The output
+ type is given by 'otype' (generally O_FOOD, O_SHIELD, or O_TRADE).
**************************************************************************/
-int get_shields_tile(const struct tile *ptile)
+int get_output_tile(const struct tile *ptile, Output_type_id otype)
{
- return base_get_output_tile(ptile, NULL, -1, -1, FALSE, O_SHIELD);
+ return base_get_output_tile(ptile, NULL, -1, -1, FALSE, otype);
}
/**************************************************************************
@@ -730,16 +731,6 @@
return base_get_output_tile(ptile, pcity,
city_x, city_y, is_celebrating, O_SHIELD);
}
-
-/**************************************************************************
- Calculate the trade produced by the tile. This obviously won't take
- into account any city or government bonuses.
-**************************************************************************/
-int get_trade_tile(const struct tile *ptile)
-{
- return base_get_output_tile(ptile, NULL, -1, -1, FALSE, O_TRADE);
-}
-
/**************************************************************************
Calculate the trade the given tile is capable of producing for the
city.
@@ -771,15 +762,6 @@
}
/**************************************************************************
- Calculate the food produced by the tile. This obviously won't take
- into account any city or government bonuses.
-**************************************************************************/
-int get_food_tile(const struct tile *ptile)
-{
- return base_get_output_tile(ptile, NULL, -1, -1, FALSE, O_FOOD);
-}
-
-/**************************************************************************
Calculate the food the given tile is capable of producing for the
city.
**************************************************************************/
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.188
diff -u -r1.188 city.h
--- common/city.h 25 Dec 2004 20:13:05 -0000 1.188
+++ common/city.h 28 Dec 2004 19:36:52 -0000
@@ -404,11 +404,7 @@
const char *get_impr_name_ex(const struct city *pcity, Impr_Type_id id);
-/* tile production functions */
-
-int get_shields_tile(const struct tile *ptile); /* shield on spot */
-int get_trade_tile(const struct tile *ptile); /* trade on spot */
-int get_food_tile(const struct tile *ptile); /* food on spot */
+int get_output_tile(const struct tile *ptile, Output_type_id otype);
/* city map functions */
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.209
diff -u -r1.209 map.c
--- common/map.c 7 Dec 2004 18:24:23 -0000 1.209
+++ common/map.c 28 Dec 2004 19:36:53 -0000
@@ -158,9 +158,9 @@
static char s[64];
my_snprintf(s, sizeof(s), "%d/%d/%d",
- get_food_tile(ptile),
- get_shields_tile(ptile),
- get_trade_tile(ptile));
+ get_output_tile(ptile, O_FOOD),
+ get_output_tile(ptile, O_SHIELD),
+ get_output_tile(ptile, O_TRADE));
return s;
}
Index: server/generator/startpos.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/startpos.c,v
retrieving revision 1.7
diff -u -r1.7 startpos.c
--- server/generator/startpos.c 22 Nov 2004 19:14:42 -0000 1.7
+++ server/generator/startpos.c 28 Dec 2004 19:36:53 -0000
@@ -45,26 +45,29 @@
int value, irrig_bonus, mine_bonus;
/* Give one point for each food / shield / trade produced. */
- value = (get_food_tile(ptile)
- + get_shields_tile(ptile)
- + get_trade_tile(ptile));
+ value = 0;
+ output_type_iterate(o) {
+ value += get_output_tile(ptile, o);
+ } output_type_iterate_end;
old_terrain = ptile->terrain;
old_special = ptile->special;
map_set_special(ptile, S_ROAD);
map_irrigate_tile(ptile);
- irrig_bonus = (get_food_tile(ptile)
- + get_shields_tile(ptile)
- + get_trade_tile(ptile)) - value;
+ irrig_bonus = -value;
+ output_type_iterate(o) {
+ irrig_bonus += get_output_tile(ptile, o);
+ } output_type_iterate_end;
ptile->terrain = old_terrain;
ptile->special = old_special;
map_set_special(ptile, S_ROAD);
map_mine_tile(ptile);
- mine_bonus = (get_food_tile(ptile)
- + get_shields_tile(ptile)
- + get_trade_tile(ptile)) - value;
+ mine_bonus = -value;
+ output_type_iterate(o) {
+ mine_bonus += get_output_tile(ptile, o);
+ } output_type_iterate_end;
ptile->terrain = old_terrain;
ptile->special = old_special;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#11717) new function get_output_tile,
Jason Short <=
|
|