[Freeciv-Dev] (PR#6871) Replace int with Impr_Type_id
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=6871 >
This patch changes the definition of Impr_Type_id from int to enum
improvement_type_id. This is coherent with the usage of Impr_Type_id.
There is a problem of a circular include dependency between
improvement.h and unittype.h. This could be resolved if we move struct
impr_effect to effects.h. Is this acceptable?
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
checking for the vaidity of the Maxwell laws on this machine... ok
checking if e=mc^2... ok
checking if we can safely swap on /dev/fd0... yes
-- kvirc 2.0.0's configure
Index: ai/advdomestic.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advdomestic.c,v
retrieving revision 1.103
diff -u -u -r1.103 advdomestic.c
--- ai/advdomestic.c 2003/04/29 08:40:11 1.103
+++ ai/advdomestic.c 2003/11/15 16:23:38
@@ -636,8 +636,9 @@
&& pplayer->spaceship.structurals < NUM_SS_STRUCTURALS)
values[id] = -80;
break;
-
- /* ignored: AIRPORT, PALACE, and POLICE. -- Syela*/
+ default:
+ /* ignored: AIRPORT, PALACE, and POLICE and the rest. -- Syela*/
+ break;
} /* end switch */
} impr_type_iterate_end;
@@ -803,9 +804,11 @@
break;
case B_MAGELLAN:
values[id] = values[B_CAPITAL] + 4; /* trump coinage and defenses */
+ break;
+ default:
+ /* also, MAGELLAN is special cased in ai_manage_buildings() */
+ /* ignoring MANHATTAN and STATUE */
break;
- /* also, MAGELLAN is special cased in ai_manage_buildings() */
- /* ignoring MANHATTAN and STATUE */
} /* end switch */
} impr_type_iterate_end;
Index: ai/aitech.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aitech.c,v
retrieving revision 1.41
diff -u -u -r1.41 aitech.c
--- ai/aitech.c 2003/09/21 14:02:14 1.41
+++ ai/aitech.c 2003/11/15 16:23:38
@@ -38,7 +38,7 @@
**************************************************************************/
static Tech_Type_id get_wonder_tech(struct player *plr)
{
- int building = get_nation_by_plr(plr)->goals.wonder;
+ Impr_Type_id building = get_nation_by_plr(plr)->goals.wonder;
if (improvement_exists(building)
&& game.global_wonders[building] == 0
Index: client/gui-gtk/cityrep.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/cityrep.c,v
retrieving revision 1.81
diff -u -u -r1.81 cityrep.c
--- client/gui-gtk/cityrep.c 2003/11/14 12:26:56 1.81
+++ client/gui-gtk/cityrep.c 2003/11/15 16:23:40
@@ -919,7 +919,7 @@
TRUE, FALSE, city_unit_present, FALSE);
append_impr_or_unit_to_menu(menu, _("Improvements in City"), FALSE, TRUE,
- FALSE, TRUE, city_got_building, FALSE);
+ FALSE, TRUE, (TestCityFunc)city_got_building,
FALSE);
append_impr_or_unit_to_menu(menu, _("Available Improvements"), FALSE, TRUE,
FALSE, FALSE, city_can_build_impr_or_unit,
Index: common/improvement.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/improvement.h,v
retrieving revision 1.21
diff -u -u -r1.21 improvement.h
--- common/improvement.h 2003/08/10 13:46:14 1.21
+++ common/improvement.h 2003/11/15 16:23:40
@@ -23,11 +23,6 @@
struct player;
-
-/* Improvement types.
- * improvement types are loaded from the buildings.ruleset file.) */
-typedef int Impr_Type_id;
-
/* Improvement status (for cities' lists of improvements)
* An enum or bitfield would be neater here, but we use a typedef for
* a) less memory usage and b) compatibility with old behaviour */
@@ -59,6 +54,9 @@
B_UNITED, B_WOMENS,
B_CAPITAL, B_LAST_ENUM
};
+typedef enum improvement_type_id Impr_Type_id;
+#else
+typedef int Impr_Type_id;
#endif
/* B_LAST is a value which is guaranteed to be larger than all
Index: common/packets.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.c,v
retrieving revision 1.262
diff -u -u -r1.262 packets.c
--- common/packets.c 2003/10/29 07:32:57 1.262
+++ common/packets.c 2003/11/15 16:23:41
@@ -2284,8 +2284,8 @@
dio_put_uint8_vec8(&dout, (int *)packet->terr_gate, T_LAST);
dio_put_uint16_vec8(&dout, (int *)packet->spec_gate, S_NO_SPECIAL);
dio_put_uint8(&dout, packet->equiv_range);
- dio_put_uint8_vec8(&dout, packet->equiv_dupl, B_LAST);
- dio_put_uint8_vec8(&dout, packet->equiv_repl, B_LAST);
+ dio_put_uint8_vec8(&dout, (int *)packet->equiv_dupl, B_LAST);
+ dio_put_uint8_vec8(&dout, (int *)packet->equiv_repl, B_LAST);
if (has_capability("obsolete_last", pc->capability)) {
dio_put_uint8(&dout, packet->obsolete_by);
} else {
@@ -2347,12 +2347,12 @@
dio_get_uint8(&din, &packet->id);
dio_get_uint8(&din, &packet->tech_req);
- dio_get_uint8(&din, &packet->bldg_req);
+ dio_get_uint8(&din, (int *)&packet->bldg_req);
dio_get_uint8_vec8(&din, (int **)&packet->terr_gate, T_LAST);
dio_get_uint16_vec8(&din, (int **)&packet->spec_gate, S_NO_SPECIAL);
dio_get_uint8(&din, (int *)&packet->equiv_range);
- dio_get_uint8_vec8(&din, &packet->equiv_dupl, B_LAST);
- dio_get_uint8_vec8(&din, &packet->equiv_repl, B_LAST);
+ dio_get_uint8_vec8(&din, (int **)&packet->equiv_dupl, B_LAST);
+ dio_get_uint8_vec8(&din, (int **)&packet->equiv_repl, B_LAST);
dio_get_uint8(&din, &packet->obsolete_by);
if (!has_capability("obsolete_last", pc->capability)
&& packet->obsolete_by == A_NONE) {
@@ -2369,7 +2369,7 @@
dio_get_uint8(&din, (int *)&(packet->effect[inx].range));
dio_get_sint16(&din, &(packet->effect[inx].amount));
dio_get_uint8(&din, &(packet->effect[inx].survives));
- dio_get_uint8(&din, &(packet->effect[inx].cond_bldg));
+ dio_get_uint8(&din, (int *)&(packet->effect[inx].cond_bldg));
dio_get_uint8(&din, &(packet->effect[inx].cond_gov));
dio_get_uint8(&din, &(packet->effect[inx].cond_adv));
dio_get_uint8(&din, (int *)&(packet->effect[inx].cond_eff));
Index: common/unittype.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unittype.h,v
retrieving revision 1.21
diff -u -u -r1.21 unittype.h
--- common/unittype.h 2003/08/04 15:42:47 1.21
+++ common/unittype.h 2003/11/15 16:23:41
@@ -173,7 +173,7 @@
int defense_strength;
int move_rate;
int tech_requirement;
- int impr_requirement;
+ int impr_requirement; /* should be Impr_Type_id */
int vision_range;
int transport_capacity;
int hp;
Index: server/cityhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityhand.c,v
retrieving revision 1.124
diff -u -u -r1.124 cityhand.c
--- server/cityhand.c 2003/10/13 01:33:31 1.124
+++ server/cityhand.c 2003/11/15 16:23:43
@@ -191,7 +191,8 @@
/**************************************************************************
...
**************************************************************************/
-void really_handle_city_sell(struct player *pplayer, struct city *pcity, int
id)
+void really_handle_city_sell(struct player *pplayer, struct city *pcity,
+ Impr_Type_id id)
{
if (pcity->did_sell) {
notify_player_ex(pplayer, pcity->x, pcity->y, E_NOEVENT,
Index: server/cityhand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityhand.h,v
retrieving revision 1.27
diff -u -u -r1.27 cityhand.h
--- server/cityhand.h 2001/02/13 17:53:20 1.27
+++ server/cityhand.h 2003/11/15 16:23:43
@@ -32,7 +32,8 @@
struct packet_city_request *preq);
void handle_city_sell(struct player *pplayer,
struct packet_city_request *preq);
-void really_handle_city_sell(struct player *pplayer, struct city *pcity, int
id);
+void really_handle_city_sell(struct player *pplayer, struct city *pcity,
+ Impr_Type_id id);
void handle_city_buy(struct player *pplayer, struct packet_city_request *preq);
void really_handle_city_buy(struct player *pplayer, struct city *pcity);
void handle_city_refresh(struct player *pplayer, struct packet_generic_integer
*preq);
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.240
diff -u -u -r1.240 citytools.c
--- server/citytools.c 2003/11/07 09:45:03 1.240
+++ server/citytools.c 2003/11/15 16:23:44
@@ -325,7 +325,7 @@
/**************************************************************************
...
**************************************************************************/
-bool can_sell_building(struct city *pcity, int id)
+bool can_sell_building(struct city *pcity, Impr_Type_id id)
{
return (city_got_building(pcity, id) ? !is_wonder(id) : FALSE);
}
@@ -495,7 +495,7 @@
/**************************************************************************
...
**************************************************************************/
-bool built_elsewhere(struct city *pc, int wonder)
+bool built_elsewhere(struct city *pc, Impr_Type_id wonder)
{
struct player *pplayer = city_owner(pc);
city_list_iterate(pplayer->cities, pcity)
@@ -1797,7 +1797,8 @@
/**************************************************************************
...
**************************************************************************/
-void do_sell_building(struct player *pplayer, struct city *pcity, int id)
+void do_sell_building(struct player *pplayer, struct city *pcity,
+ Impr_Type_id id)
{
if (!is_wonder(id)) {
pplayer->economic.gold += improvement_value(id);
@@ -1808,7 +1809,7 @@
/**************************************************************************
...
**************************************************************************/
-void building_lost(struct city *pcity, int id)
+void building_lost(struct city *pcity, Impr_Type_id id)
{
struct player *owner = city_owner(pcity);
Index: server/citytools.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.h,v
retrieving revision 1.47
diff -u -u -r1.47 citytools.h
--- server/citytools.h 2003/07/20 20:41:39 1.47
+++ server/citytools.h 2003/11/15 16:23:44
@@ -30,7 +30,7 @@
#define WARMING_FACTOR 50
bool city_got_barracks(struct city *pcity);
-bool can_sell_building(struct city *pcity, int id);
+bool can_sell_building(struct city *pcity, Impr_Type_id id);
struct city *find_city_wonder(Impr_Type_id id);
int build_points_left(struct city *pcity);
bool is_worked_here(int x, int y);
@@ -38,7 +38,7 @@
int city_tile_value(struct city *pcity, int x, int y, int foodneed, int
prodneed);
int settler_eats(struct city *pcity);
bool is_building_other_wonder(struct city *pc);
-bool built_elsewhere(struct city *pc, int wonder);
+bool built_elsewhere(struct city *pc, Impr_Type_id wonder);
bool do_make_unit_veteran(struct city *pcity, Unit_Type_id id);
int city_shield_bonus(struct city *pcity);
int city_science_bonus(struct city *pcity);
@@ -77,9 +77,10 @@
void establish_trade_route(struct city *pc1, struct city *pc2);
void remove_trade_route(struct city *pc1, struct city *pc2);
-void do_sell_building(struct player *pplayer, struct city *pcity, int id);
-void building_lost(struct city *pcity, int id);
-void change_build_target(struct player *pplayer, struct city *pcity,
+void do_sell_building(struct player *pplayer, struct city *pcity,
+ Impr_Type_id id);
+void building_lost(struct city *pcity, Impr_Type_id id);
+void change_build_target(struct player *pplayer, struct city *pcity,
int target, bool is_unit, int event);
bool is_allowed_city_name(struct player *pplayer, const char *city_name,
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.231
diff -u -u -r1.231 cityturn.c
--- server/cityturn.c 2003/11/13 20:11:31 1.231
+++ server/cityturn.c 2003/11/15 16:23:45
@@ -573,7 +573,7 @@
void advisor_choose_build(struct player *pplayer, struct city *pcity)
{
struct ai_choice choice;
- int id=-1;
+ Impr_Type_id id = -1;
int want=0;
init_choice(&choice);
@@ -677,7 +677,7 @@
target = new_target;
}
} else if (!is_unit && !can_build_improvement(pcity, target)) {
- int new_target = improvement_upgrades_to(pcity, target);
+ Impr_Type_id new_target = improvement_upgrades_to(pcity, target);
/* If the city can never build this improvement, drop it. */
if (!can_eventually_build_improvement(pcity, new_target)) {
Index: server/diplomats.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplomats.c,v
retrieving revision 1.44
diff -u -u -r1.44 diplomats.c
--- server/diplomats.c 2003/10/27 14:34:31 1.44
+++ server/diplomats.c 2003/11/15 16:23:46
@@ -841,7 +841,7 @@
- The saboteur may be captured and executed, or escape to its home town.
**************************************************************************/
void diplomat_sabotage(struct player *pplayer, struct unit *pdiplomat,
- struct city *pcity, int improvement)
+ struct city *pcity, Impr_Type_id improvement)
{
struct player *cplayer;
int count, which, target;
Index: server/diplomats.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplomats.h,v
retrieving revision 1.2
diff -u -u -r1.2 diplomats.h
--- server/diplomats.h 2003/04/04 15:47:49 1.2
+++ server/diplomats.h 2003/11/15 16:23:46
@@ -37,7 +37,7 @@
void diplomat_incite(struct player *pplayer, struct unit *pdiplomat,
struct city *pcity);
void diplomat_sabotage(struct player *pplayer, struct unit *pdiplomat,
- struct city *pcity, int improvement);
+ struct city *pcity, Impr_Type_id improvement);
int count_diplomats_on_tile(int x, int y);
int unit_bribe_cost(struct unit *punit);
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.155
diff -u -u -r1.155 ruleset.c
--- server/ruleset.c 2003/10/02 17:54:58 1.155
+++ server/ruleset.c 2003/11/15 16:23:49
@@ -327,7 +327,7 @@
const char *filename, const char
*description)
{
char *sval;
- int id;
+ Impr_Type_id id;
if (required) {
sval = secfile_lookup_str(file, "%s.%s", prefix, entry);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#6871) Replace int with Impr_Type_id,
Raimar Falke <=
|
|