<URL: http://bugs.freeciv.org/Ticket/Display.html?id=37768 >

On 3/8/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
>
>  This makes unit_bombard() to respect UCF_UNREACHABLE.

 - 'struct unit *' was passed as 'struct unit_type *' and vice versa. Fixed


 - ML

diff -Nurd -X.diff_ignore freeciv/common/combat.c freeciv/common/combat.c
--- freeciv/common/combat.c	2007-03-06 03:34:32.000000000 +0200
+++ freeciv/common/combat.c	2007-03-09 16:22:05.000000000 +0200
@@ -65,6 +65,18 @@
 }
 
 /***********************************************************************
+  Can unit attack other
+***********************************************************************/
+bool is_unit_reachable_by_unit(const struct unit *defender,
+                               const struct unit *attacker)
+{
+  struct unit_class *dclass = get_unit_class(unit_type(defender));
+
+  return unit_flag(attacker, F_ATTACK_ANY)
+    || !unit_class_flag(dclass, UCF_UNREACHABLE);
+}
+
+/***********************************************************************
   Checks if a unit can physically attack pdefender at the tile
   (assuming it is adjacent and at war).
 
@@ -94,8 +106,7 @@
   }
 
   /* 2. Only fighters can attack planes, except in city or airbase attacks */
-  if (!unit_flag(punit, F_ATTACK_ANY)
-      && unit_class_flag(get_unit_class(unit_type(pdefender)), UCF_UNREACHABLE)
+  if (!is_unit_reachable_by_unit(pdefender, punit)
       && !(pcity || tile_has_native_base(dest_tile, unit_type(pdefender)))) {
     return FALSE;
   }
diff -Nurd -X.diff_ignore freeciv/common/combat.h freeciv/common/combat.h
--- freeciv/common/combat.h	2007-03-05 21:11:49.000000000 +0200
+++ freeciv/common/combat.h	2007-03-09 16:22:18.000000000 +0200
@@ -24,6 +24,8 @@
  */
 #define POWER_FACTOR	10
 
+bool is_unit_reachable_by_unit(const struct unit *defender,
+                               const struct unit *attacker);
 bool can_player_attack_tile(const struct player *pplayer,
 			    const struct tile *ptile);
 bool can_unit_attack_unit_at_tile(const struct unit *punit,
diff -Nurd -X.diff_ignore freeciv/server/unithand.c freeciv/server/unithand.c
--- freeciv/server/unithand.c	2007-03-06 03:34:32.000000000 +0200
+++ freeciv/server/unithand.c	2007-03-09 16:18:53.000000000 +0200
@@ -699,8 +699,8 @@
 	  TILE_XY(pdefender->tile));
     }
 
-    if (!is_air_unit(pdefender)
-	|| (pcity || tile_has_native_base(ptile, unit_type(pdefender)))) {
+    if (is_unit_reachable_by_unit(pdefender, punit)
+	|| pcity || tile_has_native_base(ptile, unit_type(pdefender))) {
       see_combat(punit, pdefender);
 
       unit_versus_unit(punit, pdefender, TRUE);
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to