Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] Re: (PR#7213) is_attack_unit(punit)
Home

[Freeciv-Dev] Re: (PR#7213) is_attack_unit(punit)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#7213) is_attack_unit(punit)
From: "Arnstein Lindgard" <a-l@xxxxxxx>
Date: Fri, 9 Jan 2004 09:30:16 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7213 >

Yes, comments were definately needed.

On Thu, 8 Jan 2004 12:44:01 -0800 Raimar Falke wrote:

> > -  if (is_military_unit(punit) && unit_type(punit)->attack_strength > 0
> > -      && map_get_city(punit->x, punit->y))
> > +  }
> > +  if (is_attack_unit(punit) && map_get_city(punit->x, punit->y)) {
> >      return TRUE;
> > +  }
> 
> This doesn't seem an equivalent transformation.

You're absoloutely right, can_unit_do_auto() also needs to check
military because autoattack.c does it. Maybe autoattack.c should
replace all instances of is_military_unit() with is_attack_unit(),
but I don't know if some of those calls are related to target
aquisition.


Arnstein

? autom4te-2.53.cache
Index: client/goto.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/goto.c,v
retrieving revision 1.64
diff -u -r1.64 goto.c
--- client/goto.c       2004/01/04 00:40:03     1.64
+++ client/goto.c       2004/01/09 17:24:43
@@ -376,7 +376,7 @@
   assert(parameter->get_EC == NULL);
   parameter->get_EC = get_EC;
   assert(parameter->get_TB == NULL);
-  if (unit_type(punit)->attack_strength > 0 || unit_flag(punit, F_DIPLOMAT)) {
+  if (is_attack_unit(punit) || is_diplomat_unit(punit)) {
     parameter->get_TB = get_TB_aggr;
   } else if (unit_flag(punit, F_TRADE_ROUTE)
             || unit_flag(punit, F_HELP_WONDER)) {
Index: common/combat.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/combat.c,v
retrieving revision 1.34
diff -u -r1.34 combat.c
--- common/combat.c     2003/11/28 17:37:21     1.34
+++ common/combat.c     2004/01/09 17:25:03
@@ -87,7 +87,7 @@
   totile   = map_get_terrain(dest_x, dest_y);
 
   /* 1. Can we attack _anything_ ? */
-  if (!is_military_unit(punit) || unit_type(punit)->attack_strength == 0) {
+  if (!is_military_unit(punit) || !is_attack_unit(punit)) {
     return FALSE;
   }
 
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.192
diff -u -r1.192 unit.c
--- common/unit.c       2004/01/07 23:16:18     1.192
+++ common/unit.c       2004/01/09 17:25:19
@@ -348,7 +348,17 @@
 }
 
 /**************************************************************************
-...
+  Is the unit capable of attacking?
+**************************************************************************/
+bool is_attack_unit(struct unit *punit)
+{
+  return (unit_type(punit)->attack_strength > 0);
+}
+
+/**************************************************************************
+  Military units are capable of enforcing martial law. Military ground
+  and heli units can occupy empty cities -- see COULD_OCCUPY(punit).
+  Some military units, like the Galleon, have no attack strength.
 **************************************************************************/
 bool is_military_unit(struct unit *punit)
 {
@@ -506,11 +516,13 @@
 **************************************************************************/
 bool can_unit_do_auto(struct unit *punit) 
 {
-  if (unit_flag(punit, F_SETTLERS))
+  if (unit_flag(punit, F_SETTLERS)) {
     return TRUE;
-  if (is_military_unit(punit) && unit_type(punit)->attack_strength > 0
-      && map_get_city(punit->x, punit->y))
+  }
+  if (is_military_unit(punit) && is_attack_unit(punit)
+      && map_get_city(punit->x, punit->y)) {
     return TRUE;
+  }
   return FALSE;
 }
 
@@ -1401,7 +1413,7 @@
 **************************************************************************/
 bool unit_being_aggressive(struct unit *punit)
 {
-  if (unit_type(punit)->attack_strength==0)
+  if (!is_attack_unit(punit))
     return FALSE;
   if (map_get_city(punit->x,punit->y))
     return FALSE;
Index: common/unit.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.h,v
retrieving revision 1.106
diff -u -r1.106 unit.h
--- common/unit.h       2004/01/06 08:11:34     1.106
+++ common/unit.h       2004/01/09 17:25:22
@@ -239,6 +239,7 @@
 bool can_unit_do_auto(struct unit *punit); 
 bool is_unit_activity_on_tile(enum unit_activity activity, int x, int y);
 int get_unit_tile_pillage_set(int x, int y);
+bool is_attack_unit(struct unit *punit);
 bool is_military_unit(struct unit *punit);           /* !set !dip !cara */
 bool is_diplomat_unit(struct unit *punit);
 bool is_square_threatened(struct player *pplayer, int x, int y);

[Prev in Thread] Current Thread [Next in Thread]