[Freeciv-Dev] (PR#6225) Remove unused code
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
The patch removes some unused code from AI. Some of it is not completely
brain-dead but it would be easier to write it from scratch. Some of it is
just copy-paste...
G.
Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.144
diff -u -r1.144 aicity.c
--- ai/aicity.c 2003/09/21 14:02:14 1.144
+++ ai/aicity.c 2003/09/21 16:28:12
@@ -589,79 +589,6 @@
return bestid;
}
-/**************************************************************************
- I'm not sure how to generalize this for rulesets, because I
- don't understand what its trying to return. A military ground
- unit with hp>10 could be a Cannon, which doesn't seem like
- a "normal defender" to me... But I think I have to do something,
- because for the Civ1 ruleset, all units have hp==10, so this
- would return 0. Hence this strange a+2*d formula, which gives
- the same results as (hp>10) for the default set, and does
- _something_ for other sets. This should be revisited. --dwp
-**************************************************************************/
-static bool has_a_normal_defender(struct city *pcity)
-{
- unit_list_iterate(map_get_tile(pcity->x, pcity->y)->units, punit)
- if (is_military_unit(punit)
- && is_ground_unit(punit)
- && (unit_type(punit)->attack_strength
- + 2*unit_type(punit)->defense_strength) >= 9
- && can_build_unit(pcity, punit->type)) {
- return TRUE;
- }
- unit_list_iterate_end;
- return FALSE;
-}
-
-/**************************************************************************
- ...
-**************************************************************************/
-static Unit_Type_id ai_choose_defender_limited(struct city *pcity, int n,
- enum unit_move_type which)
-{
- Unit_Type_id bestid = 0; /* ??? Zero is legal value! (Settlers by default) */
- int j, m;
- int best= 0;
- const bool walls = TRUE; /* just assume city_got_citywalls(pcity); in the
long run -- Syela */
- bool isdef = has_a_normal_defender(pcity);
-
- simple_ai_unit_type_iterate(i) {
- m = unit_types[i].move_type;
- if (can_build_unit(pcity, i) && get_unit_type(i)->build_cost <= n &&
- (m == LAND_MOVING || m == SEA_MOVING) &&
- (m == which || which == 0)) {
- j = ai_unit_defence_desirability(i);
- j *= j;
- if (unit_type_flag(i, F_FIELDUNIT) && !isdef) j = 0; /* This is now
confirmed */
- if (walls && m == LAND_MOVING) { j *= pcity->ai.wallvalue; j /= 10; }
- if (j > best || (j == best && get_unit_type(i)->build_cost <=
- get_unit_type(bestid)->build_cost)) {
- best = j;
- bestid = i;
- }
- }
- } simple_ai_unit_type_iterate_end;
-
- return bestid;
-}
-
-/**************************************************************************
- ...
-**************************************************************************/
-Unit_Type_id ai_choose_defender_by_type(struct city *pcity,
- enum unit_move_type which)
-{
- return (ai_choose_defender_limited(pcity, pcity->shield_stock + 40, which));
-}
-
-/**************************************************************************
- ...
-**************************************************************************/
-Unit_Type_id ai_choose_defender(struct city *pcity)
-{
- return (ai_choose_defender_limited(pcity, pcity->shield_stock + 40, 0));
-}
-
/**************************************************************************
...
**************************************************************************/
Index: ai/aicity.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.h,v
retrieving revision 1.20
diff -u -r1.20 aicity.h
--- ai/aicity.h 2003/09/20 19:24:54 1.20
+++ ai/aicity.h 2003/09/21 16:28:12
@@ -25,9 +25,6 @@
void ai_manage_cities(struct player *pplayer);
void ai_choose_ferryboat(struct player *pplayer, struct city *pcity, struct
ai_choice *choice);
Unit_Type_id ai_choose_defender_versus(struct city *pcity, Unit_Type_id v);
-Unit_Type_id ai_choose_defender_by_type(struct city *pcity,
- enum unit_move_type which);
-Unit_Type_id ai_choose_defender(struct city *pcity);
enum ai_city_task { AICITY_NONE, AICITY_TECH, AICITY_TAX, AICITY_PROD};
/* These are not used (well, except AICITY_NONE) --dwp */
Index: server/settlers.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v
retrieving revision 1.171
diff -u -r1.171 settlers.c
--- server/settlers.c 2003/08/09 15:34:19 1.171
+++ server/settlers.c 2003/09/21 16:28:13
@@ -775,21 +775,6 @@
}
unit_list_iterate_end;
if (id != 0) return(id);
-#ifdef ALLOW_VIRTUAL_BOATS
- city_list_iterate(pplayer->cities, pcity)
- if (pcity->is_building_unit &&
- unit_types[pcity->currently_building].transport_capacity &&
- !unit_flag(pcity->currently_building, F_CARRIER) &&
- !unit_flag(pcity->currently_building, F_MISSILE_CARRIER)) {
- if (WARMAP_COST(pcity->x, pcity->y) < best) {
- id = pcity->id;
- best = WARMAP_COST(pcity->x, pcity->y);
- *x = pcity->x;
- *y = pcity->y;
- }
- }
- city_list_iterate_end;
-#endif
return(id);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#6225) Remove unused code,
Gregory Berkolaiko <=
|
|