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

[Freeciv-Dev] (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] (PR#7213) is_attack_unit(punit)
From: "Arnstein Lindgard" <a-l@xxxxxxx>
Date: Wed, 7 Jan 2004 08:32:12 -0800
Reply-to: rt@xxxxxxxxxxx

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

Boolean expression funct is_attack_unit(punit).
Different from is_military_unit(punit) ...


Arnstein

diff -ruN -Xdiff_ignore is_city_hilited/client/goto.c 
is_attack_unit/client/goto.c
--- is_city_hilited/client/goto.c       Sun Jan  4 11:47:43 2004
+++ is_attack_unit/client/goto.c        Mon Jan  5 13:49:56 2004
@@ -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)) {
diff -ruN -Xdiff_ignore is_city_hilited/common/combat.c 
is_attack_unit/common/combat.c
--- is_city_hilited/common/combat.c     Fri Nov 28 21:37:08 2003
+++ is_attack_unit/common/combat.c      Mon Jan  5 13:51:37 2004
@@ -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;
   }
 
diff -ruN -Xdiff_ignore is_city_hilited/common/unit.c 
is_attack_unit/common/unit.c
--- is_city_hilited/common/unit.c       Fri Nov 28 21:54:21 2003
+++ is_attack_unit/common/unit.c        Mon Jan  5 13:43:39 2004
@@ -350,6 +350,14 @@
 /**************************************************************************
 ...
 **************************************************************************/
+bool is_attack_unit(struct unit *punit)
+{
+  return (unit_type(punit)->attack_strength > 0);
+}
+
+/**************************************************************************
+...
+**************************************************************************/
 bool is_military_unit(struct unit *punit)
 {
   return !unit_flag(punit, F_NONMIL);
@@ -506,11 +514,12 @@
 **************************************************************************/
 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_attack_unit(punit) && map_get_city(punit->x, punit->y)) {
     return TRUE;
+  }
   return FALSE;
 }
 
@@ -1401,7 +1410,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;
diff -ruN -Xdiff_ignore is_city_hilited/common/unit.h 
is_attack_unit/common/unit.h
--- is_city_hilited/common/unit.h       Wed Dec  3 16:22:23 2003
+++ is_attack_unit/common/unit.h        Mon Jan  5 13:39:52 2004
@@ -230,6 +230,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]
  • [Freeciv-Dev] (PR#7213) is_attack_unit(punit), Arnstein Lindgard <=