Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] (PR#9554) Bug?: Immune submarine (protected by cruise miss
Home

[Freeciv-Dev] (PR#9554) Bug?: Immune submarine (protected by cruise miss

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: chrisk@xxxxxxxxx, freksxc@xxxxxxxxxxx, saywhat@xxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#9554) Bug?: Immune submarine (protected by cruise missile)
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 22 Mar 2005 22:17:44 -0800
Reply-to: bugs@xxxxxxxxxxx

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

This patch improves the behavior by ignoring transported units when
checking to see if a unit can attack a tile.

This is only a partial fix however.  As commented in the code, loading
of air units at sea is more-or-less optional.  With alternating movement
(or any single-player game) missiles and fighters must be loaded at the
end of the turn so it's not a problem.  However in multi-player you
could micromanage and keep your units unloaded during the turn to
protect your carriers/submarines.  And with bombers on a carrier you can
rotate 2 bombers in and out of the carrier each turn to keep the carrier
(and everything else on the tile) invulnerable to everything except
fighters (with an aegis cruiser on the tile, this makes the carrier
basically invulnerable).

It also changes the rules in that you can attack an enemy transporter
that is transporting a neutral (or even allied, except that
ally-ally-war isn't possible) unit.  So, lend-lease units are vulnerable
to being attacked.

IMO it's still best to change the logic entirely and allow attacking if
any units on the tile can be attacked.  Maybe not for 2.0 though.

-jason

Index: common/combat.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/combat.c,v
retrieving revision 1.51
diff -u -r1.51 combat.c
--- common/combat.c     14 Mar 2005 20:26:25 -0000      1.51
+++ common/combat.c     23 Mar 2005 06:12:40 -0000
@@ -116,13 +116,20 @@
 }
 
 /***********************************************************************
-  To attack a stack, unit must be able to attack every unit there
+  To attack a stack, unit must be able to attack every unit there (not
+  including transported units).
 ************************************************************************/
 bool can_unit_attack_all_at_tile(const struct unit *punit,
                                 const struct tile *ptile)
 {
   unit_list_iterate(ptile->units, aunit) {
-    if (!can_unit_attack_unit_at_tile(punit, aunit, ptile)) {
+    /* HACK: we don't count transported units here.  This prevents some
+     * bugs like a submarine carrying a cruise missile being invulnerable
+     * to other sea units.  However from a gameplay perspective it's a hack,
+     * since players can load and unload their units manually to protect
+     * their transporters. */
+    if (aunit->transported_by == -1
+       && !can_unit_attack_unit_at_tile(punit, aunit, ptile)) {
       return FALSE;
     }
   } unit_list_iterate_end;

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