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

 This makes unit_bombard() to respect UCF_UNREACHABLE.


 - 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-08 16:36:25.000000000 +0200
@@ -65,6 +65,16 @@
 }
 
 /***********************************************************************
+  Can unit attack other
+***********************************************************************/
+bool is_unit_reachable_by_unit(const struct unit_type *defender,
+                               const struct unit_type *attacker)
+{
+  return unit_flag(attacker, F_ATTACK_ANY)
+    || !unit_class_flag(get_unit_class(defender), UCF_UNREACHABLE);
+}
+
+/***********************************************************************
   Checks if a unit can physically attack pdefender at the tile
   (assuming it is adjacent and at war).
 
@@ -94,8 +104,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-08 16:36:31.000000000 +0200
@@ -24,6 +24,8 @@
  */
 #define POWER_FACTOR	10
 
+bool is_unit_reachable_by_unit(const struct unit_type *defender,
+                               const struct unit_type *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-08 16:33:55.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